akhauriyash/Code-Regression huggingface dataset:
use std::io::*;
use std::str::FromStr;

#[allow(unused_macros)]
macro_rules! scan {
  ($e:expr; $t:ty) => {
    $e.get::<$t>()
  };
  ($e:expr; $($t:ty), *) => {
    ($($e.get::<$t>(),)*)
  };
  ($e:expr => $i:expr; $t:ty) => {
    (0..$i).map(|_| $e.get::<$t>()).collect::<Vec<$t>>()
  };
  ($e:expr => $row:expr, $col:expr; $t:ty) => {
    (0..$i).map(|_| scan!($e => $col; $t)).collect::<Vec<$t>>()
  }
}

struct Scanner<R: Read> {
  reader: R
}

#[allow(dead_code)]
impl<R: Read> Scanner<R> {
  fn new(reader: R) -> Scanner<R> {
    Scanner { reader: reader }
  }
  fn safe_get<T: FromStr>(&mut self) -> Option<T> {
    let token = self.reader.by_ref().bytes().map(|c| c.unwrap() as char)
      .skip_while(|c| c.is_whitespace())
      .take_while(|c| !c.is_whitespace())
      .collect::<String>();
    if token.is_empty() { None } else { token.parse().ok() }
  }
  fn get<T: FromStr>(&mut self) -> T {
    if let Some(v) = self.safe_get() { v } else {
      writeln!(stderr(), "Terminated with EOF").unwrap();
      std::process::exit(0);
    }
  }
}

fn sin_from_deg(degree: f64) -> f64 {
  (degree * std::f64::consts::PI / 180.0).sin()
}

fn cos_from_deg(degree: f64) -> f64 {
  (degree * std::f64::consts::PI / 180.0).cos()
}

fn koch_curve(points: &mut Vec<(f64, f64)>, depth: i32, p1: (f64, f64), p2: (f64, f64)) {
  if depth == 0 {
    return;
  }
  let s = ((2.0 * p1.0 + p2.0) / 3.0, (2.0 * p1.1 + p2.1) / 3.0);
  let t = ((p1.0 + 2.0 * p2.0) / 3.0, (p1.1 + 2.0 * p2.1) / 3.0);
  let u = (
    (t.0 - s.0) * cos_from_deg(60.0) - (t.1 - s.1) * sin_from_deg(60.0) + s.0,
    (t.0 - s.0) * sin_from_deg(60.0) + (t.1 - s.1) * cos_from_deg(60.0) + s.1
  );
  koch_curve(points, depth - 1, p1, s);
  points.push(s);
  koch_curve(points, depth - 1, s, u);
  points.push(u);
  koch_curve(points, depth - 1, u, t);
  points.push(t);
  koch_curve(points, depth - 1, t, p2);
} 

fn main() {
  let cin = stdin();
  let cin = cin.lock();
  let mut sc = Scanner::new(cin);
  let n = scan!(sc; i32);
  let (s, e) = ((0.0, 0.0), (100.0, 0.0));
  let mut p = Vec::new();
  p.push(s);
  koch_curve(&mut p, n, s, e);
  p.push(e);
  for p in p.iter() {
    println!("{} {}", p.0, p.1);
  }
}



Measured memory_bytes: 5068
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <map>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;

int main(){
  str s;
  cin >> s;
  if(s[0]==s[1]||s[1]==s[2]||s[2]==s[3]) cout << "Bad" << endl;
  else cout << "Good" << endl;
  return 0;
}


Measured memory_bytes: 256
use num::pow;
use proconio::marker::Chars;
use proconio::input;

fn main() {
    input!(h:usize, w:usize, k:usize, c:[Chars; h]);
    let mut ans = 0;

    for hbit in 0..pow(2, h) {
        for wbit in 0..pow(2, w) {
            let mut cnt = 0;
            for (i, s) in c.iter().enumerate() {
                if hbit & (1 << i) == 0 {continue}
                for (j, c) in s.iter().enumerate() {
                    if wbit & (1 << j) == 0 {continue}
                    if *c == '#' {
                        cnt += 1
                    }
                }
            }
            if cnt == k {
                ans += 1
            }
        }
    }
    println!("{}", ans)
}


Measured memory_bytes: 2144
def gcd(a, b):
  while b:
	  a, b = b, a % b
  return a

n,m=map(int,input().split())
s=input()
t=input()
cnt=1
i=0
flag=0

l=int(n*m/gcd(n,m))

r=l/m

while cnt<n:
  if s[int(i*l/m)]==t[int(i*l/n)]:
    flag=1
    cnt+=r
    i+=1
  else:
    flag=0
    break

if flag==1:
  print(l)
else:
  print(-1)


Measured memory_bytes: 3316
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<cstring>
#define rep(i,n) for(int i=1;i<=n;i++)
using namespace std;
typedef long long LL;
const int INF = 0x3f3f3f3f;
int n, m, q, x, y, z, d[1010];
char c;
int dl[210][210], ds[210][210], dp[1010][210];
int main() {
	while (~scanf("%d%d",&n,&m),n+m)
	{
		rep(i, n) rep(j, n) ds[i][j] = dl[i][j] = i == j ? 0 : INF;
		rep(i, m) {
			scanf("%d%d%d %c", &x, &y, &z, &c);
			if (c == 'S') ds[x][y] = ds[y][x] = min(ds[x][y], z);
			else dl[x][y] = dl[y][x] = min(dl[x][y], z);
		}scanf("%d", &q);
		rep(i, q) scanf("%d", d + i);
		rep(k, n) rep(i, n) rep(j, n) {
			ds[i][j] = min(ds[i][j], ds[i][k] + ds[k][j]);
			dl[i][j] = min(dl[i][j], dl[i][k] + dl[k][j]);
		}memset(dp, INF, sizeof(dp));
		dp[1][d[1]] = 0;
		rep(i, q) rep(j, n) {
			dp[i][j] = min(dp[i][j], dp[i - 1][j] + dl[d[i - 1]][d[i]]);
			rep(k, n) dp[i][k] = min((LL)dp[i][k], (LL)dp[i - 1][j] + dl[d[i - 1]][j] + ds[j][k] + dl[k][d[i]]);
		}printf("%d\n", *min_element(dp[q], dp[q] + n + 1));
	}return 0;
}


Measured memory_bytes: 4312
pr = Array.new(1000000,1)
(2..1000).each{|i|
    next if pr[i] == 0
    j = i * i
    while j < 1000000
        pr[j] = 0
        j += i
    end
}
pr[0] = pr[1] = 0
(2..1000000).each{|i|
    pr[i] = pr[i] == 1 ? pr[i-1]+1 : pr[i-1]
}
while gets
    p pr[$_.to_i]
end

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

#define MAX_N 15

int N;

int g[MAX_N][MAX_N];

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

    rep(i, N)rep(j, N) g[i][j] = -1;

    rep(i, N) {
        int m;
        cin >> m;
        rep(j, m) {
            // x 証言
            // a 証言された人
            int a, x;
            cin >> a >> x;
            a--;
            g[i][a] = x;
        }
    }

    int ans = 0;
    rep(i, 1 << N) {
        vector<int> d(N);
        rep(j, N) {
            if (i >> j & 1) {
                d[j] = 1;
            }
        }

        bool ok = true;
        rep(j, N) {
            // 正直者である
            if (d[j]) {
                rep(k, N) {
                    if (g[j][k] == -1) continue;

                    // 正直者の証言が異なる時
                    if (g[j][k] != d[k]) ok = false;
                }
            }
        }

        if (ok) ans = max(ans, __builtin_popcount(i));
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
/***** author :  C0d1ngPhenomena *****/

#include <bits/stdc++.h>
#define endl "\n"
#define ll long long int
#define TestCases int T; cin>>T; while(T--)
#define rep(i,a,b) for(ll i = a; i < b; i++)
#define revrep(i,a,b) for(ll i = b-1; i >= a; i--)
#define vll vector<ll>
#define vvll vector < vll >
#define pll pair<ll, ll>
#define vpll vector <pll>
#define mp(x,y) make_pair(x,y)
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define alld(c) c.begin(),c.end(),greater<int>()
#define mem(a,val) memset(a,val,sizeof(a))
#define f first
#define s second
#define pb push_back
using namespace std;

int main()
{
	std::ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll n;
	cin >> n;

	vll arr(n);

	rep(i, 0, n)
	cin >> arr[i];

	ll sum = 0;

	rep(i, 1, n)
	{
		if (arr[i - 1] > arr[i])
		{
			sum += arr[i - 1] - arr[i];
			arr[i] = arr[i - 1];
		}
	}

	cout << sum;

	return 0;
}







Measured memory_bytes: 4780
#include <iostream>
#include<stdio.h>
#include<vector>
#include<stack>
#define MAX 100000

using namespace std;
vector<int> G[MAX];
int color[MAX], n;

void dfs_visit(int r, int id) { //???????????°
    stack<int> S;
    S.push(r);
    color[r] = id;
    while(!S.empty()) {
        int u = S.top();
        S.pop();
        for(int i = 0; i < G[u].size(); i++) {
            int v = G[u][i];
            if(color[v] == -1) {
                color[v] = id;
                S.push(v);
            }
        }
    }
}

void assignColor() { // ?????????????????°
    int id = 1;
    for(int i = 0; i < n; i++) {
        color[i] = -1;
    }
    for(int i = 0; i < n; i++) {
        if(color[i] == -1)
            dfs_visit(i, id++);
    }
}

int main()
{
    int m;
    scanf("%d%d", &n, &m);

    int s, t;
    for(int i = 0; i < m; i++) {
        scanf("%d%d", &s, &t);
        G[s].push_back(t);
        G[t].push_back(s);
    }

    assignColor();
    int q;
    scanf("%d", &q);
    for(int i = 0; i < q; i++) {
        scanf("%d%d", &s, &t);
        if(color[s] == color[t])
            printf("yes\n");
        else
            printf("no\n");
    }
    return 0;
}

Measured memory_bytes: 8912
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
static const double pi = 3.141592653589793;

int main() {
  double a, b, h, m;
  cin >> a >> b >> h >> m;
  double alpha = abs(0.5 * (h * 60 + m) - 6 * m);
  if (alpha > 180)
    alpha = 360 - alpha;
  alpha = alpha / 180 * pi;
  double ans = sqrt(a * a + b * b - 2 * a * b * cos(alpha));
  cout << fixed << setprecision(15) << ans << endl;
  return 0;
}


Measured memory_bytes: 4232
#include <iostream>
#include <vector>
using namespace std ;
using LL = long long int;


LL paty(int n,LL x,vector<LL> l,vector<LL> p)
{
    if(n==0) return 1;
    if(x == 1)
    {
        return 0;
    }
    if(x == l[n-1]+2)
    {
        return p[n-1]+1;
    }
    if(x == 2*l[n-1]+3)
    {
        return p[n];
    }
    if(x < l[n-1]+2)
    {
        return paty(n-1,x-1,l,p);
    }
    if(x > l[n-1]+2)
    {
        return  p[n-1]+paty(n-1,x-l[n-1]-2,l,p)+1;
    }
}

int main(){
    LL x;
    int n;
    cin >> n >> x;
    vector<LL> l(n+1);
    vector<LL> p(n+1);
    l[0] = 1;
    p[0] = 1;
    for(int i = 1; i< n+1;i++ )
    {
        l[i] = l[i-1]*2+3;
        p[i] = p[i-1]*2+1;
    }
    LL ans = paty(n,x,l,p);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define Sheryang main
typedef long long ll;
#pragma GCC optimize(3)
#define HEAP(...) priority_queue<__VA_ARGS__ >
#define heap(...) priority_queue<__VA_ARGS__,vector<__VA_ARGS__ >,greater<__VA_ARGS__ > >
template<class T> inline T min(T &x,const T &y){return x>y?y:x;}
template<class T> inline T max(T &x,const T &y){return x<y?y:x;}
int read()
{
    int x=0,f=1;	char c=getchar();
    while(c<'0'||c>'9')	{if(c=='-') f=-1;c=getchar();}
    while(c>='0'&&c<='9')	{x=x*10+c-'0';c=getchar();}
    return x*f;
}
struct ios
{
    inline char gc()
    {
        static const int IN_LEN=1<<18|1;
        static char buf[IN_LEN],*s,*t;
        return (s==t)&&(t=(s=buf)+fread(buf,1,IN_LEN,stdin)),s==t?-1:*s++;
    }
    template <typename _Tp> inline ios & operator >> (_Tp&x)
    {
        static char ch,sgn; ch = gc(), sgn = 0;
        for(;!isdigit(ch);ch=gc())
        {   
            if(ch==-1)return *this;sgn|=ch=='-';
        }
        for(x=0;isdigit(ch);ch=gc())x=(((x<<2)+x)<<1)+(ch^'0');
        sgn&&(x=-x); return *this;
    }
}io;
const int maxn = 1e6 + 7;
const int mod = 1e9 + 7;
/** keep hungry and keep calm! **/

/**int h,n;
int a[10005],b[10005];
int dp[10005];
int main()
{
	cin >> h >> n;
	for(int i=0;i<n;i++)	cin >> a[i] >> b[i];
	for(int i=0;i<n;i++)
	{
		for(int j=a[i];j<=h;j++)//顺序 
		{
			dp[j] = min(dp[j],dp[j-a[i]]+b[i]); 
		}
	}
	cout << dp[h] << endl;
	return 0;
}**/

ll dp[20004];
int h,n;
signed main() 
{
    ios_base::sync_with_stdio(false); cin.tie(0);
	cin >> h >> n;
    memset(dp,15,sizeof dp);
    dp[0] = 0;
    while(n--) 
	{
        int a,b;	cin >> a >> b;
        for(int i=a;i<20000;i++) 
			dp[i] = min(dp[i],dp[i-a]+b);
    }
    ll t = dp[20000];
    for(int i=h;i<20000;i++)
    	t = min(t,dp[i]);
    cout << t << endl;
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define int long long
using namespace std;
constexpr int mod=998244353;
int fact[200000];
int mypow(int x,int n){
    if(n==0)
        return 1;
    if(n%2)
        return mypow(x,n-1)*x%mod;
    int tmp=mypow(x,n/2);
    return tmp*tmp%mod;
}
int inv(int x){
    return mypow(x,mod-2);
}
int comb(int n,int k){
    return fact[n]*inv(fact[k]*fact[n-k]%mod)%mod;
}
signed main(){
    int n,m,k;
    cin>>n>>m>>k,n--;
    fact[0]=1;
    for(int i=1;i<=n;i++)
        fact[i]=fact[i-1]*i%mod;
    int ans=0;
    for(int i=0;i<=k;i++)
        (ans+=comb(n,i)*mypow(m-1,n-i))%=mod;
    cout<<ans*m%mod<<endl;
}

Measured memory_bytes: 5196
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
lst=[]
for i in range(2**N):
    h=[[],[]]
    for j in range(N):
        if (i>>j)&1==1:
            h[(j+1)%2].append([B[j],j])
        else:
            h[j%2].append([A[j],j])
    if len(h[1])==N//2:
        lst.append(h)
lsls=[]
for h in lst:
    h[0].sort()
    h[1].sort()
    cnt=h[0][0][1]
    for i in range(N-1):
        if h[i%2][i//2][0]>h[(i+1)%2][(i+1)//2][0]:
            break
    else:
        hhh=[]
        for i in range(N):
            hhh.append(h[i%2][i//2][1])
        lsls.append(hhh)
inf=float("inf")
ans=inf
if lsls:
    for h in lsls:
        flag=[0]*N
        cnt=0
        for u in h:
            flag[u]=1
            cnt+=sum(flag[u+1:])
        ans=min(ans,cnt)
if ans==inf:
    print(-1)
else:
    print(ans)

Measured memory_bytes: 132232
<?php
    list($a, $b) = explode(" ", trim(fgets(STDIN)));
    $flg = FALSE;
    if($a % 3 == 0){
        $flg = TRUE;
    }elseif($b % 3 == 0){
        $flg = TRUE;
    }elseif(($a + $b) % 3 == 0){
        $flg = TRUE;
    }
    $str = $flg == TRUE ? "Possible" : "Impossible";
    echo $str;
?>

Measured memory_bytes: 4728
import math

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

cho = (H * 60 + M) / (12 * 60) * 360
tan = M / 60 * 360
degree = abs(cho-tan)

ans_2 = A**2 + B**2 - 2*A*B*math.cos(math.radians(degree))
print(math.sqrt(ans_2))


Measured memory_bytes: 9508
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n=0;
        boolean flag = true;
        while(flag){
            n++;
            int juge = Integer.parseInt(sc.next());
            if(juge != 0){
                System.out.println("Case " + n + ": " + juge);                
            }else{
                flag = false;
            }
        }
    }
}


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

#define ll   long long int
#define rep(i,n)    for(int i=0;i<(int)n;i++)
#define show(s)     cout<<s<<endl

int main() {

    char b;

    cin >> b;

    switch(b){
        case 'A':   show('T');  break;
        case 'C':   show('G');  break;
        case 'G':   show('C');  break;
        case 'T':   show('A');  break;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <sstream>
#include <map>
#include <set>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<30
#define pb push_back
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

vector<string> split(const string &str, char delim) {
	vector<string> res;
	size_t current = 0, found;
	while((found = str.find_first_of(delim, current)) != string::npos) {
		res.push_back(string(str, current, found - current));
		current = found + 1;
	}
	res.push_back(string(str, current, str.size() - current));
	return res;
}


// s1 - s2
int f(string s1, string s2) {
	int a = (s1[0] - '0') * 10 + (s1[1] - '0');
	int b = (s1[3] - '0') * 10 + (s1[4] - '0');
	int c = (s2[0] - '0') * 10 + (s2[1] - '0');
	int d = (s2[3] - '0') * 10 + (s2[4] - '0');

	if(a == c) {
		return b - d;
	} else {
		return (a - (c + 1)) * 60 + (60 - d) + b;
	}
}

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

		map<string, vector<pair<string, string> > > IN, OUT;

		rep(i, n) {
			string a, b, c, d;
			cin >> a >> b >> c >> d;

			if(c == "I") {
				IN[d].push_back(mp(a, b));
			} else {
				OUT[d].push_back(mp(a, b));
			}
		}

		int ans = 0;
		vector<pair<string, string> > gin = IN["000"];
		vector<pair<string, string> > gout = OUT["000"];


		map<string, vector<pair<string, string> > >::iterator in, out;
		for(in = IN.begin(), out = OUT.begin(); in != IN.end() && out != OUT.end(); in++, out++) {
			if(in->first == "000") continue;

			vector<pair<string, string > > v = in->second;
			vector<pair<string, string > > v2 = out->second;

			int res = 0;
			rep(i, v.size()) {
				rep(j, gin.size()) {
					if(v[i].first != gin[j].first) continue;
			
					string a = v[i].second, b = v2[i].second, c = gin[j].second, d = gout[j].second;
					if(c <= a && b <= d) {
						res += f(b, a);
					} else if(a <= c && d <= b) {
						res += f(d, c);
					} else if(c <= a && a <= d && d <= b) {
						res += f(d, a);
					} else if(a <= c && c <= b && b <= d) {
						res += f(b, c);
					}
				}
			}

			ans = max(ans, res);
		}

		cout << ans << endl;
	}

	return 0;
}

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

void min( int* a, int b, int e )
{
    int mi = a[b];
    for( int i = b; i <= e - 1; i++ )
        if( mi > a[i] )
            mi = a[i];

    cout << mi << endl;
}

void max( int* a, int b, int e )
{
    int ma = a[b];
    for( int i = b; i <= e - 1; i++ )
        if( ma < a[i] )
            ma = a[i];

    cout << ma << endl;
}

int main()
{
    int n, q;
    int com;
    int b,e;

    cin >> n;

    int a[n];

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

    cin >> q;

    for( int i = 0; i < q; i++ )
    {
        cin >> com >> b >> e;
        if( com == 0 )
            min( a, b, e );
        else
            max( a, b, e );
    }
    return 0;
}


Measured memory_bytes: 3052
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std; 
int main()
{
	double a,b,c,p,s;
	while(cin>>a>>b>>c)
	{
		p=(a+b+c)/2;
		s=(p*(p-a)*(p-b)*(p-c));
		s=sqrt(s);
		cout<<s<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
  int D, N;
  cin >> D >> N;
  if(N == 100) ++N;
  cout << N;
  if(D==1) cout << "00";
  if(D==2) cout << "0000";
  cout << endl;
  return 0;
}


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

int main(void)
{
    int N;
    cin >> N;
    int L[N];
    for (int i = 0; i < N; i++) {
        cin >> L[i];
    }

    sort(L, L+N);
    long long count = 0;
    for (int i = 0; i < N-2; i++) {
        for (int j = i+1; j < N-1; j++) {
            for (int k = j+1; k < N; k++) {
                // c >= a + b
                if (L[k] < L[i] + L[j]) {
                    count++;
                }
                else {
                    break;
                }
            }
        }
    }
    cout << count << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
typedef long long ll;
const int INF = 100000000, mod = 1000000007;
const ll LLINF = 1LL << 50;
using namespace std;

int topP=0;
string s;

int main() {
    cin >> s;
    for (int i = 0; i < s.length(); i++) {
        if (s[i] == 'p') topP++;
    }
    cout << (int)(s.length() / 2) - topP << endl;
    return 0;
}


Measured memory_bytes: 512
/*
  AtCoder Beginner Contest 095
  B - Bitter Alchemy
*/

#include<iostream>
#include<algorithm>
using namespace std;

int N, X;
int m[100];

int main() {
  scanf("%d%d", &N, &X);

  for (int i = 0; i < N; ++i) {
    scanf("%d", &m[i]);
    X -= m[i];
  }

  int count = N;
  sort(m, m+N);
  count += X / m[0];

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

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

template<typename T>
T mod(T a, T b){
    return (a + b) % b;
}

template<typename T>
T gcd(T a, T b){
    if (b == 0) return a;
    return gcd(b, a % b);
}

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

// n を素因数分解
map<ll, ll> factor(ll n){
    map<ll, ll> mp;
    for (ll i = 2; i*i <= n; i++) {
        while (n % i == 0) {
            mp[i]++;
            n /= i;
        }
    }

    if (n > 1) {
        mp[n]++;
    }

    return mp;
}

// 文字列に "hoge" が含まれているか
// string str = "hogepiyo";
// if (str.find("hoge") != string::npos) {
//     cout << "文字列が含まれています" << endl;
// }

// char to string
// char c = 'a';
// string str = {c};

void solve(){
    ll N;
    cin >> N;

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

    vector<ll> b(N+1);
    for (int i = N; i > 0; i--) {
        if (N / i == 1) {
            b[i] = a[i];
        } else {
            ll sum = 0;
            for (int j = 2; j <= N / i; j++) {
                sum += b[j*i];
            }
            b[i] = a[i] ^ (sum % 2);
        }
    }

    int cnt = 0;
    for (int i = 1; i <= N; i++) {
        if (b[i] == 1) {
            cnt++;
        }
    }

    if (cnt == 0) {
        cout << 0 << endl;
        return;
    }

    vector<ll> candidate;
    for (int i = 1; i <= N; i++) {
        if (b[i] == 1) {
            candidate.push_back(i);
        }
    }

    cout << cnt << endl;
    for (int i = 0; i < cnt; i++) {
        if (i == 0) {
            cout << candidate[0];
        } else {
            cout << " " << candidate[i];
        }
    }
    cout << endl;

    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}


Measured memory_bytes: 4980
#include<stdio.h>

int main(void)
{
	int S, h, m, s;

	scanf("%d", &S);

	s = S % 60;
	m = ((S - s) / 60) % 60;
	h = (S - s - m) / 3600;

	printf("%d:%d:%d\n", h, m, s);

	return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
#define lp(i,n) for(int i=0;i<n;i++)
int main(){
	while(1){
		int e;
		cin>>e;
		if(e==0) break;
		int ans=e,z;
		for(int i=0;i*i*i<=e;i++){
			for(int j=0;j*j+i*i*i<=e;j++){
				z=e-i*i*i-j*j;
				ans=min(ans,z+i+j);
			}
		}
		cout<<ans<<endl;
	}

	return 0;
}


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

int main(){
  int N,K;
  cin >> N >> K;
  vector<bool> V(N,false);
  
  for(int i=0;i<K;i++){
    int d;
    cin >> d;
    for(int j=0;j<d;j++){
      int a;
      cin >> a;
      a--;
      V[a] = true;
    }
  }
  
  int ans=0;
  for(int i=0;i<N;i++){
    if(V[i]==false) ans++;
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector< tuple<string, int, int> > sp(N);
  for (int i = 0; i < N; i++) {
    string s;
    int p;
    cin >> s >> p;
    sp.at(i) = make_tuple(s,-p, i+1);
  }
  sort(sp.begin(), sp.end());

  for (int i = 0; i < N; i++) {
    cout << get<2>(sp.at(i)) << endl;
  }
}


Measured memory_bytes: 3600
const
        fi='';
        fo='';
var     n,m,res:integer;
        a:array[0..3000,0..3000]of integer;
        c,s:array[0..3000]of integer;
        cx:array[0..3000]of byte;
        g:text;

procedure solve;
var     i,j,mj:integer;
begin
        for i:=1 to m do c[i]:=1;
        res:=m;
        for i:=1 to n do
        begin
                for j:=1 to n do s[j]:=0;
                mj:=1;
                for j:=1 to m do
                begin
                        inc(s[a[j,c[j]]]);
                        if s[mj]<s[a[j,c[j]]] then mj:=a[j,c[j]];
                end;
                if s[mj]<res then res:=s[mj];
                cx[mj]:=1;
                for j:=1 to m do while (c[j]<=n) and (cx[a[j,c[j]]]=1) do inc(c[j]);
        end;
end;

procedure main;
var     i,j:integer;
begin
        assign(g,fi);
        reset(g);
        read(g,m,n);
        for i:=1 to m do for j:=1 to n do read(g,a[i,j]);
        close(g);
        assign(g,fo);
        rewrite(g);
        solve;
        writeln(g,res);
        close(g);
end;

BEGIN
        main;
END.

Measured memory_bytes: 2944
#include <bits/stdc++.h>
#include<list>
#include<algorithm>
#define ll long long int
#define ld long double
#define pb push_back
#define ff first
#define ss second
#define rep(a,b,c) for(a=b;a<c;a++)
#define repj(a,b,c) for(a=b;a<c;a++)
#define repr for(i=n-1;i>=0;i--)
#define pii pair<ll,ll>
#define pll pair<ll, ll>
#define inf 100000001
#define mod 1000000007
#define lb lower_bound
#define up upper_bound
#define rep1 for(i=1;i<=n;i++)
#define vr vector
#define ef else if
#define all(x) (x).begin(), (x).end()
#define SORT(A) sort(A.begin(), A.end());
#define REVERSE(A) reverse(A.begin(), A.end());
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
ll myXOR(ll x, ll y)
{
	return (x|y)&(~x|~y);	
}
ll powerLL(ll x, ll n) 
{ 
    ll result = 1; 
    while (n) { 
        if (n & 1) 
            result = result * x % mod; 
        n = n / 2; 
        x = x * x % mod; 
    }
    return result; 
}
int main()
{
	ll t,n,m,i,j,k,l,x,y,z,a,b,c,d,e,p,nl,np,q,r,s,h;
	string str,str1;
	cin>>n>>m;
	a=b=0;
	if(n>=2)
	{
		a = (n*(n-1))/2;
	}
	if(m>=2)
	{
		b = (m*(m-1))/2;
	}
	cout<<a+b;
}

Measured memory_bytes: 256
#line 2 "../../library/template.hpp"
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using pl = pair<ll, ll>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0; i < (ll)n; i++)
#define rep3(i, l, r) for(ll i = l; i < (ll)r; i++)
#define per(i, n) for(ll i = n-1; i >= 0; i--)
#define per3(i, l, r) for(ll i = r-1; i >= (ll)l; i--)
#define all(v) begin(v), end(v)
template<class T, class U>
inline void cmax(T& a, U b) { if (a < b) a = b; }
template<class T, class U>
inline void cmin(T& a, U b) { if (a > b) a = b; }

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
  }
} io_setup;

constexpr char el = '\n';
#line 3 "../../library/popcount.hpp"

int popcount(int n) {
  return __builtin_popcount(n);
}

ll popcount(ll n) {
  return __builtin_popcountll(n);
}
#line 3 "e.cpp"

int main() {
  ll h, w, k;
  cin >> h >> w >> k;
  vector<string> s(h);
  rep(i, h) {
    cin >> s[i];
  }

  ll ans = 1LL<<60;

  rep(bit, 1LL<<(h-1)) {
    ll sum = popcount(bit);
    ll tmp = sum+1;


    bool f = 1;

    vl cnt(tmp);
    rep(i, w) {
      vl cnt2(tmp);
      ll ind = 0;
      rep(j, h) {
        if (s[j][i] == '1') cnt2[ind]++;
        if ((bit>>j) & 1) {
          ind++;
        }
      }

      bool is_over = 1;
      rep(j, tmp) {
        if (cnt[j] + cnt2[j] > k) {
          is_over = 0;
          break;
        }
      }

      rep(j, tmp) {
        if (cnt2[j] > k) {
          f = 0;
          break;
        }
      }

      if (is_over) {
        rep(j, tmp) {
          cnt[j] += cnt2[j];
        }
      } else {
        sum++;
        rep(j, tmp) {
          cnt[j] = cnt2[j];
        }
      }
    }

    if (f) cmin(ans, sum);
  }

  cout << ans << endl;
}


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

int main(){
    int k, s;
    cin >> k >> s;
    
    int cnt = 0;
    for(int x=0;x<=k;x++){
        for(int y=0;y<=k;y++){
            if(s-x-y>=0 && s-x-y<=k){
                cnt++;
            }
        }
    }
    printf("%d\n", cnt);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#define int long long
#define fre(x) freopen(x".in","r",stdin),freopen(x".out","w",stdout)
using namespace std;

inline int read(){
	int sum=0,f=1;char ch=getchar();
	while(ch>'9'||ch<'0'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){sum=sum*10+ch-'0';ch=getchar();}
	return f*sum;
}

const int N=405;
const int Mod=1000000007;
struct node{int l,r;}a[N];
int n,C,f[N][N],p[N];

signed main(){
	n=read();C=read();
	for(int i=1;i<=n;i++) a[i].l=read();
	for(int i=1;i<=n;i++) a[i].r=read();
	f[0][0]=1;
	for(int i=1;i<=n;i++){
		for(int i=0;i<N;i++) p[i]=0;
		for(int x=a[i].l;x<=a[i].r;x++){
			int ret=1;p[0]++;
			for(int j=1;j<=C;j++){
				ret=ret*x%Mod;p[j]=(p[j]+ret)%Mod;
			}
		}
		for(int j=0;j<=C;j++){
			for(int k=0;k<=j;k++){
				f[i][j]=(f[i][j]+f[i-1][j-k]*p[k]%Mod)%Mod;
			}
		}
	}
	printf("%lld\n",f[n][C]);
	return 0;
}


Measured memory_bytes: 1536
#include <iostream>

int numOfWays(int a[], int b[], int m, int n, int index)
{
	if (n<0) return 0;
	if (n==0) return 1;
	if (index == m) return 0;
	int res = 0;
	for (int k=0; k<=b[index]; k++) {
		res += numOfWays(a, b, m, n - k*a[index], index+1);
	}
	return res;
}

int main()
{
	int m;
	while (true) {
		std::cin >> m;
		if (m==0) break;
		int a[7], b[7];
		for (int i=0; i<m; i++) std::cin >> a[i] >> b[i];
		int g; std::cin >> g;
		for (int i=0; i<g; i++) {
			int n;
			std::cin >> n;
			std::cout << numOfWays(a, b, m, n, 0) << std::endl;
		}
	}
	return 0;
}



Measured memory_bytes: 2996
// lcmとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF 1001001001
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define double long double
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n+1)
using namespace std;


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

    ll a,b,c,d,m,n,maxi=0,f=0,mini=INF;
    string str;
    set<ll> start;
    set<ll> end;

    //vector<vector<ll>> v(tate,vector<ll> (yoko));
    cin>>n;
    ll sum=1;
    for(ll i=1;i<=n;i++){
        sum*=i;
        sum%=mod;
    }
    cout<<sum<<endl;


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define inf LLONG_MAX
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    ll n; cin >> n;
    vector<ll> s(n);
    rep(i, n) cin >> s[i];
    sort(all(s));
    ll total = accumulate(all(s), 0);
    if ((total % 10) != 0) {
        cout << total << endl;
        return 0;
    }

    rep(i, s.size()) {
        if ((s[i] % 10) != 0) {
            cout << total - s[i] << endl;
            return 0;
        }
    }
    cout << 0 << endl;
    return 0;
}

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

string decToBin(int n, int d) {
	string s = "";
	while (n) {
		s = to_string(n % 2) + s;
		n /= 2;
	}
	while (s.size() < d) {
		s = "0" + s;
	}
	return s;
}

signed main() {
	int d, g;
	cin >> d >> g;
	vector<int> p(d + 1), c(d + 1);
	for (int i = 1; i <= d; ++i) {
		cin >> p[i] >> c[i];
	}

	int ans = 100000000;

	for (int i = 0; i < pow(2, d); ++i) {
		string s = "#" + decToBin(i, d);

		int cnt = 0, sum = 0, rest_max = -1;

		for (int j = 1; j < s.size(); ++j) {
			if (s[j] == '1') {
				sum += c[j] + j * p[j] * 100;
				cnt += p[j];
			}
			else {
				rest_max = j;
			}
		}
		if (sum < g) {
			int s1 = 0;
			if (rest_max != -1) {
				s1 = 100 * rest_max;
			}
			int need = (g - sum + s1 - 1) / s1;
			if (need >= p[rest_max]) {
				continue;
			}
			cnt += need;
		}
		ans = min(ans, cnt);
	}
	cout << ans << endl;
}


Measured memory_bytes: 384
#include <cstdio>
#include <algorithm>

using namespace std;

int main(int argc, const char * argv[]) {
    int queries, checkSize;
    scanf("%d%d", &queries, &checkSize);

    int count = 0, maxCount;
    int qx[100000], qy[100000];
    bool qBlack[100000];
    int totalX[1000] = {};
    int countX[1000] = {};

    for (int i = 0; i < queries; ++i) {
        int x, y;
        char colorChar[10];
        scanf("%d%d%s", &x, &y, colorChar);

        bool black = colorChar[0] == 'B';

        if ((x / checkSize + y / checkSize) % 2 != 0) {
            black = !black;
        }

        x %= checkSize;
        y %= checkSize;

        qx[i] = x;
        qy[i] = y;
        qBlack[i] = black;

        totalX[x]++;
    }

    maxCount = 0;

    for (int i = 0; i < checkSize; ++i) {
        count = 0;
        for (int l = 0; l < checkSize; ++l) {
            countX[l] = 0;
        }

        for (int k = 0; k < queries; ++k) {
            if (qBlack[k] && qy[k] >= i) {
                count++;
                countX[qx[k]]++;
            } else if (!qBlack[k] && qy[k] < i) {
                count++;
                countX[qx[k]]++;
            }
        }
        for (int j = 0; j < checkSize; ++j) {
            maxCount = max(maxCount, count);
            maxCount = max(maxCount, queries - count);
            count -= countX[j];
            count += totalX[j] - countX[j];
        }
    }

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

    return 0;
}


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

using namespace std;


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

    vector <int> a(N);
    for (int i = 0; i < N; i++){
        cin >> a[i];
    }
    
    int count = 0;
    for (int i = 1; i < N; i++){
        if (a[i - 1] == a[i]){
            a[i] = -1;
            count ++;
        }    
    }
    
    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
typedef vector<pii> vp;
typedef vector<tiii> vt;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
//cout << fixed << setprecision(10);
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 n, m, X, Y;
  cin >> n >> m >> X >> Y;
  vi x(n), y(m);
  rep(i,n) cin >> x[i];
  rep(i,m) cin >> y[i];
  x.pb(X), y.pb(Y);
  int xmax = *max_element(rng(x));
  int ymin = *min_element(rng(y));
  if (xmax < ymin) puts("No War");
  else puts("War");
  return 0;
}

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

int main(){
    char a;
    cin >> a;
    if(a == 'a' || a == 'i' || a == 'u'|| a == 'e' || a == 'o'){
        cout << "vowel" << endl;
    }else{
        cout << "consonant" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int main(){
int H,W,h,w;
cin>>H>>W>>h>>w;
  cout<<(H-h)*(W-w)<<endl;
}

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

using namespace std;

int main()
{
	ll tc;
	scanf("%lld",&tc);
	while(tc--)
	{
		ll n , d;
		scanf("%lld %lld",&n,&d);
		ll x = 127^d;
		ll ans = 0;
		for(int i = 0 ; i < n-1 ; i++)
		{
			ans += max(x,127LL);
//			cout<<ans<<endl;
			d  = min(x,127LL);
			x = 127^d;
		}
		ans += d;
		printf("%lld\n",ans);
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;
 
uint64_t gcd_impl( uint64_t n, uint64_t m ) {
    constexpr uint64_t K = 5;
    if( m == 0 ) { return n; }
    for( ; n / 32 < m; ) {
        uint64_t t = n - m;
        uint64_t s = n - m * K;
        bool q = t < m;
        bool p = t < m * K;
        n = q ? m : t;
        m = q ? t : m;
        if( m == 0 ) { return n; }
        n = p ? n : s;
    }
    return gcd_impl( m, n % m );
}
 
bool is_prime(uint64_t n){
    for(uint64_t i = 2; i*i <= n ; i++){
        if(n%i == 0)return false;
    }
    return n != 1;
}
 
int main(){
  uint64_t a,b;
  cin >> a >> b;
  if(a<b) swap(a,b);
  uint64_t g = gcd_impl(a,b);
  ll ans = 0;
  for(uint64_t i = 1; i*i <= g ; i++){
        if(g%i==0){
            if(is_prime(i)) ans++;
            uint64_t tmp = g/i;
            if(i != tmp) {
              if(is_prime(tmp)) ans++;
            }
        }
  }
  ans++;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;

int main(){ 
  int n, m;
  cin >> n >> m;
  vector<int> h(n);
  rep(i,n) cin >> h[i];
  vector<bool> ok(n, true);
  rep(i,m) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    if (h[a] <= h[b]) ok[a] = false;
    if (h[a] >= h[b])ok[b] = false;
  }
  int res = 0;
  for (int i = 0; i < n; i++) {
    if (ok[i]) res++;
  }
  cout << res << endl;
  return 0;
} 

Measured memory_bytes: 3736
#include <iostream>
#include <algorithm>
#include <functional>
#include <cmath>
#include <string>
#include <vector>
#include <queue>

using namespace std;

int main() {
  int n;
  cin >> n; 
  int ans = n / 2 + n % 2;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'
#define ALL(V) V.begin(), V.end()
#define L_B lower_bound
#define U_B upper_bound
#define pb push_back
#define ll long long
using namespace std;
template<class T, class T1> int chkmin(T &x, const T1 &y) { return x > y ? x = y, 1 : 0; }
template<class T, class T1> int chkmax(T &x, const T1 &y) { return x < y ? x = y, 1 : 0; }
const int MAXN = (1 << 20);


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    ll n ,a;
    cin>>n>>a;
    if(a>=n)
    {
        cout<<"1";
    }
    else if(n%a==0)
    {
        cout<<n/a;
    } else {
        cout<<n/a + 1;
    }
	

	return 0;
}

Measured memory_bytes: 3568
n=int(input())
d=[0]*100
for i in range(n+1):
  s=str(i)
  d[int(s[0])*10+int(s[-1])]+=1
 
ans=0
for i in range(1,10):
  for j in range(1,10):
    ans+=d[10*i+j]*d[10*j+i]
print(ans)

Measured memory_bytes: 8960
#review

def solve(k, s):
    ans = 0
    for x in range(k+1):
        for y in range(k+1):
            z = s - x - y
            if 0 <= z <= k:
                ans += 1
            elif z < 0:
                break
    return ans
 
 
def main():
    k, s = map(int, input().split())
    ans = solve(k, s)
    print(ans)
 
 
if __name__ == '__main__':
    main()

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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	ll n, m;
	cin>>n>>m;
	ll ans = 1;
	for(ll k = 1; k*k <= m; k++){
		if(m%k == 0){
			if(m/k >= n)ans = max(ans, k);
			if(k >= n)ans = max(ans, m/k);
		}
	}
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;

public class Main {
    private final int[][] search = new int[][]{
            {0, 1},
            {0, -1},
            {1, 1},
            {1, -1},
            {1, 0},
            {-1, 1},
            {-1, 0},
            {-1, -1}
    };

    public static void main(final String[] args) throws IOException {
        new Main().run();
    }

    private void run() throws IOException {
        boolean b = true;
        final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        while (b) {
            b = runOnce(reader);
        }

        reader.close();
    }

    private boolean runOnce(final BufferedReader reader) throws IOException {
        final String[] params = reader.readLine().split(" ");
        final int x = Integer.parseInt(params[0]);
        final int y = Integer.parseInt(params[1]);
        if (x == 0 && y == 0) return false;
        final Set<Field> fields = new HashSet<>();
        for (int i = 0; i < y; i++) {
            final String[] line = reader.readLine().split(" ");
            for (int j = 0; j < line.length; j++) {
                fields.add(new Field(i, j, line[j].equals("1")));
            }
        }
        int landCount = 0;
        while (true) {
            final Iterator<Field> iterator = fields.iterator();
            if (!iterator.hasNext()) {
                break;
            }
            final Field next = iterator.next();
            if (next.land) {
                searchLand(next, fields);
                landCount++;
            } else {
                fields.remove(next);
            }
        }
        System.out.println(landCount);
        return true;
    }

    private void searchLand(final Field field, final Set<Field> fields) {
        fields.remove(field);

        final Field tmp = new Field(0, 0, true);
        for (final int[] s: search) {
            tmp.x = field.x + s[0];
            tmp.y = field.y + s[1];
            if(fields.contains(tmp)) {
                searchLand(tmp, fields);
                fields.remove(tmp);
            }
        }
    }

    private final class Field {
        int x, y;
        boolean land;

        Field(final int x, final int y, final boolean land) {
            this.x = x;
            this.y = y;
            this.land = land;
        }

        @Override
        public int hashCode() {
            return x + y * 100;
        }

        @Override
        public boolean equals(final Object obj) {
            if (obj instanceof Field) {
                return ((Field) obj).x == this.x && ((Field) obj).y == this.y && this.land == ((Field) obj).land;
            }
            return super.equals(obj);
        }
    }
}

Measured memory_bytes: 33072
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

int main(void)
{
    double n, m;

    cin >> n >> m;

    vector<double> a(n);
    double sum = 0;
    int ans = 0;

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

        sum += a[i];
    }

    for (int i = 0; i < n; i++)
    {
        if (a[i] >= sum / (4 * m))
        {
            ans++;
        }
    }

    if (ans >= m)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

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

using namespace std;
using ll = long long;
using ld = long double;

const int N = 5e5 + 69;
const ll MOD = 1e9 + 7;

ll ans = 0;
ll fac[N + 10], ifac[N];
int n, m;

ll binpow(ll a, ll b) {
	ll ret = 1;
	while(b) {
		if(b & 1) {ret = (ret * a) % MOD;}
		a = (a * a) % MOD;
		b >>= 1;
	}
	return ret;
}

void init() {
	fac[0] = 1;
	for(int i = 1; i <= N; i++) {
		fac[i] = (1LL * i * fac[i - 1]) % MOD;
	}
	ifac[N] = binpow(fac[N], MOD - 2);
	for(int i = N - 1; i >= 0; i--) {
		ifac[i] = (1LL * (i + 1) * ifac[i + 1]) % MOD;
	}
}

ll C(ll a, ll b) {
	if(a < b || a < 0 || b < 0)
		return 0;
	ll temp = (fac[a] * ifac[a - b]) % MOD;
	temp = (temp * ifac[b]) % MOD;
	return temp;
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);

  #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
  #endif

  init();
  cin >> n >> m;
  // int start = max(0, 2 * n - m);
  // for(int i = start; i <= n; i++) {
  // 	ll temp = 1;
  // 	temp = (temp * ifac[n - i]) % MOD;
  // 	temp = (temp * ifac[n - i]) % MOD;
  // 	temp = (temp * ifac[i]) % MOD;
  // 	temp = (temp * ifac[m - 2 * n + i]) % MOD;
  // 	ans = (ans + temp) % MOD;
  // }
  // ans = (ans * fac[n]) % MOD;
  // ans = (ans * fac[n]) % MOD;
  // ans = (ans * fac[m]) % MOD;
  // cout << ans << '\n';
  ll sgn = 1;
  ll cur = (fac[m] * ifac[m - n]) % MOD;
  for(int i = 0; i <= n; i++) {
  	ll temp = sgn;
  	temp = (temp * cur) % MOD;
  	temp = (temp * fac[m - i]) % MOD;
  	temp = (temp * ifac[m - n]) % MOD;
  	temp = (temp * C(n, i)) % MOD;
  	ans = (ans + temp) % MOD;
  	sgn = -sgn;
  }
  ans = ((ans % MOD) + MOD) % MOD;
  cout << ans << '\n';

  return 0;
}


Measured memory_bytes: 11416
#include <iostream>
#include <vector>
#include <algorithm> 
#include <numeric>

using namespace std;

int main(void){
    
    int n;
    cin >> n;
    vector <long long> a(n);  
    for (int i=0; i<n; i++){
        cin >> a.at(i);
    }
    
    long long min = *std::min_element(a.begin(), a.end());
    long long max = *std::max_element(a.begin(), a.end());
    long long sum = std::accumulate(a.begin(), a.end(), 0LL);
    
    cout << min << " "<< max << " " << sum << endl;
    
    return 0;
}


Measured memory_bytes: 3180
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	K := readint()
	X := readint()
	if X <= K*500 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

const (
	iobufsize = 1 * 1024 * 1024 // 1 MB
)

var stdinsc = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, iobufsize), iobufsize)
	sc.Split(bufio.ScanWords)
	return sc
}()

func readint() int {
	stdinsc.Scan()
	v, err := strconv.Atoi(stdinsc.Text())
	if err != nil {
		panic(err)
	}
	return v
}

func readstr() string {
	stdinsc.Scan()
	return stdinsc.Text()
}

func pow(x, y int) int {
	if y < 1 {
		return 1
	}
	return x * pow(x, y-1)
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}


Measured memory_bytes: 640
N = int(input())
a = list(map(int, input().split()))
c = 0
for idx, i in enumerate(a):
  if idx %2 ==0:
    c += i
  else: 
    c -= i
x1 = c
print(x1)
for i in range(1,N):
  x1 = 2*a[i-1] - x1
  print(x1)

Measured memory_bytes: 14092
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define DEBUG(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));
#define SUM(x) accumulate(ALL(x),0);
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const ll mod = 1000000007;
const double eps = 1e-9;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

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 () {
  int N; cin >> N;
  vi A(N); rep(i,N) cin >> A[i];

  vi B(N);
  rep(i,N) {
    B[i] = A[i] - (i+1);
  }

  SORT(B);
  int b = B[N/2];

  ll ans = 0;
  rep(i,N) {
    ans += abs(A[i] - (b + (i+1)));
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 1792
def function(n, a)
	i = 1
	count = 0
	a.each do |block|
		if (block == i)
			i += 1
		else
			count += 1
		end
	end
	i == 1 ? -1 : count
end

n = gets.chomp.to_i
a = gets.chomp.split(' ').map(&:to_i)
puts function(n, a)


Measured memory_bytes: 18564