akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define int long long
#define rint register int
using namespace std;
 
template<typename tp> inline void read(tp &x) {
  x = 0; char c = getchar(); int f = 0;
  for (; c < '0' || c > '9'; f |= c == '-', c = getchar());
  for (; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - '0', c = getchar());
  if (f) x = -x;
}
#define pb push_back
const int N = 3e5 + 233;
int top = 0, st[N];
int S = -1, T = -1;
int dep[N], fa[N], vis[N], dp[N], tag[N], has[N];
int n, m;
vector <int> g[N];

inline void fcr(int u, int fat) {
  dep[u] = dep[fa[u] = fat] + 1;
  vis[u] = true; dp[u] = dep[u] & 1 ? 1 : -1;
  for (auto v : g[u])
    if (v != fat) {
      if (vis[v]) {
        if (S == v && T == u)
          continue;
        assert(S == -1);
        S = u; T = v;
      } else {
        fcr(v, u);
        dp[u] += dp[v];            
      }
    }
}

inline int getDist(int u, int v) {
  int d = 0;
  while (u != v) {
    if (dep[u] < dep[v]) swap(u, v);
    ++ d; u = fa[u];
  }
  return d;
}

inline void dfs(int u, int fat) {
  dp[u] = has[u] + (dep[u] & 1 ? 1 : -1); vis[u] = true;
  for (auto v : g[u])
    if (!vis[v]) dfs(v, u), dp[u] += dp[v], tag[u] += tag[v];
}

main(void) {
  read(n); read(m);
  for (int i = 1; i <= m; i ++) {
    int x, y; read(x); read(y);
    g[x].pb(y); g[y].pb(x);
  }
  fcr(1, 0);
  int sum = dp[1];
  if (S == -1) {
    if (sum)
      return puts("-1"), 0;
    int ans = 0;
    for (int i = 1; i <= n; i ++)
      ans += abs(dp[i]);
    cout << ans << "\n";
    return 0;
  }
  int d = getDist(S, T) + 1;
  if (d & 1) {
    if (sum & 1)
      return puts("-1"), 0;
    int ans = abs(sum) / 2;
  i:;
    has[S] += sum / 2; has[T] += sum / 2;
    // cout << S << " " << T << "\n";
    // for (int i = 1; i <= n; i ++) cout << dp[i] << " "; puts("");
    memset(vis, 0, sizeof vis);
    dfs(1, 0);
    if (dp[1]) {
      has[S] -= sum;
      has[T] -= sum;
      goto i;
    }      
    // for (int i = 1; i <= n; i ++) cout << dp[i] << " "; puts("");
    for (int i = 1; i <= n; i ++)
      ans += abs(dp[i]);
    cout << ans << "\n";
  } else {
    if (sum)
      return puts("-1"), 0;
    tag[S] = -1; tag[T] = 1;
    memset(vis, 0, sizeof vis);
    dfs(1, 0);
    int ans = 0;
    st[++ top] = 0;
    for (int i = 1; i <= n; i ++)
      if (tag[i]) st[++ top] = dp[i];
      else ans += abs(dp[i]);
    // for (int i = 1; i <= n; i ++) cout << dp[i] << " "; puts("");
    // cout << S << " " << T << "\n";
    // for (int i = 1; i <= top; i ++)
    //   cout << st[i] << " "; puts("");
    sort(st + 1, st + top + 1);
    // for (int i = 1; i <= top; i ++)
    //   cout << st[i] << " "; puts("");
    int x = st[(top + 1) / 2];
    for (int i = 1; i <= top; i ++)
      ans += abs(st[i] - x);
    cout << ans << "\n";
  }
}


Measured memory_bytes: 28672
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll power(ll p,ll n){
   ll result=1;
   while(n!=0){
   if(n%2==0){
    n/=2;
    p*=p;
   }
   else{
    n--;
    result=result*p;
   }
   }
    return result;
}
int main()
{
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);

   ll n,t,a,b,c,d;
   ll mod =1e9+7;
   string s1,s2;
   stack<ll>stck1;
   stack<ll>stck2;

   set<ll>st;
   cin>>n;
   map<string,ll>mp;
   while(n--){
    cin>>s1;
    mp[s1]++;
   }
   ll maxx=0;
   for(auto it:mp){
    maxx=max(maxx,it.second);
   }
   vector<string>vec;
   for(auto it:mp){
    if(it.second==maxx){
        vec.push_back(it.first);
    }
   }

   sort(vec.begin(),vec.end());

   for(auto it:vec){
    cout<<it<<endl;
   }

}


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

int main(){
    int n, m;
    cin >> n;
    map<string, int> mp;
    for(int _ = 0; _ < n; _++){
        string s;
        cin >> s;
        mp[s]++;
    }
    cin >> m;
    for(int _ = 0; _ < m; _++){
        string t;
        cin >> t;
        mp[t]--;
    }
    int ans = 0;
    for(auto x : mp){
        ans = max(ans, x.second);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,m;
	cin >> n >> m;
	 map<int,int> ans;
	for ( int i = 0; i < m; i++)
	{
	int x,y;
	cin >>x >> y;
	ans[x]++;
	ans[y]++;
	}
	for ( int i = 1 ; i <= n; i++)
	cout << ans[i] << endl;
	return 0;
}

Measured memory_bytes: 256
n,x = map(int,input().split())
a = sorted(list(map(int,input().split())))
c = 0
ans = 0
i = 0
while x>0 and i<n:
  x -= a[i]
  i += 1
  c += 1
  
if x==0:
  print(c)
else:
  print(c-1)

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

const int N = 2e5 +10;

int n, q;
long long cnt[N], add[N], tala;
vector <int> adj[N], par;
bool mark[N];

void input() {
	cin >> n >> q;
	for (int i = 0; i < n - 1; i++) {
		int u, v;
		cin >> u >> v;
		u--, v--;
		adj[u].push_back(v);
		adj[v].push_back(u);		
	}
	
	for (int i = 0; i < q; i++) {
		long long p, x;
		cin >> p >> x;
		p--;
		add[p] += x;
	}
}

void dfs(int u) {
	mark[u] = true;
	
	tala += add[u];
	cnt[u] += tala;
		
	for (auto v: adj[u]) {
		if (!mark[v])
			dfs(v);
	}
	tala -= add[u];
		
}

int main() {
	ios:: sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL);
	
	input();
	dfs(0);	
	
	for (int i = 0; i < n; i++)
		cout << cnt[i] << ' ';
			
	return 0;
}

Measured memory_bytes: 22656
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <iomanip>
#include <cassert>
#include <random>
#include <cstring>


int main() {
    int x, y; std::cin >> x >> y;
    for (int i = 0; i <= x; i++) {
        int j = x - i;
        if (2 * i + 4 * j == y) {
            std::cout << "Yes" << std::endl;
            return 0;
        }
    }
    std::cout << "No" << std::endl;
    return 0;
}

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

int search(int A[], int n, int key) {
  int i = 0;
  A[n] = key;
  while (A[i] != key) i++;
  return i != n;
}

int main() {
  int i, n, A[10000 + 1], q, key, sum = 0;

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

  scanf("%d", &q);
  for (i = 0; i < q; i++) {
    scanf("%d", &key);
    if (search(A, n, key)) sum++;
  }
  printf("%d\n", sum);

  return 0;
}


Measured memory_bytes: 3216
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

int main()
{
    int n, h;
    cin >> n >> h;
    vector<int> a(n), b(n);
    for(int i=0; i<n; ++i)
        cin >> a[i] >> b[i];
    sort(a.rbegin(), a.rend());
    sort(b.rbegin(), b.rend());

    long long ans = (h + a[0] - 1) / a[0];
    long long sum = 0;
    for(int i=0; i<n; ++i){
        sum += b[i];
        long long rest = max(0ll, h - sum);
        ans = min(ans, i + 1 + (rest + a[0] - 1) / a[0]);
    }
    cout << ans << endl;

    return 0;
}


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

int main(){
    ios::sync_with_stdio(0); cin.tie(0), cout.tie(0);
    ll n, a, b; cin >> n >> a >> b;
    if(n==1){
        if(a==b) cout << 1;
        else cout << 0;
    }
    else cout << max(0ll,max(n-2,0ll)*(b-a)+1);
}



Measured memory_bytes: 256
$selected = []
$distance = 0
INF = 10**12
def prim(matrix)
  matrix.map do |row|
    row[0] = -1
  end
  $selected << matrix[0]
  until $selected.size == matrix.size
    min_index = nil
    min_value = INF
    $selected.each do |row|
      row.each_with_index do |value, index|
        if min_value > value && value >= 0
          min_index = index
          min_value = value
        end
      end
    end
    matrix.map do |row|
      row[min_index] = -1
    end
    $distance += min_value
    $selected << matrix[min_index]
  end
end

n = gets.to_i
matrix = []
n.times do
  matrix << gets.split(' ').map(&:to_i)
end
prim matrix
p $distance


Measured memory_bytes: 7020
#include<cstdio>
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<queue>

using namespace std;

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

int main()
{
	int n;
	cin>>n;
	
	vector<int> p;
	rep(i,n)
	{
		int a;
		cin>>a;
		p.push_back(a);
	}
	
	
	int ans = 0;
	reps(i,1,(1<<n))
	{
		int cur = 1;
		rep(j,n)
		{
			if((i&(1<<j))>0)
			{
				if(p[j]%2==1) cur *= 2;
				if(p[j]%2==0) cur *= 1;
			}else
			{
				if(p[j]%2==1) cur *= 1;
				if(p[j]%2==0) cur *= 2;	
			}
		}
		ans += cur;
	}
	
	printf("%d\n",ans);
}

Measured memory_bytes: 256
program main
      implicit none
      integer(8) :: h
      integer(4) :: n, i
      integer(4),allocatable :: a(:)

      read *, h,n
      allocate( a(n) )
      read *, a

      do i = 1, n
        h = h - a(i)
        if ( h <= 0 ) then
          print *, 'Yes'
          exit
        end if
      end do

      if ( h > 0 ) then
        print *, 'No'
      end if
end program main


Measured memory_bytes: 1152
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const ll N=2e5+5;
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll n;cin>>n;
    ll p[n];for(ll i=0,x;i<n;i++)cin>>x,p[x-1]=i;
    ll ans=1,cur=1;
    for(ll i=1;i<n;i++){
        if(p[i]>p[i-1])cur++;
        else cur=1;
        ans=max(ans,cur);
    }
    cout<<n-ans<<"\n";
}


Measured memory_bytes: 1792
#include<stdio.h>
int main(void){
	int n,x;
	int i,j,k,cnt = 0;
	
	while(1){
		scanf("%d %d",&n,&x);
		if(n == 0 && x == 0)break;
		for(i  = 1;i <= n;i++){
			for(j = i+1;j <= n;j++){
				for(k = j+1;k <= n;k++){
					if(i+j+k == x)cnt++;
				}
			}
		}
		printf("%d\n",cnt);
		cnt = 0;
	}
	
	return 0;
}

Measured memory_bytes: 600
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        long a = sc.nextLong();
        long b = sc.nextLong();

        if (a % 2 == b % 2)
            System.out.println((a + b) / 2);
        else
            System.out.println("IMPOSSIBLE");
    }
}

Measured memory_bytes: 23764
#include<stdio.h>
#include<iostream>
#include<algorithm> // sort(ALL())
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue> // push(), front(), pop() 先入れ先出し
#include<map> // 連想配列 map<string, int>
#include<iomanip>
#include<set>
#include<utility>
using namespace std;
#define FOR(i, a, b) for(int i=(a); i<(b);  i++)
#define REP(i, n)    for(int i=0;   i<(n);  i++)
#define REP1(i, n)   for(int i=1;   i<=(n); i++)
#define pb push_back
#define mp make_pair
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define EPS 1e-7
#define ALL(obj) (obj).begin(), (obj).end()
using ul    = unsigned long;
using ll    = long long;
using ld    = long double;
using vint  = vector<int>;
using vll   = vector<ll>;
using pint  = pair<int, int>;
using pll   = pair<ll, ll>;
using vpint = vector<pint>;
using vpll  = vector<pll>;
const int INF = (int)1e9 + 1;
const int MOD = (int)1e9 + 7;
#define INT(argu) (int)(argu+EPS)



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

  int x;
  cin >> x;
  cout << x/500*1000 + (x-x/500*500)/5*5 << endl;
//  vint s(n);
//  REP(i, n) scan(s[i]);


//  cout << fixed << setprecision(10) <<  << endl;

  return 0;
}


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

int main(void){
    while(true){
        int n;
        cin >> n;
        if(n==0)break;
        
        double s[n];
        for(int i = 0;i<n;i++){
            int v;
            cin >> v;
            s[i] = v;
        }
        double sum = 0;
        for(int i = 0;i<n;i++){
            sum += s[i];
        }

        double ave = sum / n;

        double sum2 = 0;
        for(int i = 0;i<n;i++){
            sum2 += pow((s[i] - ave),2);
        }
        
        double ave2 = sum2 / n;
        
        double ans = sqrt(ave2);
        
        cout << fixed << ans << endl;
    }

}

Measured memory_bytes: 1240
#include <stdio.h>
#include <math.h>

int isPrime(int);

int main()
{
    int n,A;
    int k = 0;
    int i;
    scanf("%d",&n);
    for(i = 0;i < n;i++){
        scanf("%d",&A);
        k += isPrime(A);
    }
    
    printf("%d\n",k);
    return 0;
}

int isPrime(int x)
{
    int i;
    if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3;i <=sqrt(x);i+=2){
        if(x%i == 0) return 0;
    }
    return 1;
}


Measured memory_bytes: 2044
#include <iostream>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
 
int dp[3][110][2], num[110];
int n,k;
 
int main(){
    rep(i,110) num[i] = -1;
    cin >> n >> k;
    rep(i,k){
        int a,b;
        cin >> a >> b;
        a--; b--;
        num[a] = b;
    }
    if(num[0] == -1) rep(i,3) dp[i][0][0] = 1;
    else dp[num[0]][0][0] = 1;
    for(int i = 1; i < n; i++){
        rep(j,3){
            if(num[i] != -1 && num[i] != j) continue;
            dp[j][i][1] += dp[j][i-1][0];
            dp[j][i][1] %= 10000;
            rep(u,3){
                if(j == u) continue;
                dp[j][i][0] += dp[u][i-1][0]+dp[u][i-1][1];
                dp[j][i][0] %= 10000;
            }
        }
    }
        /*
    rep(i,n){
        rep(j,3){
            rep(u,2){
                cout << dp[j][i][u] << " ";
            }
            cout << endl;
        }
        cout << endl;
    }
    */
    int ans = 0;
    rep(i,3) rep(j,2) ans += dp[i][n-1][j];
    cout << ans%10000 << endl;
}

Measured memory_bytes: 1164
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    ll sum = 0;
    REP(i, 1, N) {
        if (i % 15 == 0) continue;
        else if (i % 5 == 0) continue;
        else if (i % 3 == 0) continue;
        sum += i;
    }
    cout << sum << endl;


    return 0;
}


Measured memory_bytes: 3636
object Main extends App {
  import scala.io.StdIn.readLine
  import scala.io.StdIn.readInt
  
  	var n = readInt
  	val pros = readLine.split(" ").map(_.toLong).toList.sorted
  
  if(n % 2 == 0){
    //リストは0から始まることに注意
    n =(n / 2).toInt
  	println( (pros(n - 1) until pros(n)).length )
  }
  else println("0")
}


Measured memory_bytes: 68564
import sys
import math
import bisect
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop


def LI(): return [int(x) for x in sys.stdin.readline().split()]


def I(): return int(sys.stdin.readline())


def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res


def IR(n):
    return [I() for i in range(n)]


# A
def A():
    S = input()
    if S == 'AAA' or S == 'BBB':
        print('No')
    else:
        print('Yes')
    return


# B
def B():
    N, A, B = LI()
    ans = N // (A + B) * A + min(N % (A + B), A)
    print(ans)
    return


# C
def C():

    return


# D
def D():
    return


# E
def E():
    return


# F
def F():
    return


# Solve
if __name__ == "__main__":
    B()


Measured memory_bytes: 38384
#!/usr/bin/env python3
class UnionFind():
    def __init__(self, size):
        self.table = [-1] * size

    def find(self, x):
        if self.table[x] < 0:
            return x
        else:
            self.table[x] = self.find(self.table[x])
            return self.table[x]

    def union(self, x, y):
        s1 = self.find(x)
        s2 = self.find(y)
        if s1 != s2:
            if self.table[s2] < self.table[s1]: s1, s2 = s2, s1
            self.table[s1] += self.table[s2]
            self.table[s2] = s1
        return s1 != s2


N, M = map(int, input().split())
uf = UnionFind(N + M)
for i in range(N):
    L = [int(x) - 1 for x in input().split()]
    L[0] += 1
    for j in range(L[0]):
        uf.union(L[j + 1], M + i)

ans = True
for i in range(N):
    if uf.find(M + i) != uf.find(M):
        ans = False
print(('NO', 'YES')[ans])


Measured memory_bytes: 10200
#include <iostream>
#include <vector>

using namespace std;

int main() {
	int W, H, x, y;
	cin >> W >> H >> x >> y;
	//	if (W * y + H * x - H * W > 0) {
	//		x = W - x;
	//		y = H - y;
	//	}

	int multi_sol = 0;

	if (W % 2 == 1 || H % 2 == 1) {
		multi_sol = 0;
	} else if (x == W / 2 && y == H / 2) {
		multi_sol = 1;
	} else {
		multi_sol = 0;
	}

	cout << double(W) * double(H) / double(2) << ' ' << multi_sol << endl;
}


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

std::vector<std::pair<int, long long>> uf;
std::vector<std::pair<int, int>> bridge;

long long getSize(int);
int getRoot(int);
void connect(int, int);

int main()
{
	long long n, m;
	scanf("%lld%lld", &n, &m);
	bridge.resize(m);
	for (auto& e: bridge)
	{
		scanf("%d%d", &e.first, &e.second);
		e.first--;
		e.second--;
	}
	uf.resize(n);
	for (int i{}; i < n; i++)
	{
		uf[i].first = i;
		uf[i].second = 1;
	}
	std::vector<long long> ans(m);
	ans.back() = n * (n - 1) / 2;
	for (long long i{m - 2}; i >= 0; i--)
	{
		auto& b{bridge[i + 1]};
		if (getRoot(b.first) != getRoot(b.second))
			ans[i] = ans[i + 1] - getSize(b.first) * getSize(b.second);
		else
			ans[i] = ans[i + 1];
		connect(b.first, b.second);
	}
	for (int i{}; i < m; i++)
		printf("%lld\n", ans[i]);

	return 0;
}

int getRoot(int index)
{
	if (uf[index].first == index) return index;
	int p{getRoot(uf[index].first)};
	uf[index].first = p;
	return p;
}

long long getSize(int index)
{
	return uf[getRoot(index)].second;
}

void connect(int a, int b)
{
	int p_a{getRoot(a)}, p_b{getRoot(b)};
	if (p_a == p_b) return;
	if (uf[p_a].second < uf[p_b].second)
	{
		uf[p_b].second += uf[p_a].second;
		uf[p_a].first = p_b;
	}
	else
	{
		uf[p_a].second += uf[p_b].second;
		uf[p_b].first = p_a;
	}
	return;
}

Measured memory_bytes: 4480
import cmath
import math

z = 0 + 0j
theta = 90
while True:
    r, phi = map(int, input().split(","))
    if r == phi == 0:
        break
    z += cmath.rect(r, math.radians(theta))
    theta = (theta - phi) % 360
print(math.trunc(z.real))
print(math.trunc(z.imag))

Measured memory_bytes: 7892
#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <string>
#include <cstring>
#include <sstream>
#include <queue>
#include <iomanip>
#include <algorithm>
using namespace std;

int n, a, b;

int main()
{
	cin >> n >> a >> b;
	printf("%d\n", min(a * n, b));
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXN=4000;

int nhonest,nunkind,n;
vector<int> unknown;
int ans[MAXN];
int q[MAXN],qhead,qtail;

int chead[MAXN],cnxt[MAXN];

bool test(int a,int b) {
	printf("? %d %d\n",a,b); fflush(stdout);
	char c; scanf(" %c",&c); return c=='Y';
}

int solve(vector<int> opt) {
	if(SZ(opt)==0) return -1;
	if(SZ(opt)==1) return opt[0];
	vector<int> nopt;
	for(int i=0;i+1<SZ(opt);i+=2) {
		int a=opt[i],b=opt[i+1];
		if(!test(a,b)) { unknown.PB(a); unknown.PB(b); continue; }
		if(!test(b,a)) { ans[a]=0; q[qhead++]=a; unknown.PB(b); continue; }
		nopt.PB(a);
		cnxt[b]=chead[a]; chead[a]=b;
	}
	int ret=solve(nopt);
	if(SZ(opt)%2==1) {
		int a=opt[SZ(opt)-1];
		if(ret==-1) ret=a;
		else unknown.PB(a);
	}
	return ret;
}

void run() {
	scanf("%d%d",&nhonest,&nunkind); n=nhonest+nunkind;
	if(nunkind>=nhonest) { printf("Impossible\n"); fflush(stdout); return; }
	vector<int> opt; REP(i,n) opt.PB(i); REP(i,n) chead[i]=-1,ans[i]=-1;
	unknown.clear(); qhead=qtail=0; int honest=solve(opt); assert(honest!=-1);
	ans[honest]=1; q[qhead++]=honest;
	REPSZ(i,unknown) {
		int a=unknown[i];
		ans[a]=test(honest,a)?1:0;
		q[qhead++]=a;
	}
	while(qtail<qhead) {
		int at=q[qtail++];
		for(int to=chead[at];to!=-1;to=cnxt[to]) { ans[to]=ans[at]; q[qhead++]=to; }
	}
	printf("! "); REP(i,n) printf("%d",ans[i]); puts(""); fflush(stdout);
}

int main() {
	run();
	return 0;
}


Measured memory_bytes: 852
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD=998244353;
int main()
{
    ll n,ans=1000000010000;
    scanf("%lld",&n);
    for(ll i=1;i*i<=n;i++)
    {
        if(n%i==0)
        {
            ans=min((i+n/i)-2,ans);
        }
    }
    cout<<ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <ext/numeric>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#define oo 0x3f3f3f3f
#define OO 0x3f3f3f3f3f3f3f3f
#define ones(n) __builtin_popcount(n)
#define ONES(n) __builtin_popcountll(n)

using namespace std;
//using namespace __gnu_cxx;
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef pair<int, int> ii;
typedef pair<long long, pair<int, int>> iii;
typedef pair<ii, ii> iiii;

const double PI = acos(-1.0), EPS = 1e-6;
const int N = 102, M = 100005, mod = 1000000007, mxLog = 20;
int a[N], n;
int memo[M];

int solve(int k) {
    int &ret = memo[k];
    if (~ret)
        return ret;
    ret = 0;
    for (int i = 0; i < n; ++i) {
        if (a[i] <= k)
            ret |= !solve(k - a[i]);
    }
    return ret;
}


int main() {
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "rt", stdin);
//    freopen("output.txt", "w", stdout);
#endif
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0), cout.precision(10), cout << fixed;

    int k;
    cin >> n >> k;
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    memset(memo, -1, sizeof memo);
    if (solve(k)) {
        cout << "First\n";
    }else {
        cout << "Second\n";
    }

    return 0;
}

Measured memory_bytes: 5376
using System;

namespace ConsoleApplication13
{
    class Program
    {
        static void Main(string[] args)
        {
            
            while(true){
                string input = Console.ReadLine();

                if (input == "0")
                {
                    break;
                }

                int scoreA = 0;
                int scoreB = 0;

                for (int i = 1; i < input.Length; i++)
                {
                    if (input[i] == 'A')
                    {
                        scoreA++;
                    }
                    else
                    {
                        scoreB++;
                    }
                }

                if (scoreA > scoreB)
                {
                    scoreA++;
                }
                else
                {
                    scoreB++;
                }

                    
                Console.WriteLine("{0} {1}", scoreA, scoreB);

            }


        }
    }
}

Measured memory_bytes: 19920
import java.util.*;

class Main{
    public static void main(String args[]){
        Scanner sc=new Scanner(System.in);
        while(true){
            int n=sc.nextInt();
            if(n==-1){
                break;
            }
            int cnt=0;
            if(n<=10){
                cnt=1150;
            }else if(n<=20){
                cnt=1150+125*(n-10);
            }else if(n<=30){
                cnt=1150+1250+140*(n-20);
            }else{
                cnt=1150+1250+1400+160*(n-30);
            }
            System.out.println(4280-cnt);
        }
    }
}


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

using namespace std;

int n;
int a[200005];
int pos[200005];

int main(void) {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n;
    for (int i = 1; i <= n; ++i) cin >> a[i], pos[a[i]] = i;
    int ans = 0, cur = 0;
    for (int i = 1; i <= n; ++i) {
        if (pos[i] > pos[i-1]) ++cur;
        else {
            ans = max(ans, cur);
            cur = 1;
        }
    }
    ans = max(ans, cur);
    cout << n - ans << endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>


using namespace std;
using ll = long long;

int n, p[21];
int ans;

int main()
{
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> p[i];
	}
	for (int i = 0; i < n - 2; i++)
	{
		int k[3] = { p[i], p[i + 1], p[i + 2] };
		sort(k, k + 3);
		if (k[1] == p[i + 1]) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main{

	static int []a;
	static long []prefix;
	static long []prefix(int idx){
		int last=0;
		long total=prefix[idx];
		int lo=0,hi=idx-1;
		while(lo<=hi) {
			int mid=lo+hi>>1;
			long s1=prefix[mid],s2=total-prefix[mid];
			if(s1<=s2) {
				last=mid;
				lo=mid+1;
			}
			else
				hi=mid-1;
		}
		long s1=prefix[last],s2=total-prefix[last];
		long s11=s1+a[last+1],s22=s2-a[last+1];
		return Math.abs(s2-s1)<Math.abs(s22-s11)?new long [] {s1,s2}:new long [] {s11,s22};
		
	}
	static long []suffix(int idx){
		int last=idx;
		long total=prefix[prefix.length-1]-prefix[idx-1];
		int lo=idx,hi=prefix.length-2;
		while(lo<=hi) {
			int mid=lo+hi>>1;
			long s1=prefix[mid]-prefix[idx-1],s2=total-(prefix[mid]-prefix[idx-1]);
			if(s1<=s2) {
				last=mid;
				lo=mid+1;
			}
			else
				hi=mid-1;
		}
		long s1=prefix[last]-prefix[idx-1],s2=total-(prefix[last]-prefix[idx-1]);
		long s11=s1+a[last+1],s22=s2-a[last+1];
		return Math.abs(s2-s1)<Math.abs(s22-s11)?new long [] {s1,s2}:new long [] {s11,s22};
		
	}
	public static void main(String[] args) throws IOException {
		Scanner sc=new Scanner();
		PrintWriter out=new PrintWriter(System.out);
		int n=sc.nextInt();
		a=new int [n];
		prefix=new long [n];
		for(int i=0;i<n;i++) {
			prefix[i]+=a[i]=sc.nextInt();
			if(i>0)
				prefix[i]+=prefix[i-1];
		}
		long ans=prefix[n-1];
		for(int middle=1;middle<n-2;middle++) {
			long []pre=prefix(middle);
			long []suf=suffix(middle+1);
			Arrays.sort(pre);
			Arrays.sort(suf);
			
			long max=Math.max(pre[1], suf[1]);
			long min=Math.min(suf[0], pre[0]);
			ans=Math.min(ans, max-min);
		}
		out.println(ans);
		out.close();
	}
	
	static class Scanner
	{
		BufferedReader br;
		StringTokenizer st;
		Scanner(){
			br=new BufferedReader(new InputStreamReader(System.in));
		}
		Scanner(String fileName) throws FileNotFoundException{
			br=new BufferedReader(new FileReader(fileName));
		}
		String next() throws IOException {
			while(st==null || !st.hasMoreTokens())
				st=new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		String nextLine() throws IOException {
			return br.readLine();
		}
		int nextInt() throws IOException{
			return Integer.parseInt(next());
		}
		long nextLong()  throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}
		double nextDouble() throws NumberFormatException, IOException {
			return Double.parseDouble(next());
		}
	}
}

Measured memory_bytes: 48784
#include <iostream>
#include <set>

using namespace std;
int P[100001];

int main(void){
    int N;
    cin >> N;
    
    for (int i = 1; i <= N; i++) {
        int pi;
        cin >> pi;
        P[pi] = i;
    }
    
    set<int> idx{P[N]};
    long long int answer = 0;
    for (long long int i = N-1; i > 0; i--) {
        auto l = idx.lower_bound(P[i]);
        int left1 = 0, left2 = 0;
        if (l != idx.begin()) {
            l--;
            left1 = *l;
        }
        if (l != idx.begin()) {
            l--;
            left2 = *l;
        }
        
        auto u = idx.upper_bound(P[i]);
        int right1 = N+1, right2 = N+1;
        if (u != idx.end()) {
            right1 = *u;
            u++;
        }
        if (u != idx.end()) {
            right2 = *u;
        }
        answer += i * ((left1 - left2) * (right1 - P[i]) + (P[i] - left1) * (right2 - right1));
        idx.insert(P[i]);
    }
    cout << answer << endl;
}

Measured memory_bytes: 5376
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <algorithm>

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

using namespace std;
//        tmp = stoi(S.substr(i,3));
int main(){

    ll N;

    double x;
    string u;

    double res = 0;

    cin >> N;
    REP(i,N)
    {
        cin >> x >> u;
        if(u[0] == 'J')res += x;
        else res += 380000.0 * x;
    }


    //cout << res << endl;
    printf("%.6f",res);

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  int n;
  cin >> n;
  REP(i, n) {
    int a, b, c;
    cin >> a >> b >> c;
    string ans = "NO";
    if (a * a == (c * c - b * b)) ans = "YES";
    if (b * b == (a * a - c * c)) ans = "YES";
    if (c * c == (b * b - a * a)) ans = "YES";
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 3080
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <vector>
#include <queue>
#include <functional>
#include <math.h>
#include <string.h>

using std::endl;
using std::string;

#define ll long long int
#define LEP(a, n) for(int a = 0; a < n; ++a)
#define INF 1145141919810
#define OUT std::cout
#define IN std::cin
#define itn int
#define fro for
#define sdt std

ll N, C;
ll x, v;
ll R, L, RX, LX, HR, HL, QR, QL;
ll HRN, HLN, QRN, QLN;
ll Ans = 0;

using namespace std;

int main()
{
	string s;
	int ans = 0;

	IN >> s;

	for (int a = 0; a < 4; ++a)
	{
		if (s[a] == '+') ans++;
		else ans--;
	}

	OUT << ans << endl;

	return 0;
}

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

typedef long long ll;
 
using tpl = tuple<int, int, int>;
typedef pair<int,int> pii;

void fastStream(){cin.tie(0);std::ios_base::sync_with_stdio(0);}

ll K, A, B;
int main(){

    cin >> K >> A >> B;
    if(A >= B || B - A <= 2){
        cout << 1 + K << endl;
    }
    else{
        if(A - 1 <= K){
            ll tot = 0;
            K -= (A - 1);
            tot = A;
            tot += (K / 2) * (B - A);
            tot += (K % 2);
            cout << tot << endl;
        }
        else{
            cout << 1 + K << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 256
/* binary_indexed_tree_RAQ.cpp
    BIT を用いた Range Add Query (RAQ)。区間への更新を行える

    verified: AOJ DSL_2_E
        http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DSL_2_E&lang=ja
*/

#include <bits/stdc++.h>
using namespace std;
#define ALL(obj) begin(obj), end(obj)
/* BIT: 区間和の更新や計算を行う構造体
    初期値は a_1 = a_2 = ... = a_n = 0
    ・add(l,r,x): [l,r) に x を加算する
    ・sum(i): a_1 + a_2 + ... + a_i を計算する
    ・query(l,r): [l,r) の区間の和を求める
    計算量は全て O(logn)
*/
template <typename T>
struct BIT {
    int n;             // 要素数
    vector<T> bit[2];  // データの格納先
    BIT(int n_) { init(n_); }
    void init(int n_) {
        n = n_ + 1;
        for (int p = 0; p < 2; p++) bit[p].assign(n, 0);
    }

    void add_sub(int p, int i, T x) {
        for (int idx = i; idx < n; idx += (idx & -idx)) {
            bit[p][idx] += x;
        }
    }
    void add(int l, int r, T x) {  // [l,r) に加算
        add_sub(0, l, -x * (l - 1));
        add_sub(0, r, x * (r - 1));
        add_sub(1, l, x);
        add_sub(1, r, -x);
    }

    T sum_sub(int p, int i) {
        T s(0);
        for (int idx = i; idx > 0; idx -= (idx & -idx)) {
            s += bit[p][idx];
        }
        return s;
    }
    T sum(int i) { return sum_sub(0, i) + sum_sub(1, i) * i; }

    // [l,r) の区間和を取得
    T query(int l, int r) { return sum(r - 1) - sum(l - 1); }
};

using ll = long long;
int main() {
    ll N, D, A;
    cin >> N >> D >> A;
    BIT<ll> raq(N);
    vector<ll> X(N), H(N);
    vector<pair<ll, ll>> P(N);
    for (int i = 0; i < N; i++) {
        cin >> X.at(i) >> H.at(i);
        P[i] = make_pair(X[i], H[i]);
    }
    sort(ALL(P));
    sort(ALL(X));
    for (int i = 0; i < N; i++) {
        raq.add(i + 1, i + 2, P[i].second);
    }

    ll ans = 0;
    for (int i = 0; i < N; i++) {
        ll rem = raq.query(i + 1, i + 2);
        // cout << rem << " ";
        if (rem > 0) {
            ll num = (rem + A - 1) / A;
            ll atk = num * A;
            ans += num;
            int dis = upper_bound(ALL(X), X[i] + 2 * D) - X.begin();
            // cout << i << " " << dis << " " << atk << endl;
            raq.add(i + 1, dis + 1, -atk);
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
#define fi(a) scanf("%d",&a);
#define fli(a) scanf("%ld",&a);
#define fll(a) scanf("%lld",&a);
#define pi(a) printf("%d\n",a);
#define ppi(i,a) printf("Case %d: %d\n",i,a);
#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

int main()
{
    bool flag = false;
    fast
    long long a,v,b,w,t,x,y,xx,yy;
    cin >> a >> v >> b >> w >> t;
    // x = (a-b) + (v-w)*t;
    if(b>a)
    {
        x = a + v*t;
        y = b + w*t;

        // cout << x << endl;

        if(x>0 || 0<y)
        {
            if(x>=y)
                cout << "YES\n";
            else
                cout << "NO\n";
        }
        else
        {
            if(x<=y)
                cout << "YES\n";
            else
                cout << "NO\n";
        }
    }
    else
    {
        x = a - v*t;
        y = b - w*t;

        if(x>0 || 0<y)
        {
            if(x>=y)
                cout << "YES\n";
            else
                cout << "NO\n";
        }
        else
        {
            if(x<=y)
                cout << "YES\n";
            else
                cout << "NO\n";
        }
    }
    /*  if(a>-1)
      {
          if(x>=y)
              cout << "YES\n";
          else
              cout << "NO\n";
      }
      else
      {
          if(yy>=xx)
              cout << "YES\n";
          else
              cout << "NO\n";
      }*/

    return 0;
}


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

typedef long long ll;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPM(i,n) for(ll i=(n-1); 0=<i; i--)
#define VI vector<int>
#define VS vector<string>
#define V_SORT_U(x) sort(x.begin(), x.end());
#define V_SORT_D(x) sort(x.begin(), x.end(),greater<int>());

int main(void){
    ll N,K;
    ll x,tmp_x;
    //標準入力
    cin >> N >> K;

    x = (N%K);

    tmp_x = abs(x-K);
    if(tmp_x < x) x = tmp_x;

    cout << x << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>


int main( void )
{
	int N ;
	while( scanf( "%d" ,&N ) != EOF )
	{
		long cnt[ 4 + 1 ][ 50 + 1 ] = { 1 } ;

		int i ,j ,k ;
		for( i = 1 ; i <= 4 ; ++i )
		{
			for( j = 0 ; j <= N ; ++j )
			{
				if( cnt[ i - 1 ][ j ] > 0 )
				{
					for( k = 0 ; k <= 9 ; ++k )
					{
						if( j + k < 50 + 1 )
						{
							cnt[ i ][ j + k ] += cnt[ i - 1 ][ j ] ;
						}
					}
				}
			}
		}

		printf( "%ld\n" ,cnt[ 4 ][ N ] ) ;
	}

	return 0 ;
}


Measured memory_bytes: 2076
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Edge=pair<int,int>;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  ll N;
  cin>>N;
  ll A[N],ANS[N];
  REP(i,N){
    cin>>A[i];
    ANS[i]=0;
  }
  
  REP(i,N){
    if(i%2==0) ANS[0]+=A[i];
    else ANS[0]-=A[i];
  }
  
  RREP(i,N-1){
    ANS[i]=2*A[i-1]-ANS[i-1];
  }
  
  REP(i,N) cout<<ANS[i]<<" ";
  cout<<endl;
  return 0;
}

Measured memory_bytes: 5188
#include <bits/stdc++.h>
#define sort_(a) sort(a.begin(), a.end())
#define rsort(a) sort(a.rbegin(), a.rend())
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; 0 <= i; i--)
#define for_(i, start, end) for (int i = start; i < end; i++)
#define rfor(i, start, end) for (int i = start - 1; 0 <= i; i--)
#define all(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using namespace std;
constexpr int INF32       = 1'050'000'000;
constexpr long long INF64 = 4'000'000'000'000'000'000;
constexpr int MOD7        = 1'000'000'007;
constexpr int MOD53       = 998'244'353;
constexpr double PI       = 3.14159265358979323846;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}
void scan() {}
template <class H, class... T> void scan(H &&head, T &&... args) {
    std::cin >> head;
    scan(std::forward<T>(args)...);
}
template <class T> void scan(std::vector<T> &v) {
    for (auto &&i : v) {
        scan(i);
    }
}

template <typename T> vector<T> divisor(T N) {
    vector<T> ret;
    if (N == 1) {
        ret.emplace_back(1);
        return ret;
    }
    if (N <= 0) {
        return ret;
    }
    for (unsigned long long i = 1; i * i <= (unsigned long long)N; i++) {
        if (N % i == 0) {
            ret.emplace_back(i);
            if (i != 1 && i * i != (unsigned long long)N) {
                ret.emplace_back(N / i);
            }
        }
    }
    ret.emplace_back(N);
    return ret;
}

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

    int N, M;
    scan(N, M);

    auto v = divisor(M);
    sort_(v);
    int ans = *(upper_bound(all(v), M / N) - 1);
    print(ans);

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<map>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define P pair<int,int>
#define ll __int64
int n,m;
int ss[200000],ee[200000],cc[200000];
int s[200000],e[200000],c[200000];//[s,e)
pair<int,P>t[200000];

//録画機→[s-0.5,e)必要
int r[35][211111];
const int M=100000;

int main(){
cin>>n>>m;
rep(i,n){
cin>>ss[i]>>ee[i]>>cc[i];
t[i]=mp(cc[i],mp(ss[i],ee[i]));

}

sort(t,t+n);

rep(i,n){
	c[i]=t[i].first;
	s[i]=t[i].second.first;
	e[i]=t[i].second.second;
}


int now=-1;
rep(i,n){

	if(now!=c[i]){//そのチャンネルのハジメだけ0.5ロード
	 r[c[i]][s[i]*2-1]++;
		now=c[i];
	}
	else if(r[c[i]][s[i]*2]<0)r[c[i]][s[i]*2]++;
	else r[c[i]][s[i]*2-1]++;
	r[c[i]][e[i]*2]--;
}

		for(int i=1;i<=m;i++){
		for(int j=1;j<=2*M;j++){
		int cnt=0;

		r[i][j]+=r[i][j-1];
		}
	}


int ans=0;

	for(int j=1;j<=2*M;j++){
	int cnt=0;
	for(int i=1;i<=m;i++){
		cnt+=r[i][j];
	}
		ans=max(ans,cnt);
	}
cout<<ans<<endl;



	return 0;
}

Measured memory_bytes: 32512
from collections import Counter

N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)

C = Counter(A)
count = 0

for i in range(N):
    while C[A[i]]:
        C[A[i]] -= 1
        if C[2**(A[i].bit_length()) - A[i]]:
            C[2**(A[i].bit_length()) - A[i]] -= 1
            count += 1

print(count)

Measured memory_bytes: 33296
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include<math.h>
#define ll long long

int main(){
  int n,k,k1,k2,k3,k4,k5,ans=1;
  scanf("%d",&n);
  if(n==1){
    printf("1");
    return 0;
  }
 
  for(int i=1;i<n;i++){
    k1=i*i;
    
    if(n>=32){
      k5=32;
      if(n>=k5 && ans<k5){
        ans=k5;
      }
      k5=64;
      if(n>=k5 && ans<k5){
        ans=k5;
      }
      k5=128;
      if(n>=k5 && ans<k5){
        ans=k5;
      }
      k5=256;
      if(n>=k5 && ans<k5){
        ans=k5;
      }
      k5=512;
      if(n>=k5 && ans<k5){
        ans=k5;
      }
    }
    
    if(n>=243){
      k4=243;
      if(ans<k4){
        ans=k4;
      }
      k4=729;
      if(n>=k4 && ans<k4){
        ans=k4;
      }
    }
    
    if(i<=5){
      k3=i*i*i*i;
      if(n>=k3 && ans<k3){
        ans=k3;
      }
    }
    
    if(i<=10){
      k2=i*i*i;
      if(n>=k2 && ans<k2){
      ans=k2;
      }
    }
    if(n>=k1 && ans<k1){
      ans=k1;
    }
  }
    
      printf("%d",ans);
      return 0;
}

Measured memory_bytes: 128
import sys
# import numpy as np
from collections import Counter, deque

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())
    A = deque(list(map(int, input().split())))
    B = deque([])

    if n % 2 == 0:
        for i in range(n):
            a = deque.popleft(A)
            if i % 2 == 0:
                B.append(a)
            else:
                B.appendleft(a)
    else:
        for i in range(n):
            a = deque.popleft(A)
            if i % 2 != 0:
                B.append(a)
            else:
                B.appendleft(a)
    print(" ".join(map(str, B)))


if __name__ == '__main__':
    resolve()


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

using namespace std;

#define rep(i, a) for (int (i) = 0; (i) < (a); (i)++)
#define reps(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define MP(a, b) make_pair((a), (b))
#define pb(a) push_back((a))
#define all(v) (v).begin(), (v).end()

int e;

int main()
{
	cin >> e;
	while (e) {
		int mi = 1e9;
		int r;
		for (int z = 0; (r = e - z * z * z) >= 0; z++) {
			int r2;
			for (int y = 0; (r2 = r - y * y) >= 0; y++) {
				mi = min(mi, r2 + y + z);
			}
		}
		cout << mi << endl;
		cin >> e;
	}
}


Measured memory_bytes: 3044
n = gets.to_i
k = 1
k += 1 until k * (k + 1) / 2 >= n
r =  k * (k + 1) / 2 - n
l = k
loop do
    break if l >= r
    print '()'
    r -= l
    k -= 1
end
puts ?) * (k - r) + ?( + ?) * r + ?( * (k - 1)

Measured memory_bytes: 8852
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")

using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 18; // segment tree size
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f; // memset(dp, 0x3f, sizeof(dp)), 2*INF < INT_MAX
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10; // double EPS

char in[15][15];

int H, W;

bool chk[15];
vector <pii> Vl;

bool vchk[15][15];

bool dp[4096];
void aa(int c) {
	if (!c) {
		int i, j, k;
		for (i = 0; i < W; i++) {
			for (j = 0; j < W; j++) {
				vchk[i][j] = true;
				for (auto it : Vl) {
					if (in[it.first][i] != in[it.second][j]) vchk[i][j] = false;
					if (in[it.first][j] != in[it.second][i]) vchk[i][j] = false;
				}
			}
		}
		
		memset(dp, 0, sizeof(dp));
		if (W % 2 == 0) dp[0] = true;
		else for (i = 0; i < W; i++) if (vchk[i][i]) dp[1 << i] = true;
		for (i = 0; i + 1 < (1 << W); i++) {
			if (!dp[i]) continue;
			for (j = 0; j < W; j++) if (!(i & (1<<j))) break;

			int st = j;
			for (j = st + 1; j < W; j++) {
				if (i & (1 << j)) continue;
				if (vchk[st][j]) dp[i | (1 << st) | (1 << j)] = true;
			}
		}
		if (dp[(1 << W) - 1]) {
			printf("YES\n");
			exit(0);
		}
		return;
	}

	int i, j, st;
	for (i = 0; i < H; i++) if (!chk[i]) break;
	st = i;

	if (c % 2 == 1) {
		Vl.emplace_back(st, st);
		chk[st] = true;
		aa(c - 1);
		chk[st] = false;
		Vl.pop_back();
	}
	for (i = st + 1; i < H; i++) {
		if (chk[i]) continue;

		Vl.emplace_back(st, i);
		chk[st] = chk[i] = true;
		aa(c - 2);
		chk[st] = chk[i] = false;
		Vl.pop_back();
	}
}
int main() {
	scanf("%d %d", &H, &W);
	for (int i = 0; i < H; i++) scanf("%s", in[i]);

	aa(H);
	return !printf("NO\n");
}

Measured memory_bytes: 384