akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
using namespace std;
#define ll long long

vector<vector<ll>> C;
vector<vector<ll>> DP;
int n;
ll mod = 1e9 + 7;

bool available(int num, int index){
    int bit = num & (1 << index);
    return bit != 0;
}

ll solve(int index, int av){
    if (index == -1){
        if (av == 0) return 1;
        return 0;
    }

    ll &dp = DP.at(index).at(av);
    if (dp != -1) return dp;

    ll ans = 0;

    for (int i = 0; i < n; i++){
        if (available(av, i) == false) continue;
        if (C.at(index).at(i) == 0) continue;
        ans += solve(index - 1, av xor (1 << i));
    }

    return dp = ans % mod;
}

int main(){
    cin >> n;
    C = vector<vector<ll>>(n, vector<ll>(n));
    DP = vector<vector<ll>>(n, vector<ll>((1 << n), -1));
    for (auto &a : C) for (auto &b : a) cin >> b;
    ll ans = solve(n - 1, (1 << n) - 1);
    cout << ans;
}

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

int main() {
    string s;
    cin >> s;
    int count=0;
    for(int i=0; i<4; i++){
        if(s.at(i) == '+'){
            count++;
        }
        else{
            count--;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
import collections
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

N = int(input())

c = collections.Counter(prime_factorize(N))
sum = 0

for i in c.keys():
    a = c[i]
    for n in range(c[i]):
        if a<n+1:
            break
        else:
            a-=n+1
            sum+=1

print(sum)


Measured memory_bytes: 9464
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;

int M[1000],L[1000],K[1000];
bool flag[1000];
int N, T;
int owaru[1001];

bool check(int num) {
  int aki = num;
  REP(i,N)flag[i]=0;
  REP(i,T)owaru[i]=0;
  int cnt = 0;
  REP(i,T) {
    aki += owaru[i];
    REP(j,N) {
      if (aki == 0) break;
      if (flag[j]) continue;
      if (i%(L[j]+K[j]) <= L[j]) {
        if (i+M[j]>T) return 0;
        aki--;
        owaru[i+M[j]]++;
        cnt++;
        flag[j] = 1;
        if (cnt == N) return 1;
      }
    }
  }
  return 0;
}

int main() {
  while(scanf("%d%d",&N,&T),N||T) {
    REP(i,N) scanf("%d%d%d",M+i,L+i,K+i);
    int ans = -1;
    for (int i=1; i<=N; ++i) {
      if (check(i)) {
        ans = i;
        break;
      }
    }
    printf("%d\n",ans);
  }
}

Measured memory_bytes: 1204
#include <iostream>
#include <string>
#include <map>

int main()
{
  int N;
  std::cin >> N;
  std::string s[N];
  for ( int i = 0; i < N; i++ ) std::cin >> s[i];
  int M;
  std::cin >> M;
  std::string t[M];
  for ( int i = 0; i < M; i++ ) std::cin >> t[i];

  std::map<std::string, int> m;
  for ( int i = 0; i < N; i++ ) {
    m[s[i]]++;
  }
  for ( int i = 0; i < M; i++ ) {
    m[t[i]]--;
  }
  int max = 0;
  for ( auto i = m.cbegin(); i != m.cend(); i++ ) {
    if ( i -> second > max ) {
      max = i -> second;
    }
  }
  std::cout << max << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
ll t;
cin>>t;
ll c=0;
map<string,int>mp;
while(t--)
{
    string s;
    cin>>s;
    mp[s]++;
    
}
c=mp.size();
cout<<c<<endl;



return 0;
}


Measured memory_bytes: 19196
#include <bits/stdc++.h>
#define arep(a,i,n) for(int i=(a);i<(n);i++)
#define rep(i,n) for(int i=0;i<(n);i++)
#define cinf(x,n) for(int i=0;i<(n);i++)cin>>x[i];
#define coutf(x,n) for(int i=0;i<(n);i++)cout<<x[i]<<endl;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using namespace std;

int main(){
	ll x;
	cin >> x;
	if(x>=30)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

Measured memory_bytes: 3596
n, m = map(int, input().split())
a = []
b = []
for i in range(n):
    a.append(list(input()))

for i in range(m):
    b.append(list(input()))


def ext(x, y):
    global a
    res = [[0 for _ in range(m)] for __ in range(m)]

    for i in range(m):
        for j in range(m):
            res[i][j] = a[i+x][j+y]

    return res


ans = "No"
for i in range(0, n - m + 1):
    for j in range(0, n - m + 1):
        if (ext(i, j) == b):
            ans = "Yes"

print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
using namespace std;
using ll = long long;
const int mxn = 200010;
ll dp[mxn], a[mxn], h[mxn], t[2*mxn];
int N;

void update(int idx, ll val)
{
	idx--; idx+=N; t[idx] = val; idx/=2;
	while(idx) t[idx] = max(t[2*idx], t[2*idx+1]), idx/=2;
}

ll query(int l, int r)
{
	l--, r--; l+=N, r+=N;
	ll ret = 0ll;
	for(; l<=r; l/=2, r/=2)
	{
		if(l&1) ret = max(ret, t[l]);
		if(!(r&1)) ret = max(ret, t[r]);
		l++, r--;
	}
	return ret;
}


int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin>>N;
	for(int i=1; i<=N; i++) cin>>h[i];
	for(int i=1; i<=N; i++) cin>>a[i];

	dp[1] = a[1];
	update(h[1], dp[1]);
	for(int i=2; i<=N; i++)
		dp[i] = query(1, h[i]-1)+a[i], update(h[i], dp[i]);

	ll ret = query(1, N);
	cout << ret << '\n';

	return 0;
}

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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
 
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;
 
const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;
 
const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

const LL MOD = 1000000007;

LL dp[13][100001];
LL memo[10][6];

void solve(std::string S){
    dp[0][0] = 1;

    REP(i, 10) {
        LL x = i;
        REP(j, 6) {
            memo[i][j] = x % 13;
            x *= 10;
        }
    }

    REP(i, S.size()) {
        int memo_idx2 = (S.size() - i - 1) % 6;
        if(S[i] == '?') {
            REP(j, 10) {
                int now_idx = memo[j][memo_idx2];
                REP(k, 13) {
                    dp[(now_idx+k)%13][i+1] += dp[k][i];
                    dp[(now_idx+k)%13][i+1] %= MOD;
                }
            }
        } else {
            int memo_idx1 = S[i] - '0';
            int now_idx = memo[memo_idx1][memo_idx2];
            REP(j, 13) {
                dp[(now_idx+j)%13][i+1] += dp[j][i];
                dp[(now_idx+j)%13][i+1] %= MOD;
            }
        }
    }

    cout << dp[5][S.size()] << endl;
}

int main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


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

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < (n); i++)
#define Rep(i, n) for(int i = 1; i < n; i++)

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vii = vector<pair<int, int>>;

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; }

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
ll LCM(ll a, ll b) { return (a * b) / GCD(a, b); }
int round_int(int a, int b) { return (a + (b - 1)) / b; }

// 素因数分解; 返り値は(素数, 乗数)のvector配列
vector<pair<ll, int>> factorize(ll n) {
	vector<pair<ll, int>> res;
	for (ll i = 2; i * i <= n; ++i) {
		if (n % i) continue;
		res.emplace_back(i, 0);
		while (n % i == 0) {
			n /= i;
			res.back().second++;
		}
	}
	if (n != 1) res.emplace_back(n, 1);
	return res;
}

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };
constexpr auto MAX = 100010;

// ──────────────────────────────────────────────────────────────────

constexpr auto N = 8;
constexpr auto FREE = -1;
constexpr auto NOT_FREE = 1;

int row[N], col[N], dpos[2 * N - 1], dneg[2 * N - 1];
bool X[N][N];

void initialize() {
	rep(i, N) row[i] = col[i] = FREE;
	rep(i, 2 * N - 1) dpos[i] = dneg[i] = FREE;
}

void printBoard() {
	rep(i, N) {
		rep(j, N) {
			if (X[i][j]) {
				if (row[i] != j) return;
			}
		}
	}

	rep(i, N) {
		rep(j, N) {
			cout << ((row[i] == j) ? "Q" : ".");
		}
		cout << endl;
	}
}

void recursive(int i) {
	if (i == N) {
		printBoard();
		return;
	}

	rep(j, N) {
		if (col[j] == NOT_FREE ||
			dpos[i + j] == NOT_FREE ||
			dneg[i - j + N - 1] == NOT_FREE)
			continue;

		row[i] = j;
		col[j] = dpos[i + j] = dneg[i - j + N - 1] = NOT_FREE;
		recursive(i + 1);
		row[i] = col[j] = dpos[i + j] = dneg[i - j + N - 1] = FREE;
	}
}

int main() {
	initialize();

	rep(i, N) {
		rep(j, N) {
			X[i][j] = false;
		}
	}

	int k;
	cin >> k;
	rep(i, k) {
		int r, c;
		cin >> r >> c;
		X[r][c] = true;
	}
	recursive(0);
}


Measured memory_bytes: 3116
/*
*
*   Bismillah Hir Rahman Nir Raheem
*   Name: Jaied Al Sabid
*
*/

#include <iostream>
#include <string>
#include <bits/stdc++.h>

using namespace std;

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

    int n;
    string s,t;
    cin>>n;
    cin>>s>>t;
    for(int i=0;i<n;i++)
    {
        cout<<s[i]<<t[i];
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a,b,c,k;
  cin>>a>>b>>c>>k;
  int ans=0;
  if(a>=k)
  {
    ans+=k;
    cout<<k;
    return 0;;
  }
  k-=a;
  ans+=a;
  if(k<=b)
  {
    cout<<ans;
    return 0;
  }
  k-=b;
  ans-=k;
    cout<<ans<<endl;
}

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

public class Main {
	static class Point{
		long x;
		long y;
		Point(long a , long b){
			x = a;
			y = b;
		}
		@Override
		public String toString() {
			return x+ " " +y;
		}
	}
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long xs[] = new long[N];
		long ys[] = new long[N];

		for(int i = 0 ; i < N ; ++i){
			long a = sc.nextLong();
			long b = sc.nextLong();
			long x = a - b;
			long y = a + b;
			xs[i] = x;
			ys[i] = y;
		}
		Arrays.sort(xs);
		Arrays.sort(ys);
		long xd = xs[N - 1] - xs[0];
		long yd = ys[N - 1] - ys[0];
		System.out.println(Math.max(xd, yd));
	}
}


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

vector<vector<ll>> net;

void calc_dist(ll src, vector<ll>& out){
    out.resize(net.size());
    fill(out.begin(), out.end(), -1);
    out.at(src) = 0;
    queue<ll> que;
    que.push(src);
    while(!que.empty()){
        ll cur = que.front(); que.pop();
        for(auto nxt : net.at(cur)){
            if(out.at(nxt) == -1){
                out.at(nxt) = out.at(cur) + 1;
                que.push(nxt);
            }
        }
    }
}

void solve(long long N, long long u, long long v, std::vector<long long> A, std::vector<long long> B){
    net.resize(N);
    u--; v--;
    REP(i, N - 1){
        ll a = A.at(i) - 1;
        ll b = B.at(i) - 1;
        net.at(a).push_back(b);
        net.at(b).push_back(a);
    }

    vector<ll> distu, distv;
    calc_dist(u, distu);
    calc_dist(v, distv);

    ll tgt_dist = -1;
    ll tgt = -1;
    REP(i, N){
        if(distu.at(i) < distv.at(i) && tgt_dist < distv.at(i)){
            tgt = i;
            tgt_dist = distv.at(i);
        }
    }

    cout << tgt_dist - 1 << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
int main(){
    long long N;
    scanf("%lld",&N);
    long long u;
    scanf("%lld",&u);
    long long v;
    scanf("%lld",&v);
    std::vector<long long> A(N-1);
    std::vector<long long> B(N-1);
    for(int i = 0 ; i < N-1 ; i++){
        scanf("%lld",&A[i]);
        scanf("%lld",&B[i]);
    }
    solve(N, u, v, std::move(A), std::move(B));
    return 0;
}


Measured memory_bytes: 9600
n,k = map(int, input().split())
 
str = input()
happy = 0
unhappy = 0
 
for i in range(n-1):
  if(str[i] == str[i+1]):
    happy += 1
  else:
    unhappy += 1
print( min(n-1,(happy + 2 * k )))

# 10 1
# LLLLLRRRRRの時、happy + 2 * kだけやったら10になるけど、幸福になる人数は最高でも9人(n-1人)

Measured memory_bytes: 3316
#![allow(non_snake_case)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!(
        n: usize,
        d: [usize; n],
    );
    let mut sum = 0usize;
    for i in 0..n {
        for j in (i+1)..n {
            sum += d[i]*d[j];
            // println!("{} {}", i, j);
        }
    }
    println!("{}", sum);
}


Measured memory_bytes: 4352
# coding: utf-8
# Your code here!
n = int(input())

S = []
H = []
C = []
D = []

for _ in range(n):
    suit, figure = input().split()
    figure = int(figure)
    if suit == 'S':
        S.append(figure)
    if suit == 'H':
        H.append(figure)
        
    if suit == 'C':
        C.append(figure)
        
    if suit == 'D':
        D.append(figure)
        
S.sort()
H.sort()
C.sort()
D.sort()

if len(S) != 13:
    for i in range(13):
        if (i+1)  not in S:
            print('S',str(i+1))

if len(H) != 13:    
    for i in range(13):
        if (i+1)  not in H:
            print('H',str(i+1))
        
if len(C) != 13:
    for i in range(13):
        if (i+1)  not in C:
            print('C',str(i+1))
        
if len(D) != 13:
    for i in range(13):
        if (i+1)  not in D:
            print('D',str(i+1))


Measured memory_bytes: 5616
#include<bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int (i)=0;(i) < (N); (i)++)
#define all(V) V.begin(), V.end()
using i64 = int_fast64_t;
using P = pair<int,int>;

int main(){
    int A, P;
    cin >> A >> P;
    cout << (A*3 +P) / 2 << endl;

}


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

using namespace std;

int main() {
	int a;
	cin >> a;
	int zenhan = a / 100, kohan = a % 100;
	
	if ((kohan <= 12 && kohan >= 1) && 
		(zenhan <= 12 && zenhan >= 1)){
		cout << "AMBIGUOUS" << endl;
	}
	else if (zenhan <= 12 && zenhan >= 1) {
		cout << "MMYY" << endl;
	}
	else if (kohan <= 12 && kohan >= 1) {
		cout << "YYMM" << endl;
	}
	else {
		cout << "NA" << endl; 
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define se second
#define fi first
#define ll long long
#define ld long double
#define pll pair<ll ,ll >
#define pii pair<int, int> 
#define mod 998244353
ll power(ll a,ll b){
    ll res=1;
    while(b>0){
        if(b%2!=0) res=(res*a)%mod;
        a=(a*a)%mod;
        b/=2;
    }
    return res;
}
ll ncr(ll n,ll k){
    if(k==0||k==n) return 1ll;
    if(k>n-k) k=n-k;
    ll pro=1;
    for(ll i=0;i<k;i++){
        pro=(pro*(n-i))%mod;
        pro/=(i+1);
    }
    return (pro%mod);
}
vector<int> prime;
void seive(){
    vector<bool > isprime(2001,true);
    for(int i=2;i*i<=2000;i++){
        if(isprime[i]){
            for(int j=i*i;j<=2000;j+=i){
                isprime[j]=false;
            }
        }
    }
    for(int i=2;i<=2000;i++){
        if(isprime[i]) prime.push_back(i);
    }
}

int main(void){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,m,a;
    cin>>n>>m;
    priority_queue<ll> pq;
    for(int i=0;i<n;i++){
        cin>>a;
        pq.push(a);
    }
    while(m--){
        a=pq.top();
        pq.pop();
        pq.push(a/2);
    }
    ll sum=0;
    while(!pq.empty()){
        sum+=pq.top();
        pq.pop();
    }
    cout<<sum;
    return 0;
}


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

int main(void) {
  int N, K, Q;

  cin >> N >> K >> Q;
  
  int A[Q];

  for (int i = 0; i < Q; i++)
    cin >> A[i];

  //point
  int point[N];
  for (int i = 0; i < N; i++)
    point[i] = K;

  for (int i = 0; i < Q; i++) 
    point[A[i]-1]++;

  for (int i = 0; i < N; i++) 
    point[i] = point[i] - Q;

  for (int i = 0; i < N; i++) {
    if (point[i] > 0)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }

  return 0;
}


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

using namespace std;

using ll = long long;
constexpr ll MOD = 1e9 + 7;
constexpr ll INF = 1e18;

int main() {
    ll n, m, i, j, k,c;
    cin >> n >> k >> c;
    string s;
    cin >> s;
    ll L[k+1]={},R[k+1]={};
    ll cnt = 1;
    for(i=0;i<n && cnt<=k;i++){
        if(s[i]=='o'){
            L[cnt]=i+1;
            cnt++;
            i+=c;
        }
    }
    cnt=k;
    for(i=n-1;i>=0 && cnt>=0;i--){
        if(s[i]=='o'){
            R[cnt]=i+1;
            cnt--;
            i-=c;
        }
    }
    for(i=1;i<=k;i++){
        if(L[i]==R[i]){
            cout << L[i] << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 4996
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long a = sc.nextInt();
		long b = sc.nextInt();
		long total = 0;
		int prev = sc.nextInt();
		for (int i = 1; i < n; i++) {
		    int x = sc.nextInt();
		    total += Math.min(b, (x - prev) * a);
		    prev = x;
		}
		System.out.println(total);
   }
}




Measured memory_bytes: 48164
def selection_sort(A, N):
    change_cnt = 0
    for i in range(0, N-1):
        min_idx = i
        for j in range(i+1, N):
            if A[j] < A[min_idx]:
                min_idx = j
        A[i], A[min_idx] = A[min_idx], A[i]
        if i != min_idx:
            change_cnt += 1
    print(" ".join([str(a) for a in A]))
    print(change_cnt)
N = int(input().rstrip())
A = [int(a) for a in input().rstrip().split(" ")]
selection_sort(A, N)


Measured memory_bytes: 5608
#include <stdio.h>

int main(void){
	int N;
	int H[100000];
	int i;
	scanf("%d",&N);
	for(i=0; i<N; i++){
		scanf("%d",&H[i]);
	}

	int p=0;
	int count=0;
	int max=0;
	while(p<N){
		for(i=p; H[i]>=H[i+1] && i+1<N; i++){
			count++;
		}
		p=i+1;
		if(count>max) max=count;
		count=0;
	}

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

}

Measured memory_bytes: 512
import java.util.*;

public class Main {
	public static void main(String[] args) throws Exception{
		Scanner scn = new Scanner(System.in);
		String s = scn.next();
      	int a = 0;
      	int z = s.length()-1;
      	while (a<z){
            if(s.charAt(a)=='A' && s.charAt(z)=='Z'){
                break;
            }
            if(s.charAt(a) != 'A') a++;
            if(s.charAt(z) != 'Z') z--;
        }
        System.out.println(z - a + 1);
	}
}

Measured memory_bytes: 40272
n=input()
arr=map(int,raw_input().split())

typ=0
total=1
k=0
t=0
i=0
while i<n:
    item=arr[i]
    if t==0:
        t=item
        continue
    if t>item:
        while i<n:
            item=arr[i]
            if t>=item:
                t=item
                i=i+1
            else:
                total+=1
                break
    elif t<item:
        while i<n:
            item=arr[i]
            if t<=item:
                t=item
                i=i+1
            else:
                total+=1
                break
    if i<n:
        item=arr[i]
        t=item
    i=i+1
            
print total


Measured memory_bytes: 11320
// This amazing code is by Eric Sunli Chen.
#include<bits/stdc++.h>
using namespace std;
template<typename T> bool get_int(T &x)
{
	char t=getchar();
	bool neg=false;
	x=0;
	for(; (t>'9'||t<'0')&&t!='-'&&t!=EOF; t=getchar());
	if(t=='-')neg=true,t=getchar();if(t==EOF)return false;
	for(; t<='9'&&t>='0'; t=getchar())x=x*10+t-'0';
	if(neg)x=-x;return true;
}
template<typename T> void print_int(T x)
{
	if(x<0)putchar('-'),x=-x;
	short a[20]= {},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1; i>=0; i--)putchar('0'+a[i]);
}
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define get1(a) get_int(a)
#define get2(a,b) (get1(a)&&get1(b))
#define get3(a,b,c) (get1(a)&&get2(b,c))
#define printendl(a) print_int(a),puts("")
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int,int> pii;
const int inf=0x3f3f3f3f;
const LL Linf=1ll<<61;
const double pi=acos(-1.0);

#define getcode(i,j) (((i)>>(j))&1)

char s[1<<21];
int n,k,val[21][1<<21];
int&id(int a,int n,int b,int m){return val[n][a|(b<<n)|(1<<n+m)];}

void out(int msk,int n,char v='\n'){for(int i=n-1;i>=0;i--)putchar(getcode(msk,i)+'0');putchar(v);}

int main()
{
	get2(n,k);
	for(int i=0;i<=n;i++)
	{
		scanf("%s",s);
		for(int j=0;j<(1<<i);j++)if(s[j]=='1')
			id(0,0,j,i)++;
	}
	for(int i=0;i<=n;i++)for(int j=0;j<(1<<i);j++)
	{
		for(int ii=n-i;ii>0;ii--)for(int jj=0;jj<(1<<ii);jj++)
		{
			int v=id(j,i,jj,ii);
//			out(j,i,'[');out(jj,ii,']');printf(" dp= %d\n",v);
			if(!v)continue;
			id(j,i,0,0)+=v;
			for(int t=ii-1;t>=0;t--)if(getcode(jj,t)==0)
			{
				id(j<<1,i+1,jj&(1<<t)-1,t)+=v;
				break;
			}
			for(int t=ii-1;t>=0;t--)if(getcode(jj,t)==1)
			{
				id(j<<1|1,i+1,jj&(1<<t)-1,t)+=v;
				break;
			}
		}
	}
	for(int i=n;i>=0;i--)
	{
		for(int j=0;j<(1<<i);j++)if(id(j,i,0,0)>=k)
		{
			out(j,i);
			exit(0);
		}
	}
	puts("-1");
	return 0;
}

Measured memory_bytes: 172416
from collections import defaultdict, deque
n = int(input())
data = [list(map(int, input().split())) for _ in range(n-1)]
tree = defaultdict(list)
for u, v, w in data:
    if w % 2 == 0:
        tree[u].append((v, "ok"))
        tree[v].append((u, "ok"))
    else:
        tree[u].append((v, "ng"))
        tree[v].append((u, "ng"))
# print(tree.items())
queue = deque()
queue.append(1)
visited = set()
ans = [None for _ in range(n)]
ans[0] = 1
while len(queue):
    now = queue.popleft()
    opps = tree[now]
    # print(now, opps)
    for opp in opps:
        if opp[0] not in visited:
            queue.append(opp[0])
            # print(ans[now-1])
            if opp[1] == "ok":
                ans[opp[0]-1] = ans[now-1]
            else:
                ans[opp[0]-1] = -ans[now-1]
        visited.add(opp[0])
for value in ans:
    if value == 1:
        print(1)
    else:
        print(0)




Measured memory_bytes: 64096
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define bitsz(x) int(__builtin_popcount(x))
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb(x) push_back(x)
#define INF 2e9
#define LINF 1e18
#define mod 1000000007
template<class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
const int di[4] = {1,0,-1,0};
const int dj[4] = {0,1,0,-1};


struct edge { ll from, to, cost; };
vector<edge> es; //辺の数でresize
vector<ll> d; //頂点の数でresize
int n, m; //頂点数と辺数
bool negative = false;

void bellmanford(int s) {
    rep(i,n) d[i] = LINF;
    d[s] = 0;
    rep(loop,n) {
        bool update = false;
        rep(i,m) {
            edge e = es[i];
            if (d[e.from] != LINF && d[e.to] > d[e.from] + e.cost) {
                d[e.to] = d[e.from] + e.cost;
                update = true;
                //閉路検出
                if (loop == n-1 && e.to == n-1) {
                    negative = true;
                    break;
                }
            }
        }
        if (!update) break;
    }
}

//負の閉路検出（おまけ）
//trueなら負の閉路が存在
bool find_negative_loop() {
    rep(i,n) d[i] = 0;
    rep(i,n) {
        rep(j,m) {
            edge e = es[j];
            if (d[e.to] > d[e.from] + e.cost) {
                d[e.to] = d[e.from] + e.cost;
                //n回目にも更新があるなら負の閉路が存在
                if (i == n-1) return true;
            }
        }
    }
    return false;
}

int main() {
    cin >> n >> m;
    d.resize(n);
    es.resize(m);
    rep(i,m) {
        edge e;
        cin >> e.from >> e.to >> e.cost;
        e.from--; e.to--;
        e.cost *= -1;
        es[i] = e;
    }
    // if (find_negative_loop()) {
    //     cout << "inf" << endl;
    //     return 0;
    // }
    bellmanford(0);
    if (negative) cout << "inf" << endl;
    else cout << -d[n-1] << endl;
}

Measured memory_bytes: 3616
import java.util.*;

public class Main {
	//static boolean f;
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		/* 入力の受け取り
		 * String s = sc.next();
		 * int a = sc.nextInt();
		 * long a = sc.nextLong();
		 */
		
		// 文字列(String)を文字(char)に分解
		// char[] s_char = s.toCharArray();
		
		int x = sc.nextInt();
		int y = sc.nextInt();
		int z = sc.nextInt();
		
		System.out.println(z+" "+x+" "+y);
		
		/*
		 * if(f)
		 *	System.out.println("Yes");
		 * else
		 * 	System.out.println("No");
		 */
	}
}


Measured memory_bytes: 19796
x, k, d = map(int, input().split())
if(x <0):
    if(x+k*d<=d):
        print(abs(x+k*d))
    elif(x%d == 0):
        if((x/d)%2 == k%2):
            print(0)
        else:
            print(d)
    else:
        if((x//d)%2 == k%2):
            print(x%d)
        else:
            print(d-x%d)
else:
    if(x-k*d>=-d):
        print(abs(x-k*d))
    elif(x%d == 0):
        if((x//d)%2 == k%2):
            print(x%d)
        else:
            print(d-x%d)
    else:
        if((x//d)%2 == k%2):
            print(x%d)
        else:
            print(d-x%d)

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

using ll = long long;

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

    ll x;cin>>x;

    ll ans=x/11LL;
    ans*=2;
    int m=x%11LL;
    if(m>0)ans++;
    if(m>6)ans++;

    cout<<ans<<"\n";

    return 0;
}


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

using namespace std;

int main()
{
    int N, x = 0, A;
    string S;
    cin >> N >> S;
    vector<int> v;

    for (int i = 0; i < S.length(); i++)
    {
        if (S[i] == 'I')
        {
            x++;
            v.push_back(x);
        }

        if (S[i] == 'D')
        {
            x--;
            v.push_back(x);
        }
    }

    sort(v.begin(), v.end(), greater<>());

    if (v[0] >= 0)
    {

        cout << v[0];
    }

    else
    {
        cout << 0;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,a,b,c;cin>>n>>a>>b>>c;
  int l[n];
  int ans=100000000;
  for(int i=0;i<n;i++)cin>>l[i];
  for(int i=0;i<(1<<(2*n));i++){
    int num[n];fill(num,num+n,0);
    int cnt[4];fill(cnt,cnt+4,0);
    int u=i;
    for(int j=0;j<n;j++){
      cnt[u%4]++;
      num[j]=u%4;
      u/=4;
    }
    if(cnt[0]==0||cnt[1]==0||cnt[2]==0)continue;
    int sum[3];fill(sum,sum+3,0);
    vector<int> v;
    int ss=0;
    for(int j=0;j<n;j++){
      if(num[j]==0){
        if(sum[0]>0)ss+=10;
        sum[0]+=l[j];
        
      }
      if(num[j]==1){
        if(sum[1]>0)ss+=10;
        sum[1]+=l[j];
       
      }
      if(num[j]==2){
        if(sum[2]>0)ss+=10;
        sum[2]+=l[j];
        
      }
      if(num[j]==3){
        v.push_back(l[j]);
      }
    }
    v.push_back(sum[0]);
    v.push_back(sum[1]);
    v.push_back(sum[2]);
    int uu=10000000;
    for(int j=0;j<v.size();j++){
      for(int k=0;k<v.size();k++){
        for(int l=0;l<v.size();l++){
          if(l==j||j==k||k==l)continue;
          uu=min(abs(a-v[j])+abs(b-v[k])+abs(c-v[l]),uu);
        }
      }
    }
    ss+=uu;
    //if(ss==53){
     // for(int j=0;j<n;j++)cout<<num[j]<<" ";
   // }
    ans=min(ans,ss);
    
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
a,b = map(int,input().split())

#a,bの最大公約数
def gcd(a, b):
   while b:
       a, b = b, a % b
   return a

#a,bの最小公倍数
def lcm(a, b):
   return a * b // gcd (a, b)

print(lcm(a,b))

Measured memory_bytes: 2940
const Main = (input) => {
    input = input.split("");
    var sum = 0;

    if (input[0] === '1') sum++;
    if (input[1] === '1') sum++;
    if (input[2] === '1') sum++;

    console.log(sum);

}

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


Measured memory_bytes: 7372
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] h = new int[n];
        for (int i=0;i<n;i++)h[i]=sc.nextInt();
        int ans = 0;
        for (int i=0;i<n;i++){
            int count = i;
            while (count<n-1&&h[count]>=h[count+1])count++;
            ans=Math.max(ans,count-i);
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 59608
#include <algorithm>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
constexpr ll INF = 1ll << 55;

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

// multi-dimensional vector (require c++14)
template <typename T, typename U>
static inline vector<U> make_nd_vector(T &&n, U &&val) noexcept {
  static_assert(is_integral<T>::value,
                "[make_nd_vector] 1st argument must be an integer type");
  return vector<U>(forward<T>(n), forward<U>(val));
}
template <typename T, typename... Args>
static inline decltype(auto) make_nd_vector(T &&n, Args &&... args) noexcept {
  static_assert(is_integral<T>::value,
                "[make_nd_vector] 1st argument must be an integer type");
  return vector<decltype(make_nd_vector(forward<Args>(args)...))>(
      forward<T>(n), make_nd_vector(forward<Args>(args)...));
}
//
// Print from Iterator
template <typename ite>
void print_ite(ite start, ite end, char sp = ' ', char en = '\n') {
  for (auto i = start; i != end; i++)
    cout << *i << sp;
  cout << en;
}
//
inline void Yes(bool condition) { cout << (condition ? "Yes\n" : "No\n"); }

vector<pair<ll, int>> prime_fact(ll n) {
  vector<pair<ll, int>> res;
  for (ll i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      int count = 0;
      while (n % i == 0) {
        n /= i;
        count++;
      }
      res.emplace_back(i, count);
    }
  }
  if (n != 1)
    res.emplace_back(n, 1);
  return res;
}

int main() {
  ll n;
  cin >> n;
  vector<ll> sum;
  for (ll i = 0; i < 1e6; i++) {
    sum.push_back(i * (i + 1) / 2);
  }
  int ans = 0;
  auto v = prime_fact(n);
  for (int i = 0; i < v.size(); i++) {
    int sisuu = v[i].second;
    int cnt = lower_bound(all(sum), sisuu) - sum.begin();
    if (sum[cnt] != sisuu)
      cnt--;
    ans += cnt;
  }
  cout << ans << endl;
}


Measured memory_bytes: 11192
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int maxPossibleVal = m / n;
        if (m % n == 0) {
            System.out.println(maxPossibleVal);
            return;
        }
        int ans = 1;
        for (int i=2; i<=maxPossibleVal; i++) {
            if (m % i == 0) {
                ans = i;
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 23636
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<queue>
#include<stack>
#include<map>

using namespace std;

template<typename A, typename B> bool chmin(A &a, const B &b){ return b < a && (a = b, true); }
template<typename A, typename B> bool chmax(A &a, const B &b){ return a < b && (a = b, true); }

int main(){
  int cnt;
  string s;
  cin >> s;
  for (int i = 0; i < 3; i++){
    if (s[i] == '1'){
      cnt += 1;
    }
  }
  cout << cnt << '\n';
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  ll n, m;
  string s, t;
  cin >> n >> m >> s >> t;

  if (s[0] != t[0]) {
    cout << -1 << endl;
    return 0;
  }

  ll lcmv = n / __gcd(n, m) * m;
  int a = lcmv / n, b = lcmv / m;

  map<ll, char> mp;
  ll tt = a;
  rep(i, 1, n) {
    mp[tt] = s[i];
    tt += a;
  }

  tt = b;
  rep(i, 1, m) {
    if (mp.count(tt)) {
      if (mp[tt] != t[i]) {
        cout << -1 << endl;
        return 0;
      }
    }
    tt += b;
  }

  cout << lcmv << endl;
}


Measured memory_bytes: 6144
#include<iostream>
using namespace std;
int main()
{
  int n,flag=0;
  string s;
  cin>>n;
  int a[30]={0};
  cin>>s;
  for(int i=0;i<n;i++)
  {
    a[s[i]-'a']++;
  }
  for(int i=0;i<30;i++)
  {
    if(a[i]%2!=0)
    {
      flag=1;
      cout<<"No";
      break;
    }
  }
  if(flag==0)
    cout<<"Yes";
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cctype>
#include <string>

using namespace std;

typedef long long ll;

#define rep(i,n)  for(int i=0;i<(n);++i)
#define all(x) (x).begin(),(x).end()

ll gcd(ll x, ll y) { return y ? gcd(y, x%y) : x; }

const int mod = 1000000007;
const int INF = 1001001001;

int graph[10][10];

int main() {
    int n, m;
    cin >> n >> m;
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        a--;b--;
        graph[a][b] = 1;
        graph[b][a] = 1;
    }

    int array[] = {0, 1, 2, 3, 4, 5, 6, 7};

    int ans = 0;

    do {
        bool flag = true;
        for (int i = 1; i < n; i++) {
            if(graph[array[i-1]][array[i]] != 1) {
                flag = false;
                break;
            }
        }
        if(flag) ans += 1;
    }while (next_permutation(array+1, array + n));

    cout << ans << endl;
}

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

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
const int inf = 1e9;
const ll linf = 1LL << 50;

int main(int argc, char const* argv[])
{
  int n;
  cin >> n;
  int res = 1;
  while(res <= n){
    res *= 2;
  }
  cout << res / 2 << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <functional>
#include <map>
#include <queue>

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

using namespace std;
using ll = long long;
using P = pair<int, int>;
using TP = tuple<ll, ll, ll>;
ll MOD = 1e9+7;
ll INF = 1e18;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int H, W;
    cin >> H >> W;
    vector<vector<char>> s(H, vector<char>(W,0));
    vector<vector<int>> row(H, vector<int>(W,0));
    vector<vector<int>> col(H, vector<int>(W,0));
    
    REP(i, H){
        REP(j, W){
            cin >> s[i][j];
        }
    }
    REP(i, H){
        int cnt = 1;
        REP(j, W-1){
            if(s[i][j] == '.' && s[i][j+1] == '#'){
                row[i][j] = cnt;
                cnt = 1;
            }else if(s[i][j] == '.' && s[i][j+1] == '.'){
                cnt++;
            }
            if(j == W-2 && s[i][j+1] == '.' ){
                row[i][j+1] = cnt;
            }
        }
        REP(j, W-1){
            if(s[i][W-j-2] == '.' && s[i][W-j-1] == '.'){
                row[i][W-j-2] = row[i][W-j-1];
            }
        }
    }
    
    REP(i, W){
        int cnt = 1;
        REP(j, H-1){
            if(s[j][i] == '.' && s[j+1][i] == '#'){
                col[j][i] = cnt;
                cnt = 1;
            }else if(s[j][i] == '.' && s[j+1][i] == '.'){
                cnt++;
            }
            if(j == H-2 && s[j+1][i] == '.' ){
                col[j+1][i] = cnt;
            }
        }
        REP(j, H-1){
            if(s[H-j-2][i] == '.' && s[H-j-1][i] == '.'){
                col[H-j-2][i] = col[H-j-1][i];
            }
        }
    }
    if(W==1&&H==1){
        cout << 1 << endl;
        return 0;
    }
//    REP(i, H){
//        REP(j, W){
//            cout << row[i][j] << " ";
//        }
//        cout << endl;
//    }
//    cout << endl;
//    REP(i, H){
//        REP(j, W){
//            cout << col[i][j] << " ";
//        }
//        cout << endl;
//    }

    int m = 0;
    REP(i, H){
        REP(j, W){
            m = max(m, row[i][j]+col[i][j] + (row[i][j] != 0 && col[i][j] != 0 ? -1:0));
        }
    }
    cout << m << endl;
    return 0;
}


Measured memory_bytes: 35712
# 入力
# スペース区切りの整数の入力(未知数)
list_s = [string for string in input().split()]

# 計算と出力
if (list_s[0][-1] == list_s[1][0]) and (list_s[1][-1] == list_s[2][0]) :
    print("YES")
else :
    print("NO")

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, q;
  string s;
  vector<set<int>> ind(26);
  vector<int> o;
  cin >> n;
  cin >> s >> q;
  for(int i = 0; i < n; i++) ind[s[i] - 'a'].insert(i);
  for(int i = 0; i < q; i++) {
    int t;
    cin >> t;
    if(t == 1) {
      int in;
      char c;
      cin >> in >> c;
      if(s[in - 1] != c) {
        ind[s[in - 1] - 'a'].erase(in - 1);
        ind[c - 'a'].insert(in - 1);
        s[in - 1] = c;
      }
    } else {
      int l, r, cnt = 0;
      cin >> l >> r;
      for(int j = 0; j < 26; j++) {
        if(ind[j].size()) {
          auto it = ind[j].lower_bound(l - 1);
          if(it == ind[j].end()) continue;
          if(*it < r) cnt++;
        }
      }
      o.push_back(cnt);
    }
  }
  for(int i = 0; i < o.size(); i++) cout << o[i] << '\n';
}

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

int main(){
	long long int n;cin >> n;
	long long int mini = 0;
	long long int minn = INT64_MAX;
	for(int i = 0;i < 5;i++){
		long long int t;cin >> t;
		if(t < minn){
			minn = t;
			mini = i;
		}
	}
	cout << (n + (minn - 1)) / minn + 4;
}
// make pair, tuple
// make pair, tuple
// 
// __gcd(int, int);
// lcm = a * b / __gcd(a, b);
// 
// bool isPrime(int n){
//       if(n <= 1)return false;
//       if(n <= 3)return true;
//       if(n % 2 == 0 || n % 3 == 0)return false;
//       for(int i = 5;i * i <= n;i += 6){
//             if(n % i == 0 || n % (i + 2) == 0)return false;
//       }
//       return true;
// }
// int countSubString(string s, string temp){
//       int ans = 0;
//       size_t f = s.find(temp);
//       while(f != string::npos){
//             ans++;
//             f = s.find(temp, f + 1);
//       }
//       return ans;
// }
// 
// #Count leading & trailing zero of an integer bits
// __builtin_clz(n);
// __builtin_clzll(n);
//
// #Count 1s bits of an integer
// __builtin_popcount(n);
// __builtin_popcountll(n);
//
// #Error checking
// assert(n == 3);
// 
// #Error Printing
// cerr << "Some thing";

// #binary exponentiation
// long long binpow(long long a, long long b) {
//     long long res = 1;
//     while (b > 0) {
//         if (b & 1)
//             res = res * a;
//         a = a * a;
//         b >>= 1;
//     }
//     return res;
// }


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
typedef long long LL;
LL ans1,ans2;
LL a,b,c,d,e,f;
double nong;
int main()
{
	scanf("%lld%lld%lld%lld%lld%lld",&a,&b,&c,&d,&e,&f);
	ans1=100*a;
	for (LL a1=0;a1<=30;a1+=a)
	    for (LL b1=0;b1<=30;b1+=a)
	    {
	    	LL wa=a1*100+b1*100;
	    	for (LL i=0;i<=3000;i+=c)
	    	    for (LL j=0;j<=3000;j+=d)
	    	    {
	    	    	LL su=i+j;
	    	    	if (su+wa>f) continue;
	    	    	if (su>(a1+b1)*e) continue;
	    	    	if (nong*(su+wa)<(100.0)*su) 
	    	    	{
	    	    		nong=(su*100.0)/(su+wa);
	    	    		ans1=su+wa;
	    	    		ans2=su;
	    	    	}
	    	    }
	    }
	printf("%lld %lld",ans1,ans2);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

const int N = 7400000;
int x[N];

int main()
{
    int m,n;
    while(cin >>m >>n,m)
    {
        fill(x,x+N,0);

        for(int i=m; i<N; ++i)
        {
            if(x[i]==0)
            {
                for(int j=i; j<N; j+=i) x[j]=1;
                --n;
                if(n==0) break;
            }
        }

        int ans = m;
        while(x[ans]==1) ++ans;
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 31948
from collections import Counter
N = int(input())
S = Counter(list(input() for _ in range(N)))

#%%
max_v = max(S.values())
words = []
for k, v in S.most_common():
    if v == max_v:
        words.append(k)
    else:
        break

words.sort()
for w in words:
    print(w)

Measured memory_bytes: 121680
#include <bits/stdc++.h>
#define pq priority_queue
#define P pair<int, int>
#define P2 pair<int, P>
#define P3 pair<int, P2>
using namespace std;
typedef long long ll; typedef long double ld;
constexpr int gcd(int a, int b){return b ? gcd(b, a % b) : a;}
constexpr int lcm(int a, int b){return a / gcd(a, b) * b;}
constexpr int INF = 1e9, MOD = INF + 7, around[] = {0, 1, 1, -1, -1, 0, -1, 1, 0, 0};
constexpr int inv(const int x, int n, const int mod){ll ret=1,pos=x;while(n){if(n&1)(ret*=pos)%=mod;(pos*=pos)%=mod;n>>=1;}return ret;}
template<int n> struct Factorial{ll arr[n+1],ary[n+1];constexpr Factorial():arr(),ary(){arr[0]=1;ary[0]=1;for(int i=0;i<n;i++){arr[i+1]=arr[i]*(i+1)%MOD;ary[i+1]=inv(arr[i+1],MOD-2,MOD);}}};
constexpr Factorial<10> fact;
constexpr int comb(int a, int b){ll pos = fact.arr[a], pot = fact.ary[a - b], por = fact.ary[b];return pos * pot % MOD * por % MOD;}
constexpr int vx[] = {1, 0, -1, 0}, vy[] = {0, 1, 0, -1};
constexpr int sqrtN = 512, logN = 32;
constexpr ld PI = abs(acos(-1));
constexpr ll LINF=1e18;

int main(){
	int n, m; cin >> n >> m;
	int li[100010]; bool li2[100010] = {}; li2[0] = true;
	for(int i = 0; i < n; i++) li[i] = 1;
	for(int i = 0; i < m; i++){
		int a, b; cin >> a >> b; a--; b--;
		
		if(li2[a] and li[a] == 1){
			li2[a] = false;
			li[a]--; li[b]++;
			li2[b] = true;
		}else if(li2[a] and li[a] > 1){
			li[a]--; li[b]++;
			li2[b] = true;
		}else{
			li[a]--; li[b]++;
		}
	}
		
	int c = 0;
	for(int i = 0; i < n; i++) c += li2[i];
	cout << c << endl;
	return 0;
}


Measured memory_bytes: 768
N=int(input())
T, A = map(int, input().split())
H =  list(map(int, input().split()))

ans=0
min_dif = float("inf")
for i, h in enumerate(H):
  dif = abs(A-(T-h*0.006))
  if dif<min_dif:
    min_dif = dif
    ans=i

print(ans+1)

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

int main() {
  double w,h,x,y; cin >> w >> h >> x >> y;
  int a;
  if(w/2==x && h/2==y)a=1;
  else a=0;

  double ans=w*h/2.0;
  cout << ans << ' ' << a << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
 
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, x, y;
  cin >> n >> x >> y;
  vector <int> res(n, 0);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j < i; j++) {
      if (i <= x) {
        res[i - j]++;
      } else {
        if (j >= y) {
          res[i - j]++;
        } else {
          if (j <= x && i >= y) {
            res[i - y + 1 + x - j]++;
          } else if (i >= y && j >= x) {
            res[min(i - j, j - x + 1 + i - y)]++;
          } else if (i <= y && j >= x) {
            res[min(i - j, y - i + 1 + j - x)]++;
          } else {
            res[min(i - j, y - i + 1 + x - j)]++;
          }
        }
      }
    }
  }
  for (int k = 1; k <= n - 1; k++) {
    cout << res[k] << '\n';
  }
  return 0;
}

Measured memory_bytes: 256
A, V = map(int, input().split())
B, W = map(int, input().split())
T = int(input())

if A < B:
    if (A + V * T >= B + W * T):
        print("YES")
    else:
        print("NO")
else:
    if (A - V * T <= B - W * T):
        print("YES")
    else:
        print("NO")




Measured memory_bytes: 9052
#include<iostream>
using namespace std;
int main(){
  int n,y,flag=0,sum,i,j,k;
  cin >> n >> y;
  for(i=0;i<=n;i++){
    for(j=0;j+i<=n;j++){
      sum=i*10000+j*5000+(n-i-j)*1000;
      if(sum==y){
        flag=1;
        break;
      }else if(sum>y) break;
    }
    if(flag==1) break;
  }
  if(flag==1){
    printf("%d %d %d\n",i,j,n-i-j);
  }else{
    printf("-1 -1 -1\n");
  }
  return 0;
}


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

int main() {
  long long A,B,N;
  cin >> A >> B >> N;
  long long ans = 0;
  long long K = 0;
  K = min(B-1,N);
  ans = A*K/B-A*(K/B);
  cout << ans <<endl;
}


Measured memory_bytes: 3636
#include <cstdio>
#include <stack>

int main()
{
  long long n;
  scanf("%lld", &n);
  if (n == 0)
  {
    puts("0");
    return 0;
  }
  std::stack<char> st;
  while (n != 0)
  {
    st.emplace((n & 1) + '0');
    n = (n & (~1)) / (-2);
  }
  while (st.size() > 0)
  {
    putchar(st.top());
    st.pop();
  }
  putchar('\n');
  return 0;
}

Measured memory_bytes: 256