akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N ;
  cin >> N;
 
  if (N%1000%111==0) {
    cout << "Yes" << endl;
  }
  else if (N%1110<=9) {
    cout << "Yes" << endl;
  }
  else cout << "No" << endl;
}

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

char s[3][110];
int now[3] = {0, 0, 0};

int rec(int i){
    if(now[i] == strlen(s[i])) return i;
    char next = s[i][now[i]];
    now[i]++;
    return rec(next - 'a');
}

int main(){
    for(int i = 0; i < 3; i++) int ret = scanf("%s", s[i]);
    printf("%c\n", rec(0) + 'A');
    return 0;
}


Measured memory_bytes: 1712
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <limits>
#include <numeric>
#include <cmath>

using namespace std;

template<class T>
class Input {
public:
    auto operator()() const {
        T v;
        cin >> v;
        return v;
    }
};

template<class L, class R>
class Input<pair<L, R>> {
public:
    auto operator()() const {
        L l;
        R r;
        cin >> l >> r;
        return make_pair(l, r);
    }
};

template<class U>
class Input<vector<U>> {
public:
    auto operator()() const {
        Input<size_t> in{};
        auto n = in();
        return (*this)(n);
    }
    auto operator()(size_t n) const {
        vector<U> v;
        v.reserve(n);
        Input<U> in{};
        for (size_t i = 0; i < n; ++i) {
            auto u = in();
            v.emplace_back(move(u));
        }
        return v;
    }
};

template<class U>
class Input<vector<vector<U>>> {
public:
    auto operator()() const {
        Input<size_t> in{};
        auto n = in();
        auto m = in();
        return (*this)(n, m);
    }
    auto operator()(size_t n, size_t m) const {
        vector<vector<U>> v;
        v.reserve(n);
        Input<vector<U>> in{};
        for (size_t i = 0; i < n; ++i) {
            auto u = in(m);
            v.emplace_back(move(u));
        }
        return v;
    }
};

class InputType
{
public:
    template<class T>
    operator T() const {
        Input<T> i{};
        return i();
    }
};

class InputType2
{
public:
    InputType2(size_t n)
        : n_(n)
    {}
    template<class T>
    operator T() const {
        Input<T> i{};
        return i(n_);
    }
private:
    size_t n_;
};

auto input() {
    return InputType();
}

template<class... Args>
auto input(Args&&... args) {
    return InputType2(std::forward<Args>(args)...);
}

size_t bitcount(size_t n) {
    size_t c = 0;
    while (n) {
        if (n & 1ull)
            ++c;
        n >>= 1;
    }
    return c;
}

auto make_order(size_t n) {
    vector<size_t> a(n, 0);
    iota(begin(a), end(a), 0);
    return a;
}

template<class T>
auto next_permutation(T&& x) {
    using std::begin;
    using std::end;
    return next_permutation(begin(x), end(x));
}

using ll = long long;
using ull = unsigned long long;

int main() {
    string n = input();
    if (n[0] == '7' || n[1] == '7' || n[2] == '7')
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3628
import math
k = int(input())
ans = 0
for i in range(1,k+1):
    for j in range(1,k+1):
        g = math.gcd(i,j)
        for x in range(1,k+1):
            g0 = math.gcd(g,x)
            ans += g0
print(ans)

Measured memory_bytes: 9180
N, M = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(N)]
ans = 0
cnt = 0

for ab in sorted(AB):
    for i in range(ab[1]):
        if cnt < M:
            ans += ab[0]
            cnt += 1
        else:
            break
    if cnt >= M:
        break

print(ans)


Measured memory_bytes: 28652
#include<bits/stdc++.h>
using namespace std;
int n,k;
long long a[233333],ta[233333],tb[233333];
map<pair<long long,long long>,int> mp;
map<long long,int> vis;
inline bool chk(long long x){long long sx=sqrt(x)+0.5;return sx*sx==x;}
int main()
{
	ios_base::sync_with_stdio(false);
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i],ta[i]=tb[i]=1;
	int fll=0;
	for(int d=2;d<=2153;d++)
	{
		int fl=1;
		for(int j=2;j*j<=d;j++)if(d%j==0){fl=0;break;}
		if(fl)
		{
			for(int i=1;i<=n;i++)
			{
				int cnt=0;
				while(a[i]%d==0)cnt++,a[i]/=d;
				if(cnt%3==1)ta[i]*=d,tb[i]*=d*d;
				else if(cnt%3==2)ta[i]*=d*d,tb[i]*=d;
			}
		}
	}
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		if(a[i]!=1)
		{
			if(chk(a[i]))ta[i]*=a[i],tb[i]*=(long long)(sqrt(a[i])+0.5);
			else if(a[i]<=100000)ta[i]*=a[i],tb[i]*=a[i]*a[i];
			else
			{
				ans++;
				continue;
			}
		}
//		cerr<<"add "<<i<<' '<<a[i]<<' '<<ta[i]<<' '<<tb[i]<<endl;
		if(ta[i]!=1)mp[make_pair(ta[i],tb[i])]++;
		else fll=1;
	}
	for(auto x:mp)
	{
//		cerr<<x.first.first<<' '<<x.first.second<<' '<<x.second<<endl;
		if(vis[x.first.second])continue;
		vis[x.first.first]=1;
		int cnt1=x.second,cnt2=0;
		auto _=make_pair(x.first.second,x.first.first);
		if(mp.find(_)!=mp.end())cnt2=mp[_];
		ans+=max(cnt1,cnt2);
	}
	cout<<ans+fll<<endl;
	return 0;
}

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

using namespace std;

#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define pb push_back
#define mp make_pair
typedef long long LL;
typedef pair<int, int> PII;

int n;
int a[100005];

int cnt[100005];

int best[2], best2[2], bestNum[2];
void solve(int ind) {
    forn(i, 100005) {
        cnt[i] = 0;
    }

    for (int i = ind; i < n; i += 2) {
        ++cnt[a[i]];
    }

    best[ind] = 0;
    best2[ind] = 0;
    bestNum[ind] = -1;
    forn(i, 100005) if (cnt[i] > best[ind]) {
        best2[ind] = best[ind];
        best[ind] = cnt[i];
        bestNum[ind] = i;
    } else {
        best2[ind] = max(best2[ind], cnt[i]);
    }
}

int main() {
    scanf("%d", &n);
    forn(i, n) {
        scanf("%d", a + i);
    }
    solve(0);
    solve(1);
    int ans = n - best[0] - best[1];
    if (bestNum[0] == bestNum[1]) {
        ans += min(best[0] - best2[0], best[1] - best2[1]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
// Problem : D - String Formation
// Contest : AtCoder - AtCoder Beginner Contest 158
// URL : https://atcoder.jp/contests/abc158/tasks/abc158_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

// #pragma GCC optimize ("O3")
// #pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const ld pii=3.14159265359;
const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy
 
int main() 
{
	ios_base::sync_with_stdio(0); cin.tie(0);    
	string S;
	cin>>S;
	int Q;
	cin>>Q;
	vector<char> start,end;
	bool flip=false;
	F0R(x,Q)
	{
		int choice;
		cin>>choice;
		if(choice==1)
		{
			flip=!flip;
			continue;
		}
		int pt;
		char ch;
		cin>>pt>>ch;
		if(pt==1)
		{
			if(flip)
			{
				end.pb(ch);
			}
			else
			{
				start.pb(ch);
			}
		}
		else
		{
			if(flip)
			{
				start.pb(ch);
			}
			else
			{
				end.pb(ch);
			}
		}
	}
	string ans="";
	F0Rd(x,sz(start))
	{
		ans=ans+start[x];
	}
	ans=ans+S;
	F0R(x,sz(end))
	{
		ans=ans+end[x];
	}
	if(flip)
	{
		F0Rd(x,sz(ans))
		{
			cout<<ans[x];
		}
	}
	else
		cout<<ans<<endl;
	return 0;
}
// read the question correctly (ll vs int)
// template by bqi343
 



Measured memory_bytes: 2188
eval"N,*A="+`dd`.split*?,
b=A.pop N.times{$*[A[_1]]||=_1}
c=(b+b)[(A&b).map{|x|(b.bsearch_index{_1>x}||N)-$*[x]}.max||0,N]
puts (0...N).any?{A[_1]==c[_1]}?:No:[:Yes,c]

Measured memory_bytes: 89316
#include <iostream>
using namespace std;
bool rec10(int i);

int main(){
    int n;
    cin >> n;
    for(int i=1;i<=n;i++){
        if(i%3==0) cout << " " << i;
        else if(rec10(i)){
            cout << " " << i;
        }
    }
    cout << "\n";
}

bool rec10(int i){
    if(i%10==3) return true;
    else if(i/10==0) return false;
    rec10(i/10);
}


Measured memory_bytes: 3080
a=int(input())
b=int(input())
c=int(input())
x=int(input())
ans=0
for i in range(a+1):
  for j in range(b+1):
    for k in range(c+1):
      if (500*i)+(100*j)+(50*k)==x:
        ans+=1
print(ans)        

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include<queue>
#include<set>
using namespace std;

int main()
{
  long long n, y;
  cin >> n >> y;

  for (int i = 0; i <= n; i++)
  {
    for (int j = 0; j <= n - i; j++)
    {
      if (10000 * i + 5000 * j + 1000 * (n - i - j) == y)
      {
        cout << i << " " << j << " " << n - i - j << endl;
        exit(0);
      }
    }
  }

  cout << "-1 -1 -1" << endl;

}

Measured memory_bytes: 256
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>
#include <iomanip>

using namespace std;

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

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

struct UnionFind {
	UnionFind(int n) :parent(n), rank(n, 0), nums(n, 1), groupnum(n) {
		iota(parent.begin(), parent.end(), 0);
	}
	int find(int a) {
		return parent[a] == a ? a : (parent[a] = find(parent[a]));
	}
	bool same(int a, int b) {
		return find(a) == find(b);
	}
	void unite(int a, int b) {
		a = find(a), b = find(b);
		if (a == b)
			return;
		groupnum--;
		if (rank[a] < rank[b]) {
			parent[a] = b;
			nums[b] += nums[a];
		}
		else {
			parent[b] = a;
			nums[a] += nums[b];
			if (rank[a] == rank[b])
				rank[a]++;
		}
	}
	int group_count() {
		return groupnum;
	}
	int get_group_size(int i) {
		return nums[find(i)];
	}
	vector<int> parent;
	vector<int> rank;
	vector<int> nums;
	int groupnum;
};

int main() {
	int n, m, k;
	cin >> n >> m >> k;
	vector<int> friends(n, 0);
	vector<vector<int>> ng(n);
	UnionFind uf(n);
	REP(i, m){
		int a, b;
		cin >> a >> b;
		a--, b--;
		uf.unite(a, b);
		friends[a]++, friends[b]++;
	}

	REP(i, k){
		int c, d;
		cin >> c >> d;
		c--, d--;
		ng[c].push_back(d);
		ng[d].push_back(c);
	}

	REP(i, n){
		int ans = uf.get_group_size(i) - friends[i] - 1;
		for(auto dame: ng[i]){
			if(uf.same(i, dame))
				ans--;
		}
		cout << (i==0?"":" ") << ans;
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 7552
import java.util.Scanner;

public class Main {
    public static void debug(String str) {
        System.out.println(str);
    }

    public static void main(String[] args) {

        String S;

        try (Scanner sc = new Scanner(System.in)) {
            S = sc.next();
        }
        boolean out = false;

        int i = 1;
        for(char c : S.toCharArray()){
            if(i %2 == 1){
                if(c == 'L'){
                    out = true;
                    break;
                }
            }else{
                if(c == 'R'){
                    out = true;
                    break;
                }
            }
            i++;
        }
        String result = "";
        if(out){
            result ="No";
        }else{
            result ="Yes";
        }

        System.out.println(result);
    }


}


Measured memory_bytes: 23892
//最大公約数
//2018-12-07
//Ebitani Akira

#include <stdio.h>
#include <stdlib.h>

int gcd(int,int);
void swap(int *,int *);

int main (){
  int x, y;
  int N=1;
  int i;

  scanf("%d%d", &x, &y);

  for( i=0 ; i<9 ; i++ ){
    N *= 10;
  }

  if( x<1 || x>N || y<1 || y>N ){
    printf("数字が大き過ぎます。\n");
    exit(1);
  }

  printf("%d\n",gcd(x, y));

  return 0;
}

int gcd(int x, int y){
  int r;

  if(x<y){
    swap(&x,&y);
  }

  while(y>0){
    r=x%y;
    x=y;
    y=r;
  }

  return x;
}

void swap(int *x, int *y){
  int temp;
  temp = *x;
  *x = *y;
  *y = temp;
}

  



Measured memory_bytes: 2144
#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(int i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define wi(t) int t;cin>>t;while(t--)
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
	uniform_int_distribution<int> uid(0,lim-1);
	return uid(rang);
}
int mpow(int base, int exp); 
void ipgraph(int n, int m);
void dfs(int u, int par);

const int mod = 1000000007;
const int N = 3e5, M = N;
//=======================

vi g[N];
int a[N];
ll int gcd(ll int a, ll int b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
      
} 
void solve()
    { 
int n,x,t;
cin>>n>>x>>t;
ll int ans=0;
if(n%x==0)
{
	ans=(n/x)*t;
}
else
{
	ans=(n/x+1)*t;
}
cout<<ans;	

    }

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());

   // wi(t)
    {
      solve();
    }

    return 0;
}

int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}

void ipgraph(int n, int m){
	int i, u, v;
	while(m--){
		cin>>u>>v;
    u--, v--;
		g[u].pb(v);
		g[v].pb(u);
	}
}

void dfs(int u, int par){
	for(int v:g[u]){
		if (v == par) continue;
		dfs(v, u);
	}
}







Measured memory_bytes: 10620
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        try (Scanner s = new Scanner(System.in)) {
            int a = s.nextInt();
            long b = s.nextLong();
            long n = s.nextLong();
            long x = Math.min(b - 1, n);
            System.out.println((a * x) / b);
        }
    }
}


Measured memory_bytes: 35760
"use strict";

const main = arg => {
    const inputList = arg.trim().split("\n");
    // 回答を記述
    const N = parseInt(inputList[0].split(" ")[0]);
    const sum = N + N ** 2 + N ** 3;

    console.log(sum)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29740
#include<iostream>
using namespace std;
int main()
{
    int a1;
    cin >> a1;
  	int a2;
    cin >> a2;
    int a3;
    cin >> a3;
  
    if((a1+a2+a3) <= 21) 
      cout << "win" << endl;
    else
      cout << "bust" << endl;
 
    return 0;
}

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

#define     fast()              ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
#define     ll                  long long int
#define     test()              ll t; cin>>t; while(t--) 
#define     lp0(i,begin,end)    for(ll i=begin;i<end;i++)
#define     lp1(i,begin,end)    for(ll i=begin;i<=end;i++)
#define     rlp(i,begin,end)    for(ll i=end;i>=begin;i--)
#define     prec(n)             fixed<<setprecision(n)
#define     initial(a,i)        memset(a,i,sizeof(a))
#define     pb                  push_back
#define     PI                  3.1415926535897932384626433832795
#define     MOD                 1000000007
#define     F                   first
#define     S                   second
#define     all(a)              (a).begin(),(a).end()
#define     BPC(x)              __builtin_popcountll(x)
#define     gcd(a,b)            __gcd(a,b)

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

ll power(ll x,ll n)
{
    ll result = 1;
    while (n)
    {
        if (n & 1)
            result = result * x;
        n = n / 2;
        x = x * x;
    }
    return result;
}


// Solution Function
void solution(ll compte)
{
    // cout<<compte<<"\n";
    ll n,k;
    cin>>n>>k;
    if(n>=13)
    cout<<k;
    else if(n>5 && n<13)
    cout<<(k/2);
    else cout<<0;
}
    // Driver Function
int main()
{
    ll compte = 1;
    //test()
    //{
        solution(compte);
        compte++;
    //}
    return 0;
}


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

using namespace std;

#define REP(i, n)   for(int i = 0; i < (n); i++)
#define REPS(i, n)  for(int i = 1; i <= (n); i++)
#define RREP(i, n)  for(int i = (n)-1; i >= 0; i--)
#define RREPS(i, n) for(int i = (n); i > 0; i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define mt make_tuple
#define pb push_back

using ll  = long long;
using pi  = pair<int, int>;
using pl  = pair<ll, ll>;
using vi  = vector<int>;
using vl  = vector<ll>;
using vs  = vector<string>;
using vb  = vector<bool>;
using vvi = vector<vi>;
using vvl = vector<vl>;

const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const ll  INFL = 1e18;
const double PI = 3.141592653589793;
const double EPS = 1e-9;

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

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int N, Ma, Mb; cin >> N >> Ma >> Mb;
    vector<tuple<int, int, int>> d(N);
    REP(i, N)
    {
        int a, b, c; cin >> a >> b >> c;
        d[i] = mt(a, b, c);
    }

    int dp[N+1][401][401];
    REP(i, N+1) REP(j, 401) REP(k, 401) dp[i][j][k] = INF;

    dp[0][0][0] = 0;
    REP(i, N)
    {
        int a, b, c;
        tie(a, b, c) = d[i];
        REP(j, 401)
        {
            REP(k, 401)
            {
                chmin(dp[i+1][j][k], dp[i][j][k]);
                if(j+a < 401 && k+b < 401) chmin(dp[i+1][j+a][k+b], dp[i][j][k] + c);
            }
        }
    }

    int ans = INF;
    REPS(i, 1000)
    {
        if(i*Ma > 400 || i*Mb > 400) break;
        chmin(ans, dp[N][i*Ma][i*Mb]);
    }
    if(ans == INF) cout << -1 << endl;
    else cout << ans << endl;
}

Measured memory_bytes: 29348
parseInt(x)=parse(Int, x)
parseMap(x::Array{SubString{String},1})=map(parseInt, x)

function main()
	n = readline() |> parseInt
	x = readline() |> chomp
	k = 0
	for i in 1:n
		if x[i]=='1'
			k += 1
		end
	end
	dp0 = zeros(Int,n)
	dp1 = zeros(Int,n)
	dp2 = zeros(Int,n)
	nw0 = 1
	nw1 = 1
	nw2 = 1
	a0 = 0
	a1 = 0
	a2 = 0
	for i in n:-1:1
		dp1[i]=nw1%(k+1)
		if x[i]=='1'
			a1 = (a1+dp1[i])%(k+1)
		end
		nw1 = nw1*2%(k+1)
		if k>0
			dp0[i]=nw0%k
			if x[i]=='1'
				a0 = (a0+dp0[i])%k
			end
			nw0 = nw0*2%k
		end
		if k>1
			dp2[i]=nw2%(k-1)
			if x[i]=='1'
				a2 = (a2+dp2[i])%(k-1)
			end
			nw2 = nw2*2%(k-1)
		end
	end
	ans = zeros(Int,n)
	for i in 1:n
		if x[i]=='1'
			if k>1
				z = mod(a2-dp2[i],k-1)
				ct = 1
				while z>0
					r = 0
					kt = 0
					while 2^r<=z
						if (z>>r)%2==1
							kt += 1
						end
						r += 1
					end
					z = z%kt
					ct += 1
				end
				ans[i] = ct
			end
		else
			z = (a1+dp1[i])%(k+1)
			ct = 1
			while z>0
				r = 0
				kt = 0
				while 2^r<=z
					if (z>>r)%2==1
						kt += 1
					end
					r += 1
				end
				z = z%kt
				ct += 1
			end
			ans[i] = ct
		end
	end
	for i in 1:n
		println(ans[i])
	end
end

main()

Measured memory_bytes: 196992
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
template <class T> T ceil(T a, T b) {
    return (a + b - 1) / b;
}
template <class T> T round(T a, T b) {
    return (a + b / 2) / b;
}
template <class T> T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}
template <class T> T lcm(T a, T b) {
    return a * b / gcd(a, b);
}
template <class T> bool amax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

ll mod_pow(ll n, int x) {
    const int MOD = 1e9 + 7;
    if (x == 0) {
        return 1L;
    } else if (x % 2 == 0) {
        return (mod_pow(n * n % MOD, x / 2)) % MOD;
    } else {
        return (n * (mod_pow(n * n % MOD, x / 2) % MOD)) % MOD;
    }
}

// main
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    const int MAX_N = 1e5;
    int N, A;
    cin >> N;
    vector<int> v(N, 0);
    REP(i, N) {
        cin >> A;
        v[A]++;
    }
    if (N % 2 == 0) {
        if (v[0] != 0) {
            cout << 0 << endl;
            return 0;
        }
        FOR(i, 1, N, 1) {
            if (v[i] != 0 && v[i] != 2) {
                cout << 0 << endl;
                return 0;
            }
        }
        cout << mod_pow(2L, N / 2) << "\n";
    } else {
        if (v[0] != 1) {
            cout << 0 << endl;
            return 0;
        }
        FOR(i, 1, N, 1) {
            if (v[i] != 0 && v[i] != 2) {
                cout << 0 << endl;
                return 0;
            }
        }
        cout << mod_pow(2L, (N - 1) / 2) << "\n";
    }
    return 0;
}


Measured memory_bytes: 640
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = (ll)1e9;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

#define out(s) cout << s;
#define output(s) cout << s << endl;
#define outputf(s, f) cout << fixed << setprecision() << s << endl;

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

	for (int i = 0; i <= n / 7; i++)
	{
		for (int j = 0; j <= n / 4; j++)
		{
			if (n == 7 * i + 4 * j)
			{
				output("Yes");
				return 0;
			}
		}
	}

	output("No");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define owo(i,a, b) for(int i=(a);i<(b); ++i)
#define uwu(i,a, b) for(int i=(a)-1; i>=(b); --i)
#define senpai push_back
#define ttgl pair<int, int>
#define ayaya cout<<"ayaya~"<<endl
 
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
gpu_hash_map<int, int> mp;*/
using ll = long long;
using ld = long double;
const ll MOD = 1000000007;
const ll root = 62;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
ll binpow(ll a,ll b){ll res=1;while(b){if(b&1)res=(res*a)%MOD;a=(a*a)%MOD;b>>=1;}return res;}
ll modInv(ll a){return binpow(a, MOD-2);}
const double PI = acos(-1);
const double eps = -1e6;
const int INF = 0x3f3f3f3f;
const int NINF = 0xc0c0c0c0;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;
const ll NINFLL = 0xc0c0c0c0c0c0c0c0;
const int mxN = 100001;
int n, x;
int arr[mxN];
array<ll, 2> lr[mxN];
pair<ll, int> takeval[mxN];
ll psum[mxN];
ll bad = 0;
int main() {
    //freopen("greedy.in", "r", stdin);
    //freopen("file.out", "w", stdout);
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    cin.tie(0)->sync_with_stdio(0);
    cin>>n>>x;
    owo(i, 0, n) {
        cin>>arr[i]>>lr[i][0]>>lr[i][1];
        bad-=1LL*lr[i][0]*arr[i];
        takeval[i].first = arr[i]*lr[i][0] + (x-arr[i])*lr[i][1];
        takeval[i].second = i;
    }
    sort(takeval, takeval+n);
    reverse(takeval, takeval+n);
    owo(i, 0, n) {
        psum[i+1] = psum[i] + takeval[i].first;
    }
    ll l = 0;
    ll r = 1LL*n*x;
    while(l<r) {
        ll deficit = bad;
        ll mid = (l+r)/2;
        int tt = mid/x;
        int over = mid-tt*x;
        owo(i, 0, n) {
            ll curr = 0;
            curr+=psum[tt];
            if(i<tt&&tt!=n) {
                curr-=takeval[i].first;
                curr+=takeval[tt].first;
            }
            int id = takeval[i].second;
            curr+=1LL*min(over, arr[id])*lr[id][0] + 1LL*max(0, over-arr[id])*lr[id][1];
            deficit = max(deficit, bad+curr);
        }
        if(deficit>=0) {
            r = mid;
        }else {
            l = mid+1;
        }
    }
    cout<<l<<"\n";
    return 0;
}

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

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
// *st.find_by_order(index), 0-based
// order_of_key(e)

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int H,W,M; cin>>H>>W>>M;
	map<int,ll> ctH, ctW;
	map<ii,ll> ct;
	ll mxH=0, mxW=0;
	for (int i=0; i<M; i++) {
		int h,w; cin>>h>>w;
		mxH=max(mxH,++ctH[h]);
		mxW=max(mxW,++ctW[w]);
		ct[{h,w}]++;
	}
	vector<int> x,y;
	for (auto it : ctH)
		if(it.second==mxH)
			x.push_back(it.first);
	for (auto it : ctW)
		if(it.second==mxW)
			y.push_back(it.first);
	ll a=x.size(), b=y.size();
	if(a*b>M) {
		cout<<mxH+mxW<<"\n";
		return 0;
	}
	ll ret=0;
	for (auto h : x)
		for (auto w : y)
			ret=max(ret,mxH+mxW-ct[{h,w}]);
	cout<<ret<<"\n";
	return 0;
}

Measured memory_bytes: 63672
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <memory.h>
using namespace std;

int main()
{
	ios::sync_with_stdio(0);
	int a, b, c;
	cin >> a >> b >> c;
	if (c >= a && c <= b)
		cout << "Yes\n";
	else
		cout << "No\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0;}


int main() {
    int n;
    cin >> n;
    vector<int>a(n);
    rep(i,n) cin >> a[i];
    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());
    ll ans = 0;
    int cnt = 0;
    rep(i,n) {
        if(cnt==n-1) break;
        if(i==0) {
            ans += a[i];
            cnt++;
            continue;
        }
        rep(j,2) {
            ans += a[i];
            cnt++;
            if(cnt==n-1) break;
        }
    }
    cout<< ans << endl;
}
    




Measured memory_bytes: 4040
#include <iostream>
#include <vector>
#include <algorithm> 
#include <queue>
#include <functional>
#include <map>
#include <string>
using namespace std;
typedef long long ll;

const int MAX_E = 2005;
const int MAX_V = 1005;
const ll INF = 10000000000000000;
struct edge{ ll from, to, cost; };
edge es[MAX_E];

ll d[MAX_V];
ll V, E;

void bellman_ford(int s){
    for (int i = 0; i < V; i++) d[i] = INF;
    d[s] = 0;
    ll count = 0;
    while (true){
        bool update = false, update2 = false;
        for (int i = 0; i < E; i++){
            edge e = es[i];
            if (d[e.from] != INF && d[e.to] > d[e.from] + e.cost){
                d[e.to] = d[e.from] + e.cost;
                update = true;
                if (e.to == V - 1){
                    update2 = true;
                }
            }
        }

        if (!update){
            cout << -d[V - 1] << endl;
            return;
        }
        count++;
        if (count == V){
            if (update2){
                cout << "inf" << endl;
                return;
            }
            else{
                cout << -d[V - 1] << endl;
                return;
            }
        }
    }
}

int main(void){

    cin >> V >> E;

    for (int i = 0; i < E; i++){
        ll a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        es[i] = { a, b, -c };
    }

    bellman_ford(0);

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char c;
  cin >> c;
 
  if(c == 'a' || c == 'e' || c == 'o' || c == 'i' || c == 'u')
    cout << "vowel" << endl;
  else cout << "consonant" << endl;
  
  // ここにプログラムを追記
}

Measured memory_bytes: 3572
a,b=map(int,input().split())
c=g=1;e=f=0
while b:
    d,m=divmod(a,b)
    h=c-d*e
    i=f-d*g
    a,b=b,m
    c,e=e,h
    f,g=g,i
print(c,f)

Measured memory_bytes: 7628
r1, c1, r2, c2 = map(int, input().split())

MOD = 10 ** 9 + 7
MAX = 2 * 10 ** 6 + 10
modinv = lambda a, mod=MOD: pow(a, mod - 2, mod)
fac, inv = [1] * MAX, [1] * MAX
for i in range(1, MAX):
    fac[i] = fac[i - 1] * i % MOD
    inv[i] = modinv(fac[i])


def comb(n, k, error=0):
    if not 0 <= k <= n:
        return error
    return fac[n] * inv[k] * inv[n - k] % MOD


ans = comb(r2 + c2 + 2, r2 + 1) + comb(r1 + c1, r1) - comb(r1 + c2 + 1, r1) - comb(r2 + c1 + 1, c1)
ans %= MOD
print(ans)


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

int main()
{
    int n;
    double ans;

    cin >> n; 
    vector<int> v(n);
    rep(i, n) {
        cin >> v[i];
    }

    sort(v.begin(), v.end());
    ans = v[0];
    rep(i,n-1) {
        ans = (double)(ans + v[i + 1]) / 2.0;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3720
#include <iostream>
int main(){
    long long  N, W;
    std::cin >> N >> W;
    long long dp[N + 1][W + 1];//N番目までの品物を選んだ時の時のWの価値の最大
    for(int i = 0; i < N + 1; i++){
        for(int j = 0; j < W + 1; j++) dp[i][j] = 0;
    }
    long long v[N], w[N];
    for(int i = 0; i < N; i++) std::cin >> v[i] >> w[i];
    for(int i = 0; i < N; i++){
        for(int j = 0; j <= W; j++){
            if(j - w[i] < 0) dp[i + 1][j] = dp[i][j];
            else if(j - w[i] >= 0){
                dp[i + 1][j] = std::max(dp[i][j], dp[i + 1][j - w[i]] + v[i]);
            }
        }
    }
    std::cout << dp[N][W] << std::endl;
}


Measured memory_bytes: 10976
function Main(input) {
    input = input.trim().split("\n").map(function(x) { return x.split(" ")});
    let N = parseInt(input[0][0], 10);
    let arr_D = [];
    for (let i = 0; i < N; i++){
        arr_D.push(input[i + 1].map(e => parseInt(e, 10)));
    }
    arr_D.push([0, 1]);
    let tmp = -1;
    let tmp2;
    let ans = 'No';
    for (let i = 0; i < N + 1; i++){
        if (arr_D[i][0] !== arr_D[i][1]){
            tmp2 = i;
            if (tmp2 - tmp > 3){
                ans = 'Yes';
                break;
            } else {
                tmp = tmp2;
            }
        }
    }
    console.log(ans);
    
    
}



Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 30724
ls = []

#ls = [[84, 97, 66], [79, 89, 11], [61, 59, 7]]

input = []
3.times do
  ls << gets.split(" ").map(&:to_i)
end
n = gets.chomp!.to_i

n.times do
  input << gets.chomp!.to_i
end


# あたり番号格納配列
hit = 0

# [0, 1, 2], [0, 0, 0], [1, 1, 1], [2, 2, 2], [2, 1. 0]
# ls_2に一致パターンを定義
ls_2 = [
  [ls[0][0], ls[1][1], ls[2][2]],
  [ls[0][2], ls[1][2], ls[2][2]],
  [ls[0][1], ls[1][1], ls[2][1]],
  [ls[0][0], ls[1][0], ls[2][0]],
  [ls[0][2], ls[1][1], ls[2][0]],
  [ls[0][0], ls[0][1], ls[0][2]],
  [ls[1][0], ls[1][1], ls[1][2]],
  [ls[2][0], ls[2][1], ls[2][2]]
]
ls_2.each do |e|
  count = 0
  input.each do |num|
    for i in 0..2 do
      if num == e[i]
        count += 1
      end
    end
  end
  if count == 3
    # ビンゴ回数カウント
    hit += 1
  end
end

if hit > 0
  puts "Yes"
else
  puts "No"
end


Measured memory_bytes: 1788
#include<iostream>
using namespace std;
int main(){
  int n;
  while(cin>>n,n){
    int ans[7]={};
    for(int i=0;i<n;i++){
      int a;
      cin>>a;
      if(a>60)
	a=60;
      ans[a/10]++;
    }
    for(int i=0;i<7;i++)
      cout<<ans[i]<<endl;
  }
  return 0;
}

Measured memory_bytes: 3072
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

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

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

    ll N, M;
    cin >> N >> M;
    vec A(N);
    ll cnt = 0, tmp = 0;
    Rep (i, N) {
        cin >> A[i];
        tmp += A[i];
    }

    Rep (i, N) {
        if (A[i] >= tmp / double(4*M)) cnt++;
    }

    if (cnt >= M) cout << "Yes\n";
    else cout << "No\n";


}

Measured memory_bytes: 256
a = readlines.map{|e| e.chomp.to_i }
k = a[5]
x = 1
(0..4).each do |i|
  (1..4).each do |j|
    x *= a[j] - a[i] <= k ? 1 : 0
  end
end
print x == 1 ? 'Yay!' : ':('

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int dx[] = {1,0,-1,0};
int dy[] = {0,-1,0,1};
const ll INF = 1001001001;

int main(){
    int N;
    cin >> N;
    int ans = 0;
    int a;
    for(int i=0;i<N;i++){
        cin >> a;
        while(a%2 == 0){
            ans++;
            a /= 2;
        }
    }
    cout << ans << endl;
}


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

int vars;
int pos;
string str;
bool formula() {
  if(str[pos] == 'T') { pos++; return true; }
  if(str[pos] == 'F') { pos++; return false; }
  if(isalpha(str[pos])) {
    return (vars>>(str[pos++]-'a') & 1);
  }
  if(str[pos] == '-') {
    pos ++;
    return !formula();
  }
  if(str[pos] == '(') {
    pos ++;
    int f = formula();
    bool ret;
    if(str[pos] == '*') {
      pos++;
      ret = formula() && f;
    }
    else if(str[pos] == '+') {
      pos++;
      ret = formula() || f;
    }
    else if(str[pos] == '>') {
      pos++;
      ret = f<=formula();
    }
    pos ++;
    return ret;
  }
}

int main() {
  while(cin>>str && str!="#") {
    
    int arw = str.find("->");
    while(arw!=(int)string::npos) {
      str.replace(arw, 2, ">");
      arw = str.find("->", arw+1);
    }
    
    bool ok = true;
    for(vars=0;vars<(1<<11);vars++) {
      pos = 0; bool fs = formula();
      pos ++;
      if(fs != formula()) { ok = false; break; }
    }
    if(ok) {
      cout << "YES" << endl;
    }
    else {
      cout << "NO" << endl;
    }
  }
  return 0;
}

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

const long long FACT_MAX = 4000;
long long famod[FACT_MAX+1];
long long simod[FACT_MAX+1];
long long fimod[FACT_MAX+1];

const long long MOD = 998244353;

void create_fact_mod(int num){
    famod[0] = 1;
    famod[1] = 1;
    for(int i=2; i<=num; i++){
        famod[i] = famod[i-1] * i % MOD;
    }
}

void create_seq_inv_mod(int num){
    simod[0] = 1;
    simod[1] = 1;
    for(int i=2; i<=num; i++){
        simod[i] = (MOD - MOD/i) * simod[MOD%i] % MOD;
    }
}

void create_fact_inv_mod(int num){
    fimod[0] = 1;
    fimod[1] = 1;
    for(int i=2; i<=num; i++){
        fimod[i] = fimod[i-1] * simod[i] % MOD;
    }
}

void create_mod_tables(int num){
    create_fact_mod(num);
    create_seq_inv_mod(num);
    create_fact_inv_mod(num);
}

long long comb_mod(int n, int k){
    if(n<0 || k<0 || n-k<0) return 0;
    return famod[n] * fimod[n-k] % MOD * fimod[k] % MOD;
}

long long h_mod(int n, int k){
    return comb_mod(n+k-1, k);
}

void add(long long&a, long long b){
    a = (a + b) % MOD;
}

int main(){
    long long i, j, k;
    long long K, N;
    cin >> K >> N;

    create_mod_tables(4000);

    for(i=2; i<=2*K; i++){
        long long np = i <= K+1 ? (i-1)/2 : (2*K-i+1)/2;
        long long ans = 0;
        for(j=0; j<=np; j++){
            long long result = 0;
            if(i%2==0){
                result = (h_mod(K-1, N-2*j) + h_mod(K-1, N-2*j-1)) % MOD;
            }else{
                result = h_mod(K, N-2*j);
            }
            add(ans, (j%2==0 ? 1 : -1) * comb_mod(np, j) * result % MOD);
        }
        add(ans, MOD);
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <random>
#include <string>
#include <bitset>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <cstring>
#include <cstdlib>
#include <cctype>

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999

using namespace std;

typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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


llong pow(int x, int n){
    llong ans = x;
    if (n == 0) return 1;

    for(int i = 0; i < n - 1; i++) {
        ans *= x;
    }

    return ans;
}


void swap(int *X, int *Y){
    int t = *X; *X = *Y; *Y = t;
}


string toUpper(string s) {
    string t = s;
    REP(i, s.size()) {
        t[i] = toupper(s[i]);
    }
    return t;
}


string toLower(string s) {
    string t = s;
    REP(i, s.size()) {
        t[i] = tolower(s[i]);
    }
    return t;
}

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

    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            if (4 * i + 7 * j == n) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

    cout << "No" << endl;
    return 0;
}

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

int N;
string S;

int main()
{
    cin >> S;
    N = S.size();

    if(S[0] == '0' || S[N - 2] == '0' || S[N - 1] == '1')
    {
        cout << -1 << endl;
        return 0;
    }

    for(int i = 0; i < N - 1; i++)if(S[i] != S[N - 2 - i])
    {
        cout << -1 << endl;
        return 0;
    }

    int top = 1, next = 2;
    for(int i = 0; i < N - 1; i++)
    {
        cout << top << " " << next << endl;
        if(S[i] == '1')top = next;
        next++;
    }
    return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//
 
struct Edge {
	int to, a, b;
};
 
ll dp[55][5100]; // 都市 i, 銀貨 j 枚
int MAX_CNT = 5050;
 
int N, M, S; // 最初 銀貨 S
vector<Edge> g[55];
int C[50], D[50];
 
int main() {
	cin >> N >> M >> S;
	S = min(MAX_CNT, S);
	REP(i, M) {
		int u, v, a, b;
		scanf("%d %d %d %d", &u, &v, &a, &b);
		--u; --v;
		g[u].emplace_back(Edge{v, a, b});
		g[v].emplace_back(Edge{u, a, b});
	}
	REP(i, N) scanf("%d %d", C + i, D + i);
	
	// (d, u, cnt)
	using ll3 = tuple<ll, ll, ll>;
	
	fill(dp[0], dp[N], longINF);
	
	priority_queue<ll3, vector<ll3>, greater<ll3>> pq;
	pq.emplace(0, 0, S);
	dp[0][S] = 0;
	
	while (!pq.empty()) {
		ll cur_t, u, cur_c;
		tie(cur_t, u, cur_c) = pq.top();
		pq.pop();
		
		if (cur_t > dp[u][cur_c]) continue;
		
		// 1 枚変換
		ll nex_c = min((ll)MAX_CNT, cur_c + C[u]);
		if (chmin(dp[u][nex_c], dp[u][cur_c] + D[u])) pq.emplace(dp[u][cur_c] + D[u], u, nex_c);
		
		for (Edge &e : g[u]) {
			if (e.a > cur_c) continue;
			
			ll nex_t = cur_t + e.b;
			if (chmin(dp[e.to][cur_c - e.a], nex_t)) pq.emplace(nex_t, e.to, cur_c - e.a);
		}
	}
	
	
	FOR(i, 1, N) {
		ll ans = longINF;
		REP(j, MAX_CNT + 1) chmin(ans, dp[i][j]);
		printf("%lld\n", ans);
	}
	return 0;
}

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

using namespace std;
typedef long long ll;
#define tr(container, it) \
        for (auto it = container.begin(); it != container.end(); it++)
#define scontains(c, x) ((c).find(x) != (c).end())   //O(log n)
#define contains(c, x) (find((c).begin(),(c).end(),x) != (c).end()) //O(n)
#define ill(_x)  ll _x;scanf("%lld",&_x);
#define idb(_x)  double _x;scanf("%lf",&_x);
#define all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define mll map<ll,ll>
#define vll vector<ll>
#define sll set<ll>
#define vs vector<string>
#define in0(x, a, b)((x)>=a && (x)<=b    )
#define in1(x, a, b)((x)>a && (x)<b)
#define  rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define gcd __gcd
const double pi = 3.14159265358979323846;
const int INF = 0x3f3f3f3f;
const int MOD = (int)(1e9+7);

int pDivisors(int n, int t)
{
    vector<int> v;
    int mx = 0;
    for (int i=1; i<=sqrt(n); i++)
    {
        if (n%i == 0)
        {
            if(i<=t)mx = max(i, mx);
            if(n/i<=t)mx = max(n/i, mx);
        }

    }
    return mx;
}

void _(){
    int n,m;
    cin >> n >>m;
    cout << pDivisors(m, m/n);
}


int main() {
#ifdef Debug
    freopen("/home/joduskame/Desktop/cpp/IO/Input.txt", "r", stdin);
    freopen("/home/joduskame/Desktop/cpp/IO/Output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    _();
    return 0;

}





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

int N, M;
vector<int> X, dist;

int main() {
  scanf("%d %d", &N, &M);
  X = vector<int>(M);
  for (int i = 0; i < M; ++i) scanf("%d", &X[i]);
  
  if (N >= M) {
    printf("0\n");
    return 0;
  }

  sort(X.begin(), X.end());
  for (int i = 0; i < M-1; ++i) dist.push_back(X[i+1] - X[i]);
  sort(dist.begin(), dist.end(), greater<int>());

  int ans = X[M-1] - X[0];
  for (int i = 0; i < N-1; ++i) ans -= dist[i];

  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 1276
//C++14 (Clang 3.8.0)

#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#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 <ctime>
#include <string>
#include <climits>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int maxn=200003;
int main(){
  int res=0;
  int n;
  cin>>n;
  int flag[8];
  fill(flag,flag+8,0);
  int h=0;
  for(int i=0;i<n;i++){
    int tmp;
    cin>>tmp;
    if(tmp>=3200)h++;
    else flag[tmp/400]++;
    
  }
  for(int i=0;i<8;i++){
    if(flag[i]!=0)res++;
  }
  if(res==0){
    cout<<1<<" "<<h<<endl;
  }
  else{
    cout<<res<<" "<<res+h<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int samecount(string S){
    int A = 0;
    for(int i = 0;i < S.size();i++){
        int QA = 1;
        for(int j = i ;j < S.size() - 1;j++){
           if(S.at(j) == S.at(j + 1)){
               QA++ ;
           }
           if(S.at(j) != S.at(j + 1)){
               break;
           }
           
        }
        A = max(QA,A);
    }
    return A;
}

int64_t minn(int64_t a,int64_t b){
    if(a >= b) return b;
    else return a;
}
int main(){
    int N;
    cin >>N;
    vector<int>  A(N);
    for(int i = 0;i <N;i++){
        cin >> A[i];
    }
   int memo = 1;//次に押すボタン
   int ans = 0;//ボタンを押した回数
   bool frag = 0;//可能か


   for(int i = 0;i < N+1;i++){
       ans++;
       memo = A[memo-1];
       if(memo == 2){
           frag = 1;
           break;
       }
   }
   if(frag) cout << ans << endl;
   else cout << -1 << endl;

}




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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  cout<<fixed;
  string S;
  cin>>S;
  int k = S.size();
  int o=0;
  rep(i,k)
    if(S[i]=='o')o++;
  if(o+(15-k)>=8)
    cout << "YES"<<endl;
  else
    cout << "NO" << endl;
  return 0;
}


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

int N, A, B, C, D;
string S;

int main()
{
    cin >> N >> A >> B >> C >> D;
    cin >> S;

    A--;
    B--;
    C--;
    D--;

    bool flag = false;

    if(D < C)
    {
        for(int i = B; i < D; i++)
        {
            if(S[i] == '#' && S[i + 1] == '#')flag = true;
        }
        bool flag2 = false;
        for(int i = B - 1; i < D; i++)
        {
            if(S[i] == '.' && S[i + 1] == '.' && S[i + 2] == '.')flag2 = true;
        }
        if(!flag2)flag = true;
        for(int i = A; i < C; i++)
        {
            if(S[i] == '#' && S[i + 1] == '#')flag = true;
        }
    }
    else
    {
        for(int i = B; i < D; i++)
        {
            if(S[i] == '#' && S[i + 1] == '#')flag = true;
        }
        for(int i = A; i < C; i++)
        {
            if(S[i] == '#' && S[i + 1] == '#')flag = true;
        }
    }

    if(flag)cout << "No" << endl;
    else cout << "Yes" << endl;
}


Measured memory_bytes: 640