akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 2 - 170;

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> v;
    for (int i = 0; i < n; ++i) {
        int w;
        scanf("%d", &w);
        v.emplace_back(w);
    }
    sort(v.begin(), v.end());
    if(v[n-1] < k){
        cout << "IMPOSSIBLE\n";
        return 0;
    }
    int p = v[0];
    for (int i = 1; i < n; ++i) {
        p = __gcd(p, v[i]);
    }
    if(k % p){
        cout << "IMPOSSIBLE\n";
    }else {
        cout << "POSSIBLE\n";
    }
    return 0;
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
#define ll long long
#define str string
#define optimizator ios_base::sync_with_stdio(0);
using namespace std;
int main(){
	optimizator;
	int n;
	cin>>n;
	double a=n;
	if(n==1){
		cout<<fixed<<setprecision(9)<<1.00000000;
		return 0;
	}
	if(n%2==0){
		cout<<fixed<<setprecision(9)<<(1.0/2);
	}
	else{
		cout<<fixed<<setprecision(9)<<(1.0*(a+1))/2/a;
	}
}

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

int main(void){
    long n;
    cin >> n;
    long m=0, a=0, r=0, c=0, h=0;
    vector<long> v(5);
    for(long i=0; i<n; i++){
        string name;
        cin >> name;
        switch(name[0]){
            case 'M': m++; break;
            case 'A': a++; break;
            case 'R': r++; break;
            case 'C': c++; break;
            case 'H': h++; break;
        }
    }
    long sum=0;
    sum += m*a*r;
    sum += m*a*c;
    sum += m*a*h;
    sum += m*r*c;
    sum += m*r*h;
    sum += m*c*h;
    sum += a*r*c;
    sum += a*r*h;
    sum += a*c*h;
    sum += r*c*h;
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int M = 1e9 + 7;
const int N = 1e5 + 5;
int n;
int m;
long long a[N];
int main()
{
            ios_base::sync_with_stdio(false);
            cin.tie(0);
            cout.tie(0);
            cin >> n;
            cin >> m;
            a[0] = 1;
            for(int i = 1 ; i < N ; i++){
                    a[i] = i * a[i - 1];
                    a[i] %= M;
            }
            if(n == m){
                    long long res = 2;
                    res *= a[n];
                    res %= M;
                    res *= a[m];
                    res %= M;
                    cout << res << endl;
            }
            else{
                    if(m > n){
                            swap(n , m);
                    }
                    if(n - m > 1){
                            cout << 0 << endl;
                    }
                    else{
                            long long res = 1;
                            res *= a[n];
                            res %= M;
                            res *= a[m];
                            res %= M;
                            cout << res << endl;
                    }
            }
            return 0;
}


Measured memory_bytes: 1024
import Control.Applicative
import Data.List
import Data.Char

getInt :: IO Int
getInt = (\a -> read a :: Int) <$> getLine

getIntArray :: IO [Int]
getIntArray = ((map (\a -> read a :: Int)) . words) <$> getLine

getStrArray :: Int -> IO [String]
getStrArray 0 = return [] :: IO [String]
getStrArray n = (:) <$> getLine <*> (getStrArray (n - 1))

isGood :: String -> String
isGood [a, b, c, d] 
    | a == b && b == c = "Yes"
    | b == c && c == d = "Yes"
    | otherwise = "No"

main = do
    putStrLn =<< isGood <$> getLine


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

int main(){
	char acd;
	cin >> acd;
	if(acd == 'A'){
		cout << "T" << endl;
	}else if(acd == 'T'){
		cout << "A" << endl;
	}else if(acd == 'G'){
		cout << "C" << endl;
	}else if(acd == 'C'){
		cout << "G" << endl;
	}

	return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

int n;

int main(){
    cin >> n;
    vector<ll> ans(n);
    rep(i,n){
        ll num;
        ll idx = n/2;
        if(n % 2 == 0){
            if(i%2 == 0)idx += i/2;
            else idx -= (i+1)/2;
        }
        else {
            if(i%2 == 0)idx -= i/2;
            else idx += (i+1)/2;
        }
        // cout << "!" << " " << idx << endl;;
        cin >> num;
        ans[idx] = num;
    }
    rep(i,n){
        if(i != n-1)cout << ans[i] << " ";
        else cout << ans[i] << endl;
    }
}

Measured memory_bytes: 3712
// AOJ 2177: Champernowne Constant
// 2017.11.5 bal4u@uu

#include <stdio.h>
#include <string.h>

long long len[11];
int ten[10] = {1};

int main()
{
	int n, k, i, j, num;
	long long nine;
	char buf[200], *p;

	for (nine = 9, i = 1; i <= 10; i++, nine *= 10) len[i] = i*nine, ten[i] = ten[i-1]*10;
	for (i = 1; i <= 10; i++) len[i] += len[i-1];

	while (scanf("%d%d", &n, &k) && n > 0) {
		for (i = 1; len[i] < n; i++);
		j = n - (int)len[i-1] - 1;
		num = j / i + ten[i-1];
		sprintf(buf, "%d", num);
		p = buf + j % i;
		i = strlen(p);
		while (i < k) sprintf(p+i, "%d", ++num), i = strlen(p);
		*(p+k) = 0;
		puts(p);
	}
	return 0;
}

Measured memory_bytes: 1724
import sys

N = int(input())
W = list(input() for _ in range(N))

if len(set(W)) == N:
	for i in range(N-1):
		a = W[i]
		b = W[i+1] 
		if a[-1] != b[0]:
			print('No')
			sys.exit()
	print('Yes')
else:
	print('No')

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

int main() {
  int N;
  cin >> N;
  
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  
  sort(A.begin(),A.end());
  
  int count = 0;
  for (int i = 0; i < N; i++) {
    count += A.at(i);
  }
  
  int S,R;
  S = count/N;
  int answer = 0;
  int answerb = 0;
  for (int i = 0; i < N; i++) {
    R = A.at(i)-S;
    answer += R*R;
  }
  for (int i = 0; i < N; i++) {
    R = A.at(i) - S - 1;
    answerb += R*R;
  }
  
  if (answer < answerb) {
  cout << answer <<endl;
  }
  else {
    cout << answerb <<endl;
  }
  
}


Measured memory_bytes: 256
a=[]
b=int(input())
c=[]
i=0
while i<b:
    a.append(int(input()))
    i+=1
for x in a:
    c.append(x)
c.sort()

i=1

if c[-1]!=c[-2]:
    while i<=b:
        if a[i-1]!=c[-1]:
            print(c[-1])
        else:
            print(c[-2])
        i+=1
else:
    while i<=b:
        print(c[-1])
        i+=1

Measured memory_bytes: 14120
h,w = map(int,input().split())
l = []
for _ in range(h):
    a = list(map(str,input()))
    l.append(a)

tmp = 0

for i in range(h):
    for j in range(w):
        if l[i][j] == "#":
            if j < tmp:
                print("Impossible")
                exit()
            else:
                tmp = j


print("Possible")

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

const int MAX = 3e5 + 5;
const int MOD = 998244353;
int n, dp[MAX], z[MAX], lg[MAX];
pair <int, int> a[MAX], rmq[MAX][20];

void build_rmq() {
	for(int i = 1; i <= n; i++) {
		lg[i] = log2(i);
		rmq[i][0] = { a[i].first + a[i].second, i };
	}

	for(int j = 1; (1 << j) <= n; j++) {
		for(int i = 1; i <= n; i++) {
			int pos = i + (1 << (j - 1));
			rmq[i][j] = rmq[i][j - 1];
			
			if(pos <= n)
				rmq[i][j] = max(rmq[i][j], rmq[pos][j - 1]);
		}
	}
}

pair <int, int> query(int a, int b) {
	int k = lg[b - a + 1];
	return max(rmq[a][k], rmq[b - (1 << k) + 1][k]);
}

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

	for(int i = 1; i <= n; i++) {
		scanf("%d%d", &a[i].first, &a[i].second);
		a[i].second--;
	}

	sort(a + 1, a + n + 1);

	build_rmq();

	z[n + 1] = 1;
	for(int i = n; i > 0; i--) {
		int p = upper_bound(a + 1, a + n + 1, make_pair(a[i].first + a[i].second, (int) 2e9)) - a - 1;
		assert(p >= i);

		int q = query(i, p).second;

		if(a[q].first + a[q].second > a[i].first + a[i].second)
			dp[i] = dp[q];

		else dp[i] = a[i].first + a[i].second;

		int who = upper_bound(a + 1, a + n + 1, make_pair(dp[i], (int) 2e9)) - a - 1;

		z[i] = (z[i + 1] + z[who + 1]) % MOD;
	}

	printf("%d\n", z[1]);
	return 0;
}

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

using namespace std;

int main(){
	ll x;
	cin >> x;
	ll ans=1;
	while(true){
		ll num = ans*(ans+1)/2;
		if(num>=x)break;
		ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 3644
import java.util.*;

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

        //リスト定義
        ArrayDeque<Integer> deque = new ArrayDeque<Integer>();
        
        int num = sc.nextInt();
        
        int pattern;    //d
        int number = 0,order;
        for(int i = 0;i < num;i++){
            //命令変数定義
            order = sc.nextInt();
            //条件定義
            switch(order){
                //push
                case 0:
                    pattern = sc.nextInt();
                    number = sc.nextInt();
                    //先頭に追加
                    if(pattern == 0)    deque.addFirst(number);
                    //末尾に追加
                    else if(pattern == 1)   deque.addLast(number);
                    break;
                //randomAccess
                case 1:
                    number = sc.nextInt();
                    Iterator<Integer> ite = deque.iterator();
                    for(int j = 0;j < number;j++)   ite.next();
                    System.out.println(ite.next());
                    break;
                //pop
                case 2:
                    pattern = sc.nextInt();
                    //先頭削除
                    if(pattern == 0)    deque.removeFirst();
                    //末尾削除
                    if(pattern == 1)    deque.removeLast();
                    break;
            }
        }
    }
}


Measured memory_bytes: 302688
using System;

namespace _0184
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                int n = int.Parse(Console.ReadLine());
                if (n == 0) { break; }
                int[] a = new int[7];
                for (int i = 0; i < n; i++)
                { int d = int.Parse(Console.ReadLine());
                    a[Math.Min(d / 10,6)]++;
                }
                for(int i = 0; i < 7; i++)
                {
                    Console.WriteLine(a[i]);
                }
            }
        }
    }
}

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

constexpr int nax = 1e5, maxm = nax, qax = nax, dax = 10;

struct Ev
{
    int v, d, c;
};

int n, m, q, col[nax + 1][dax + 1];
vector< int > gr[nax + 1];
Ev evs[qax];

void dfs(const int v, const int d, const int c)
{
    col[v][d] = c;
    if (d and not col[v][d - 1])
        dfs(v, d - 1, c);
    if (d) for (int s : gr[v])
        if (not col[s][d - 1])
            dfs(s, d - 1, c);
}
        

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

    cin >> n >> m;

    for (int i = 0; i < m; ++i)
    {
        int p, q; cin >> p >> q;
        gr[p].push_back(q);
        gr[q].push_back(p);
    }

    cin >> q;

    for (int i = 0; i < q; ++i)
        cin >> evs[i].v >> evs[i].d >> evs[i].c;
    
    for (int i = q - 1; i >= 0; --i)
        if (not col[evs[i].v][evs[i].d])
            dfs(evs[i].v, evs[i].d, evs[i].c);

    for (int i = 1; i <= n; ++i)
        for (int j = 0; j <= dax; ++j)
            if (col[i][j] or j == dax)
            {
                cout << col[i][j] << '\n';
                break;
            }
}

Measured memory_bytes: 12024
#include <bits/stdc++.h>
#include <random>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using Pt = pair<int, int>;

int main()
{
	ll D, T, S;
	cin >> D >> T >> S;
	if (T * S >= D)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}

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

using namespace std;

typedef long long ll;

struct UFnode
{
  int value_;
  int rank_, p_, index_, size_;
  UFnode(int value) : value_(value), rank_(0), p_(-1), size_(1) {}
  int size() const { return size_; }
};

struct UF
{
  vector<UFnode> ufnodes_;
  map<int, int> value_to_index_;
  int size_;

  UF() : size_(0) {}
  int size() const { return size_; }
  int tree_size(int value)
  {
    if (value_to_index_.count(value) == 0) { return 0; }
    int pix = ufnodes_[value_to_index_[value]].p_;
    return ufnodes_[pix].size();
  }

  void make_set(int value)
  {
    UFnode node(value);
    ufnodes_.push_back(node);
    int ix = ufnodes_.size() - 1;
    ufnodes_[ix].index_ = ufnodes_[ix].p_ = value_to_index_[value] = ix;
    ++size_;
  }

  int find_set(int value, int index = -1)
  {
    if (index == -1) {
      if (value_to_index_.count(value) == 0) { return -1; }
      index = value_to_index_[value];
    }
    if (ufnodes_[index].p_ != index) {
      ufnodes_[index].p_ = find_set(ufnodes_[ufnodes_[index].p_].value_, ufnodes_[index].p_);
    }
    return ufnodes_[index].p_;
  }

  void unite(int x, int y)
  {
    int s1 = find_set(x), s2 = find_set(y);
    if ((s1 == s2) || (s1 == -1) || (s2 == -1)) { return; }
    if (ufnodes_[s1].rank_ > ufnodes_[s2].rank_) {
      ufnodes_[s2].p_ = s1;
      ufnodes_[s1].size_ += ufnodes_[s2].size_;
    }
    else {
      ufnodes_[s1].p_ = s2;
      ufnodes_[s2].size_ += ufnodes_[s1].size_;
      if (ufnodes_[s1].rank_ == ufnodes_[s2].rank_) { ++ufnodes_[s2].rank_; }
    }
    --size_;
  }

  bool is_connected(int x, int y) { return find_set(x) == find_set(y); }
};

int main()
{
  int n = 0, m = 0;
  scanf("%d %d", &n, &m);
  vector<int> pos(n + 1, -1);
  UF uf;
  for (int i = 1; i <= n; ++i) {
    int a = -1;
    scanf("%d", &a);
    pos[i] = a;
    uf.make_set(a);
  }

  for (int i = 0; i < m; ++i) {
    int x, y;
    scanf("%d %d", &x, &y);
    uf.unite(x, y);
  }

  int ans = 0;
  for (int i = 1; i <= n; ++i) {
    if (uf.is_connected(i, pos[i])) { ++ans; }
  }
  printf("%d\n", ans);

  return 0;
}


Measured memory_bytes: 7824
#include<bits/stdc++.h>
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define nd second
#define st first
using namespace std;
using ll=long long;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using vi=vector<int>;
using vl=vector<ll>;
using mii=map<int,int>;
using si=set<int,int>;
using vpi=vector<pii>;
using vpl=vector<pll>;

const int N=(int)3e3+5;

int n,m,a,b,c,q,dp[N][N];
vi V;
string A,B,wyn;

int R(int l, int p){
	return rand()%(p-l+1)+l;
}

void wczytaj(){
	cin>>A>>B;
	A='#'+A;
	B='#'+B;
}

void solve(){
	for (int i=1; i<A.size(); ++i){
		for (int j=1; j<B.size(); j++){
			dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
			if (A[i]==B[j]){
				dp[i][j]=max(dp[i][j],dp[i-1][j-1]+1);
			}
		}
	}
	int i=A.size()-1,j=B.size()-1;
	while (i and j){
		if (A[i]==B[j]){
			wyn+=A[i];
			i--;
			j--;
		}
		else if (dp[i-1][j]==dp[i][j]){
			i--;
		}
		else j--;
	}
	reverse(wyn.begin(),wyn.end());
	if (wyn.size()==0){
		cout<<' ';
		return;
	}
	cout<<wyn<<'\n';
}

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int ilosc_przypadkow_testowych=1;
//	cin>>ilosc_przypadkow_testowych
	for (int i=1; i<=ilosc_przypadkow_testowych; ++i){
		wczytaj();
		solve();
	}
}

Measured memory_bytes: 35456
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
typedef long long ll;
  
int f(int x){
  int ans=0;
  while(x >0){
    ans += x%10;
    x /= 10;
  }
  return ans;
}

int main(){
  int x;
  cin >> x;
  if(x%f(x) == 0) cout << "Yes" << endl;
  else cout << "No" << endl; 
  
  return 0;
}


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

using namespace std;

int main() {
    long n = LONG_MIN;
    cin >> n;
    long k = 0;
    cin >> k;
    vector<vector<long>> adr(n, vector<long>(3));
    long s = 0;
    for (int i = 0; i < n; ++i) {
	cin >> adr[i][0];
	s += adr[i][0];
    }

    long fn = s;
    long fd = k+n;
    long used = 0;
    for (int i = 0; i < n; ++i) {
	adr[i][1] = adr[i][0]*fd / fn;
	if (adr[i][1] == 0) {adr[i][1] = 1;}
	adr[i][2] = adr[i][0] / adr[i][1];
	used += adr[i][1];
    }

    long remains = fd - used;

    sort(adr.begin(), adr.end(), [](vector<long> &a, vector<long> &b) {return b[2] < a[2];});
    long rmax = LONG_MIN;
    for (int i = 0; i < n; ++i) {
	long delta = (i < remains) ? 1 : 0;
	long rcur = adr[i][0] / (adr[i][1] + delta);
	if (adr[i][0] % (adr[i][1] + delta) > 0) {++rcur;};
	rmax = max(rmax, rcur);
    }
    cout << rmax << "\n";
}




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

int main()
{
  int N; cin >> N;
  long cnt[100005] = {};
  int D[100005] = {};
  int mx_D = 0;
  for (int i = 0; i < N; i++)
  {
    cin >> D[i];
    mx_D = max(mx_D, D[i]);
    cnt[D[i]]++;
  }
  
  if (cnt[0] != 1 || D[0] != 0)
  {
    cout << 0 << endl;
    return 0;
  }
  
  long ans = 1;
  long mod = 998244353;
  
  for (int j = 1; j <= mx_D; j++)
  {
    for (int k = 0; k < cnt[j]; k++)
    {
      ans *= cnt[j - 1];
      ans %= mod;
    }
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1408
def comb(n,k):
    return (ex[n]*pow(ex[k],mod-2,mod)*pow(ex[n-k],mod-2,mod))%mod

H,W,A,B = map(int,input().split())
mod = 10**9+7

ex = [1]
for i in range(1,2*10**5+1):
    ex.append((ex[-1]*i)%mod)

ans = 0
for i in range(W-B):
    ans += comb(H+B+i-A-1,B+i)*comb(A+W-B-i-2,A-1)
    ans %= mod
    

print(ans)

Measured memory_bytes: 52816
// B - Cut and Count
#include <bits/stdc++.h>
using namespace std;
#define rp(i,s,e) for(int i=(s);i<(e);++i)

int main(){
	int N; string S; cin>>N>>S;
	int maxi = 0;
	rp(sep, 1, N){
		int count = 0;
		for(char c='a'; c<='z'; ++c){
			bool l = false, r = false;
			rp(i, 0, sep) if(c==S[i]){ l = true; break; }
			rp(i, sep, N) if(c==S[i]){ r = true; break; }
			if(l&&r) count++;
		}
		maxi = max(maxi, count);
	}
	cout<< maxi <<endl;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**9)

N = int(input())
ab = [list(map(int,input().split())) for _ in range(N-1)]

#%%
# 1-indexed
adj_list = [[] for _ in range(N+1)]

for a,b in ab:
    adj_list[a].append(b)
    adj_list[b].append(a)

# DFSで各頂点を1，2に割り当てる．

group = [1]*(N+1)
group[0] = -1

def dfs(v,par,grp):
    # 頂点vからpar以外の子へ遷移
    # grpで頂点vのグループを持つ
    
    # 1 xor 3 = 2
    nxt_grp = grp^3
    
    for child in adj_list[v]:
        if child==par:
            continue
        group[child] = nxt_grp
        dfs(child,v,nxt_grp)
    
    return 

dfs(1,-1,1)

ans = [0]*(N+1)
used = [False]*(N+1)


group_num = [0]*2
for g in group[1:]:
    group_num[g-1] += 1
    
    
    
if min(group_num) <= N//3:
    # どちらかのグループの要素数がN//3以下のとき，そのグループに0(mod3)を割り当てる
    if min(group_num) == group_num[0]:
        minidx = 1
    else:
        minidx = 2
    
    idx = 3
    idx_n = 1
    for i,g in enumerate(group):
        if i==0:continue
        if g==minidx:
            ans[i] = idx            
            used[idx] = True
            idx += 3

    for i,g in enumerate(group):
        if i==0:continue
        if ans[i]!=0:continue
        while used[idx_n]:
            idx_n += 1
        ans[i] = idx_n
        used[idx_n] = True
        idx_n += 1
    
    print(*ans[1:])

else:
    # 順番に1,2を割り当て，Nを超えたら0を割り当て
    idx_1 = 1
    idx_2 = 2
    for i,g in enumerate(group):
        if i==0:continue
        if g==1:
            if idx_1>N:continue
            ans[i] = idx_1
            used[idx_1] = True
            idx_1 += 3
        else:
            if idx_2>N:continue
            ans[i] = idx_2
            used[idx_2] = True
            idx_2 += 3

    idx = 3
    for i in range(1,N+1):
        if ans[i]==0:
            while used[idx]:
                idx += 3
            ans[i] = idx
            used[idx] = True

    print(*ans[1:])
    
    

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

#define llint long long int
#define pb push_back

using namespace std;

int main(){
  int n, t;
  float a;
  cin >> n >> t >> a;
  float mind = 100000.0;
  int ans;
  for(int i = 0; i < n; i++){
    int h;
    cin >> h;
    float avg = t - 0.006*h;
    float diff = abs(avg - a);
    if(diff < mind){
      ans = i;
      mind = diff;
    }
  }
  cout << ans + 1;
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder.ABC169
{
    public class Problem4
    {
        public static void Main(string[] args)
        {
            var input = ulong.Parse(Console.ReadLine());

            var res = (ulong)0;

            if (input == 1)
            {
                res = 0;
            }
            else if (IsPrime(input))
            {
                res = 1;
            }
            else
            {
                var factors = PrimeFactors(input)
                    .GroupBy(x => x)
                    .Select(x => CountFactor((ulong)x.Count()));
                
                res = (ulong)factors.Sum(x => (decimal)x);
            }

            Console.WriteLine(res.ToString());
        }

        public static IEnumerable<ulong> PrimeFactors(ulong n)
        {
            ulong i = 2;
            ulong tmp = n;

            while (i * i <= n) //※1
            {
                if (tmp % i == 0)
                {
                    tmp /= i;
                    yield return i;
                }
                else
                {
                    i++;
                }
            }
            if (tmp != 1) yield return tmp;//最後の素数も返す
        }

        public static bool IsPrime(ulong num)
        {
            if (num < 2) return false;
            else if (num == 2) return true;
            else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

            double sqrtNum = Math.Sqrt(num);
            for (ulong i = 3; i <= sqrtNum; i += 2)
            {
                if (num % i == 0)
                {
                    // 素数ではない
                    return false;
                }
            }

            // 素数である
            return true;
        }

        public static ulong CountFactor(ulong num)
        {
            var con = (ulong)1;
            var i = (ulong)1;
            while (con <= num)
            {
                i++;
                con += i;
            }

            return i - 1;
        }
    }
}


Measured memory_bytes: 28252
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cctype>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <stdio.h>
#include <string.h>
#include <cstdlib>
#include <math.h>
#include <bitset>
#define INF 2000000000
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
typedef long long ll;
#define PL pair<long long, long long>
#define P pair<int,int>
#define mk make_pair
#define en endl;
#define WHITE 0
#define BLACK 2
#define GRAY 1
#define RE return 0;
#define HERE cout<<"         here"
#define out(value) cout<<value<<en


//int main(){
//  int d,n;
//  cin>>d>>n;
//
//  int ans=1;
//  for(int i=0; i<d; i++){
//    ans*=100;
//  }
//
//  cout<<n*ans<<en
//}

int main(){
  int n;
  cin>>n;
  int ans=0;
  for(int i=0; i<n; i++){
    int a;
    cin>>a;
    while(a%2==0){
      a/=2;
      ans++;
    }
  }

  cout<<ans<<en
}

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

int main(){
    int n, s, d;
    cin >> n;
    while(n-- > 0){
        cin >> s >> d;
        int ans = 0;
        while(s != d){
            int p;
            for(int i = 0; i < 31; i++){
                if(s%(1<<i) == 0 && s+(1<<i) <= d)   p = i;
            }
            ans++;
            s += (1<<p);
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3136
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <climits> // FOO_MAX, FOO_MIN
#include <cmath> 
#include <cstdlib> // abs(int)
#include <numeric>
#include <iomanip>
#include <map>
#include <set>

using namespace std;

#define roundup(n,d) ( ((n) + ((d)-1)) / (d) )
#define assign_max(into, compared) (into = max((into), (compared)))
#define assign_min(into, compared) (into = min((into), (compared)))
#define rep(i,n) for(long long i = 0;i < n;++i)
#define FAST_IO ios::sync_with_stdio(false); cin.tie(nullptr);
#define fix(n) fixed << setprecision(n)
#define ALL(v) v.begin(),v.end()

#define PI 3.14159265358979323846;

using ll = long long;
using ull = unsigned long long;
using vll = vector<long long>;


int main(void){
    FAST_IO
    string days[7] = {"SUN","MON","TUE","WED","THU","FRI","SAT"};

    string s;
    cin >> s;
    ll ans = 0;
    rep(i,7){
        if(days[i] == s){
            ans = 7 - i;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3144
//
// Created by munaiyi on 2020/3/26.
//
#include <bits/stdc++.h>

using namespace std;

const int mod = 998244353;
const int maxn = 3e3 + 5;

int dp[maxn][maxn];
int a[maxn];

int main() {
    int n, s;
    scanf("%d%d", &n, &s);
    for (int i = 1; i <= n; i++) {
        scanf("%d", a + i);
    }
    memset(dp, 0, sizeof(dp));
    dp[1][0] = 1;
    dp[1][a[1]] = 1;
    for (int i = 2; i <= n; i++) {
        for (int j = 0; j <= s; j++) {
            dp[i][j] = dp[i - 1][j];
            if (j >= a[i]) {
                dp[i][j] = dp[i][j] + dp[i - 1][j - a[i]];
                if (dp[i][j] >= mod) dp[i][j] -= mod;
            }
        }
        dp[i][0]++;
        dp[i][a[i]]++;
    }
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        ans += dp[i][s];
        if (ans >= mod) ans -= mod;
    }
    printf("%d\n", ans);
    return 0;
}


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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define log_2(a) (log((a)) / log(2))
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

int root[SIZE];
LL sz[SIZE];

void init() {
    for(int i = 0; i < SIZE; ++i) {
        root[i] = i;
        sz[i] = 1;
    }
}

int Root(int x) {
    if(x == root[x]) return x;

    int rt = Root(root[x]);
    sz[x] = sz[rt];
    return rt;
}

bool Unite(int x, int y) {
    int rx, ry;
    rx = Root(x);
    ry = Root(y);

    if(rx == ry) return false;
    if(sz[rx] > sz[ry]) {
        root[ry] = rx;
    } else {
        root[rx] = ry;
    }

    sz[rx] += sz[ry];
    sz[ry] = sz[rx];
    return true;
}

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

    LL N, M;
    cin >> N >> M;
    init();

    vector<P> v(M);
    for(int i = 0; i < M; ++i) {
        cin >> v[i].F >> v[i].S;
    }

    LL res = N * (N - 1) / 2;
    vector<LL> r;
    for(int i = M - 1; i >= 0; --i) {
        r.pb(res);
        Root(v[i].F);
        Root(v[i].S);
        LL a = sz[v[i].F];
        LL b = sz[v[i].S];
        if(Unite(v[i].F, v[i].S)) {
            res -= a * b;
        }
    }
    reverse(all(r));

    for(int i = 0; i < r.size(); ++i) {
        cout << r[i] << endl;
    }

    return 0;
}



Measured memory_bytes: 7376
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <math.h>
#include <numeric>
#include <set>
#include <list>
#include <bitset>
using namespace std;

int main()
{
    int N;
    cin >> N;
    set<char> S;
    string ans[2] = {"Three", "Four"};
    for (int i = 0; i < N; i++)
    {
        char s;
        cin >> s;
        S.insert(s);
    }
    cout << ans[S.size() - 3] << endl;
    return 0;
}

Measured memory_bytes: 256
// atcoder/abc130/E/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }


int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n, m;
  while (cin >> n >> m) {
    vector<int> s(n);
    vector<int> t(m);
    const int N = 2 * 1000 + 5;
    const lli mod = 1e9 + 7;
    cin >> s >> t;

    static lli dp[N][N];
    fill(&dp[0][0], &dp[N - 1][N - 1] + 1, 0);

    static lli sum[N][N];
    fill(&sum[0][0], &sum[N - 1][N - 1] + 1, 0);

    for (int i = 1; i <= s.size(); ++i) {
      for (int j = 1; j <= t.size(); ++j) {
        dp[i][j] = 0;
        if (s[i-1] == t[j-1]) {
          dp[i][j] = sum[i - 1][j - 1] + 1;
        }

        sum[i][j] += sum[i - 1][j];
        sum[i][j] += sum[i][j - 1];
        sum[i][j] -= sum[i - 1][j - 1];
        sum[i][j] += mod + dp[i][j];
        sum[i][j] %= mod;
      }
    }

    lli x = 0;
    for (int i = 0; i <= s.size(); ++i) {
      for (int j = 0; j <= t.size(); ++j) {
        x += dp[i][j];
        x %= mod;
      }
    }
    cout << (x + 1) % mod << endl;
  }

  return 0;
}


Measured memory_bytes: 63104
import kotlin.Long as Num

const val mod=1000000007

fun modpow(n:Num,p:Num=mod-2L):Num=when {
	p==0L->1L
	p%2==1L->n*modpow(n,p-1)%mod
	else-> {
		val d=modpow(n,p/2)
		d*d%mod
	}
}

fun nCr(n:Num,r:Num):Num {
	if(n-r<r)
		return nCr(n,n-r)
	var res=1L
	for(i in n-r+1..n) {
		res*=i
		res%=mod
	}
	for(i in 2..r) {
		res*=modpow(i)
		res%=mod
	}
	return res
}

fun main(args:Array<String>) {
	val (n,a,b)=readLine()!!.split(" ").map {it.toLong()}

	val t=modpow(2,n)
	val u=nCr(n,a)
	val v=nCr(n,b)
	println((t+mod*2-1-u-v)%mod)
}


Measured memory_bytes: 37768
#include <functional>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <iomanip>
#include <utility>
#include <cstdlib>
#include <sstream>
#include <bitset>
#include <vector>
#include <cstdio>
#include <ctime>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <list>
#include <map>
#include <set>

using namespace std;

typedef vector<int> VI;
typedef pair<int,int> PII;
typedef long long ll;

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(a)  (a).begin(),(a).end()
#define PB push_back
#define sz size()

const double EPS = 1e-10;
const int INF = 100000000;

int main(){
    int n;
    cin>>n;
    rep(i,n){
        int s;
        cin>>s;
        cout<<"Case "<<i+1<<":"<<endl;
        rep(j,10){
            s=(s*s)/100;
            s%=10000;
            cout<<s<<endl;
        }
    }
    
    return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<stack<int>> S(n);
  int q;
  cin >> q;
  for (int i = 0; i < q; i++){
    int s;
    cin >> s;
    if (s == 0){
      int t, x;
      cin >> t >> x;
      S[t].push(x);
    }
    if (s == 1){
      int t;
      cin >> t;
      if (!S[t].empty()){
        cout << S[t].top() << endl;
      }
    }
    if (s == 2){
      int t;
      cin >> t;
      if (!S[t].empty()){
        S[t].pop();
      }
    }
  }
}


Measured memory_bytes: 4256
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(X,Y) ((X)>(Y)?X=(Y),true:false)
#define chmax(X,Y) ((X)<(Y)?X=(Y),true:false)
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

typedef vector<int> vertex;
typedef vector<vertex> graph;

#define N 112345
int n;
graph g;
bool used[N];

int dfs(int x){
	used[x] = true;
	int r = 0;
	for(int y: g[x]){
		if(used[y]) continue;
		r ^= dfs(y);
	}
	return r+1;
}

int main(){
	cin>>n;
	g = graph(n);
	rep(i, n-1){
		int x, y;
		cin>>x>>y; x--; y--;
		g[x].push_back(y);
		g[y].push_back(x);
	}
	cout<<(dfs(0)-1?"Alice":"Bob")<<endl;
	return 0;
}


Measured memory_bytes: 8960
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
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; }

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) do{}while(0)
#endif



vector<int> v[100001];
ll n, m;

int dfs( int node, int parent ){
	if ( v[node].size() > 2 )
		return node;
	for ( auto next_node : v[node] ){
		if( next_node == parent )
			continue;
		return dfs(next_node, node);
	}
	return -1; //
}

bool test(){
	vector<int> node; // 4方向に道があるノード
	bool node6 = false;
	rep(i,n){
		int s = SZ(v[i]);
		if ( s % 2 ){
			return false;
		}
		if ( s >= 6 ){
			node6 = true;
		}
		if ( s >= 4 )
			node.push_back(i);
	}
	
	if ( node6 )
		return true;
	
	if ( SZ(node) >= 3 ){
		return true;
	}
	if ( SZ(node) < 2 ){
		return false;
	}
	
	for ( auto next_node : v[node[0]] ){
		if ( dfs( next_node, node[0] ) == node[0] ){
			return true;
		}
	}
	return false;
}

int main(){
	cin >> n >> m;
	
	rep(i,m){
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	
	if ( test() ){
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	
	return 0;
}




Measured memory_bytes: 9080
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;

const int mod = 1e9 + 7;
int k;
string s;
long long fac[2000001][2];

long long modpow(long long a, long long b){
	if(!b) return 1;
	long long ret = modpow(a, b / 2);
	ret = (ret * ret) % mod;
	if(b % 2) ret = (ret * a) % mod;
	return ret;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> k >> s;
	int n = (int)s.length();
	fac[0][0] = fac[0][1] = 1;
	for(int i = 1; i <= n + k; i++){
		fac[i][0] = (fac[i - 1][0] * i) % mod;
		fac[i][1] = modpow(fac[i][0], mod - 2);
	}
	long long ans = 0;
	for(int i = 0; i <= k; i++){
		long long one = ((fac[n + k - i - 1][0] * fac[n - 1][1]) % mod * fac[k - i][1]) % mod;
		long long two = (modpow(26, i) * modpow(25, k - i)) % mod;
		ans = (ans + (one * two) % mod) % mod;
	}
	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 35620
#include <bits/stdc++.h>
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
using ll = long long;
using ull = unsigned long long;
ll mod = 1e9 + 7;


int main(){
	

	int N, D; std::cin >> N >> D;

	if(N % (D * 2 + 1) == 0)std::cout << N / (D * 2 + 1);
	else std::cout << N / (D * 2 + 1) + 1;


	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <bitset>
#include <stack>
#include <deque>
using namespace std;
typedef pair<int, int> pii;
typedef long long LL;
const int MAXN = 1234;
LL a[MAXN];

int main() {
    int N, K;
    while (~scanf("%d %d", &N, &K)) {
          vector<LL> V1;
          for (int i = 0; i < N; i++) {
              scanf("%lld", &a[i]);
          }
          for (int i = 0; i < N; i++) {
              LL sum = 0;
              for (int j = i; j < N; j++) {
                  sum += a[j];
                  V1.push_back(sum);
              }
          }
          LL ans = 0;
          for (LL i = 40; i >= 0; i--) {
              LL tmp = ((LL)1 << i);
              ans |= tmp;
              int cnt = 0;
              for (auto i : V1) {
                  if ((i & ans) >= ans) cnt++;
              }
              if (cnt < K) ans ^= tmp;
          }
          printf("%lld\n", ans);
    }
    return 0;
}


Measured memory_bytes: 6128
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
using namespace std;
const int mod = 1000000007;
#define ll long long

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

ll A[100010];
ll B[100010], C[100010];
ll G[100010];
int main()
{
	int N; cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	B[0] = 0;
	C[N] = 0;
	for (int i = 0; i < N - 1; i++) {
		B[i + 1] = gcd(B[i], A[i]);
	}
	for (int i = N - 1; i > 0; i--) {
		C[i] = gcd(C[i + 1], A[i]);
	}
	for (int i = 0; i < N; i++) {
		G[i] = gcd(B[i], C[i + 1]);
	}
	sort(G, G + N,greater<ll>());
	cout << G[0] << endl;
}

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

namespace ABC087A
{
    class Program
    {
        static void Main(string[] args)
        {
            
            int x, a, b, c;

            x = int.Parse(Console.ReadLine());
            a = int.Parse(Console.ReadLine());
            b = int.Parse(Console.ReadLine());

            c = (x - a) % b;

            Console.WriteLine(c);
            Console.ReadKey();
         }
    }
}


Measured memory_bytes: 11092
def main():
    r_p_formula = list(input().split())
    
    stack = []
    res = 0
    for element in r_p_formula:
        try:
            num = int(element)
            stack.append(num)
            
        except ValueError:
            last_num = stack.pop()
            sec_last_num = stack.pop()
            stack.append(calc(sec_last_num, last_num, element))
            
    print(stack.pop())

def calc(num1, num2, ope):
    if ope == "+":
        return num1 + num2
    elif ope == "-":
        return num1 - num2
    elif ope == "*":
        return num1 * num2
    else:
        return 0

if __name__ == '__main__':
    main()
    


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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

li n;

int main() {
    cin >> n;
    double res = 0;
    rin{
        double val;
        string typ;
        cin >> val >> typ;
        if (typ == "BTC") {
            val *= 380000;
        }
        res += val;
    }

    printf("%.12f\n", res);


    return 0;
}

Measured memory_bytes: 256
n=int(input())
div=[0]*(n+10)
for i in range(1,n+1):
  k=i
  for j in range(1,int(i**0.5)+1):
    cnt=0
    while k%(j+1)==0:
      k//=(j+1)
      cnt+=1
    div[j+1]+=cnt
  if k>1:
    div[k]+=1
ans=0
d=dict()
for i,j,k in [[4,4,2],[24,2,1000],[14,4,1000],[74,1000,1000]]:
  cnti,cntj,cntk=0,0,0
  for l in range(2,n+1):
    if j==1000 and k==1000:
      if div[l]>=i:
        ans+=1
    for m in range(2,n+1):
      if l!=m and j!=1000 and k==1000:
        if div[l]>=i and div[m]>=j:
            ans+=1
      for o in range(2,n+1):
        if (m,l) not in d:
          if l!=o and l!=m and m!=o:
            if i!=1000 and j!=1000 and k!=1000:
              if div[l]>=i and div[m]>=j and div[o]>=k:
                ans+=1
                d[(l,m)]=0
print(ans)

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

int main(){
 char number[1001];

 while(1){
  int sum=0, count=0;
  scanf( "%s", number );
  if( number[0] == '0' ){
    break;
  }

  while( number[count] != '\0' ){
    sum += number[count] - '0';
    count++;
  }

  cout << sum << endl;
 }

 return 0;
}


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

using namespace std;

int main(){
	size_t N;
	string S;
	int cnt[2];
	int i;
	
	cin >> S;
	
	N=S.length();
	
	cnt[0]=0;
	cnt[1]=0;
	for(i=0; i<N; i++){
		if(S[i]=='0')	cnt[0]++;
		if(S[i]=='1')	cnt[1]++;
	}
	
	cout << 2*min(cnt[0],cnt[1]) << endl;
	
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d", &x)
#define sz(v) (int) v.size()
#define pr(v) For(i, 0, sz(v)) {cout<<v[i]<<" ";} cout<<endl;
#define slld(x) scanf("%lld", &x)
#define all(x) x.begin(), x.end()
#define For(i, st, en) for(ll i=st; i<en; i++)
#define tr(x) for(auto it=x.begin(); it!=x.end(); it++)
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define ll long long
#define int long long
#define mp make_pair
#define F first
#define S second
typedef pair<int, int> pii;
typedef vector<int> vi;
#define MOD 1000000007
#define INF 1000000000000000007LL

const int N = 100005;
 
// it's swapnil07 ;)
 
#ifdef SWAPNIL07
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
int begtime = clock();
#define end_routine() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
#else
#define endl '\n'
#define trace(...)
#define end_routine()
#endif


signed main()
{
    fast
    #ifdef SWAPNIL07
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    int a, b, k; cin>>a>>b>>k;
    int ans = (b/k)-(a-1)/k;
    if(a==0 && k>1)
        ans++;
    cout<<ans;
    return 0;
}




Measured memory_bytes: 256
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        a: [u64; n],
    }
    let mut ans = "second";
    for i in 0..n {
        if a[i] % 2 == 1 {
            ans = "first";
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
using namespace std;
int main() {
	int N, X, L[102], D = 0, sum = 1;
	cin >> N >> X;
	for (int i = 0; i < N; i++) {
		cin >> L[i];
		D = D + L[i];


		if (D > X) {
			cout << sum << endl;
			return 0;
		}
		sum = sum + 1;
		if (sum >= N + 1) {
			cout << N + 1 << endl;
			return 0;
		}
	}
		cout << sum << endl;
		return 0;
	}





Measured memory_bytes: 256
from collections import defaultdict
n = int(input())
A = list(map(int, input().split()))
dd = defaultdict(int)
dd[0] += 1
S = [0]*(n+1)
for i in range(n):
    S[i+1] = S[i]+A[i]
    dd[S[i+1]] += 1
print(sum(v*(v-1)//2 for v in dd.values()))


Measured memory_bytes: 40868