akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define MOD 1000000007
#define INF 1e9
#define All(x) (x).begin(), (x).end()

using namespace std;
typedef long long ll;


int main() {
  int n;
  ll k;
  cin >> n >> k;
  vector<int> a(n);
  REP(i, n) cin >> a[i];
  vector<int> root;
  vector<int> check(n, -1);
  int now = 1;
  root.push_back(1);
  check[0] = 1;
  int s;
  while (1) {
    now = a[now - 1];
    if(check[now-1]!=-1){
      s = check[now - 1];
      break;
    }
    root.push_back(now);
    check[now - 1] = root.size();
  }


  int l = (int)root.size();

  if(k<l){
    cout << root[k] << endl;
    return 0;
  }

  s--;
  k -= s;
  ll ans = k % (l - s);
  cout << root[s + ans] << endl;

  return 0;
}


Measured memory_bytes: 5748
r1, c1, r2, c2 = map(int, input().split())
MOD = 10**9 + 7

def factorial(n, mod=10**9+7):
    a = 1
    for i in range(1,n+1):
        a = a * i % mod
    return a


def power(n, r, mod=10**9+7):
    if r == 0: return 1
    if r%2 == 0:
        return power(n*n % mod, r//2, mod) % mod
    if r%2 == 1:
        return n * power(n, r-1, mod) % mod


def comb(n, k, mod=10**9+7):
    if n < k or k < 0:
        result = 0
    else:
        a = factorial(n, mod=mod)
        b = factorial(k, mod=mod)
        c = factorial(n-k, mod=mod)
        result = (a * power(b, mod-2, mod=mod) * power(c, mod-2, mod=mod)) % mod
    return result


def g(r, c):
  return comb(c+r+2, r+1) - 1

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

Measured memory_bytes: 3064
import sys
input = sys.stdin.readline

n = int(input())
L = [list(map(int,input().split())) for i in range(n)]
A= []

for i in range(n):
    A.append([L[i][0]-L[i][1], L[i][0]+L[i][1]])
A.sort(key=lambda x:x[1])

m = -float("inf")
ans = 0
for i in range(n):
    if m > A[i][0]:
        ans += 1
    else:
        m = A[i][1]
print(n-ans)

Measured memory_bytes: 72412
#include <iostream>
using namespace std;
int main(){
     int a, b, i=0, sum=0;
     cin >> a >> b;
     
     while(i < 2) {
     
     	if(a > b) {
     	  sum += a;
     	  a-- ;
     	} else {
     	  sum += b;
     	  b--;
     	}
     	i++;
     }
     
     cout << sum << endl;
}

Measured memory_bytes: 256
A, B, H, M = map(int, input().split())
import math
th1 = 2*math.pi/12*(H+M/60)
th2 = 2*math.pi/60*M
theta = min(abs(th1-th2),2*math.pi-abs(th1-th2))
print(math.sqrt(A**2+B**2-2*A*B*math.cos(theta)))

Measured memory_bytes: 9500
from numpy import*;I=lambda:map(int,input().split());W,H,N=I();m=zeros((H,W))
for i in range(N):x,y,a=I();m[y*(a>3):y*(a==3or H),x*(a==2):x*(a<2or W)]=1
print(W*H-int(sum(m)))

Measured memory_bytes: 12500
#include <cstdio>
#include <algorithm>
using namespace std;
int main(void)
{
	int total;
	while(scanf("%d",&total)!=EOF)
	{
		//int test[100000];
		int *test;
		test = new int[total];
		int totalin=0;
		for(int i=0;i<total;i++)
			scanf("%d",&test[i]);
		sort(test,test+total);
		for(int i=0,pre=-1;i<total;i++)
		{
			if(test[i]==pre)
			{
				pre =-1;
				totalin--;
			}
			else
			{
				pre = test[i];
				totalin++;
			}
		}
		printf("%d",totalin);
	}
	return 0;
}

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

#define range 524289
#define mod 998244353
#define eps 1e18
#define PI 3.14159265358979323846
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define ALL(V) V.begin(), V.end()
#define _ <<" "<<

using namespace std;

typedef long long ll;
typedef vector <ll> vi;
typedef vector<vi> vvi;
typedef pair <ll, ll> ii;
typedef pair<int, pair<int,int> > iii;
typedef vector<ii> vii;
typedef vector<iii> viii;


int e[8] = {1,-1,1, -1, 2,2,-2,-2};
int z[8] = {2, 2,-2, -2, 1,-1,1,-1};

vvi a;
vi dp;
vi vis;

void dfs(int u){
    vis[u] = 1;
    dp[u] = 1;
    for(int v : a[u]){
        if(!vis[v]){
            dfs(v);
        }

        dp[u] = max(dp[u], 1+dp[v]);

    }
    //cout<<u<<" "<<dp[u]<<endl;
}


int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    // cin>>t;
    while(t--){

        int n, m;
        cin>>n>>m;
        a = vvi(n+1);
        vis = vi(n+1);
        dp = vi(n+1);
        for (int i = 0; i < m; ++i)
        {
            /* code */
            ll x,y;
            cin>>x>>y;
            a[x].pb(y);
        }
        ll maxpath = 0;
        for (int i = 1; i <= n; ++i)
        {
            if(vis[i]){
                maxpath = max(maxpath, dp[i]);
            }
            else{
                dfs(i);
                maxpath = max(maxpath, dp[i]);
            }
        }

        cout<<maxpath-1<<endl;



    }

}



Measured memory_bytes: 9344
#include<stdio.h>
#include<string.h>

int main(){
  int i,five,ans;
  do{
    scanf("%d",&i);
    if(i==0) break;
    for(five=5,ans=0;five<=i;five*=5)
      ans+=i/five;
    printf("%d\n",ans);
  }while(1);
  return 0;
}

Measured memory_bytes: 0
import bisect
N = int(input())
L = list(map(int, input().split()))

L = sorted(L)
count = 0
for i in range(1,N-1):
    for j in range(i+1,N):
              posi = bisect.bisect_right(L,L[j]-L[i])
              if i-posi > 0:
                  count += i-posi
print(count)

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

long long choose2(long long n){
  return n*(n-1)/2;
}

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

  vector<int> A(N);
  for(int i = 0; i < N; i++) cin >> A.at(i);
  for(int i = 0; i < N; i++) A.at(i)--;
  vector<int> cnt(N);
  for(int i = 0; i < N; i++) cnt.at(A.at(i))++;
  
  long long total = 0;
  for(int i = 0; i < N; i++){
    total += choose2(cnt.at(i));
  }
  for(int i = 0; i < N; i++){
    long long ans = total;
    ans -= choose2(cnt.at(A.at(i)));
    ans += choose2(cnt.at(A.at(i))-1);
    cout << ans << endl;
  }
  
}

Measured memory_bytes: 4096
N,M = gets.split.map(&:to_i)

a = Array.new(N) {Array.new(2)}

for i in 0..N-1 do
  a[i][0], a[i][1] = gets.split.map(&:to_i)
end

#安い順にする
a.sort! { |x, y| x[0] <=> y[0] }

count = 0
ans = 0

for i in 0..N-1 do
  if count + a[i][1] < M
    count += a[i][1]
    ans += a[i][0] * a[i][1]
  else
    ans += a[i][0] * (M - count)
    break
  end
end

puts ans


Measured memory_bytes: 10104
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll w,h,x,y;
	cin>>w>>h>>x>>y;
	double ans=w/2.0*h;
	int c=0;
	if(x*2==w and y*2==h)c=1;
	fcout(10)<<ans<<" ";
	cout<<c<<endl;
	return 0;
}

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

int main() {
  
  int A,B,N=0;
  cin >> A >> B;
  
  for(int i=A;i<=B;i++){
    
    if(i/10000==i%10 && i/1000%10==i%100/10){
      N++;
    }
    
  }
  
  cout << N << endl;
}

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

const int mod = 1000000007;

int main() {

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

	int ans = 0;
	int x = 0;
	for (int i = 0; i < n; i++) {
		ans = (ans + (long long)a[i] * x) % mod;
		x = (x + a[i]) % mod;
	}

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

Measured memory_bytes: 4028
import math

A, B = map(int, input().split())

flag = 0

for x in range(1,1252):
    if math.floor(0.08 * x) == A and math.floor(0.10 * x) == B:
        ans = x
        flag = 1
        break
if flag == 0:
    ans = -1

print(ans)

Measured memory_bytes: 9120
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
#define pi 3.14159
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
#define mp make_pair
#define pq priority_queue
#define mod 1000000007
#define f first
#define s second
#define pii pair< int, int >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)

using namespace std;
string repeat(string s, int n) {
    string s1 = "";
    for (int i=0; i<n;i++)
        s1+=s;
    return s1;
}
string getString(char x) {
    string s(1, x);
    return s;
}

void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int gcd(int a, int b){
    if (a == 0)  return b;
    return gcd(b % a, a);
}
void  solve(){
  int n,k,ans=0,c=0;
  cin>>n>>k;
  int a[n];
  rep(i,0,n) cin>>a[i];
  for(int i=0;i<n;i++){
    c++;
    if(c==k && i!=n-1){
      i--;
      c=0;
      ans++;
    }
  }
  if(c>0) ans++;
  cout<<ans<<endl;
}
int main(){
    optimizeIO();
    // tc
    { solve();
    }
}


Measured memory_bytes: 3988
#include <bits/stdc++.h>
typedef long long ll;
using std::cout;
using std::endl;
using std::cin;

std::vector<std::vector<int>> g, G, vec(750, std::vector<int>(2, 0));
std::vector<int> li, a, b;
int n, m, count = 0;

bool solve(int s) {
	std::queue<int> qu; qu.push(s);
	li[s] = 0;
	
	while(!qu.empty()) {
		auto p = qu.front(); qu.pop();
		
		for(auto e : G[p]) {
			if(~li[e] and li[p] == li[e]) return false;
			if(~li[e]) continue;
			
			li[e] = !li[p];
			qu.push(e);
		}
	}
	
	for(int i = 0; i < n; i++) {
		if(li[i] == -1) continue;
		
		for(auto e : G[i]) if(li[i] == li[e]) return false;
	}
	
	return true;
}

void latte(int s) {
	std::queue<int> qu; qu.push(s);
	std::vector<bool> used(n, false); used[s] = true;
	vec[count][0]++;
	
	while(!qu.empty()) {
		auto p = qu.front(); qu.pop();
		
		for(auto e : G[p]) {
			if(used[e]) continue; used[e] = true;
			
			vec[count][li[e]]++;
			qu.push(e);
		}
	}
	count++;
}

int main(){
	cin >> n >> m; g.resize(n); G.resize(n); li.resize(n, -1);
	bool edge[n][n] = {}; a.resize(m); b.resize(m);
	for(int i = 0; i < m; i++) {
		cin >> a[i] >> b[i];
		
		g[a[i] - 1].push_back(b[i] - 1);
		g[b[i] - 1].push_back(a[i] - 1);
		edge[a[i] - 1][b[i] - 1] = edge[b[i] - 1][a[i] - 1] = true;
		a[i]--; b[i]--;
	}
	
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < n; j++) {
			if(edge[i][j] or i == j) continue;
			G[i].push_back(j);
		}
	}
	
	for(int i = 0; i < n; i++) {
		if(li[i] == -1) {
			if(!solve(i)) {
				cout << -1 << endl;
				return 0;
			} else {
				latte(i);
			}
		}
	}
	
	bool dp[count + 1][701] = {}; dp[0][0] = true;
	for(int i = 0; i < count; i++) {
		for(int j = 0; j < 701; j++) {
			if(!dp[i][j]) continue;
			dp[i + 1][j + vec[i][0]] = true;
			dp[i + 1][j + vec[i][1]] = true;
		}
	}
	
	int mi = 1e9;
	for(int i = 0; i < 701; i++) {
		if(!dp[count][i]) continue;
		
		mi = std::min(mi, i * (i - 1) / 2 + (n - i) * (n - i - 1) / 2);
	}
	
	cout << mi << endl;
	return 0;
}


Measured memory_bytes: 6272
#include<iostream>
using namespace std;
int main()
{
	int a,b,ans;
	cin>>a>>b;
	int x;
	x=(a+b)/2;
	if((a+b)%2!=0)
	{
		ans=x+1;
	}
	else
	{
		ans=x;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
struct circle{
    double x;
    double y;
    double r;
};
 
int judge_intersection(circle ca, circle cb){
    double dis2 = (ca.x - cb.x) * (ca.x - cb.x)
                + (ca.y - cb.y) * (ca.y - cb.y);
    if((ca.r > cb.r) && ((ca.r - cb.r) * (ca.r - cb.r) > dis2)){
        return 2;
    } else if((cb.r > ca.r) && ((ca.r - cb.r) * (ca.r - cb.r) > dis2)){
        return -2;
    } else if((ca.r + cb.r) * (ca.r + cb.r) >= dis2){
        return 1;
    } else {
        return 0;
    }
}
 
int main()
{
    int n;
    cin >> n;
    for(int i = 0; i < n; i++){
        circle ca, cb;
        cin >> ca.x >> ca.y >> ca.r
            >> cb.x >> cb.y >> cb.r;
        cout << judge_intersection(ca, cb) << endl;
    }
    return 0;
}

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



int main() {
	int n,i,ans=0;
	cin >> n;
	vector<int> a(n,0);
	for (i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (i = 1; i < n - 1; i++) {
		if ((a[i - 1]<a[i] && a[i + 1]>a[i]|| (a[i + 1]<a[i] && a[i - 1]>a[i]))) {
			ans++;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define eb emplace_back
#define precision(n) cout << fixed << setprecision(n);
#define fast {ios_base::sync_with_stdio(false);cin.tie(NULL);}
int main()
{
   int t;
   int f=0;
   int cnt=0;
   cin>>t;
   while(t--)
   {
       int a,b;
       cin>>a>>b;
       //int f=0;
       //int cnt=0;
       if(a==b)
       {
           cnt++;
           if(cnt==3)
           {
               f=1;
           }
       }
       else
       {
           cnt=0;
       }
   }
   if(f)
   {
       cout<<"Yes"<<endl;
   }
   else
   {
       cout<<"No"<<endl;
   }
    return 0;
}




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

const int INF = 1e9;

int main() {
    int n, m;
    while (cin >> n >> m, n) {
        vector <vector <int>> G(n, vector <int> (n, INF));
        rep (i, m) {
            int a, b, c;
            cin >> a >> b >> c;
            a--; b--;
            G[a][b] = c;
            G[b][a] = c;
        }
        //state -> dist, pre, now, usedTicket
        using state = tuple <int, int, int, bool>;
        priority_queue <state> que;
        vector <vector <vector <int>>> dp(n, vector <vector<int>> (n, vector <int> (2, INF)));

        que.emplace(0, 0, 0, 0);
        dp[0][0][0] = 0;
        dp[0][0][1] = 0;

        while(!que.empty()) {
            state p = que.top(); que.pop();
            int dist, pre, now; bool usedTicket;
            tie(dist, pre, now, usedTicket) = p;

            rep (to, n) {
                if (now == to || G[now][to] == INF) continue;
                //チケット使わない
                if (dp[to][now][usedTicket] > dist + G[now][to]) {
                    dp[to][now][usedTicket] = dist + G[now][to];
                    que.emplace(dist + G[now][to], now, to, usedTicket);
                }
                //チケット使う
                if (!usedTicket && G[pre][now] != INF) {
                    if (dp[to][now][true] > dist - G[pre][now]) {
                        dp[to][now][true] = dist - G[pre][now];
                        que.emplace(dist - G[pre][now], now, to, true);
                    }
                }
            }
        }
        int ans = INF;
        rep (i, n) rep (j, 2) {
            ans = min(ans, dp[n - 1][i][j]);
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3420
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<int,int> P;
const LL mod=1000000007;
const LL LINF=1LL<<62;
const LL INF=1<<17;




int main(){
    string s;cin >> s;
    LL c=0,ans=0;
    for (int i = 0; i < s.length(); i++) {
        if(s[i]=='B') c++;
        else ans+=c;
    }
    cout << ans << endl;
    return 0;
}




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

// キーの挿入
void insertList(list<int> &l, int t)
{
    l.push_front(t);
}

// キーの削除
void deleteList(list<int> &l, int t)
{
    // Erase-Removeイディオム
    // https://ja.wikibooks.org/wiki/More_C%2B%2B_Idioms/%E6%B6%88%E5%8E%BB%E3%83%BB%E5%89%8A%E9%99%A4(Erase-Remove)
    // これでは要素全てを削除してしまう
    //list.erase(remove(list.begin(),list.end(),t),list.end());

    for (list<int>::iterator it = l.begin(); it != l.end(); it++)
    {
        if (*it == t)
        {
            l.erase(it);
            break;
        }
    }
}

// 先頭要素の削除
void deleteFirstList(list<int> &l)
{
    l.pop_front();
}

// 末尾要素の削除
void deleteLastList(list<int> &l)
{
    l.pop_back();
}

void printList(list<int> &l)
{
    int i = 0;
    for (list<int>::iterator it = l.begin(); it != l.end(); it++)
    {
        if (i)
            cout << " ";

        printf("%d", *it);
        i++;
    }
    cout << endl;
}

int main()
{
    int n = 0;
    //cin >> n;
    scanf("%d", &n);

    list<int> list;
    rep(i, n)
    {
        string order;
        int key;

        char input[15];
        //cin >> order;
        scanf("%s", input);
        order = input;

        if (order == "insert")
        {
            scanf("%d", &key);
            insertList(list, key);
        }
        else if (order == "delete")
        {
            scanf("%d", &key);
            deleteList(list, key);
        }
        else if (order == "deleteFirst")
        {
            /* code */
            deleteFirstList(list);
        }
        else if (order == "deleteLast")
        {
            /* code */
            deleteLastList(list);
        }

        //printList(list);
    }

    printList(list);

    return 0;
}


Measured memory_bytes: 34524
#include <iostream>
#include <string>

using namespace std;

int main() {
  string str, target;
  cin >> target;
  for(int i=0; i<target.length(); i++) {
    if('A' <= target[i] && target[i] <= 'Z') {
      target[i] += 32;
    }
  }

  int counter = 0;
  while(cin >> str) {
    if(str == "END_OF_TEXT") {
      break;
    }
    for(int i=0; i<str.length(); i++) {
      if('A' <= str[i] && str[i] <= 'Z') {
        str[i] += 32;
      }
    }
    if(str == target) counter++;
  }
  cout << counter << endl;
  return 0;
}

Measured memory_bytes: 3124
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
using namespace std;
using ll = int64_t;
using vi = vector<int>;
using vvi = vector<vi>;

int main() {
    int n;
    cin >> n;
    vector<pair<int, int> > ssp;
    vector<pair<int, int> > ssm;
    int total = 0;
    rep(i, n) {
        string S;
        cin >> S;
        int mi=0;
        int c = 0;
        rep(j, S.size()) {
            if(S[j] == '(') {
                ++c;
            } else {
                --c;
                mi = min(mi, c);
            }
        }
        total += c;
        if(c >= 0) ssp.push_back(make_pair(mi, c));
        else ssm.push_back(make_pair(mi-c, -c));
    }

    sort(ssp.rbegin(), ssp.rend());
    sort(ssm.rbegin(), ssm.rend());

    int cri = 0;
    int j=0;
    while(j != ssp.size()) {
        if(cri + ssp[j].first < 0) {
            cout << "No" << endl;
            return 0;
        }
        cri += ssp[j].second;
        ++j;
    }
    j = 0;
    cri = 0;
    while(j != ssm.size()) {
        if(cri + ssm[j].first < 0) {
            cout << "No" << endl;
            return 0;
        }
        cri += ssm[j].second;
        ++j;
    }
    
    if(total) {
        cout << "No" << endl;
        return 0;
    }

    cout << "Yes" << endl;
    
}

Measured memory_bytes: 11160
a,b=map(int,input().split())
#a,b=2,4
#a,b=5,11
#a,b=123,456
#a,b=123456789012, 123456789012

def xor(a,b):
    x=a
    for i in range(a+1,b+1):
        x=x^i
    print("xor:",x)

ia=len(bin(a))-2
ib=len(bin(b))-2

def px(b,ib):
    bbr=[]
    ip=1
    for i in range(ib):
        ip*=2
        bc=(b//ip)*(ip//2)
        bc+=max((b%ip+1)-(ip//2),0)
        bbr.append(bc)
    return bbr

aar=px(a-1,ib)
bbr=px(b,ib)

c=[0]*ib
ip=1
for i in range(ib):
    ip*=2
    ci=bbr[i]-aar[i]
    c[i]=ci%2

ip=1
csum=0
for i in range(ib):
    csum+=c[i]*ip
    ip*=2
    
print(csum)
    

Measured memory_bytes: 9252
#include <stdio.h>

//function to sort and print array using insertion
int BubbleSort (int arr[], int n)
{
    int i, j, count=0, temp;
    for (i=0; i<n-1; i++){
        for (j = n-1; j>=i+1; j--){
        	if (arr[j]<arr[j-1]){
				temp = arr[j];
            	arr[j] = arr[j-1];
            	arr[j-1] = temp;
                count++;
        	}
    	}
    }
    return count;
}

//test sort
int main()
{
    int i, n, swap;
    
    scanf("%d", &n);
    
    int a[n];
    
    for(i=0; i<n; i++)
        scanf("%d", &a[i]);
    
    swap = BubbleSort(a,n);
    
    for(i=0; i<n; i++){
    	printf("%d", a[i]);
    	if(i<n-1)
    		printf(" ");
    	else 
    		printf("\n");
    }
    
    printf("%d\n",swap);
    
    return 0;
}





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

int main(){
    int N;
    cin >> N;
    vector<int> d(N);
    for(int i = 0; i < N; i++) cin >> d.at(i);

    set<int> vvv;
    for(int i = 0; i < N; i++) vvv.insert(d.at(i));

    cout << vvv.size() << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = (ll)(x)-1;0 <= i; i--)
#define reps(i,x) for(ll i = 1; i < (ll)(x)+1; i++)
#define rreps(i,x) for(ll i = (ll)(x); 1 <= i; i--)
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const int n_max = 1e5+10;

int main(){
    string s;cin >> s;
    bool ok = false;
    if(s[2] == s[3] && s[4] == s[5])ok = true;
    cout << (ok ? "Yes" : "No") << endl;
}

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

typedef long long  ll;

ll MOD = 1000000007;
ll INF = 10000000000000000;
double PI = 3.1415926535;

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<pair<ll,ll>>>;

int main(){
 ll N;cin >> N;
 ll ans = 0;
 if(N % 2 == 1){
   cout << 0 << endl;
 }else{
   for(int i = 0;i <= 24;i++){
     if(N >= 10 * (ll)pow(5,i)){
     ans += N / ((ll)10 * (ll)pow(5,i));
     }
   }
   cout << ans << endl;
 }
}

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

int n,cnt;
int a[55];

int main()
{
	
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		if(a[i]!=i+1) cnt++;
	}
	if(cnt==0 || cnt==2) cout<<"YES\n";
	else cout<<"NO\n";
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main()
{
  int n; cin>>n;
  vector<int> l(10005);
  for(int x = 1 ; x <= 105; x++)
    for(int y = 1 ; y <= 105;y++)
      for(int z = 1 ; z <= 101 ; z++)
        if(x*x + y*y + z*z + x*y + y*z + z*x < 10005)
          l[x*x + y*y + z*z + x*y + y*z + z*x]++;
  for(int i = 1 ; i <= n ; i++)
  {cout<<l[i]<<endl;}
}

Measured memory_bytes: 3552
Option Strict On

Module Module1
    Sub Main()
        'let'
        Dim S As String = Console.ReadLine()

        'var'
        Dim ans As Long = 0

        For Each c As Char In S
            ans += New Long() {-1, 1}(Convert.ToInt32(c = "+"))
        Next

        Console.WriteLine(ans)

    End Sub
End Module

Measured memory_bytes: 20432
import Control.Applicative
import Control.Monad
import Data.List
import Data.Array
import Data.Char

main = do
  [x, a, b] <- map (read::String -> Int) . words <$> getLine
  let diff = b - a
  putStrLn $ if diff <= 0 then "delicious" else if diff <= x then "safe" else "dangerous"


Measured memory_bytes: 508
import sys
input = sys.stdin.readline
import numpy as np


def read():
    N = int(input().strip())
    A = [-1]
    for _ in range(N):
        a = int(input().strip())
        A.append(a)
    return N, A

def solve(N, A):
    i = 1
    for n in range(1, N+1):
        i = A[i]
        if i == 2:
            return n
    return -1

if __name__ == '__main__':
    inputs = read()
    print(solve(*inputs))


Measured memory_bytes: 16332
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;

#define all(a) (a).begin(), (a).end()

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

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

    vector<int> v = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

    int k; cin>>k;

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

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	static boolean isEvenStr(String str) {
		return str.substring(0, str.length() / 2).equals(str.substring(str.length() / 2));
	}
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String str = sc.next();
		int ans = 0;
		for(int i = str.length() - 1; i >= 0; i--) {
			if(isEvenStr(str.substring(0, i))) {
				ans = i;
				break;
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 21972
#include <iostream>
#include <cstring>

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

void bsort(int a[], int lim)
{
	int tmp;

    for (int i = 0; i <= lim-1; i++)
        for (int j = lim; i < j; j--)
		{
            if (a[j-1] > a[j])
			{
				tmp = a[j];
				a[j] = a[j-1];
				a[j-1] = tmp;
            }
        }	
}

int main()
{
	int n, m, i;
	int out;
	int t[20002];

	while( std::cin >> n >> m , (n||m) )
	{
		std::memset( t, 0, sizeof(t));
		out = 0;

		for( i = 1; i <= n+m; i++)
		{
			std::cin >> t[i];
		}

		bsort( t, n+m );

		for( i = 0; i <= m+n; i++)
		{
			t[i] = t[i+1] - t[i];
		}
		for( i = 0; i <= m+n-1; i++)
		{
			out = max(out, t[i]);
		}

		std::cout << out << std::endl;
	}

	return 0;
}

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

#ifdef LOCAL
    #include "debug.h"
    #define input \
        freopen("input.txt", "r", stdin); \
        freopen("output.txt", "w", stdout);
#else
    #define debug(...) 4
    #define input 4
#endif

const int mod = 1e9 + 7;
using ll = long long;
const int N = 2e5 + 5;



int32_t main() {
    input;
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int d, t, s;
    cin >> d >> t >> s;


    long double x = (long double) d / s;
    if(x <= t) {
        cout << "Yes\n";
    }
    else {
        cout << "No\n";
    }

}






Measured memory_bytes: 3616
import java.util.Scanner;

public class Main {

    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) throws Exception {
        int N = sc.nextInt();
        int M = sc.nextInt();
        int[] S = new int[M];
        char[] C = new char[M];
        for (int i = 0; i < M; i++) {
            S[i] = sc.nextInt();
            C[i] = (char) ('0' + sc.nextInt());
        }

        int ans;
        if (N == 1) {
            ans = 0;
        } else if (N == 2) {
            ans = 10;
        } else {
            ans = 100;
        }

        while (true) {
            char[] c = Integer.toString(ans).toCharArray();

            if (c.length > N) {
                ans = -1;
                break;
            }

            boolean valid = true;
            for (int i = 0; i < M; i++) {
                if (c[S[i] - 1] != C[i]) {
                    valid = false;
                    break;
                }
            }

            if (valid) {
                break;
            }

            ans++;
        }

        System.out.println(ans);
    }

}


Measured memory_bytes: 25044
#include <iostream>

using namespace std;

void swap(int& a,int& b){
  int t=a;
  a=b;
  b=t;
}

int main(){
  int x,y,z;
  cin>>x; cin>>y; cin>>z;
  if(y<x) swap(x,y);
  if(z<y) swap(y,z);
  if(y<x) swap(x,y);
  cout<<x<<" "<<y<<" "<<z<<'\n';
  return 0;
}

Measured memory_bytes: 3076
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def main():
    N = int(input())
    ans = 0
    for i in range(1, N + 1, 2):
        num = 0
        for j in range(1, i + 1):
            num += (i % j == 0)
        ans += num == 8
    print(ans)


if __name__ == '__main__':
    main()


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

#define CHMIN(a, b) a=min((a), (b))
#define CHMAX(a, b) a=max((a), (b))

const ll MOD=1000000007ll;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int bit[114514][40], kbit[40], ans[40];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	ll k, a;
	cin>>n>>k;
	REP(i, n){
		cin>>a;
		int cnt=0;
		while(a>0){
			bit[i][cnt++]=a&1;
			a/=2;
		}
	}
	int kcnt=0;
	while(k>0){
		kbit[kcnt++]=k&1;
		k/=2;
	}
	bool lower=false;
	FORR(i, 0, 40){
		int cnt=0;
		REP(j, n){
			if(bit[j][i]){
				++cnt;
			}
		}
		if(cnt*2<n){
			if(!lower && kbit[i]==0){
				ans[i]=cnt;
			}
			else{
				ans[i]=n-cnt;
			}
		}
		else{
			ans[i]=cnt;
			if(!lower && kbit[i]==1){
				lower=true;
			}
		}
	}
	ll res=0, beki=1;
	REP(i, 40){
		// DEBUG(res);
		// DEBUG(ans[i]);
		res+=beki*ans[i];
		beki*=2;
	}
	cout<<res<<'\n';
	return 0;
}


Measured memory_bytes: 16640
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <algorithm>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

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

    set<string> v;
    rep(i, (int)s.length()){
        for(int j = 1; j <= 5; j++){
            v.insert(s.substr(i, j));
        }
    }
    auto it = v.begin();
    for(int i = 0; i < k-1; i++){
        it++;
    }
    cout << *it << endl;
    return 0;
}


Measured memory_bytes: 1152
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		int sum1 = 0;
		int sum2 = 0;
		int sum3 = 0;
		int sum4 = 0;
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();  
		for (int i=0; i < N ;i++){
			String S = in.next();
				if (S.equals("AC")){
					sum1= sum1 +1;
				}
				else if (S.equals("WA")){
					sum2= sum2 +1;
				}
      			else if (S.equals("TLE")){
					sum3= sum3 +1;
				}
      			else if (S.equals("RE")){
					sum4= sum4 +1;
				}
        }
      System.out.println("AC x " + sum1);
      System.out.println("WA x " + sum2);
      System.out.println("TLE x " + sum3);
      System.out.println("RE x " + sum4);
	}
}

Measured memory_bytes: 58140
import java.util.Scanner;

public class Main{
    public static void main(String[]argc){
        Scanner sc = new Scanner(System.in);
        for(int k=0;;k++){
            int H = sc.nextInt();
            int W = sc.nextInt();
            if(H==0&&W==0) break;
            for(int i=0;i<H;i++){
                for(int j=0;j<W;j++){
                    System.out.printf("#");
                }
                System.out.printf("\n");
            }
            System.out.printf("\n");
        }
    }
}


Measured memory_bytes: 63256
# -*- coding: utf-8 -*-
"""
Created on Sat Feb 16 20:52:33 2019

@author: Owner
"""


import collections
import scipy.misc
import sys
import numpy as np
import math
from operator import itemgetter
import itertools
import copy

#素因数を並べる
def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n /= i
      table.append(int(i))
    i += 1
  if n > 1:
    table.append(int(n))
  return table   
# 桁数を吐く
def digit(i):
    if i > 0:
        return digit(i//10) + [i%10]
    else:
        return []
    
def getNearestValueIndex(list, num):
    """
    概要: リストからある値に最も近い値のインデックスを取得する関数
    @param list: データ配列
    @param num: 対象値
    @return 対象値に最も近い値
    """

    # リスト要素と対象値の差分を計算し最小値のインデックスを取得
    idx = np.abs(np.asarray(list) - num).argmin()
    return idx

"""
N, X = map(int, input().split())

x = [0]*N
x[:] = map(int, input().split())

P = [0]*N
Y = [0]*N
for n in range(N):
    P[n], Y[n] = map(int, input().split())
    
all(nstr.count(c) for c in '753')

ABT = zip(A, B, totAB)
result = 0
# itemgetterには何番目の配列をキーにしたいか渡します
sorted(ABT,key=itemgetter(2))
#A, B, totAB = zip(*ABT)


(x >> i) & 1

"""

N, M = map(int, input().split())
cnt_res = [0]*M
for n in range(N):
    KA =[]
    KA = list(map(int, input().split()))
    K = KA.pop(0)
    for m in range(K):
        num = KA[m]
        cnt_res[num-1] += 1
print(cnt_res.count(N))


Measured memory_bytes: 14288
#include <iostream>
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <set>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <bitset>
#include <stack>
#include <queue>
#include <ctype.h>

typedef long long int lli;
#define rep(i,s,N) for(int i=s;i<N;i++)
#define MOD 1000000007
#define more(a,b) (((a)>(b))?(a):(b))
#define less(a,b) (((a)<(b))?(a):(b))
using namespace std;


int main(void)
{
	int N; cin >> N;
	int min = 200001;
	int ans = 0;
	rep(i, 0, N) {
		int tmp; cin >> tmp;
		if (tmp <= min) {
			min = tmp;
			ans++;
		}
	}
	cout << ans << endl;

	return 0;
}


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

#define step(i, s, n, d) for(int i=s; i<n; i+=d)
#define FOR(i,s,n) step(i,s,n,1)
#define rep(i,n) FOR(i,0,n)
#define gets(x) x; cin >> x;
#define puts(x) x; cout << x << endl;
#define list_input(x, n) x[n]; rep(i,n){ gets(x[i]);}
#define ll long long

int main(){
  ll N, n, r=0;
  cin >> N;
  ll a[N];
  rep(i, N){
    cin >> a[i];
  }
  sort(a, a+N);
  n = a[N-1];
  double val = n*1.000/2;
  rep(i, N-1){
    if (abs(val-r) > abs(val-a[i])) {
      r = a[i];
    }
  }
  if (N > 2) {
    cout << n << " " << r << endl;
  }else{
    cout << a[N-1] << " " << a[0] << endl;
  }
}


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

int main(){
  char s[100010];
  int n;
  scanf("%s",s);
  n=strlen(s);
  for(int i=0;i<n-2;i++){
    if(s[i]==s[i+1]){
      printf("%d %d\n",i+1,i+2);
      return 0;
    }
    else if(s[i]==s[i+2]){
      printf("%d %d\n",i+1,i+3);
      return 0;
    }
  }
  if(s[n-2]==s[n-1]){
    printf("%d %d\n",n-1,n);
    return 0;
  }
  printf("-1 -1\n");
}

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

using namespace std;
using namespace atcoder;

using lint = long long;
#define rep(i, n) for(lint i = 0; i < lint(n); i++)
#define repu(i, a, b, s) for(lint i = lint(a); i < lint(b); i += lint(s))
#define repd(i, a, b, s) for(lint i = lint(a); i > lint(b); i += lint(s))
#define endl "\n"
constexpr lint INF = 2e18;
constexpr lint MOD = 1e9 + 7;

void solve() {

    lint N, Q;
    cin >> N >> Q;
    dsu uni(N);

    rep(i, Q) {
        lint t, u, v;
        cin >> t >> u >> v;
        if(t == 0) {
            uni.merge(u, v);
        } else {
            if(uni.same(u, v)) {
                cout << 1 << endl;
            } else {
                cout << 0 << endl;
            }
        }
    }
}

int main(int argc, char *argv[]) {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    solve();
}

Measured memory_bytes: 3996
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

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

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

ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}





///////////////////////////




int main() {
	ll N, K;
	cin >> N >> K;

	ll ans = 0;

	for (ll B = K + 1; B <= N; B++) {
		ll d = N / B;
		ans += d * (B - K);
		ans += max(N - d * B - max(1, K)+1, 0);
		//cout << ans << endl;
	}

	cout << ans;

	system("PAUSE");

}


Measured memory_bytes: 504
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define cyes cout<<"YES"<<endl
#define cno cout<<"NO"<<endl
#define sp <<" "<<
#define cst(x) cout<<fixed<<setprecision(x)
#define pi 3.14159265359
#define mod 1000000007
struct edge {
    int to; 
    int weight;
    edge(int t, int w) : to(t),weight(w) {}
};
using namespace std;
using ll = long long;
using ld = long double;
using Graph = vector<vector<int>>;
using que_a = priority_queue<int, vector<int>, greater<int> >;
using que_d = priority_queue<int>;
using pint = pair<int,int>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(){

    int a,b,c,d,e,f; cin >> a >> b >> c >> d >> e >> f;

    vector<int> water,sugar;
    set<int> was,sus;
    int i = 0, j;
    while(i*a*100 <= f){
        j = 0;
        while(i*a*100 + j*b*100 <= f){
            int o = i*a*100 + j*b*100;
            if(i+j != 0 && !was.count(o)) {
                was.insert(o);
                water.push_back(o);
            }
            j++;
        }
        i++;
    }
    int p = 0,q;
    while(c*p <= f){
        q = 0;
        while(c*p + d*q <= f){
            int o = c*p + d*q;
            if(!sus.count(o)) {
                sus.insert(o);
                sugar.push_back(o);
            }
            q++;
        }
        p++;
    }
    int wa_size = water.size();
    int su_size = sugar.size();
    int ans_sum = 0;
    int ans_sug = 0;
    ld dens = -1.0;
    rep(x,wa_size)rep(y,su_size){

            int sum = water.at(x)+sugar.at(y);
            if(sum <= f && sugar.at(y) <= water.at(x)*e/100){
                if(sugar.at(y)/double(sum) > dens){
                    dens = sugar.at(y)/double(sum);
                    ans_sum = sum;
                    ans_sug = sugar.at(y);
                } 
            }
    }
    cout << ans_sum sp ans_sug << endl;
    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
using namespace std; // 575

int main() {
	int N[3], K;
	cin >> N[0] >> N[1] >> N[2] >> K;
	sort(N, N+3);
	cout << N[0] + N[1] + (N[2] << K);
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり
また、コンテスト後に https://31536000.hatenablog.com/ で解説していると思うので、良かったら読んでねー

*/

Measured memory_bytes: 256
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
			　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <iostream>
#include <vector>
#include <array>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <climits>
#include <tuple>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <algorithm>
#include <memory>
#include <iomanip>

#define rep(i, n) for(Int (i) = 0; (i) < (n); ++(i))
#define debug(var) std::cout << #var << ": " << var << "\n"
using Int = int64_t;
constexpr Int INF = INT_MAX;
constexpr Int mod = 1e9 + 7;

///nの約数を列挙する関数。計算量はO(√n)
std::vector<Int> Divisor(Int n) {
	std::vector<Int> res;
	for (Int i = 1; i * i <= n; ++i) {
		if (n % i == 0) {
			res.push_back(i);
			if (i * i != n)res.push_back(n / i);
		}
	}
	std::sort(std::begin(res), std::end(res));
	return res;
}

void calc() {

	Int N, M; std::cin >> N >> M;
	auto divisor = Divisor(M);
	Int ans = 0;
	for (const auto& elem : divisor) {
		if (M >= elem * N)ans = elem;
	}

	std::cout << ans;

}


int main() {

	calc();

	return 0;
}

Measured memory_bytes: 256
# kleene Inversion

n, k = map(int, input().split())
a = list(map(int, input().split()))
_mod = 10**9+7

ca = 0
cb = 0

for i in range(0, n):
    for j in range(i, n):
        if a[i] > a[j]:
            ca += 1

for i in range(0, n):
    for l in range(0, n):
        if a[i] > a[l]:
            cb += 1

count = ca * k + cb * (k*(k-1))//2
print(count % _mod)


Measured memory_bytes: 3188
#include<iostream>
#include<cstdio>
#include<algorithm>
int main(void)
{
	int a[5]={0};
	for(int i=0;i<5;i++)
	{
		scanf("%d",&a[i]);
		if(a[i]<40){
			a[i]=40;
		}
	}
	printf("%d\n",(a[0]+a[1]+a[2]+a[3]+a[4])/5);
	return 0;
}
//13:23.577 clear!!


Measured memory_bytes: 3152
import numpy

def main():
    n, k, q = (int(x) for x in input().split() )
    
    #n個の要素を持つ配列の作成
    a = [0 for i in range(n)]
    
    for i in range(q):
      ai = int(input())
      a[(ai-1)] = a[(ai-1)] + 1
      
    #for i in range( n ):
    #  print(a[i])
    
    for i in range( n ):
      if k - q + a[i] > 0:
        print("Yes")
      else:
        print("No")
      
if __name__ == '__main__': main()

Measured memory_bytes: 14032
// Problem : E - Coprime
// Contest : AtCoder - AtCoder Beginner Contest 177
// URL : https://atcoder.jp/contests/abc177/tasks/abc177_e
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define int long long
#define db double
#define mod 1000000007
#define pb push_back
#define pp pair<int,int>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repe(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=b;i>=a;i--)
#define maxn 1000005
#define ss second
#define ff first
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
int inv(int a, int b){
 return 1<a ? b - inv(b%a,a)*b/a : 1;
}
set<int> s[maxn];
int a[maxn];
void solve()
{
	for(int i=2;i<maxn;i++)
	{
		if(a[i] == 0)
		{
			a[i] = i;
			for(int j=i;j<maxn;j+=i)
			if(a[j] == 0)
				a[j] = i;
		}
	}
	int n,gc,flag=0;
	cin >> n;
	for(int i=0;i<n;i++)
	{
		int x;
		cin >> x;
		if(i == 0)
			gc = x;
		gc = __gcd(x,gc);
		while(x != 1 and flag == 0)
		{
			int p = a[x];
			s[p].insert(i);
			if(s[p].size() > 1)
			{
				flag = 1;
				break;
			}
			x = x/p;
		}
	}
	if(!flag)
	{
		cout << "pairwise coprime" <<"\n";
	}
	else if(gc == 1)
	{
		cout <<"setwise coprime" <<"\n";
	}
	else cout <<"not coprime" <<"\n";
}
signed main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    //cin >> t;
    while(t--)
    solve();
    return 0;
}


Measured memory_bytes: 61936
#include<bits/stdc++.h>
#define ll long 
 
using namespace std;
 
main(){
    int n,m=0,c=0;
    cin>>n>>m;
    int a[n+1];
    for(int i=1;i<=n;i++){
        cin>>a[i];
        if(a[i]>=m) c++;
    }
    cout<<c;
    return 0;
}

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

int main(void){
  int n;
  cin >> n;
  int a[n];
  for(int i = 0; i < n; i++) cin >> a[i];
  int ans = 200 * 200 * 100;
  int sum;
  for(int i = -100; i <= 100; i++){
    sum = 0;
    for(int j = 0; j < n; j++){
      sum += (a[j] - i) * (a[j] - i);
    }
    if(sum < ans) ans = sum;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll  long long
//#define int long long
#define inf 0x3f3f3f3f
#define fi first
#define se second
#define pb push_back
#define pa pair<int,int>
#define mkp(a,b) make_pair(a,b)
const int N=2e5+10;
const int mod=998244353;
using namespace std;


struct Point
{
   int x,y;
   Point(){}
   Point(int x,int y):x(x),y(y){}
};
typedef Point Vector;
inline int cross(Vector a,Vector b){return a.x*b.y-a.y*b.x;}
inline int dot(Vector a,Vector b){return a.x*b.x+a.y*b.y;}
int x[5],y[5];
int32_t main()
{
   //ios::sync_with_stdio(0); cin.tie(0);cout.tie(0);
   int q; scanf("%d",&q);
   while(q--)
   {
   	  for(int i=1;i<=4;i++) scanf("%d%d",&x[i],&y[i]);
   	  if(max(x[1],x[2])<min(x[3],x[4])||min(x[1],x[2])>max(x[3],x[4])||max(y[1],y[2])<min(y[3],y[4])||min(y[1],y[2])>max(y[3],y[4])) 
   	  {
   	  	puts("0");
   	  	continue;
   	  }	
   	  ll p1=cross(Point(x[3]-x[1],y[3]-y[1]),Point(x[2]-x[1],y[2]-y[1])); 
   	  ll p2=cross(Point(x[4]-x[1],y[4]-y[1]),Point(x[2]-x[1],y[2]-y[1]));
   	  ll p3=cross(Point(x[1]-x[3],y[1]-y[3]),Point(x[4]-x[3],y[4]-y[3]));  
   	  ll p4=cross(Point(x[2]-x[3],y[2]-y[3]),Point(x[4]-x[3],y[4]-y[3]));   
   	  if(p1*p2<=0&&p3*p4<=0) puts("1");
   	  else puts("0");
   }
return 0;
}
/*

*/



Measured memory_bytes: 3172
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cstring>
#include<iostream>
using namespace std;
typedef long long ll;
string s1,s2,sq,sh;
int q,prime,p;
bool flag=1;
int main(){
    cin>>s1>>q;
    while(q--){
        cin>>prime;
        if(prime==1){
            flag=!flag;
        }else{
            cin>>p>>s2;
            if((p+flag)%2){
//                s1=s1+s2;
                s1.insert(s1.size(),s2);
            }else{
//                s1=s2+s1;
                s1.insert(0,s2);
            }
        }
    }
    if(flag){
        cout<<s1;
    }else{
        int len=s1.size();
        for(int i=len-1;i>=0;i--){
            cout<<s1[i];
        }
    }
    return 0;
}


Measured memory_bytes: 1028