akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>

typedef long long LL;
const int MN = 55, MV = 1 << 18;

LL Binom[MN][MN], Ans;
int N, K, S, T, A[MN], part[MV];

int main() {
	scanf("%d%d%d%d", &N, &K, &S, &T);
	for (int i = 1; i <= N; ++i) {
		scanf("%d", &A[i]);
		if ((A[i] & S) != S || (A[i] | T) != T) {
			--i, --N;
			continue;
		}
	}
	for (int i = 0; i <= N; ++i) {
		Binom[i][0] = 1;
		for (int j = 1; j <= i; ++j)
			Binom[i][j] = Binom[i - 1][j - 1] + Binom[i - 1][j];
	}
	for (int i = 0; i <= N; ++i)
		for (int j = 2; j <= K; ++j)
			Binom[i][j] += Binom[i][j - 1];
	for (int X = 0; X < 1 << 18; ++X) {
		if ((X & S) != S || (X | T) != T) continue;
		LL Sum = 0;
		for (int i = 1; i <= N; ++i) ++part[A[i] & X];
		for (int i = 1; i <= N; ++i) if(part[A[i] & X])
			Sum += Binom[part[A[i] & X]][K], part[A[i] & X] = 0;
		Ans += Sum * (__builtin_parity(X ^ S) ? -1 : 1);
	}
	printf("%lld\n", Ans);
	return 0;
}

Measured memory_bytes: 2772
a,b=map(int,input().split())
if a==1:
  if b==1:
    print("Draw")
  else:
    print("Alice")
else:
  if b==1:
    print("Bob")
  else:
    if a==b:
      print("Draw")
    elif a<b:
      print("Bob")
    else:
      print("Alice")

Measured memory_bytes: 9180
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>


using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define loop(n) FOR(i,0,n)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int imos[30][101010];

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

	for (int i = 0; i < N; i++) {
		int a, b, c; cin >> a >> b >> c;

		//使用できるかどうかが要、0.5秒使えないというのは
		//-1しても同じ。
		a--;
		
		//チャンネル数は0indexed
		c--;

		//入力のbは開区間なので含まない。
		//b-1までが有効、累積和の出口は[s t]だとsに+1してt+1に-1するのでこれ
		//で辻褄があう
		imos[c][a]++;
		imos[c][b]--;
	}

	//端だけ記録されているのを区間に広げる。
	for (int c = 0; c < C; c++) {
		for (int i = 1; i < 101010; i++) {
			imos[c][i] += imos[c][i - 1];
		}
	}

	int ans = 0;

	//各時間に対して
	for (int i = 0; i < 101010; i++) {
		int cnt = 0;

		//すべてのチャンネルをチェックし
		for (int c = 0; c < C; c++) {
			//同時刻に放送されている番組数を足していていく。
			if (imos[c][i]) {
				cnt++;
			}
		}

		ans = max(ans, cnt);
	}

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

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

int main(){
  int n; string s;
  cin>>n>>s;
  if(n%2==0){
    if(s.substr(0,n/2)==s.substr(n/2,n/2)){
      cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
/*
 * 2344.cc: Multi Ending Story
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 500000;

/* typedef */

typedef long long ll;
typedef queue<int> qi;

/* global variables */

int c0s[MAX_N], c1s[MAX_N], lns[MAX_N], ds[MAX_N], prts[MAX_N];
ll dp[MAX_N][2];
int fs[MAX_N];

/* subroutines */

/* main */

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

  c0s[n - 1] = c1s[n - 1] = -1;
  lns [n - 1] = 1;
  ds[0] = 0;
  prts[0] = -1;

  qi q;
  
  for (int i = 0; i < n - 1; i++) {
    int &c0 = c0s[i], &c1 = c1s[i];
    cin >> c0 >> c1;
    c0--, c1--;

    if (c0 == n - 1) fs[i]++;
    else ds[c0] = ds[i] + 1, prts[c0] = i;
    if (c1 == n - 1) fs[i]++;
    else ds[c1] = ds[i] + 1, prts[c1] = i;

    if (fs[i] >= 2) q.push(i);
  }

  dp[n - 1][0] = dp[n - 1][1] = 0;

  while (! q.empty()) {
    int u = q.front(); q.pop();
    int uc0 = c0s[u], uc1 = c1s[u];

    lns[u] = lns[uc0] + lns[uc1];

    dp[u][0] = dp[uc0][0] + dp[uc1][0] + lns[u];

    ll udp0 = dp[uc0][1] + 1 + dp[uc1][0] + lns[uc1];
    ll udp1 = dp[uc0][0] + lns[uc0] + dp[uc1][1] + 1;
    ll udp2 = dp[uc0][1] + dp[uc1][1] + ds[u] + 2;
    dp[u][1] = min(min(udp0, udp1), udp2);

    int v = prts[u];
    if (++fs[v] >= 2) q.push(v);
  }

  printf("%lld\n", min(dp[0][0], dp[0][1]));
  return 0;
}

Measured memory_bytes: 20732
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(), x.end()
int main() {
	/*freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);*/
	int A, B, M;
	cin >> A >> B >> M;
	vector<int> a(A), b(B);
	for (int i=0; i<A; i++) cin >> a[i];
	for (int i=0; i<B; i++) {
		cin >> b[i];
	}
	int price = *min_element(all(a)) + *min_element(all(b));
	for (int i=0; i<M; i++) {
		int x, y, c;
		cin >> x >> y >> c;
		if (a[x-1]+b[y-1]-c < price) price = a[x-1]+b[y-1]-c;
	}
	cout << price << '\n';
	return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}

	public void run() {
		Scanner sc = new Scanner(System.in);
		long n=sc.nextLong();
		long v[]=new long[5];
		long min = Long.MAX_VALUE;
		for(int i=0; i<5; i++) {
			v[i]=sc.nextLong();
			min=Math.min(min, v[i]);
		}
		long ans = 5;
		if(n>min) {
			if((n-min)%min!=0) {
				ans += (n-min)/min+1;
			}else {
				ans += (n-min)/min;
			}
		}

		System.out.println(ans);
		sc.close();
	}

}


Measured memory_bytes: 21844
num = int(input())
ac = 0
tle = 0
wa = 0
re = 0

for i in range(num):
  word = input()
  if word == "AC":
    ac += 1
  if word == "TLE":
    tle += 1
  if word == "WA":
    wa += 1
  if word == "RE":
    re += 1

print("AC x " + str(ac)) 
print("WA x " + str(wa)) 
print("TLE x " + str(tle)) 
print("RE x " + str(re)) 

Measured memory_bytes: 9072
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=(n)-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<par<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

long long modpow(long long x,long long n = mod - 2) {
    long long result = 1;
    while (n > 0) {
        if ((n & 1) == 1) {
            result = (result * x) % mod;
        }
        x = (x * x) % mod;
        n >>= 1;
    }
 
    return result;
}

class Combination {
    private:
    vector<int> x, y;
    
    int modpow(int x, int n, int mod = (int)1e9 + 7) {
        int ret = 1;
        while (n > 0) {
            if ((n & 1)) {
                ret = ret * x % mod;
            }
            x = x * x % mod;
            n >>= 1;
        }
        return ret;
    }
    
    public:
    Combination(int n) {
        x.resize(n+1);
        y.resize(n+1);        
        x[0]=y[0]=1;
        for (int i = 1; i <= n; i++) {
            x[i]=(x[i-1]*i)%mod;
            y[i]=modpow(x[i],mod-2);
        }
    }
    
    int get(int n, int r) {
        return x[n] * y[n - r] % mod * y[r] % mod;
    }
    
};
      
void run(){
    int n,a,b,c;
    cin>>n>>a>>b>>c;
    Combination comb(2*n);
    int ans=0;
    int pa=a*modpow(a+b)%mod;
    int pb=b*modpow(a+b)%mod;
    int ec=100*modpow(a+b)%mod;
    REP(i,n,2*n-1){
        ans+=comb.get(i-1,n-1)*(modpow(pa,n)*modpow(pb,i-n)%mod+modpow(pa,i-n)*modpow(pb,n)%mod)%mod*i%mod*ec%mod;
        ans%=mod;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3328
import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); } bool DEBUG = 0; 
void log(A ...)(lazy A a){ if(DEBUG) print(a); }
void print(){ writeln(""); } void print(T)(T t){ writeln(t); } void print(T, A ...)(T t, A a){ write(t, " "), print(a); }
string unsplit(T)(T xs){ return xs.array.to!(string[]).join(" "); }
string scan(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T scan(T)(){ return scan.to!T; } T[] scan(T)(int n){ return n.iota.map!(i => scan!T()).array; }
T lowerTo(T)(ref T x, T y){ if(x > y) x = y; return x; } T raiseTo(T)(ref T x, T y){ if(x < y) x = y; return x; }

// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- //

void solve(){
    int n = scan!int;
    int[] as = scan.map!(c => c.to!int - '1').array;

    bool has1 = 0;
    foreach(a; as) if(a == 1) has1 = 1;
    log("as:", as, "has1:", has1);

    if(! has1) foreach(i; 0 .. n) as[i] /= 2;
    log("as:", as);

    while(n > 1){
        int m = maxm(n);
        as = f(as, n, m);
        n = as.length.to!int;
        log("n:", n, "as:", as);
    }

    int ans = as[0];
    if(! has1) ans *= 2;

    if(has1 && ans == 2) "0".writeln;
    else ans.writeln;
    
}
int maxm(int n){
    int m = 1;
    while(m * 2 < n) m *= 2;
    return m;
}


int[] f(int[] as, int n, int m){ // m = 2 ** k
    int[] res;
    foreach(i; 0 .. n - m) res ~= abs(as[i] - as[i + m]);
    return res;
}

Measured memory_bytes: 14504
/*input
54
0 0 1 0 1 2 1 2 3 2 3 3 4 4 5 4 6 5 7 8 5 6 6 7 7 8 8 9 9 10 10 11 9 12 10 13 14 11 11 12 12 13 13 14 14 15 15 15 16 16 16 17 17 17
*/
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ld, ld> pd;

typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef vector<pi> vpi;
typedef vector<vpi> vpii;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
typedef vector<pd> vpd;
typedef vector<bool> vb;
typedef vector<vb> vbb;
typedef std::string str;
typedef std::vector<str> vs;

#define x first
#define y second
#define debug(...) cout<<"["<<#__VA_ARGS__<<": "<<__VA_ARGS__<<"]\n"

const int MOD = 1000000007;
const ll INF = std::numeric_limits<ll>::max();
const int MX = 100101;
const ld PI = 3.14159265358979323846264338327950288419716939937510582097494L;

template<typename T>
pair<T, T> operator+(const pair<T, T> &a, const pair<T, T> &b) { return pair<T, T>(a.x + b.x, a.y + b.y); }
template<typename T>
pair<T, T> operator-(const pair<T, T> &a, const pair<T, T> &b) { return pair<T, T>(a.x - b.x, a.y - b.y); }
template<typename T>
T operator*(const pair<T, T> &a, const pair<T, T> &b) { return (a.x * b.x + a.y * b.y); }
template<typename T>
T operator^(const pair<T, T> &a, const pair<T, T> &b) { return (a.x * b.y - a.y * b.x); }

template<typename T>
void print(vector<T> vec, string name = "") {
	cout << name;
	for (auto u : vec)
		cout << u << ' ';
	cout << '\n';
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int N;
	cin >> N;
	vi sk(N);
	for (int i = 0; i < N; ++i)
	{
		cin >> sk[i];
	}

	ll ats = 1;

	vi kiek(MX, 0);

	kiek[0] = 3;
	for (int i = 0; i < N; ++i)
	{
		ats = (ats * kiek[sk[i]]) % MOD;
		kiek[sk[i]]--;
		kiek[sk[i] + 1]++;
	}
	printf("%lld\n", ats);
}

/* Look for:
* special cases (n=1?)
* overflow (ll vs int?)
* the exact constraints (multiple sets are too slow for n=10^6 :( )
* array bounds
*/


Measured memory_bytes: 1024
n = int(input())
t = [0] * (n+1)
x = [0] * (n+1)
y = [0] * (n+1)

for i in range(n):
  t[i+1], x[i+1], y[i+1] = map(int, input().split())
  
for i in range(n):
  tdiff = t[i+1]-t[i]
  ddiff = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i])
  if tdiff < ddiff or (tdiff % 2) != (ddiff % 2):
    print("No")
    exit(0)

print("Yes")

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

int main(){
	int H1, M1, H2, M2, K;
	scanf("%d%d%d%d%d", &H1, &M1, &H2, &M2, &K);
	printf("%d\n", (H2 * 60 + M2) - (H1 * 60 + M1) - K);
	return 0;
}

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

int main()
{
    string s;
    int i;
    cin >> s;
    i = s.size();
    if (s[i - 1] == 's')
    {
        cout << s + "es" << endl;
    }
    else
    {
        cout << s + "s" << endl;
    }
    return (0);
}


Measured memory_bytes: 3628
#include<stdio.h>
#include<iostream>
#include<algorithm>
#define int long long 
using namespace std;
int a[100005];
main()
{
	int i,j,k,n,x,y;
	cin>>n;
	for(i=1;i<=n;i++)scanf("%lld",&a[i]);
	sort(a+1,a+n+1);
	int last=a[n],cnt=0;
	for(i=n-1;i>=1;i--)
	{
		if(a[i]==last&&cnt==0)
		{
			x=a[i];cnt++;
			last=a[i-1];i--;
			continue;
		}
		
		if(a[i]==last&&cnt==1)
		{
			cout<<x*a[i];
			return 0;
		}last=a[i];
	}
	cout<<0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define MD 1000000007
typedef long long int ll;

int main(){
    int n;
    cin>>n;
    if(n==1){
        cout<<"Hello World"<<endl;
    }else{
        int a,b;
        cin>>a>>b;
        cout<<a+b<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
n = int(input())
P = [int(p) for p in input().split()]

ans = 0
for i in range(1, n-1):
    if max(P[i-1], P[i], P[i+1]) != P[i] and min(P[i-1], P[i], P[i+1]) != P[i]:
        ans += 1
print(ans)

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {

		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		String line = reader.readLine();
		String[] str = line.split(" ");
		int N = Integer.parseInt(str[0]);
		int A = Integer.parseInt(str[1]);
		int B = Integer.parseInt(str[2]);

		if (N * A <= B) {
			System.out.println(N*A);
		}
		else {
			System.out.println(B);
		}
	}
}


Measured memory_bytes: 21332
#include <bits/stdc++.h>
using namespace std;
#define modulo 998244353
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 10000000000000000



int main(){
	
	string s;
	cin>>s;
	
	sort(s.begin(),s.end());
	
	if(s=="abc"){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
		
    return 0;
}


Measured memory_bytes: 256
use std::io::*;
fn gcd(a: u64, b: u64) -> u64 {
    if b == 0 {
        return a;
    }
    gcd(b, a % b)
}
fn lcm(a: u64, b: u64) -> u64 {
    a / gcd(a, b) * b
}
fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let a: u64 = itr.next().unwrap().parse::<u64>().unwrap() - 1;
    let b: u64 = itr.next().unwrap().parse().unwrap();
    let c: u64 = itr.next().unwrap().parse().unwrap();
    let d: u64 = itr.next().unwrap().parse().unwrap();

    let l = lcm(c, d);
    let x = b + b / l - b / c - b / d;
    let y = a + a / l - a / c - a / d;

    println!("{}", x - y);
}


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

int dp[1005][1005]; //d[i][j]:=s1...siとt1...tjのLCSの長さ

int main(){
    int q;
    string X[150], Y[150];

    cin >> q;
    for(int i=0; i<q; i++){
        cin >> X[i];
        cin >> Y[i];
    }

    for(int i=0; i<q; i++){
        for(int j=0; j<1005; j++) for(int k=0; k<1005; k++) dp[j][k] = 0;

        for(int j=0; j<X[i].size(); j++){
            for(int k=0; k<Y[i].size(); k++){
                if(X[i][j] == Y[i][k]) dp[j+1][k+1] = dp[j][k]+1;
                else dp[j+1][k+1] = max(dp[j][k+1], dp[j+1][k]);
            }
        }
        cout << dp[X[i].size()][Y[i].size()] << endl;
    }
}



Measured memory_bytes: 7140
using System.Collections.Generic;
using System;

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line, int.Parse);
        var d = new Dictionary<long, long>();
        var d2 = new Dictionary<long, long>();
        for (int i = 0; i < n; i++)
        {
            var e1 = i + a[i];
            var e2 = i - a[i];
            if (d.ContainsKey(e1)) d[e1]++;
            else d[e1] = 1;
            if (d2.ContainsKey(e2)) d2[e2]++;
            else d2[e2] = 1;
        }
        getAns(d, d2);
    }
    static void getAns(Dictionary<long, long> a, Dictionary<long, long> b)
    {
        var ans = 0L;
        foreach (var x in a)
        {
            if (b.ContainsKey(x.Key)) ans += x.Value * b[x.Key];
        }
        Console.WriteLine(ans);
    }
}


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

using namespace std;

int main(){
    int n, t; cin >> n >> t;
    vector<int> as(n);
    for(int i=0; i<n; ++i){
        cin >> as[i];
    }
    int current_max=as[n-1];
    int current_max_diff=0;
    int ans=0;
    for(int i=n-2; i>=0; --i){
        if(as[i]>current_max){
            current_max=as[i];
        } else{
            int d=current_max-as[i];
            if(d==current_max_diff) ++ans;
            else if(d>current_max_diff){
                current_max_diff=d;
                ans=1;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
#include <math.h>

#include <algorithm>
#include <iostream>
#include <vector>

using ll = long long;
#define rep(inc, bgn, end) for (int inc = bgn; inc < end; ++inc)
#define repe(inc, bgn, end) for (int inc = bgn; inc <= end; ++inc)

using namespace std;

int main() {
    int l, r;
    cin >> l >> r;
    int div = 2019;
    int x   = l % div;
    int y   = r % div;
    // printf("%d %d %d\n", x, y, r - l);

    int ans = 2020;
    if (((r - l) < div) && (x < y)) {
        repe(i, l, r) {
            repe(j, i + 1, r) {
                ans = min(ans, ((i % div) * (j % div)) % div);
            }
        }
    } else {
        ans = 0;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
int main(){
    int i,j,n,tmp,num;
    int array[10];
    for(i=0;i<10;i++){
        scanf("%d",&array[i]);
        }
    
    for(j=0;j<3;j++){
        tmp=0;
        for(i=0;i<10;i++){
            if(tmp<array[i]){
                tmp=array[i];
                num = i;
            }
        }
        array[num]=0;
        printf("%d\n",tmp);
    }
    
}

Measured memory_bytes: 1780
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const ll mod=998244353;
const ll inf = (ll)1e17;
const ld eps = 1e-12;
const ld PI = 3.14159265358979323846;
ll mul(ll a, ll b, ll m = mod) { return (ll)(a * b) % m;}
ll add(ll a, ll b, ll m = mod) { a += b; if(a >= m) a -= m; if(a < 0) a += m; return a;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll powmod(ll a,ll b){ll res=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res%mod;}
long modInverse(long a) {return powmod(a, mod-2);}


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

    int n;
    cin>>n;
    vector<ll>v(n);
    for(int i=0;i<n;i++)cin>>v[i];
    map<ll,ll>m;
    for(int i=0;i<n;i++){
        m[v[i]]++;
    }
    ll res=0;
    auto it=m.begin();
    for(it;it!=m.end();it++){
        ll k=it->second;
        res+=k*(k-1)/2;
    }
    for(int i=0;i<n;i++){
        ll k=m[v[i]];
        ll ans1=k*(k-1)/2;
        k--;
        ll ans2=k*(k-1)/2;
        cout<<res-ans1+ans2<<endl;
    }
    return 0;
    }


Measured memory_bytes: 11136
#include "bits/stdc++.h"
using namespace std;
int main(){
  int input,a,b,c;
  cin>>input;
  a=input/100;b=input-a*100;
  b=b/10; c=input-a*100-b*10;
  if(a==1){
    input+=800;
  }else{
    input-=800;
  }
  if(b==1){
    input+=80;
  }else{
    input-=80;
  }
  if(c==1){
    input+=8;
  }else{
    input-=8;
  }
  cout<<input<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define EPS 1e-10
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define first_more_idx(ve, num) upper_bound(all(ve), num)-ve.begin() // idx = first_more_idx(ve,num); if(idx = ve.size()) , then not exist
#define first_lessequal_idx(ve, num) lower_bound(all(ve), num)-ve.begin()
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > >
#define pq_pair_ts priority_queue <pair<ll,ll> > // only sort first param
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}
ll power(ll x, ll n){if(n == 0) return 1;return  (n%2)? x*power(x, n-1)%MOD : power(x*x%MOD, n/2);}
ll dx[]={0, 0, -1, 1};
ll dy[]={1, -1, 0, 0};// up,down,left right


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

    ll A, B ;
    cin >> A >> B ;
    
    ll ans = A % B;
    ans = min(ans, B - ans);
    cout << ans << endl;
    

    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


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

int main(){
    int n;
    cin>>n;
    rep2(1,i,10){
        rep2(1,j,10){
            if(i*j==n){
                cout<<"Yes"<<endl;
                return 0;
            }
        }
    }
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
def resolve():
    import sys
    import string
    input = sys.stdin.readline
    # row = [int(x) for x in input().rstrip().split(" ")]
    # n = int(input().rstrip())
    n, k, q = [int(x) for x in input().rstrip().split(" ")]

    scores = [k - q for _ in range(n)]

    for i in range(q):
        a = int(input().rstrip())
        scores[a-1] += 1


    for score in scores:
        if score <= 0:
            print("No")
        else:
            print("Yes")

if __name__ == "__main__":
    resolve()


Measured memory_bytes: 81080
#include <stdio.h>

int main(){
  int n=0;
  int sort[101];
  scanf("%d", &n);
  for(int i=n;i>0;i--){
    scanf("%d", &sort[i]);
  }
  for(int i=1;i<=n;i++){
    printf("%d", sort[i]);
    if(i!=n){printf(" ");}else{printf("\n");}
  }
}

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

int main()
{
    char s[100];
    bool flag=true;
    while(cin>>s)
    {
        int i;
        if(strlen(s)&1) flag=false;
        for(i=0;i<strlen(s);i+=2){

            if(s[i]=='h' and s[i+1]=='i') continue;
            else flag=false;
        }
        if(flag) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define square(x) pow(x 2.0)
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define max_queue(x) priority_queue<x>
#define min_queue(x) priority_queue<x, vector<x>, greater<x>>
#define big_sort(v) sort(all(v), [](int a, int b) { return a > b; })//大きい順にソート
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
/*
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
*/
int main() {
  ll x,y,z;
  cin >> x >> y >> z;
  cout << z << " " <<  x << " " << y << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;

int main()
{
    int m;
    int k;
    cin >> m >> k;
    int l = 1;
    for(int i = 0; i < m; i++){
        l *= 2;
    }
    if(k == 0){
        for(int i = 0; i < l; i++){
            cout << i << " " << i << " ";
        }
    }
    else if(m == 1 && k == 1){
        cout << -1 << endl;
    }
    else if(k < l){
        cout << k << " ";
        for(int i = 0; i < l; i++){
            if(i == k) continue;
            cout << i << " ";
        }
        cout << k << " ";
        for(int i = l - 1; i >= 0; i--){
            if(i == k) continue;
            cout << i << " ";
        }
        cout << endl;
    }
    else cout << -1 << endl;
}

Measured memory_bytes: 1920
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int n,a,b;
	cin>>n>>a>>b;
	if(n*a>b)
		printf("%d\n",b);
	else
		printf("%d\n",n*a);
}

Measured memory_bytes: 256
using System;
using System.IO;
namespace aoj{
    class program{
     
    static void Main() {
		string rl="";
		while((rl=Console.ReadLine())!=null){
			string[] tmp = rl.Split(' ');
			int w=int.Parse(tmp[0]);
			int h=int.Parse(tmp[1]);
			if(w==0 &&h==0)
				break;
			DrawRect dr = new DrawRect(w,h);
			dr.draw();
	    }
    }
}
class DrawRect{
	int width;
	int height;
	public DrawRect(int w, int h){
		width=w;
		height=h;
	}
	
	public void draw(){
		for(int i=0; i<width; i++){
			for(int j=0; j<height; j++)
				Console.Write("#");
			Console.WriteLine("");
		}
		Console.WriteLine("");		
	}		
}
		
}

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

int main() {
int N; cin >> N;
vector<double> v(N);
for(int i = 0; i < N ; i++){
  cin >> v[i];
}
sort(v.begin(), v.end());
double a; a = v[0];
for (int j = 1; j < N; j++){
  a = (a + v[j]) / 2 ;
}

cout << a << endl;
}


Measured memory_bytes: 256
import collections
N = int(input())
D = sorted(list(map(int, input().split())))

M = int(input())
T = sorted(list(map(int, input().split())))

DD = collections.Counter(D)
TT = collections.Counter(T)
ch = 1
for t,num_t in TT.items():
    num_d = DD[t]
    if num_t > num_d:
        ch = 0

if ch == 1:
    print('YES')
else:
    print('NO')


Measured memory_bytes: 57312
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int> 
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
ll a,b,c;
int main(){
    cin>>a>>b>>c;
    if(a+b>=c) return cout<<"No"<<endl,0;
    ll lft=4ll*a*b;
    ll rit=(c-a-b)*(c-a-b);
    cout<<((lft<rit)?"Yes":"No")<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;
 
#define rep(i, n) for(int i = 0; i < (int)(n);    i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef std::vector<int> vi;
typedef std::vector<std::vector<int>> vvi;

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }


int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  std::string S; std::cin >> S;
  int Q; std::cin >> Q;
  std::deque<char> ans;
  for(auto&& s : S) ans.push_back(s);
  bool flag = false;
  rep(i, Q) {
    int n; std::cin >> n;
    if ( n == 1 ) {
      flag = !flag;
    }
    else {
      int f; char c; std::cin >> f >> c;
      if ( f == 1 && !flag ) ans.push_front(c);
      if ( f == 1 &&  flag ) ans.push_back(c);
      if ( f == 2 && !flag ) ans.push_back(c);
      if ( f == 2 &&  flag ) ans.push_front(c);
    }
  }

  if ( flag ) {
    for(auto c = ans.rbegin(); c != ans.rend(); ++c) std::cout << *c ;
    std::cout << std::endl;
  }
  else {
    for(auto c = ans.begin(); c != ans.end(); ++c) std::cout << *c ;
    std::cout << std::endl;
  }

  return 0;
}


Measured memory_bytes: 976
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace lineAralgebra
{
	class Program
	{
		static void Main(string[] args)
		{
			var input = Console.ReadLine().Split(' ');
			var n = int.Parse(input[0]);
			var k = int.Parse(input[1]);
			var q = int.Parse(input[2]);

			var users = new int[n];
			for (var i = 0; i < users.Length; i++)
			{
				users[i] = 0;
			}

			var a = new int[q];

			for (var i = 0; i < a.Length; i++)
			{
				a[i] = int.Parse(Console.ReadLine());
			}

			for (var i = 0; i < a.Length; i++)
			{
				var correct = a[i] - 1;
				users[correct]++;
				// for (var j = 0; j < users.Length; j++)
				// {
				// 	if (j == correct) continue;
				// 	users[j]--;
				// }
			}
			for (var i = 0; i < users.Length; i++)
			{

				if (k + users[i] - q  > 0) System.Console.WriteLine("Yes");
				else
				{
					System.Console.WriteLine("No");
				}
			}

		}

		/** test cases:
		 * null ==> null
		 * 1 ==> 1
		 * 1->2 ==> 2->1
		 * 1->2->3 ==> 2->1->3
		 * 1->2->3->4 ==> 2->1->4->3
		 */
	}
}

Measured memory_bytes: 16092
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
import math
from fractions import gcd
import random
import string
import copy
from itertools import permutations
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7


#############
# Main Code #
#############

# print(rand_List(1, 10, 10))
N, T = getNM()
price = getList()
max_list = [0] * N

# この先訪れる店の中で最も値段が高い店の値段
def maximizer(num_list):
    num_N = len(num_list)
    res = 0
    for i in range(1, num_N + 1):
        res = max(res, price[-i])
        num_list[-i] = res
maximizer(max_list)

# 最大マージンを調べる
def margin_checker():
    margin = 0
    for i in range(N - 1):
        margin = max(max_list[i] - price[i], margin)
    return margin

max_margin = margin_checker()

cnt = 0
# ループはしないはず
while True:
    for i in range(N - 1):
        if max_list[i] - price[i] == max_margin:
            price[i] += 1
            cnt += 1
    if margin_checker() < max_margin:
        break
    # ループはしないはずだが念の為
    maximizer(max_list)
    max_margin = margin_checker()
print(cnt)

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

void testCase(){
    int a, b, c, d;
    cin>>a>>b>>c>>d;
    bool flag = true;
    while(a > 0 && c > 0){
        if(flag){
            c -= b;
        }
        else{
            a -= d;
        }
        flag = !flag;
    }
    if(a <= 0) cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
}

int main(){
    int t;
    t = 1;
    // cin>>t;
    while(t--){
        testCase();
    }
}



Measured memory_bytes: 3612
#include<algorithm>
#include<bitset>
#include<climits>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<queue>
#include<set>
#include<string>
#include<time.h>
#include<tuple>
#include<utility>
#include<vector>

using namespace std;
const long mod = 1000000007;

int main() {

	long N, K; cin >> N >> K;

	if (K > (N - 1) * (N - 2) / 2) { cout << -1 << endl; return 0; }

	long ret = ((N - 1) * (N - 2) / 2) - K;

	cout << N - 1 + ret << endl;

    for (int i = 2; i <= N; i++) cout << 1 << " " << i << endl;
    
	for (int i = 2; i <= N && ret != 0; i++) {

		for (int j = i + 1; j <= N && ret != 0; j++) {
			cout << i << " " << j << endl;
			ret--;
		}
	}
}

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

int mtrx[70][55][55];
int ans[70][55][55];
int n,k;

int32_t main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int mo=1000000007;
    cin>>n>>k;
    memset(mtrx,0,sizeof(mtrx));
    for(int i=0;i<n;i++)
        for(int j=0;j<n;j++)
            cin>>mtrx[0][i][j];

    for(int pow=1;pow<60;pow++)
    {
        for(int i=0;i<n;i++)
            for(int j=0;j<n;j++)
                for(int k1=0;k1<n;k1++)
                    mtrx[pow][i][j]=((mtrx[pow-1][i][k1] * mtrx[pow-1][k1][j])%mo + mtrx[pow][i][j])%mo;
    }
   /* for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
            cout<<mtrx[1][i][j]<<" ";
        cout<<"\n";
    }*/
    memset(ans,0,sizeof(ans));
    for(int i=0;i<n;i++)
        ans[0][i][i]=1;

    int c=-1;
    for(int pow=0;pow<60;pow++)
    {
        if(k & (1LL<<pow))
        {
            //cout<<pow<<" \n";
            c++;
            for(int i=0;i<n;i++)
                for(int j=0;j<n;j++)
                    for(int k1=0;k1<n;k1++)
                        ans[c+1][i][j]=((ans[c][k1][j] * mtrx[pow][i][k1])%mo + ans[c+1][i][j])%mo;
        }
    }
    int solv=0;
    for(int i=0;i<n;i++)
        for(int j=0;j<n;j++)
            solv=(solv + ans[c+1][i][j])%mo;

    cout<<solv;
} 

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

using namespace std;

using ll = long long;

#define ALL(A) A.begin(),A.end()

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

    bool TF = false;

    while(N>=1)
    {
        if(N%10==7)
        {
            cout << "Yes" << endl;
            TF = true;
            break;
        }
        N/=10;
    }
    if(!TF) cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long A,B;
  cin>>A>>B;
  if(abs(A-B)%2==1){
    cout<<"IMPOSSIBLE"<<endl;
  }
  else{
    cout<<min(A,B)+abs(A-B)/2<<endl;
  }
}

Measured memory_bytes: 3552
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int n, cap;
    cin>>n>>cap;
    vector<int> weights;
    vector<long long int> values;
    int m = 0;
    for(int i=0; i<n; i++){
        int w, v;
        cin>>w>>v;
        m += v;
        weights.push_back(w);
        values.push_back(v);
    }
    
    long long int dp[n+1][m+1];
    memset(dp, -1, sizeof(dp));
    
    for(int i=0; i<n+1; i++){
        for(int j=0; j<m+1; j++){
            if(j==0){
                dp[i][j] = 0;
                continue;
            }
            
            if(i==0){
                dp[i][j] = -1;
                continue;
            }
            
            if(values[i-1]<=j){
                
                // not selecting the current
                long long int a,b;
                a = dp[i-1][j];
                
                // selecting if previous nothing exits
                if(dp[i-1][j-values[i-1]]!=-1){
                    b = weights[i-1] + dp[i-1][j-values[i-1]];
                }
                else{
                    b = -1;
                }
                
                if(b!=-1 && a!=-1){
                    dp[i][j] = min(a,b);
                }
                else if(b==-1 && a!=-1)
                    dp[i][j] = a;
                else
                    dp[i][j] = b;
                    
            }
            else{
                dp[i][j] = dp[i-1][j];
            }
            
            // cout<<dp[i][j]<<" ";
        }
        // cout<<endl;
    }
    
    long long int ans = 0;
    int ind = 0; 
    
    for(int i=m; i>=0; i--){
        if(dp[n][i]==-1)
            continue;
        if(dp[n][i]<=cap){
            ind = i;
            break;
        }
    }
    cout<<ind;
    
}

Measured memory_bytes: 82376
#include<stdio.h>
int countDivisor(int,int,int);
int main(void)
{
  int a,b,c;
  scanf("%d%d%d",&a,&b,&c);
  printf("%d\n",countDivisor(c,a,b));
  return 0;
}
int countDivisor(int x,int min,int max)
{
  int i;
  int cnt=0;
  for(i=min;i<=max;i++)
    {
      if(x%i==0) cnt++;
    }
  return cnt;
}



Measured memory_bytes: 2140
#include<iostream>
using namespace std;
int main(){

int a[4][3][10];
for(int i=0;i<=3;i++){
 for(int j=0;j<=2;j++){
  for(int k=0;k<=9;k++){
   a[i][j][k]=0;
  }
 }
}

int n;
cin>>n;

int b,f,r,v;
for(int l=1;l<=n;l++){
 cin>>b>>f>>r>>v;
 a[b-1][f-1][r-1] += v;
}

for(int i=0;i<=3;i++){
 for(int j=0;j<=2;j++){
  for(int k=0;k<=9;k++){
   cout<<" "<<a[i][j][k];
  }
  cout<<endl;
 }
 if(i==3)break;
 cout<<"####################"<<endl;
}

}



Measured memory_bytes: 3080
N = int(input())
X = int(input(), 2)

M = 2 * (10 ** 5) + 10
ret = [0] * (M + 1)
for i in range(M + 1) :
  x = i
  c = 0
  while x != 0 :
    x = x % bin(x).count('1')
    c += 1
  ret[i] = c
  
p = bin(X).count('1')
a = X % (p + 1)
if p > 1 :
  b = X % (p - 1)

for i in range(N - 1, -1, -1) :
  if (1 << i) & X :
    if p == 1 :
      print(0)
    else :
      print(ret[(b - pow(2, i, p - 1)) % (p - 1)] + 1)
  else :
    print(ret[(a + pow(2, i, p + 1)) % (p + 1)] + 1)

Measured memory_bytes: 95168
from sys import stdin
def stdinput():
    return stdin.readline().strip()

from collections import deque

def main():
    n ,q = map(int, stdinput().split())
    ps = deque()
    for _ in range(n):
        p, t = stdinput().split()
        t = int(t)
        ps.append([p, t])

    ctime = 0
    while len(ps) > 0:
        p = ps.popleft()
        if p[1] <= q:
            ctime += p[1]
            print(f'{p[0]} {ctime}')
        else:
            ctime += q
            p[1] -= q
            ps.append(p)

if __name__ == '__main__':
    main()


Measured memory_bytes: 13312
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,a,b) for(int i=a;i<b;i++)
#define each(it,v) for(auto it : v)
#define mod 1000000007
#define all(v) (v).begin(),(v).end()
#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define vpii vector<pair<int,int>>
#define vv vector<vector<int>>
using namespace std;

main()
{
    int n,m,k; cin>>n>>m>>k;
    if(k==0||k==n*m)
    {
        cout<<"Yes"<<endl;
        return 0;
    }

    rep(i,n)
    {
        rep(j,m)
        {
            if((n*m-(i+1)*(j+1)-(n-i-1)*(m-j-1))==k)
            {
                cout<<"Yes"<<endl;
                return 0;
            }
        }
    }
    cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#define N 100
#define WHITE 0
#define GRAY 1
#define BLACK 2

int prim(void);

int n, A[N][N];

int main()
{
  int i, j;

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

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

int prim()
{
  int i, j, color[n], mg[n], p[n], mc, place, to, sum=0;

  for(i=0;i<n;i++){
    color[i]=WHITE;
    mg[i]=2001;
  }
  mg[0]=0;
  p[0]=-1;

  while(1){
    /* printf("k\n");*/
    mc=2001;
    for(i=0;i<n;i++){
      if(color[i]!=BLACK && mg[i]<mc){
	mc=mg[i];
	place=i;
      }
    }

    if(mc==2001) break;

    color[place]=BLACK;

    for(to=0;to<n;to++){
      if(color[to]!=BLACK && A[place][to]!=-1){
	if(A[place][to]<mg[to]){
	  mg[to]=A[place][to];
          p[to]=place;
	  color[to]=GRAY;
	}
      }
    }
    for(i=0;i<n;i++){
      /* printf("%d\n",mc);*/
    }
     sum+=mc;
  }
    return sum; 
}



Measured memory_bytes: 2148
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repA(i,a,b) for(ll i=a;i<=b;i++)
#define repD(i,b,a) for(int i=b;i>=a;i--)
#define fill(a) memset(a,0,sizeof(a))
#define f first
#define s second
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int main()
{
    ll k;
    cin>>k;
    queue<ll>q;
    repA(i,1,9)
    q.push(i);
    if(k<=9)
    {
        cout<<k<<endl;
    }
    else
    {
        k-=9;
        while(k)
        {
            ll a=q.front();
            q.pop();
            if(a%10!=0){
                ll var=a*10+(a%10-1);
                k--;
                if(k==0)
                {
                    cout<<var<<endl;
                    return 0;
                }
                q.push(var);
            }
            q.push(a*10+(a%10));
            k--;
            if(k==0){
                cout<<a*10+(a%10)<<endl;
                return 0;
            }
            if(a%10!=9){
                ll var=a*10+(a%10+1);
                k--;
                if(k==0)
                {
                    cout<<var<<endl;
                    return 0;
                }
                q.push(var);
            }
        }
    }
}


Measured memory_bytes: 768
#include<cstdio>
#include<cstring>
 
char s[55];
 
int main()
{
    scanf("%s", s);
    int lng = strlen(s);
 
    bool jdg = true;
 
    int c = 0;
 
    if (s[0] == 'K') c = 0;
    else if (s[0] == 'A' && s[1] == 'K') c = 1;
    else jdg = false;
 
    if (s[c + 1] == 'I' && s[c + 2] == 'H') c += 2;
    else jdg = false;
 
    if (s[c + 1] == 'B') c += 1;
    else if (s[c + 1] == 'A' && s[c + 2] == 'B') c += 2;
    else jdg = false;
 
    if (s[c + 1] == 'R') c += 1;
    else if (s[c + 1] == 'A' && s[c + 2] == 'R') c += 2;
    else jdg = false;
 
    if (lng == c + 1 || (s[c + 1] == 'A' && lng == c + 2)) c++;
    else jdg = false;
 
    
 
    if (jdg) printf("YES\n");
    else printf("NO\n");
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 1e9+100;
const ll MOD = 1e9+7;
const bool debug = 0;
//-----------------------------------------------//

int main() {
	int a, b;
	cin >> a >> b;
	
	int k = log10(b) + 1;
	int x = a;
	REP(i, k) x *= 10;
	x += b;
	
	bool ans = false;
	for (int i = 1; i * i <= x; i++) ans |= i * i == x;
	puts(ans ? "Yes" : "No");
	
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
int N,K;

int win(int me) {
  int i=0;
  while(me<K) {
    me*=2;
    i++;
  }
  return i;
}

double probability(int i) {
  return pow(0.5,i);
}
 
int main() {
  INCANT;
  cin >> N >> K;
  if (K==1) {
    cout << 1 << endl;
    return 0;
  }
  double SUM=0;
  rep(i, N) {
    SUM+=probability(win(i+1));
  }
  SUM/=N;
  cout << SUM << "\n";
  return 0;
}

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

const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;
const int MOD=1000000007;

int a[300000];
int main(){
	int K,n;cin>>K>>n;
	rep(i,n)scanf("%d",&a[i]);
	int Max=0;
	rep(i,n-1)Max=max(Max,a[i+1]-a[i]);
	Max=max(Max,a[0]+K-a[n-1]);
	cout<<K-Max<<endl;
}

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


int main() {
    int K;
    cin >> K;
    int ans = 0;
    for (int i = 1; i <= K; i++){
        for (int j = i + 1; j <= K; j++){
            if ((i + j) % 2) ans++;
        }
    }
    cout << ans << endl;
}


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

int main() {
  int n;
  cin >> n;
  vector<int>d(n);
  for(int i=0;i<n;i++)cin >> d[i];
  
  sort(d.begin(),d.end());
  int cnt=0;
  for(int i=0;i<n-1;i++){
    if(d[i]==d[i+1]){
      cnt++;
    }
  }
  
  cout << n-cnt;
}

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

int main()
{
    int n, m; cin>>n>>m;
    vector<vector<int>> g(n);
    for(int i=0; i<m; ++i) {
        int a, b; cin>>a>>b;
        --a, --b;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    vector<int> color(n);
    function<bool(int, int)> is_bipartite=[&](int v, int c)->bool{
        bool res=true;
        color[v]=c;
        for(int u: g[v]) {
            if (color[u]==c) return false;
            if (color[u]) continue;
            res=res&&is_bipartite(u, -c);
        }
        return res;
    };

    if (is_bipartite(0, 1)) {
        long b=0, w=0;
        for(int c: color) ++(c>0?b:w);
        cout<<b*w-m<<endl;
    }
    else {
        cout<<n*(n-1L)/2-m<<endl;
    }
}

Measured memory_bytes: 6656