akhauriyash/Code-Regression huggingface dataset:
// Contest: AtCoder Beginner Contest 143 (https://atcoder.jp/contests/abc143)
// Problem: F: Distinct Numbers (https://atcoder.jp/contests/abc143/tasks/abc143_f)


// region {{{ boilerplate
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <chrono>
#include <cstdint>
#include <deque>
#include <exception>
#include <forward_list>
#include <functional>
#include <initializer_list>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#if __cplusplus >= 201703L
#   include <optional>
#   include <string_view>
#   include <variant>
#endif

using namespace std;

#if __cplusplus >= 201703L
#   define all(a)      begin(a),end(a)
#   define sz(x)       ((int)size(x))
#else
#   define all(a)      (a).begin(),(a).end()
#   define sz(x)       ((int)(x).size())
#endif

#define rep(a, b)      for(int a = 0; a < (b); ++a)
#define reps(a, b, c)  for(int a = (b); a < (c); ++a)
#define trav(a, b)     for(auto& a : b)

using ll = long long;
using ld = long double;
using u64 = uint64_t;
using u32 = uint32_t;

using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vpi = vector<pi>;

#if __cplusplus >= 201703L
#   define MAYBE_UNUSED [[maybe_unused]]
#else
#   define MAYBE_UNUSED
#endif

MAYBE_UNUSED static constexpr int INF = (int)1e9 + 5;
MAYBE_UNUSED static constexpr ll INFL = (ll)1e18 + 5;
MAYBE_UNUSED static mt19937 rng((u32)chrono::duration_cast<chrono::nanoseconds>(chrono::high_resolution_clock::now().time_since_epoch()).count());
//endregion }}}

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

    int n, ai; cin >> n;
    map<int, int> m;
    rep(i, n)
        cin >> ai, m[ai]++;

    multiset<int> s;
    trav(p, m) s.emplace(p.second);
    vi c(n + 1);
    reps(i, 1, n+1) {
        c[i] += c[i-1] + sz(s);
        s.erase(i);
    }

    reps(k, 1, n+1) {
        int l = 0, r = n / k + 1;
        while (r - l > 1) {
            int mi = (r + l) / 2;
            (c[mi] >= k * mi ? l : r) = mi;
        }
        cout << l << '\n';
    }

    return 0;
}


Measured memory_bytes: 29056
A, B, C, D = map(int, input().split(" "))
if A < C:
  one = [A, B]
  two = [C, D]
else:
  two = [A, B]
  one = [C, D]
if one[1] < two[0]:
  print(0)
  exit(0)
if one[1] >= two[1]:
  print(two[1] - two[0])
  exit(0)
if one[1] < two[1]:
  print(one[1] - two[0])
  exit(0)



Measured memory_bytes: 3064
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <map>
using namespace std;
int a[200];
int main()
{
	int n,k;
	scanf("%d%d",&n,&k);
	for(int i = 1; i <= n; i++) scanf("%d",&a[i]);
	int ans = 0;
	for(int i = 1; i <= n; i++){
		ans += min(a[i],abs(a[i]-k))*2;
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 256
def main():
    N = int(input())
    S = [input() for i in range(N)]
    T = input()

    S1 = [s.replace("?", "z") for s in S]
    S2 = [s.replace("?", "a") for s in S]
    S1.append(T)
    S2.append(T)

    idx1 = sorted(S1).index(T)
    idx2 = (N+1) - 1 - sorted(S2, reverse=True).index(T)

    ans = range(idx1+1, idx2+1+1)
    print(*ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 5364
#include<stdio.h>

int left(int i){
  return 2*i;
}
int right(int i){
  return 2*i+1;
}

void maxHeapify(int A[],int i,int n){
  int l = left(i);
  int r = right(i);
  int large;
  int tmp;

  if(l <= n && A[l] > A[i]){
    large = l;
  }else{
    large = i;
  }
  if(r <=n && A[r] > A[large]){
    large = r;
  }

  if(large != i){
    tmp = A[i];
    A[i] = A[large];
    A[large] = tmp;
    maxHeapify(A,large,n);
  }
}


void buildMaxHeap(int A[],int n){
  int i;
  for(i=n/2;i>0;i--){
    maxHeapify(A,i,n);
  }
}

int main(){
  int i;
  int n;
  int A[500000];

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

  for(i=1;i<=n;i++){
    printf(" %d",A[i]);
  }
 puts("");
  return 0;
}



Measured memory_bytes: 3656
#include<stdio.h>

int main(void){
    int n,m,l,i,j,k;
    int a[100][100],b[100][100];
    long c[100][100]={0};
    
    scanf("%d %d %d",&n,&m,&l);
    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
           scanf("%d",&a[i][j]);
        }
    }
    
     for(i=0;i<m;i++){
        for(j=0;j<l;j++){
           scanf("%d",&b[i][j]);
        }
    }
    
    for(i=0;i<n;i++){
        for(j=0;j<l;j++){
            for(k=0;k<m;k++){
                c[i][j]+=a[i][k]*b[k][j];
            }
            if(j==l-1){
                printf("%ld",c[i][j]);
            }else{
                printf("%ld ",c[i][j]);
            }            
        }
        printf("\n");
    }
    
    return 0;
    
}



Measured memory_bytes: 2044
use proconio::input;


fn solve(n: i64, mut x: i64, a: Vec::<i64>) -> i64 {
    let mut ans = 0;
    for i in 0..n as usize {
        x -= a[i];
        ans += 1;

        if x <= 0 {
            break;
        }
    }

    if x != 0 {
        ans -= 1;
    }

    return ans;
}


fn main() {
    input!{
        n: i64,
        mut x: i64,
        mut a: [i64; n],
    }

    a.sort();
    println!("{}", solve(n, x, a));
}


Measured memory_bytes: 2164
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

# def conb(n,r): 
#     return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

x,y = inpl()
x,y = max(x,y),min(x,y)
if (x+y)%3 or y*2 < x:
    print(0)
    quit()
n = (x+y)//3 + 1
k = x-n+2


def cmd(n,r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

a = cmd(n-1,k-1)%mod
print(a)


Measured memory_bytes: 102028
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
int n,x[23333],y[23333];
const ld r=2e14;
typedef pair<ld,ld> pnt;
ld dis2(pnt a,pnt b)
{return (a.fi-b.fi)*(a.fi-b.fi)+(a.se-b.se)*(a.se-b.se);}
ld pi=acosl(-1);
ld gf(ld x)
{
	while(x<0) x+=pi+pi;
	while(x>=pi+pi) x-=pi+pi;
	return x;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
		scanf("%d%d",x+i,y+i);
	for(int i=1;i<=n;++i)
	{
		map<ld,int> ps;
		ps[0]=ps[pi+pi]=0;
		int mm=0;
		for(int j=1;j<=n;++j) if(j!=i)
		{
			ld L,R; ++mm;
			pnt m((x[i]+x[j])/2.0,(y[i]+y[j])/2.0);
			int dx=y[i]-y[j],dy=x[j]-x[i];
			//k=atan(dy/dx)
			if(!dx) L=pi*0.5,R=pi*1.5;
			else
			{
				ld k=dy/ld(dx),b=m.se-m.fi*k;
				ld A=k*k+1,B=2*k*b,C=b*b-r*r;
				ld d=sqrt(B*B-4*A*C);
				ld x1=(-B+d)/(2*A),x2=(-B-d)/(2*A);
				L=atan2l(x1*k+b,x1); R=atan2l(x2*k+b,x2);
			}
			L=gf(L); R=gf(R);
			if(L>R) swap(L,R);
			ld M=(L+R)/2;
			pnt g(r*cosl(M),r*sinl(M));
			//cerr<<L<<","<<R<<"\n";
			ld di=dis2(g,pnt(x[i],y[i])),dj=dis2(g,pnt(x[j],y[j]));
			if(di>dj) swap(L,R);
			if(L<=R)
				ps[L]++, ps[R]--;
			else
				ps[0]++,ps[R]--,ps[L]++,ps[pi+pi]--;
		}
		int s=0; ld ca=0;
		for(auto x=ps.begin();;++x) 
		{
			auto y=x; ++y;
			if(y==ps.end()) break;
			s+=x->se; if(s==mm) ca+=y->fi-x->fi;
		}
		printf("%.10lf\n",double(ca/(pi+pi)));
	}
}


Measured memory_bytes: 512
n, k = map(int, input().split())

lmt = (n - 1) * (n - 2) // 2
if k > lmt:
    print(-1)
    exit()

a = set()
for u in range(1, n):
    a.add((u, n))
# star
# pair_count == lmt

rest = lmt - k
if rest > 0:
    for u in range(1, n - 1):
        for v in range(u + 1, n):
            a.add((u, v))
            rest -= 1
            if rest == 0:
                break
        else:
            continue
        break

print(len(a))
for aa in a:
    print(*aa)


Measured memory_bytes: 4028
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<string.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
long long int mod=1e9+7;
bool debug=false;
typedef long long ll;
int main(){
	string s;
	cin>>s;
	char a,b;
	if(s[0]==s[1]){
		if(s[2]==s[3]&&s[2]!=s[0])cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}else{
		if(s[0]==s[2]&&s[1]==s[3])cout<<"Yes"<<endl;
		else if(s[0]==s[3]&&s[1]==s[2])cout<<"Yes"<<endl;
		else cout<<"No"<<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 rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
constexpr ll mod = 1e9+7;
constexpr ll inf = LLONG_MAX;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */

/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ----------------------end----------------------- */
int main() {
    int ans[1000];
    ans[0] = 0;
    rep1(i, 999) ans[i]=ans[i-1]+i;
    int a,b;cin >> a >> b;
    cout << ans[b-a-1]-a << endl;
    // for(auto p:ans) cout << p << endl;
    // cout << ans[5] << endl;
    return 0;
}

Measured memory_bytes: 3600
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;
using llong = long long;

llong h, n;
llong H;
llong a[100005];

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

    if (H >= h) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
	
	public static void main(String[] args) throws IOException{
		BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
		
		int cash=Integer.parseInt(in.readLine());
		
		long total=(cash/500)*1000;
		
		cash%=500;
		
		total+=(cash/5)*5;
		
		
		System.out.println(total);
		

	}

}


Measured memory_bytes: 21204
#include <iostream>
#include <vector>
#define rep(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
using namespace std;

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

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

  int n; cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];

  ll LCM = a[0];
  rep(i, n) {
    LCM = lcm(LCM, a[i]);
  }
  LCM--;

  ll ans = 0;
  rep(i, n) {
    ans += a[i]-1;
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main()
{
int a,b,c;
cin>>a>>b>>c;
int ar[] ={a,b,c};
    int count5 = 0;
    int count7 = 0;
    for (int i = 0; i < 3; i++)
    {
        if (ar[i] == 5)
        {
            count5++;
        }
        else if (ar[i] == 7)
        {
            count7++;
        }
    }

    cout << ((count5 == 2 && count7 == 1) ? "YES" : "NO") << endl;

    return 0;
}

Measured memory_bytes: 256
from heapq import heappush, heappop
import re
from collections import deque
import sys
import math
input = sys.stdin.readline


def int_raw():
    return int(input())

def str_in():
    return input().strip("\n")

def ss_raw():
    return input().split()


def ints_raw():
    return tuple(map(int, ss_raw()))


DIV = 10**9+7


def mod_inv_prime(a, mod=DIV):
    return pow(a, mod-2, mod)


def mod_inv(a, b):
    r = a
    w = b
    u = 1
    v = 0
    while w != 0:
        t = r//w
        r -= t*w
        r, w = w, r
        u -= t*v
        u, v = v, u
    return (u % b+b) % b


def ncr(n, r, mod=DIV):
	r = min(r, n-r)
	ret = 1
	for i in range(1, r+1):
		ret = ret * (n-i+1) % mod
		ret = ret * mod_inv(i, mod) % mod
	return ret


class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1)
        self.mini = [i for i in range(n+1)]

    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
        mini = min(self.mini[x],self.mini[y])
        self.mini[x]=mini
        self.mini[y]=mini
    
    def same_check(self, x, y):
        return self.find(x) == self.find(y)

def main():
    n = int_raw()
    As = ints_raw()
    return 1.0/sum([1.0/a for a in As])
    
print(main())


Measured memory_bytes: 38256
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <bitset>
#include <vector>
#include <queue>
#include <map>
#include <set>

#define i64 int64_t
#define ff(ii,nn,mm) for(int ii=nn;ii<mm;ii++)
#define st(vvv) sort(vvv.begin(),vvv.end())
#define rvs(vvv) reverse(vvv.begin(),vvv.end())
int inf = 1000000007;
i64 giant = 4000000000000000000;

using namespace std;



int main() {
	int a, b, c;
	cin >> a >> b >> c;
	while (a > b&&c>0) {
		b++;
		c--;
	}
	cout << c << endl;
	return 0;
}

Measured memory_bytes: 256
process.stdin.resume();
process.stdin.setEncoding('utf8');

process.stdin.on('data', function (chunk) {
    const n = chunk.toString();
    const a = n.split(" ");
    const b = area(a[0],a[1]);
    const c = gaisyu(a[0],a[1]);
    console.log(`${b} ${c}`);
});
function area(tate,yoko){
    return tate*yoko;
}
function gaisyu(tate,yoko){
    const k = tate*2;
    const q = yoko*2;
    return k+q;
}


Measured memory_bytes: 15248
n = int(input())
li_in = list(map(int, input().split()))
q = int(input())
li_check = list(map(int, input().split()))

ubd = 2000

table = [False] * (ubd + 5)
S = [0] * n


def enum(i):
    global table
    if i == n:
        sum = 0
        for j in range(n):
            sum += li_in[j] * S[j]
        if sum <= 2000:
            table[sum] = True
    else:
        enum(i + 1)
        S[i] = 1
        enum(i + 1)
        S[i] = 0


enum(0)

for val in li_check:
    if table[val]:
        print('yes')
    else:
        print('no')


# 失敗作: 毎回再帰で計算
# 各回，数が一つくるごとに全探索している．
# 時間がかかりすぎる．最初に可能な数を全て計算した上でストックし，それを各数に対して用いれば良い．

# S = [0] * n
# flag = False


# def enum(i, val):
#     global flag
#     if i == n:
#         sum = 0
#         for j in range(n):
#             sum += li_in[j] * S[j]
#         if sum == val:
#             flag = True
#     else:
#         enum(i + 1, val)
#         S[i] = 1
#         enum(i + 1, val)
#         S[i] = 0


# for val in li_check:
#     flag = 0
#     enum(0, val)
#     if flag:
#         print('yes')
#     else:
#         print('no')



Measured memory_bytes: 5632
n,m = gets.chomp.split(" ").map{|i|i=i.to_i}
a = gets.chomp.split(" ").map{|i|i=i.to_i}


a.sort!.reverse!
#pp a


priority_queue=[]

priority_queue << a[0]/2

a.delete_at(0)

(m-1).times do|i|
  #puts "now a"
  #pp a
  #puts "now priority_queue"
  #pp priority_queue
  #puts "============"
  if a == [] then
    #puts "slakdfja;lsdkfj"
    a=priority_queue
    priority_queue = []
    priority_queue<<a[0]/2
    a.delete_at(0)
  elsif a[0] > priority_queue[0] then 
    priority_queue << a[0]/2
    a.delete_at(0)
  elsif a[0] <= priority_queue[0] then
    priority_queue << priority_queue[0]/2
    priority_queue.delete_at(0)
  end
  #puts "now a"
  #pp a
  #puts "now priority_queue"
  #pp priority_queue
  #puts "============"
end

#pp a
#pp priority_queue

# puts a.sum+priority_queue.sum
all=0
a.each do|elm|
  all += elm
end

priority_queue.each do|elm|
  all += elm
end

puts all







Measured memory_bytes: 13952
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int , int> P;
typedef pair<ll, ll> PL;
const int INT_INF = 2147483646;
const ll LL_INF = 9223372036854775807;
 
bool SecondCompare(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second<b.second;
}
 
bool SecondCompareDes(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second>b.second;
}

ll n;
const int SI = 1e5+10;
ll a[SI],b[SI],sa[SI],samem[SI];
ll suma,sumsa;
 
int main(){
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        suma += a[i];
    }
    for(int i = 0; i < n; i++){
        cin >> b[i];
        sa[i] = b[i]-a[i];
        sumsa += sa[i];
    }
    sort(sa,sa+n);
  
    ll ans = 0;
    if(sumsa > 0){
        cout << -1 << endl;
        return 0;
    }

    ll minus = 0;
    for(int i = 0; i < n; i++){
        if(b[i] > a[i]) minus += b[i]-a[i];
    }

    ll sum = 0;
    while(minus > sum){
        sum += abs(sa[ans]);
        ++ans;
    }
    for(int i = 0; i < n; i++){
        if(b[i] > a[i]) ++ans;
    }
    cout << ans << endl;
}

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

using namespace std;

int main() {
	int n, q;
	cin >> n;
	vector<int> a(n);
	for (int i = 0;i < n;i++) {
		cin >> a[i];
	}
	cin >> q;
	vector<int> b(q);
	for (int i = 0;i < q;i++) {
		cin >> b[i];
	}
	unique(a.begin(), a.end());
	int count = 0;
	for (int i = 0;i < q;i++) {
		if (lower_bound(a.begin(), a.end(), b[i]) == a.end())continue;
		if (*lower_bound(a.begin(), a.end(), b[i]) == b[i])count++;
	}
	cout << count << endl;
}


Measured memory_bytes: 3312
#include <bits/stdc++.h>
using namespace std;
#define int long long int
mt19937 rng(chrono::duration_cast<chrono::nanoseconds>(chrono::high_resolution_clock::now().time_since_epoch()).count());
#define mp make_pair
#define pb push_back
#define F first
#define S second
const int N=200005;
#define M 1000000007
#define double long double
#define BINF 10000000000001
#define init(arr,val) memset(arr,val,sizeof(arr))
#define MAXN 5000004
#define deb(x) cout << #x << " " << x << "\n";
const int LG = 22;



#undef int 
int main() {
#define int long long int
ios_base::sync_with_stdio(false); 
cin.tie(0); 
cout.tie(0);
 

 


    int x, y, n, m, k;
    cin >> x >> y >> n >> m >> k;
    int a[n], b[m], c[k];
    int ans = 0;
    priority_queue<int> q;

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

    for(int i = 0; i < m; i++){
        cin >> b[i];
    }

    for(int i = 0; i < k; i++){
        cin >> c[i];
        q.push(c[i]);
    }



    multiset<int>v, d;
    sort(a, a + n);
    reverse(a, a + n);
    sort(b, b + m);
    reverse(b, b + m);

    for(int i = 0; i < x; i++)
        v.insert(a[i]);
    for(int i = 0; i < y; i++)
        d.insert(b[i]);



    while(q.size()){
        int val = q.top();
        q.pop();
        int d1 = 0, d2 = 0;
        d1 = max(d1, val - *v.begin());
        d2 = max(d2, val - *d.begin());

        if(d1 == 0 and d2 == 0)
            break;
        if(d1 > d2){
            v.erase(v.begin());
            v.insert(val);
        }else{
            d.erase(d.begin());
            d.insert(val);
        }

    }

    for(auto i : v)
        ans += i;
    for(auto i : d)
        ans += i;

    cout << ans << endl;



    
    
    
    





return 0;  
}

Measured memory_bytes: 11892
def factorial_mod(n, mod):
    a = 1
    for i in range(1, n + 1):
        a *= i
        a %= mod
    return a


def comb_mod(n, k, mod):
    if k > n:
        return 0
    fact_n = factorial_mod(n, mod)
    fact_k = factorial_mod(k, mod)
    fact_n_k = factorial_mod(n - k, mod)
    fact_n_div_k = (fact_n * pow(fact_k, mod - 2, mod)) % mod
    return (fact_n_div_k * pow(fact_n_k, mod - 2, mod)) % mod


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

for i in range(1, k + 1):
    ans = comb_mod(n - k + 1, i, mod) * comb_mod(k - 1, i - 1, mod)
    ans %= mod
    print(ans)




Measured memory_bytes: 3316
import java.util.Scanner;

public class Main {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] arr = new int[N];
        for(int i=0;i<N;i++){
            arr[i] = sc.nextInt();
        }

        System.out.println(new SolverC().solve(arr, N));
    }
}

class SolverC {
    public long solve(int[] arr, int N){
        long res = 0;
        for(int i=1;i<N;i++){
            if(arr[i] < arr[i-1]){
                int diff = arr[i-1] - arr[i];
                arr[i] += diff;
                res += diff;
            }
        }

        return res;
    }
}

Measured memory_bytes: 60308
h,w = map(int,input().split())
s = [0]*(h+2)
for i in range(1,h+1):
    s[i] = ["#"] + list(input()) + ["#"]
s[0] = ["#"]*(w+2)
s[-1] = ["#"]*(w+2)

from collections import deque
qx = deque([])
qy = deque([])
qx.append(1)
qy.append(1)
r = [[0 for j in range(w+2)] for i in range(h+2)]
r[1][1] = 1
ans = 0
while qx:
    x = qx.popleft()
    y = qy.popleft()
    
    if s[x-1][y] == "." and r[x-1][y] == 0:
        qx.append(x-1)
        qy.append(y)
        r[x-1][y] = r[x][y] + 1
    if s[x+1][y] == "." and r[x+1][y] == 0:
        qx.append(x+1)
        qy.append(y)
        r[x+1][y] = r[x][y] + 1
    if s[x][y-1] == "." and r[x][y-1] == 0:
        qx.append(x)
        qy.append(y-1)
        r[x][y-1] = r[x][y] + 1
    if s[x][y+1] == "." and r[x][y+1] == 0:
        qx.append(x)
        qy.append(y+1)
        r[x][y+1] = r[x][y] + 1

c = 0
for i in range(h+2):
    for j in range(w+2):
        if s[i][j] == ".":
            c += 1
if r[h][w] != 0:    
    print(c-r[h][w])
else:
    print(-1)

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

int main()
{
  int N,M,count=0;
  int H[1000000]{0};
  int A[1000000]{0};
  int B[1000000]{0};
  bool ans[1000000]{false};

  cin>>N>>M;
  for(int i=0;i<N;i++){
    cin>>H[i];
  }
  for(int i=0;i<M;i++){
    cin>>A[i]>>B[i];
  }
  
  for(int i=0;i<M;i++){
    if(H[A[i]-1]<H[B[i]-1]){
      ans[A[i]-1]=true;
    }else if(H[A[i]-1]>H[B[i]-1]){
      ans[B[i]-1]=true;
    }else{
      ans[A[i]-1]=true;
      ans[B[i]-1]=true;
    }
  }
  for(int i=0;i<N;i++){
    if(!ans[i])count++;
  }
  cout<<count;
  return 0;
}

Measured memory_bytes: 16332
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] V = Console.ReadLine().Split(' ');
            int R = int.Parse(V[0]);
            int G = int.Parse(V[1]);
            int B = int.Parse(V[2]);
            int N = int.Parse(V[3]);
            int count = 0;
            int g = 0;
            int r = 0;

            for (r = 0; r * R <= N; r++)
            {
                for (g = 0; g * G + r * R <= N; g++)
                {
                    if((N - g * G - r * R)%B == 0 || N == g * G + r * R) count++;
                }
            }

            Console.WriteLine(count);
        }

    }
}


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

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

Measured memory_bytes: 256
require 'complex'
N, D = gets.split(" ").map(&:to_i)

points = []
N.times do
  points << gets.split(" ").map(&:to_i)
end

def dist(a, b)
  d = 0
  D.times do |i|
    d += (a[i] - b[i]) ** 2
  end
  return Math.sqrt(d)
end

count = 0
points.each_with_index do |point, ind|
  (N - ind - 1).times do |j|
    d = dist(point, points[ind + j + 1])
    count += 1 if d.to_i.to_f == d
  end
end

puts count

Measured memory_bytes: 14304
#include<iostream>
using namespace std;
int main() {
    int a, b;
    cin >> a >> b;
    if (a < b) {
        cout << "a < b" << endl;
    } else if (a > b) {
        cout << "a > b" << endl;
    } else {
        cout << "a == b" << endl;
    }   
    
    return 0;
}


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

int main(void) {
    int N;cin>>N;
    int N1 = N / 10;
    int N2 = N % 10;
    if (N1 == 9 || N2 == 9) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf = 1<<29;
int N;
vector<int> fromFen(100005, inf), fromSun(100005, inf);
bool seen[100005];
vector<int> adj[100005];
void bfs(string mode, vector<int> &d){
	queue<int> q;
	for(int i=0;i<N;i++){
		seen[i]=false;
	}
	if(mode=="s"){
		q.push(0);
		seen[0]=true;
	}
	else{
		q.push(N-1);
		seen[N-1]=true;
	}
	while(!q.empty()){
		int z=q.front();
		q.pop();
		for(auto x:adj[z]){
			if(!seen[x]){
				seen[x]=true;
				q.push(x);
				d[x]=d[z]+1;
			}
		}
	}
}

int main(){
    cin>>N;
    for(int i=0; i<N-1; i++){
	     int a,b;
	     cin>>a>>b;
	     --a;
	     --b;
	     adj[a].push_back(b);
	     adj[b].push_back(a);
    }
    fromSun[0]=fromFen[N-1]=0;
    bfs("f", fromFen);
    bfs("s", fromSun);
    int sun=0,fen=0;
    for(int i=0; i<N; i++){
        if(fromSun[i] <= fromFen[i]) sun++;
        else fen++; 
    }
    if(sun>fen) cout<<"Fennec";
    else cout<<"Snuke";
}


Measured memory_bytes: 6784
n, m = map(int, input().split())
A = list(map(int, input().split()))
dp = {}
dp[0] = 1
a, s = 0, 0
for i in A:
    a += i
    a %= m
    if a in dp:
        s += dp[a]
        dp[a] += 1
    else:
        dp[a] = 1
print(s)


Measured memory_bytes: 62576
#include<bits/stdc++.h>
using namespace std;
#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define For(i,n) for(ll i=0; i<n; ++i)
#define all(v) (v).begin(), (v).end()
#define ff first
#define ss second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define deb(x) cout<<"For debug : "<<x<<endl;
typedef long long ll;
#define ld long double

void solve()
{
    string s="ACL";
    int n; cin>>n;
    For(i,n)
    {
        cout<<s;
    }
}

int main(){
    optimize();
    ll T=1;
    //cin>>T;
    while(T--)
    {
        solve();
    }
    return 0;
}


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

using  namespace  std;

#define PI              acos(-1.0)
#define lcm(a,b)        (a * (b / __gcd(a,b)))
#define en '\n'

#define READ_IN freopen("Input.txt","r",stdin);
#define READ_OUT freopen("Output.txt","w",stdout);
#define Infi                0x3f3f3f3f
#define long_Infi           1e17 +10;

const int dx[] = {+1,-1,+0,+0};                         // 4 X directions
const int dy[] = {+0,+0,+1,-1};                         // 4 Y directions
const int dx8[] = {+0,+0,+1,-1,-1,+1,-1,+1};            // King X Moves
const int dy8[] = {-1,+1,+0,+0,+1,+1,-1,-1};            // King Y Moves
const int kx[] = {-2, -2, -1, -1,  1,  1,  2,  2};      // Knight X Moves
const int ky[] = {-1,  1, -2,  2, -2,  2, -1,  1};      // Knight Y Moves



int  Set    (int N,int pos) {return N=N | (1<<pos);}    /// turn a bit on
int  reset  (int N,int pos) {return N= N & ~(1<<pos);}  /// turn a bit off
bool check  (int N,int pos) {return (bool)(N & (1<<pos));} /// check, if a bit is on or not

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define trace(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define trace(x...)
#endif

typedef long long int           ll;
typedef unsigned long long int  llu;
typedef pair<int,int> pii;

int main(void){

    int a,b,c;
    cin >> a >> b >> c;

    swap(a,b);
    swap(a,c);

    cout <<a << " " << b <<  " " << c << endl;


    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define PI 3.1415926535
#define SEGMAX 131072
typedef long long ll;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<Pll> vPll;
typedef vector<vector<int>> vvi;
typedef vector<vector<bool>> vvb;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<double>> vvd;
typedef vector<vector<Pi>> vvPi;
typedef priority_queue<int, vector<int>, greater<int>> pqli;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi>> pqlP;
string YN(bool y) { return (y?"YES":"NO"); }
string yn(bool y) { return (y?"Yes":"No"); }
string ON(bool y) { return (y?"OK":"NG"); }
void swap(long long *x, long long *y)
{
	long long temp=*x;
	*x=*y;
	*y=temp;
}
long long GCD(long long m, long long n)
{
	long long temp;

	if(m<n) swap(&m, &n);

	while(n!=0){
		temp=m%n; m=n; n=temp;
	}
	return m;
}
int main(void)
{
	int n, k;

	cin>>n>>k;

	vll a(n);

	rep(i, n) cin>>a[i];

	ll max=0, gcd=a[0];

	rep(i, n){
		if(max<a[i]) max=a[i];

		gcd=GCD(a[i], gcd);
	}

	if(k<=max&&k%gcd==0){
		cout<<"POSSIBLE"<<endl;
	}else{
		cout<<"IMPOSSIBLE"<<endl;
	}
}

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

vector<int> divisor(int n){ //約数列挙
    vector <int> v;
    for(int i=1;i*i<=n;i++){
        if(n%i==0){
            v.push_back(i);
            if(i!=n/i) v.push_back(n/i);
        }
    }
    return v;
}

int main(){
    int n;
    cin >> n;
    int a[n+1];
    vector<int> v;
    int sum[n+1];
    memset(sum,0,sizeof(sum));

    for(int i=1;i<=n;i++) cin >> a[i];
    for(int i=n;i>=1;i--){
        vector<int> save;
        save=divisor(i);
        if(a[i]==1){
            if(sum[i]%2==0){
                v.push_back(i);
                for(auto x:save){
                    sum[x]++;
                }
            }
        }
        else{
            if(sum[i]%2==1){
                v.push_back(i);
                for(auto x:save){
                    sum[x]++;
                }
            }
        }
    }
    cout << v.size() << endl;
    rep(i,v.size()){
        printf("%d ",v[i]);
    }
}

Measured memory_bytes: 3064
using System;
//using System.Text;
using System.Linq;
class Program
{
    static void Main()
    {
        int[] a = new int[10];
        for (int i = 0; i < 10; i++) a[i] = int.Parse(Console.ReadLine());
        Array.Sort(a);
        for (int i = 9; i > 6; i--) Console.WriteLine(a[i]);
    }
}

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

map<int64_t, int64_t> primeFact(int64_t n) {
    map<int64_t, int64_t> prime;
    for(int64_t i = 2; i * i <= n; i++) {
        int64_t cnt = 0;
        while(n % i == 0) cnt++, n /= i;
        if(cnt) prime[i] = cnt;
    }
    if(n > 1) prime[n]++;
    return prime;
}

void solve() {
    int N; cin >> N;
    int64_t ans = 0;
    for(int i = 1; i < N; ++i) {
        int n = N - i;
        auto p = primeFact(n);
        int64_t tmp = 1;
        for(auto &[key, val] : p) {
            tmp *= val + 1;
        }
        ans += tmp;
    }
    cout << ans << '\n';
}

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


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define INF 10007

int main()
{
	//freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    //ios_base::sync_with_stdio(false);
    //cin.tie(NULL);
    long long a,b,c,d;
    cin >> a >> b >> c >> d;
    cout << max(a*c,max(a*d,max(b*c,b*d))) << "\n";
}


Measured memory_bytes: 3632
#include <iostream>
#include <string.h>
using namespace std;
#define int long long

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string n; 
    cin >> n;
    int res =0;
    for(char i : n){
        res += (i-'0');
        res = res%9;
    }
    if(res%9==0){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }
    
    return 0;
}

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

int main()
{
    ll n,i,j,t,sz,dp[100];
    string s;
    while(cin>>s)
    {
        sz=s.size();
        int ans=0;
    for(i=0;i<sz;i++)
    {
        ans+=s[i]-'0';
    }
    if(ans==7)
    {
        cout<<s[0]<<"+"<<s[1]<<"+"<<s[2]<<"+"<<s[3]<<"=7"<<endl;
        continue;
    }
    ans=0;
    ans+=s[0]-'0';
     ans+=s[1]-'0';
      ans+=s[2]-'0';
       ans-=s[3]-'0';
       if(ans==7)
    {
        cout<<s[0]<<"+"<<s[1]<<"+"<<s[2]<<"-"<<s[3]<<"=7"<<endl;
        continue;
    }
     ans=0;
    ans+=s[0]-'0';
     ans+=s[1]-'0';
      ans-=s[2]-'0';
       ans-=s[3]-'0';
       if(ans==7)
    {
        cout<<s[0]<<"+"<<s[1]<<"-"<<s[2]<<"-"<<s[3]<<"=7"<<endl;
        continue;
    }
    ans=0;
    ans+=s[0]-'0';
     ans+=s[1]-'0';
      ans-=s[2]-'0';
       ans+=s[3]-'0';
         if(ans==7)
    {
        cout<<s[0]<<"+"<<s[1]<<"-"<<s[2]<<"+"<<s[3]<<"=7"<<endl;
        continue;

    }

    ans=0;
    ans+=s[0]-'0';
     ans-=s[1]-'0';
      ans+=s[2]-'0';
       ans+=s[3]-'0';
       if(ans==7)
    {
        cout<<s[0]<<"-"<<s[1]<<"+"<<s[2]<<"+"<<s[3]<<"=7"<<endl;
        continue;
    }
    ans=0;
    ans+=s[0]-'0';
     ans-=s[1]-'0';
      ans+=s[2]-'0';
       ans-=s[3]-'0';
       if(ans==7)
    {
        cout<<s[0]<<"-"<<s[1]<<"+"<<s[2]<<"-"<<s[3]<<"=7"<<endl;
        continue;
    }
    ans=0;
    ans+=s[0]-'0';
     ans-=s[1]-'0';
      ans-=s[2]-'0';
       ans-=s[3]-'0';
       if(ans==7)
    {
        cout<<s[0]<<"-"<<s[1]<<"-"<<s[2]<<"-"<<s[3]<<"=7"<<endl;
        continue;
    }
    ans=0;
    ans+=s[0]-'0';
     ans-=s[1]-'0';
      ans-=s[2]-'0';
       ans+=s[3]-'0';
       if(ans==7)
    {
        cout<<s[0]<<"-"<<s[1]<<"-"<<s[2]<<"+"<<s[3]<<"=7"<<endl;
        continue;
    }

}
}


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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/
int main() {
  ll n;
  cin >> n;
  vector<pll> info(n);
  REP(i,n){
    ll a;
    cin >> a;
    info[i] = make_pair(a,i+1);
  }
  sort(info.begin(),info.end());
  REP(i,n) cout << info[i].second << " ";
  cout << endl;
  return 0;
}


Measured memory_bytes: 2432
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define pb push_back
#define MOD 1000000007
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a=0,b=0,c=0;
    cin>>a>>b>>c;
    set<int> s;
    for(int i=1;i<=b;++i)
    {
		s.insert((a*i)%b);
	}
	if(s.find(c%b)!=s.end())
		cout<<"YES";
	else
		cout<<"NO";
	cout<<endl;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
a.sort()

b = a.copy()
d = b[0] + 0

while len(b) > 1 :

    for i in range(1,len(b)) :
        b[i] = b[i] % b[0]

    if b.count(0) == len(b)-1 :
        d = b[0]
        break
    else :
        b.sort()
        for j in range(b.count(0)) :
            b.remove(0)

print(d)

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

  
int main () 
{ 
    //stack <int> s; 
    double n;
    cin>>n;
    double c=2*3.14159*n;
    cout<<setprecision(20)<<c<<endl;
         
    
     /*for(int i=1;i<=n;i++)
     cout<<a[i]<<" ";
     cout<<endl;*/
  
    return 0; 
} 

Measured memory_bytes: 3788
#include<stdio.h>
int main(){
    int a[100][100]={0};
    int b[100]={0};
    int c[100]={0};
    int m,n,i,j;
    
    scanf("%d %d",&n,&m);
    
    for(i=0;i<n;i++){
        for(j=0;j<m;j++)
            scanf("%d",&a[i][j]);
    }
    for(i=0;i<m;i++){
        scanf("%d",&b[i]);
    }
    for(i=0;i<n;i++){
        for(j=0;j<m;j++)
            c[i]+=a[i][j]*b[j];
    }
    for(i=0;i<n;i++)
        printf("%d\n",c[i]);
    return 0;
}

Measured memory_bytes: 648
from collections import deque

def main():
    n = int(input())
    edge = []
    edge_id = []
    for i in range(n):
        edge.append([])
        edge_id.append(dict())
    for i in range(n-1):
        a, b = map(int, input().split())
        edge[a-1].append(b-1)
        edge[b-1].append(a-1)
        edge_id[a-1].update({b-1: i})
        edge_id[b-1].update({a-1: i})
    m = int(input())
    uv = []
    for i in range(m):
        uv.append(list(map(int, input().split())))

    edge_mask = []
    for i in range(m):
        distance_from_u = []
        visited = []
        for j in range(n):
            distance_from_u.append(0)
            visited.append(False)
        que = deque()
        que.append([uv[i][0]-1, 0])
        while len(que) > 0:
            now, dist = que.popleft()
            if visited[now]:
                continue
            visited[now] = True
            distance_from_u[now] = dist
            for x in edge[now]:
                if not visited[x]:
                    que.append([x, dist+1])
        next = uv[i][1]-1
        edge_set = set()
        while distance_from_u[next] > 0:
            for x in edge[next]:
                if distance_from_u[x] < distance_from_u[next]:
                    edge_set.add(edge_id[next][x])
                    next = x
                    break
        edge_mask.append(edge_set)

    dp_mask = []
    for i in range(n-1):
        new_mask = 0
        for j in range(m):
            if i in edge_mask[j]:
                new_mask = new_mask | (1 << j)
        dp_mask.append(new_mask)

    dp = []
    for i in range(n):
        dp.append([])
        for j in range(1 << m):
            dp[i].append(0)
    dp[0][0] = 1
    for i in range(n-1):
        for j in range(1 << m):
            dp[i+1][j] += dp[i][j]
            dp[i+1][j|dp_mask[i]] += dp[i][j]

    ans = dp[n-1][(1<<m)-1]

    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 731444
s = int(input())
a = [s]

for n in range(1000000):
  if a[n]%2==0:
    if int(a[n]/2) not in a:
      a.append(int(a[n]/2))
    else:
      print(n+2)
      exit()
  else:
    if int(3*a[n]+1) not in a:
      a.append(int(3*a[n]+1))
    else:
      print(n+2)
      exit()

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

#ifdef LOCAL
#include "dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

#define rep(i, n) for (int i = 0; i < (n); i++)
#define mins(x, y) (x = min(x, y))
#define maxs(x, y) (x = max(x, y))
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using P = pair<int, int>;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

void solve() {
  int n, x, y;
  cin >> n >> x >> y;
  x--, y--;
  vvi dist(n, vi(n, INF));
  rep(i, n) dist[i][i] = 0;
  rep(i, n) rep(j, n) {
    if (i < j) {
      dist[i][j] = min(dist[i][j], j - i);
      dist[i][j] = min(dist[i][j], abs(x - i) + abs(y - j) + 1);
    }
  }
  // dumpv(dist, n, n);
  vi cnt(n);
  rep(i, n) rep(j, n) {
    if (i < j) {
      cnt[dist[i][j]]++;
    }
  }
  // dump(cnt);
  rep(i, n - 1) cout << cnt[i + 1] << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  // freopen("temp.1", "r", stdin);
  solve();
  return 0;
}

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

using namespace std;

template <class T> void mini(T &l, T r) {l = min(l, r);}
template <class T> void maxi(T &l, T r) {l = max(l, r);}

string to_string(string s) {
  return '"' + s + '"';
}

string to_string(bool a) {
  return a ? "T" : "F";
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

using ll = long long;
using ld = long double;

const int L = 3e4;

vector < vector <int> > v2;
vector < vector <int> > v3;

void run() {
  int n;
  for (int i = 0; i * 6 + 6 <= L; ++i) {
    v2.push_back({i * 6 + 2, i * 6 + 4, i * 6 + 6});
  }
  for (int i = 0; i * 12 + 9 <= L; ++i) {
    v3.push_back({i * 12 + 3, i * 12 + 9});
  }
  debug(v2.back(), v3.back());
  debug(v2.size(), v3.size());
  debug(v2.size() * 3 + v3.size() * 2);
  cin >> n;
  if (n == 19999) {
    for (int i = 0; i < v2.size() - 1; ++i) {
      for (auto x : v2[i]) printf("%d ", x);
    }
    for (int i = 0; i < v2.back().size() - 1; ++i) printf("%d ", v2.back()[i]);
    for (int i = 0; i < v3.size(); ++i) {
      for (auto x : v3[i]) printf("%d ", x);
    }
    return;
  }
  if (n & 1) {
    if (n - 3 > 0) {
      printf("2 4 6 ");
      n -= 3;
      for (int i = 1; i + 1 < v2.size(); i += 2) {
        if (n > 6) {
          n -= 6;
          for (auto x : v2[i]) printf("%d ", x);
          for (auto x : v2[i + 1]) printf("%d ", x);
        } else {
          break;
        }
      }
      for (int i = 0; i < v3.size(); ++i) {
        if (n >= 2) {
          n -= 2;
          for (auto x : v3[i]) printf("%d ", x);
        } else {
          break;
        }
      }
      assert(!n);
    } else {
      if (n == 3) puts("2 5 63");
    }
  } else {
    if (n - 6 > 0) {
      for (int i = 0; i + 1 < v2.size(); i += 2) {
        if (n > 6) {
          n -= 6;
          for (auto x : v2[i]) printf("%d ", x);
          for (auto x : v2[i + 1]) printf("%d ", x);
        } else {
          break;
        }
      }
      for (int i = 0; i < v3.size(); ++i) {
        if (n >= 2) {
          n -= 2;
          for (auto x : v3[i]) printf("%d ", x);
        } else {
          break;
        }
      }
      debug(n);
      assert(!n);
    } else {
      if (n == 4) {
        puts("2 5 20 63");
      }
      if (n == 6) {
        puts("2 3 4 6 45 60");
      }
      
    }
  }
}

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


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+20;
const ll mod=1e9+7;
int n,a[N],b[N];
int main()
{
	while(cin>>n)
	{
		for(int i=1;i<=n;i++)
			scanf("%d",&a[i]);
		int cnt=0,l=1,r=n;
		for(int i=n;i>=1;i--)
		{
			if(cnt%2)
				b[r--]=a[i];
			else
				b[l++]=a[i];
			cnt=1-cnt;
		}
		for(int i=1;i<=n;i++)
			cout<<b[i]<<' ';
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 3712
<?php
# 整数の入力
fscanf(STDIN, "%d", $a);
# スペース区切りの整数の入力
fscanf(STDIN, "%d %d", $b, $c);
# 文字列の入力
fscanf(STDIN, "%s", $s);

$N = $a;
echo floor($N / 3);

Measured memory_bytes: 4728