akhauriyash/Code-Regression huggingface dataset:
import numpy as np
m,n=map(int,input().split())
x=[]
for i in range(m):
  a=list(map(int,input().split()))
  x.append(a)
y=[]
for i in range(m):
  z=[0,0,0,0,0,0,0,0]
  z[0]=x[i][0]+x[i][1]+x[i][2]
  z[1]=x[i][0]+x[i][1]-x[i][2]
  z[2]=x[i][0]-x[i][1]+x[i][2]
  z[3]=x[i][0]-x[i][1]-x[i][2]
  z[4]=-x[i][0]+x[i][1]+x[i][2]
  z[5]=-x[i][0]+x[i][1]-x[i][2]
  z[6]=-x[i][0]-x[i][1]+x[i][2]
  z[7]=-x[i][0]-x[i][1]-x[i][2]
  y.append(z)
p=np.array(y)
sidx = p.argsort(axis=0)
p=p[sidx, np.arange(sidx.shape[1])]
z=[0,0,0,0,0,0,0,0]
for i in range(m-1,m-n-1,-1):
  for j in range(8):
  	z[j]+=p[i][j]
print(max(z))

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

int main(){
    int n, k;
    char s[15], tmp;
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> s[i];
    }
    cin >> k;
    tmp = s[k-1];
    for(int i = 0; i < n; i++){
        if(s[i] != tmp){
            s[i] = '*';
        }
        cout << s[i];
    }
    cout << endl;
}


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

int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    int ans = 0;
    for(int i = 1; i < n; i++){
        vector<int> x(26, 0), y(26, 0);
        for(int j = 0; j < i; j++){
            x[s[j]-'a'] = 1;
        }
        for(int j = i; j < n; j++){
            y[s[j]-'a'] = 1;
        }
        int coans = 0;
        for(int j = 0; j < 26; j++){
            if(x[j] == 1 && y[j] == 1) coans++;
        }
        if(ans < coans) ans = coans;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>

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

        if(a > 9) {
                printf("%d", -1);
                return 0;
        }
        if(b > 9) {
                printf("%d", -1);
                return 0;
        }
        printf("%d", a*b);
        return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;
int GCD(int x, int y) {
    return x ? GCD(y % x, x) : y;
}

int main(){
	int n,k,a[101010]={},f=1;
	string ans[2]={"POSSIBLE","IMPOSSIBLE"};
	cin>>n>>k;
	FOR(i,0,n){
		cin>>a[i];
		if(a[i]==k){
			cout<<ans[0]<<endl;
			return 0;
		}
	}
	sort(a,a+n);
	int g=a[0];
	FOR(i,1,n){
		g=GCD(g,a[i]);
	}
	if(k%g==0&&k<=a[n-1])f=0;

	cout<<ans[f]<<endl;
    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>
#include<limits>
#include<bitset>
#include<functional>
#include<type_traits>
#include<queue>
#include<stack>
#include<array>
#include<random>
#include<utility>
#include<cstdlib>
#include<ctime>

using namespace std;

typedef  long long ll;
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep2(i, begin_i, end_i) for (int i = (int)begin_i; i < (int)end_i; i++)

long long INF = 1LL<<60;
long long dp[100010];
int h[100010];
int x;
int c[3][3];
int a[3],b[3];
int row[3];
int column[3];
int main(){
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            cin>>c[i][j];
        }
    }
    rep(i,3){b[i]=c[0][i];}
    rep(i,3)a[i]=c[i][0]-b[0];
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            if(a[i]+b[j]!=c[i][j]){
                cout<<"No"<<endl;
                return 0;
            }
        }
    }
     cout<<"Yes"<<endl;
     return 0;
}




Measured memory_bytes: 256
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)*}
    };
}

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, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

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

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
fn mod_pow(x: i64, y: i64, z: i64) -> i64 {
    if y == 0 {
        1
    } else {
        let h = mod_pow(x, y / 2, z);
        let res = (h * h) % z;
        if y % 2 == 0 {
            res
        } else {
            (res * x) % z
        }
    }
}
fn main() {
    input!{
        N: i64,
    }
    let M:i64 = 1_000_000_007;
    let ans = (M + mod_pow(10, N, M) - (mod_pow(9, N, M) * 2 % M - mod_pow(8, N, M)) % M)%M;
    println!("{}", ans);
}


Measured memory_bytes: 2184
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <math.h>

#define PREP(i, m, n) for(int i = m; i < n; i++)
#define MREP(i, m, n) for(int i = m - 1; i >= n; i--)

#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()
#define X first
#define Y second
#define MP make_pair
#define PB push_back

using namespace std;

int main(){
	string chl = "xxkstnhmyr";
	string mot = "aiueo";
	string dir = "TLURD";
	map<char, int> m;
	rep(i, dir.size()) m[dir[i]] = i;

	string s;
	cin >> s;
	for(int i = 0; i < s.size(); i += 2){
		int t = s[i] - '0';
		int t2 = m[s[i+1]];
		if(t == 0){
			string str[] = {"wa", "", "nn", "", "wo"};
			cout << str[t2];
		}else{
			if(t > 1) cout << chl[t];
			cout << mot[t2];
		}
	}
	cout << endl;


	return 0;
}

Measured memory_bytes: 1196
#include <float.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部定数
#define D_HUMAN_MAX		100										// 最大人数
#define D_POS_MAX		105										// 最大位置

// 内部変数
static FILE *szpFpI;											// 入力
static int siHCnt;												// 人数
static int si1Pos[D_HUMAN_MAX];									// 位置[人]

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpA;
	static int siTNo;
#endif

// １行出力
int
fOutLine(
	char *pcpLine				// <I> １行
)
{
	char lc1Buf[1024];

#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, pcpLine)) {
		siRes = -1;
	}
#else
	printf("%s", pcpLine);
#endif

	return 0;
}

// 実行メイン
int
fMain(
)
{
	int i, j;
	char lc1Buf[1024];

	// 人数 - 取得
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
	sscanf(lc1Buf, "%d", &siHCnt);

	// 位置 - 取得
	for (i = 0; i < siHCnt; i++) {
		fscanf(szpFpI, "%d", &si1Pos[i]);
	}
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);

	// 総和 - セット
	int liMin = INT_MAX;
	for (i = 1; i < D_POS_MAX; i++) {
		int liSum = 0;
		for (j = 0; j < siHCnt; j++) {
			int liLen = i - si1Pos[j];
			liSum += liLen * liLen;
		}

		// 最小値 - 更新
		if (liMin > liSum) {
			liMin = liSum;
		}
	}

	return liMin;
}

// １回実行
int
fOne(
)
{
	int liRet;
	char lc1Buf[1024];

	// 入力 - セット
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", siTNo);
	szpFpI = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", siTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#else
	szpFpI = stdin;
#endif

	// 実行メイン
	liRet = fMain();

	// 出力
	sprintf(lc1Buf, "%d\n", liRet);
	fOutLine(lc1Buf);

	// 残データ有無
#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, "")) {
		siRes = -1;
	}
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpI);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", siTNo);
	}
	else {
		printf("NG %d\n", siTNo);
	}
#endif

	return 0;
}

// プログラム開始
int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		siTNo = i;
		fOne();
	}
#else
	fOne();
#endif

	return 0;
}



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

int main()
{
	int N,M;
	cin >> N >> M;
	if (N == M)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
	return 0;
}

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

int main(){
	string S;
	cin >> S;
	int N = S.size();
	int c1 = 0, c2 = 0;
	rep(i,N){
		if (i%2 == 0 && S[i] == '1') c1++;
		if (i%2 == 1 && S[i] == '0') c1++;
	}
	rep(i,N){
		if (i%2 == 0 && S[i] == '0') c2++;
		if (i%2 == 1 && S[i] == '1') c2++;
	}
	cout << min(c1,c2) << endl;

	return 0;
}


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

const int64_t MOD = 1000000007;

uint64_t PowerMod(uint64_t n, uint64_t k, uint64_t mod=MOD) {
    uint64_t ret = 1;
    while (k) {
        if (k & 1) {
            ret = ret * n % mod;
        }
        n = n * n % mod;
        k >>= 1;
    }
    return ret;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    int64_t numOrigin = 0;
    int64_t numVerticle = 0;
    int64_t numHorizontal = 0;
    map<pair<int,int>, pair<int,int>> m;

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

        if (a == 0 && b == 0) ++numOrigin;
        else if (a == 0) ++numHorizontal;
        else if (b == 0) ++numVerticle;
        else {
            bool sign = true;
            if (a < 0) {
                a = -a;
                sign = !sign;
            }
            if (b < 0) {
                b = -b;
                sign = !sign;
            }
            auto gcd = __gcd(a, b);
            a /= gcd;
            b /= gcd;
            if (!sign) {
                swap(a, b);
            }
            auto key = make_pair(a, b);
            if (!m.count(key)) {
                m[key] = make_pair(0, 0);
            }
            if (sign) ++m[key].second;
            else ++m[key].first;
        }
    }

    uint64_t ans = 1;
    for (const auto &p : m) {
        ans = (ans * (PowerMod(2, p.second.first) + PowerMod(2, p.second.second) + MOD - 1)) % MOD;
    }
    ans = (ans * (PowerMod(2, numVerticle) + PowerMod(2, numHorizontal) + MOD - 1)) % MOD;
    ans = (ans + numOrigin) % MOD;
    ans = (ans + MOD - 1) % MOD;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 16056
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;

int main() {
	int n;
	cin >> n;
	int c1 = 0, c2 = 0;
	for (int i = 0; i < n; i++) {
		string a, b;
		cin >> a >> b;
		if (a > b) {
			c1 +=3;
		}
		else if (a == b) {
			c1++;
			c2++;
		}
		else {
			c2 += 3;
		}
	}
	cout << c1 << " " << c2 << endl;
	return 0;
}



Measured memory_bytes: 3152
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using P   = pair<ll, ll>;
using mat = vector<vector<ll>>;
typedef string::const_iterator State;
class ParseError {};

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

const ll INF = 1e16;
const ll MOD = 1e9 + 7;
const ld EPS = 1e-12;

template <typename T>
void dump(T x) { cout << x << endl; }
void dumpf(ld x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
inline ll mod(ll a, ll b) {
	if (a > 0) return a % b;
	if (a % b == 0) return 0;
	ll x = -a / b + 1;
	a += x * b;
	return a % b;
}
ll powm(ll a, ll b, ll c) {
	if (b == 0)
		return 1;
	else if (b % 2 == 0) {
		ll d = powm(a, b / 2, c);
		return (d * d) % c;
	} else
		return (a * powm(a, b - 1, c)) % c;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
//ll dx[4] = {1, 0, -1, 0};
//ll dy[4] = {0, 1, 0, -1};

int main() {
	IOS();
	ll h, w, n;
	cin >> h >> w >> n;
	map<P, bool> mp;
	for (int i = 0; i < n; i++) {
		ll x, y;
		cin >> x >> y;
		mp[P(x, y)] = true;
	}
	ll ymax = 1;
	for (int i = 1; i <= h; i++) {
		//dump(ymax);
		P l = P(i + 1, 1), r = P(i + 1, ymax + 1);
		if (mp.lower_bound(r) != mp.lower_bound(l)) { // x >= l ⇔ x >= r
			dump(i);								  //x方向に動かせるか
			return 0;
		}
		if (!mp[P(i + 1, ymax + 1)]) ymax++;
	}
	dump(h);
	return 0;
}


Measured memory_bytes: 21888
N,Y=map(int,input().split())
Y=Y//1000
ans=[-1,-1,-1]
for i in range(N+1):
    for j in range(N-i+1):
        if 10*i+5*j+N-i-j==Y:
                ans=[i,j,N-i-j]
                break
print(ans[0],ans[1],ans[2])

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Text;

namespace AtTest.C_Challenge
{
    class ABC_058
    {
        static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        static void Method(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            var alphabets = new int[26];
            for (int i = 0; i < n; i++)
            {
                string s = Console.ReadLine();
                var alphaTemp = new int[26];
                for(int j = 0; j < s.Length; j++)
                {
                    alphaTemp[s[j] - 'a']++;
                }
                for(int j = 0; j < 26; j++)
                {
                    if (i == 0 || alphaTemp[j] < alphabets[j])
                    {
                        alphabets[j] = alphaTemp[j];
                    }
                }
            }
            for(int i = 0; i < 26; i++)
            {
                for(int j = 0; j < alphabets[i]; j++)
                {
                    Console.Write((char)('a' + i));
                }
            }
            Console.WriteLine("");
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define rep(i,x,y) for (int i = x; i <= y; i ++)
#define dep(i,y,x) for (int i = y; i >= x; i --)
#define sz() (int)(x.size())
 
using namespace std;
typedef long long LL;   
 
const int N = 200000 + 7;
 
int n,a[N],temp[N],u[N],T[N * 4];
LL s[N],K,ans;
 
bool cmp(int x,int y) {return s[x]<s[y];}
 
void init()
{
    rep(i,0,n) u[i] = i;
    sort(u, u + n + 1, cmp);
 
    temp[u[0]]=1;
    rep(i,1,n) if (s[u[i]]!=s[u[i-1]]) temp[u[i]]=temp[u[i-1]]+1; else temp[u[i]]=temp[u[i-1]];
    rep(i,0,n) a[i]=temp[i];
}
 
void add(int k,int l,int r,int x)
{
    if (l == r) ++ T[k];
    else
    {
        int mid = (l + r) >> 1;
        if (x <= mid) add((k << 1), l, mid, x); 
        else add((k << 1) | 1, mid + 1, r, x);
        ++ T[k];
    }
}
 
int query(int k,int l,int r,int x,int y)
{
    if ((x<=l)&&(r<=y))
        return T[k];
    else
    {
        int mid=(l+r)>>1,ans=0;
        if (x<=mid) ans+=query((k<<1),l,mid,x,y);
        if (y>mid) ans+=query((k<<1)|1,mid+1,r,x,y);
        return ans;
    }
}
 
int main()
{
    scanf("%d%lld",&n,&K);
    rep(i,1,n) scanf("%lld",&s[i]),s[i]-=K;
 
    rep(i,1,n) s[i]+=s[i-1];
 
    init();
 
    add(1,1,n,a[n]);
    dep(i,n-1,0)
    {
        ans+=(LL)(query(1,1,n,a[i],n));
        add(1,1,n,a[i]);
    }
 
    printf("%lld\n",ans);
 
    // system("pause");
    return 0;
}

Measured memory_bytes: 7296
S=input()
l=len(S)
dp1=[0]*l
dp2=[0]*l
dp1[0]=1
for i in range(1,l):
    if S[i-1]!=S[i]:
        dp1[i]=max(dp1[i-1],dp2[i-1])+1
    else:
        dp1[i]=dp2[i-1]+1
    if i==1:
        dp2[i]=1
        continue
    if i==2:
        dp2[i]=max(dp1[i-2],dp2[i-2])+1
        continue
    if S[i-3:i-1]!=S[i-1:i+1]:
        dp2[i]=max(dp1[i-2],dp2[i-2])+1
    else:
        dp2[i]=dp1[i-2]+1
    
print(max(dp1[l-1],dp2[l-1]))

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

int main(){
    int N, k, Flag=0;
    string S;
    cin >> N >> S;
    if(N%2==1){
        cout << "No" << endl;
    }else{
        for(int i=0; i < N/2; ++i){
            k = N/2;
            k +=i;
            if(S.at(i) != S.at(k)){
                Flag=1;
                break;
            }
        }
        if(Flag==1){
            cout << "No" << endl;
        }else{
            cout << "Yes" << endl;
        }
    }
}

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

int main (){
  int A,B,C,D;
  cin>>A>>B>>C>>D;
  while(1){
  C-=B;
  if(C<=0){
    cout<<"Yes";
    return 0;
  }
  A-=D;
  if(A<=0){
    cout<<"No";
    return 0;
  }
}
}


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

#define all(v)  begin(v), end(v)
#define endl    '\n';
#define int     long long
#define pii     pair<int, int>
#define sz(x)   (int) x.size()

void test_case() {
    int n;
    cin >> n;

    int ans = 0;

    for (int a = 1; a < n; a++) {
        int b = n / a;
        if (n % a == 0) {
            b -= 1;
        }
        ans += b;
    }
    cout << ans << endl;
}

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

    int t = 1;
    // cin >> t;

    while (t--) { 
        test_case();
    }
    return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll mod=1000000007;
ll MOD=998244353;
int inf=1000001000;
ll INF=100000000000000000;


int main() {
    int v,E;
    cin >> v >> E;
    vector<vector<pp>> e(v+1,vector<pp>(0));
    rep(i,E){
        int f,g,h;
        cin >> f >> g >> h;
        e[f].push_back(mk(g,h));
        e[g].push_back(mk(f,h));
    } 
    rep(i,v) {
        int f;
        cin >> f;
    }
    int t;
    cin >> t;
    rep(i,80){
        cout << -1 << endl;
        t--;
        if (t==0) return 0;
    }
    queue<int> q;
    q.push(1);
    while(true){
        int f=q.front();
        int u=rand()%e[f].size();
        q.pop();
        q.push(e[f][u].first);
        rep(i,e[f][u].second){
            cout << e[f][u].first << endl;
            t--;
            if (t==0) return 0;
        }
    }
}


Measured memory_bytes: 1228
n = int(input())
lis = [[] for _ in range(n)]

for i in range(n):
    a = int(input())
    for _ in range(a):
        x,y = map(int,input().split())
        lis[i].append((x-1,y))
ans = 0
for i in range(1, 1 << n):
    flag = True
    for j in range(n):
        if (i >> j) & 1 == 0: #j人目が正直者でないか?
            continue
        for x,y in lis[j]:
            if (i>>x) & 1 != y: #仮定と結果が異なる
                flag = False
                break
        if not flag:
            break
    if flag:
        ans = max(ans,bin(i)[2:].count('1')) #iの2進数の1の個数(0x抜き)
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;
typedef int64_t ll;


int main() {
    vector<int> a(4);
    for (int i = 0; i < 4; i++){
        cin >> a.at(i);
    }
    sort(ALL(a));
    cout << abs(a.at(0) + a.at(3) - a.at(1) - a.at(2)) << endl;
    

}



Measured memory_bytes: 3164
using System;

public class Problem_B
{
  public static void Main(string[] args)
  {
    var inputs = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
    int n = inputs[0], m = inputs[1], x = inputs[2];
    var a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);

    var min = Math.Min(x, Math.Abs(n - x));
    var cost1 = 0;
    for (var i = x; i < n; i++)
    {
      foreach (var gate in a)
        if (gate == i) cost1++;
    }
    var cost2 = 0;
    for (var i = x; i >= 0; i--)
    {
      foreach (var gate in a)
        if (gate == i) cost2++;
    }
    Console.WriteLine($"{Math.Min(cost1, cost2)}");
  }
}


Measured memory_bytes: 13268
N = gets.to_i
INF = 1e8
xmx = [-INF]*4
ymx = [-INF]*4
xmn = [INF]*4
ymn = [INF]*4
N.times do |i|
    *xy, d = gets.split
    x, y = xy.map(&:to_f)
    d = "RLUD".index(d)
    xmx[d] = [xmx[d], x].max
    ymx[d] = [ymx[d], y].max
    xmn[d] = [xmn[d], x].min
    ymn[d] = [ymn[d], y].min
end

cand = []
[xmx, ymx, xmn, ymn].each do |arr|
    arr.each do |a|
        arr.each do |b|
            d = (a-b).abs
            cand.push(d)
            cand.push(d/2)
        end
    end
end

ans = 1e18
dx = [1, -1, 0, 0]
dy = [0, 0, 1, -1]
cand.each do |t|
    xmax = -INF
    ymax = -INF
    xmin = INF
    ymin = INF
    4.times do |k|
        xmax = [xmax, xmx[k] + t*dx[k]].max
        ymax = [ymax, ymx[k] + t*dy[k]].max
        xmin = [xmin, xmn[k] + t*dx[k]].min
        ymin = [ymin, ymn[k] + t*dy[k]].min
    end
    ans = [ans, (xmax-xmin)*(ymax-ymin)].min
end
puts ans

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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

void solve() {
    ll N;
    cin >> N;
    Vl cnts(26, L_INF);
    Vl tmps;
    for (ll i = 0; i < N; i++) {
        string s;
        cin >> s;
        tmps.assign(26, 0);
        for (const auto& c : s) {
            ++tmps[c - 'a'];
        }
        for (ll j = 0; j < 26; j++) {
            cnts[j] = min(cnts[j], tmps[j]);
        }
    }

    string ans;
    for (ll i = 0; i < 26; i++) {
        char c = (char)('a' + i);
        if (cnts[i] != L_INF) {
            for (ll j = 0; j < cnts[i]; j++) {
                ans += c;
            }
        }
    }

    cout << ans << "\n";
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    ofstream ofs("./in_out/output.txt");
    cout.rdbuf(ofs.rdbuf());
#endif
    solve();
    cout << flush;
    return 0;
}

Measured memory_bytes: 256
def main():
    N = int(input())
    n = 1
    # 1～n番目の問題を全部解いた時の点数が初めてN点以上になるnを求める
    while n * (n + 1) // 2 < N:
        n += 1
    # 後は間を抜いて、ジャストN点になるよう調整していく
    d = n * (n + 1) // 2 - N
    solve = [1] * (n + 1)  # 1-indexで扱うので0番目は使わない
    for i in range(n, 0, -1):
        if i <= d:
            d -= i
            solve[i] = 0
        if d == 0:
            break
    for i in range(1, n + 1):
        if solve[i] == 1:
            print(i)


if __name__ == '__main__':
    main()


Measured memory_bytes: 74500
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 100001;
const ll mod = 1e9+7;
int n, tot;
struct coo
{
    int x, y;
    int id;
}c[maxn];
bool cmp1(coo a, coo b){
  return a.x < b.x;
}
bool cmp2(coo a, coo b){
  return a.y < b.y;
}
int dx[maxn],dy[maxn];
struct Edge{
  int u, v;
  int cost;
}e[maxn];
bool cmp(Edge a, Edge b){
  return a.cost < b.cost;
}
int p[maxn];
int find(int x){return p[x] == x ? x : p[x] = find(p[x]);}
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);cout.tie(0);
  scanf("%d", &n);
  for(int i = 0; i <= n; i++) p[i] = i;
  for(int i = 1; i <= n; i++){
    scanf("%d%d", &dx[i], &dy[i]);
  }
  for(int i = 1; i <= n; i++)
  {
    c[i].x = dx[i]; c[i].y = dy[i];c[i].id = i;
  }
  sort(c+1,c+1+n,cmp1);
  for(int i = 1; i < n; i++){
    e[tot].u = c[i].id;
    e[tot].v = c[i+1].id;
    e[tot].cost = c[i+1].x - c[i].x;
    tot++;
  }
  sort(c+1,c+1+n,cmp2);
  for(int i = 1; i < n; i++){
    e[tot].u = c[i].id;
    e[tot].v = c[i+1].id;
    e[tot].cost = c[i+1].y - c[i].y;
    tot++;
  }
  sort(e,e+tot,cmp);
  ll ans = 0;
  int cnt = 0;
  for(int i = 0; i < tot; i++){
    int f = find(e[i].u);
    int t = find(e[i].v);
    if(f!=t){ans+=e[i].cost;p[t] = f;cnt++;}
    if(cnt == n-1)break;
  }
  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 3840
#include <stdio.h>
int main(){
 int n,i,a=0,p[20]={};
 scanf("%d",&n);
 for(i=0;i<n;i++)scanf("%d",&p[i]);
 for(i=1;i<n-1;i++)if(((p[i-1]<p[i])&&(p[i]<p[i+1]))||((p[i+1]<p[i])&&(p[i]<p[i-1])))a++;
 printf("%d\n",a);
 return 0;
}

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

int main() {
  int A, B;
  cin >> A >> B;

  int ans = 0;
  for (int x = A; x <= B; x++) {
    string s = to_string(x);
    if (s[0] == s[4] && s[1] == s[3]) ans += 1;
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

int N, M, L;
vector<vector<pair<int, int> > > WorkTable;
vector<int> UnitPrice;

int main() {
	int s, t, e;
	long long int salary;

	cin >> N >> M;
	WorkTable.resize(N);
	UnitPrice.resize(M);
	while (cin >> s >> t >> e, s) {
		WorkTable[s - 1].push_back(make_pair(t - 1, e));
	}
	cin >> L;
	for (int i = 0; i < L; ++i) {
		for (int j = 0; j < M; ++j) {
			cin >> UnitPrice[j];
		}

		for (int j = 0; j < N; ++j) {
			salary = 0;
			for (unsigned int k = 0; k < WorkTable[j].size(); ++k) {
				salary += WorkTable[j][k].second * UnitPrice[WorkTable[j][k].first];
			}
			cout << (j == 0 ? "" : " ") << salary;
		}
		cout << endl;
	}

}



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

int main(){
   int N,count;
   cin>>N;
   vector<int> vec(N);
   vector<int> vec_min(N);
   count=0;
  
   for(int i=0;i<N;i++){
      cin>>vec.at(i);
   }
   
   vec_min.at(0)=vec.at(0);
   for(int i=0;i<N-1;i++){
      vec_min.at(i+1)=min(vec_min.at(i),vec.at(i+1));
   }
  
   for(int i=0;i<N;i++){
      if(vec_min.at(i)==vec.at(i)){
         count++;
      }
   }
   cout<<count<<endl;
}


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

#define LL long long
#define LD long double
#define SC(t,x) static_cast<t>(x)
#define AR(t) vector < t >
#define PII pair < int, int >
#define PLL pair < LL, LL >
#define PIL pair < int, LL >
#define PLI pair < LL, int >
#define MP make_pair
#define PB push_back
#define PF push_front
#define POB pop_back
#define POF pop_front
#define PRF first
#define PRS second
#define INIT(ar,val) memset ( ar, val, sizeof ( ar ) )
#define lp(loop,start,end) for ( int loop = start; loop < end; ++loop )
#define lpd(loop,start,end) for ( int loop = start; loop > end; --loop )
#define lpi(loop,start,end) for ( int loop = start; loop <= end; ++loop )
#define lpdi(loop,start,end) for ( int loop = start; loop >= end; --loop )
#define qmax(a,b) (((a)>(b))?(a):(b))
#define qmin(a,b) (((a)<(b))?(a):(b))
#define qabs(a) (((a)>=0)?(a):(-(a)))

const int INF = 0x3fffffff;
const int SINF = 0x7fffffff;
const long long LINF = 0x3fffffffffffffff;
const long long SLINF = 0x7fffffffffffffff;
const int MAXN = 107;
const LD PI = acos ( -1.0 );
const LD EPS = 1e-11;

struct cT
{
	cT () : id ( 0 ), x ( 0 ), y ( 0 ), ans ( 0 ) {}
	cT ( int _x, int _y ) : id ( 0 ), x ( _x ), y ( _y ), ans ( 0 ) {}

	cT operator - ( const cT &a ) const
	{
		return cT ( x - a.x, y - a.y );
	}

	LL operator * ( const cT &a ) const
	{
		return SC ( LL, x ) * a.y - SC ( LL, y ) * a.x;
	}

	LL dot ( const cT &a ) const
	{
		return SC ( LL, x ) * a.y + SC ( LL, y ) * a.x;
	}

	bool operator < ( const cT &a ) const
	{
		return ( x ^ a.x ) ? ( x < a.x ) : ( y < a.y );
	}

	int id, x, y;
	LD ans;
}cr[MAXN];

int n;
int stk[MAXN];
LD ang[MAXN];

void init ();
void input ();
void work ();

LD getang ( int x, int y )
{
	LD ans = atan2 ( y, x );
	if ( ans < -EPS ) ans += 2 * PI;
	return ans;
}

LD dec ( LD x, LD y )
{
	LD ans = x - y;
	if ( ans < -EPS ) ans += 2 * PI;
	if ( ans > 2 * PI - EPS ) ans -= 2 * PI;
	return ans;
}



int main ()
{
	init ();
	input ();
	work ();
}



void init ()
{
	// Init Everything Here

	ios::sync_with_stdio ( false );
}

void input ()
{
	// input method

	cin >> n;
	lp ( i, 0, n ) cin >> cr[i].x >> cr[i].y, cr[i].id = i;
}

void work ()
{
	// main work

	sort ( cr, cr + n );

	int top = 0;
	stk[++top] = 0;
	lp ( i, 1, n ) {
		while ( top > 1 && ( cr[stk[top]] - cr[stk[top - 1]] ) * ( cr[i] - cr[stk[top]] ) <= 0 ) --top;
		stk[++top] = i;
	}
	int tmp = top;
	lpdi ( i, n - 2, 0 ) {
		while ( top > tmp && ( cr[stk[top]] - cr[stk[top - 1]] ) * ( cr[i] - cr[stk[top]] ) <= 0 ) --top;
		stk[++top] = i;
	}
	if ( top > 1 ) --top;

	stk[top + 1] = stk[1];
	lpi ( i, 1, top ) {
		ang[i] = getang ( cr[stk[i + 1]].y - cr[stk[i]].y, cr[stk[i]].x - cr[stk[i + 1]].x );
	}

	ang[0] = ang[top];
	lpi ( i, 1, top ) cr[stk[i]].ans = dec ( ang[i], ang[i - 1] ) / ( 2 * PI );

	sort ( cr, cr + n, [] ( cT &x, cT &y ) { return x.id < y.id; } );

	lp ( i, 0, n ) cout << setprecision ( 13 ) << fixed << cr[i].ans << endl;
}

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

typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> ii;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sz(vs) (ll)(vs.size())
#define rep(i,a,b) for (ll i = a; i < b; ++i)
#define rep_(i,a,b) for (ll i = a; i > b; --i)
#define endl '\n'
const ll mod = 1e9 + 7;

const ll maxn = 2e5 + 4;

ll n, a[maxn];

// #include "debug.h"
void solve() {
	cin >> n;
	ll current_max = 0;
	ll ans = 0;
	for (ll i = 0; i < n; ++i) {
		cin >> a[i];
		ans += max(0ll, current_max - a[i]);
		current_max = max(current_max, a[i]);
	}
	cout << ans;
}

void aux() {
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	cout<<fixed<<setprecision(10);
	aux();
	ll _ = 1;
	// cin>>_;
	while(_--) {
		solve();
	}
	return 0;
}

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

int main() {
    int N, M; cin >> N >> M;
    vector<vector<int> > s(M);
    for (int i = 0; i < M; ++i) {
        int k; cin >> k;
        for (int j = 0; j < k; ++j) {
            int a; cin >> a; --a;
            s[i].push_back(a);
        }
    }
    vector<int> p(M);
    for (int i = 0; i < M; ++i) cin >> p[i];
    
    long long res = 0;
    for (int bit = 0; bit < (1<<N); ++bit) {
        bool ok = true;
        for (int i = 0; i < M; ++i) {
            int con = 0;
            for (auto v : s[i]) {
                if (bit & (1<<v)) ++con;
            }
            if (con % 2 != p[i]) ok = false;
        }
        if (ok) ++res;
    }
    cout << res << endl;
}

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

using i64 = int_fast64_t;
using f64 = double;

constexpr i64 INF = INT_FAST64_MAX / 2;
constexpr f64 EPS = DBL_EPSILON;

void solve() {
    i64 n;
    cin >> n;
    for (i64 i = 1; i <= 3500; i++) {
        for (i64 j = 1; j <= 3500; j++) {
            i64 k1 = n * i * j;
            i64 k2 = 4 * i * j - n * (i + j);
            if (k2 > 0 && k1 % k2 == 0) {
                cout << i << " " << j << " " << k1 / k2 << endl;
                return;
            }
        }
    }
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}


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

using namespace std;

bool visited[100001];
int main()
{
    int n , nums = 0 , num;
    scanf("%d" , &n);
    for(int i = 0; i < n; i ++){
        scanf("%d" , &num);
        if(!visited[num]){
            nums ++;
            visited[num] = true;
        }
    }
    if(nums % 2 == 0){
        nums --;
    }
    printf("%d" , nums);
    return 0;
}


Measured memory_bytes: 384
N = int(input())
A = list(map(int,input().split()))
MAX = 10**18
ret = 1
flag = True
if 0 in A:
    print(0)
else:
    for a in A:
        ret *= a
        if ret > MAX:
            print(-1)
            flag = False
            break
    if flag and ret <= MAX:
        print(ret)

Measured memory_bytes: 21600
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[9]={1,0,-1,0,1,1,-1,-1,0};
const ll dx[9]={0,-1,0,1,1,-1,1,-1,0};
template<class T> inline bool chmin(T& a, T b) {
    if (a >= b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
ll digit(ll n){
    ll ret=0;
    while(n){
        ret+=n%10;n/=10;
    }
    return ret;
}
double g(ll n){
    if(n==0)return INF;
    return (double)n/digit(n);
}
int main(){
    ll k;cin >> k;
    vl pos;
    ll dig=0;
    while(dig<14){
        rep(i,1000){
            pos.pb(i*pow(10,dig)+pow(10,dig)-1);
            //cout << *pos.rbegin() <<endl;
        }
        dig++;
    }
    sort(all(pos));pos.erase(unique(all(pos)),pos.end());
    //cout << pos.size() <<endl;
    vl ans;
    /*rep(i,pos.size()){
        bool ok=true;
        repl(j,i,pos.size()){
            if(g(pos[i])>g(pos[j]))ok=false;
        }
        if(ok)ans.pb(pos[i]);
        //if(ok)cout << pos[i] <<endl;
    }*/
    double now=INF;
    per(i,pos.size())if(chmin(now,g(pos[i])))ans.pb(pos[i]);
    rev(all(ans));
    rep(i,k)cout << ans[i] <<endl;
} 

Measured memory_bytes: 4044
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;

int main(){
	int n,L;
	vector<string> v;
	string s;
	cin >> n >>L;
	for(int i=0;i<n;i++){
		cin >> s;
		v.push_back(s);
	}
	sort(v.begin(),v.end());
	for(int i=0;i<n;i++){
		cout << v[i];
	}
	cout <<endl;
	return 0;
}

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

typedef pair<int, int> P;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define mp make_pair
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }

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

  int N;
  string S;
  ll cnt = 0;
  cin >> N >> S;
  vector<int> v1;
  vector<int> v2;
  vector<int> v3;
  rep (i, N) {
    if (S[i] == 'R')
      v1.pb(i);
    if (S[i] == 'G')
      v2.pb(i);
    if (S[i] == 'B')
      v3.pb(i);
  }
  rep (i, N-2) {
    for (int j = i; j < N-1; j++) {
      int k = 2*j-i;
      if (k <= N-1 && S[i] != S[j] && S[j] != S[k] && S[i] != S[k])
        cnt++;
    }
  }
  cout << (ll)v1.size()*v2.size()*v3.size()-cnt << endl;
}


Measured memory_bytes: 3656
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>

using namespace std;

typedef long long ll;
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 = (1LL << 60) - 1;
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
#define MAX_N 100100 * 3

string s[3];

int main() {
	rep(i, 3) {
		cin >> s[i];
		cout << (char)(s[i][0] - 'a' + 'A');
	}
	cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

ll a[111111];

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n; cin>>n;
	for(int i = 0; i < n; i++)
	{
		cin>>a[i];
	}
	ll cur=1;
	ll ans = 0;
	for(int i = 0; i < n; i++)
	{
		if(a[i]<cur) continue;
		if(a[i]==cur)
		{
			cur++;
			continue;
		}
		ans+=(a[i]-1)/cur;
		if(cur==1) cur++;
	}
	cout<<ans<<'\n';
}


Measured memory_bytes: 1024
from collections import deque
N, M = map(int, input().split(' '))
neib = {}
for i in range(M):
    a, b = map(int, input().split(' '))
    if not a in neib.keys():
        neib[a] = [b]
    else:
        neib[a].append(b)
    if not b in neib.keys():
        neib[b] = [a]
    else:
        neib[b].append(a)

q = deque([])
q.append([1])
res = 0
while len(q) > 0:
    p = q.pop()
    if set(p) == set([i for i in range(1, N+1)]):
        res += 1
    cand = neib[p[-1]]
    for n in cand:
        if not n in p:
            q.append(p + [n])

print(res)

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

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

    int start[a], temp;
    multimap<int,int>finish;
    map<int,int>::iterator it;

    for(int i=0;i<a;i++) {
        cin >> start[i] >> temp;
        finish.insert(make_pair(temp,i));
    }

    int currentTime=0,activityCount=0, activityList[a];
    int i=0;
    for(it=finish.begin();it!=finish.end();it++)
    {

        int currentFinishTime = it->first;
        int currentActivity = it->second;
        if(start[currentActivity]>currentTime) {
            currentTime = currentFinishTime;
            activityCount++;
            activityList[i++] = currentActivity;
        }
    }


    cout << activityCount << endl;

    return 0;
}


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

int f[2];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int n;
    cin>>n;
    if(n%10==2 || n%10==4 || n%10==5 || n%10==7 || n%10==9)cout<<"hon\n";
    else if(n%10==0 || n%10==1 || n%10==6 || n%10==8)cout<<"pon\n";
    else if(n%10==3)cout<<" bon\n";

    return 0;
}

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

int main(void){
    int a,b,c,t,s;
    cin>>a>>b>>c;

    if(a>=b){
        if(c>=a){
            t=c;
        }else t=a;
    }else if(c>=b){
        t=c;
    }else t=b;

    s=t*10+a+b+c-t;

    cout<<s<<endl;

    return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		String str = sc.next();
		
		int currentHighestLength = 0;
		int counter = 0;
		
		while (counter < str.length()) {
			int testLength = 1;
			int currentHighestTestLength = 0;
			if (str.charAt(counter) == 'A' && str.length() - counter > currentHighestLength) {
				while (counter + testLength < str.length()) {
					if (str.charAt(counter + testLength) == 'Z' && testLength + 1 > currentHighestLength) {
						currentHighestTestLength = testLength + 1;
						testLength++;
					} else {
						testLength++;
					}
				}
				counter++;
			} else {
				counter++;
			}
			if (currentHighestTestLength > currentHighestLength) {
				currentHighestLength = currentHighestTestLength;
			} else {
			}
		}
		System.out.println(currentHighestLength);
	}

}


Measured memory_bytes: 24772
#include<bits/stdc++.h>
#define endl  "\n"
#define ll long long
#define PI acos(-1.0)
#define test cout<<"\n****\n"
#define precise fixed(cout);cout<<setprecision(12)
#define fast  ios_base :: sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using  namespace  std;


int main(){


    string str;
    cin>>str;

     if(str[0]=='R' && str[1]=='R' && str[2]=='R'){
        cout<<"3\n";
    }
    else if((str[0]=='R' && str[1]=='R') || (str[1]=='R' && str[2]=='R')){
        cout<<"2\n";
    }
     else if(str[0]=='R' || str[1]=='R' || str[2]=='R'){
        cout<<"1\n";
    } else{
        cout<<"0\n";
    }
    return 0;
}


Measured memory_bytes: 3608
import java.util.Scanner;
class Main {
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			int[] a = new int[n];
			for(int i = 0; i < n; i++) {
				a[i] = sc.nextInt();
			}
			int q = sc.nextInt();

			for(int i = 0; i < q; i++) {
				int head = 0;
				int foot = n - 1;
				int target = sc.nextInt();
				int result = n;
				if(target <= a[0])
					result = 0;
				else while(head <= foot) {
					int mid = (head + foot) / 2;
					if(a[mid] < target) {
						if(mid < n - 1 && a[mid+1] >= target) {
							result = mid + 1;
							break;
						}
						else {
							head = mid + 1;
						}
					}
					else {
						foot = mid - 1;
					}
				}
				System.out.println(result);
			}
		}
	}
}


Measured memory_bytes: 106144
#include <cstdio>
#include <cstring>
#include <algorithm>

const int maxN = (int)2e5 + 10;

int N, A[maxN];

void input()
{
    scanf("%d", &N);
    for (int i = 1; i <= N; i++) scanf("%d", A + i);
}

using LL = long long;

LL solve()
{
    LL ans = 0;
    int cnt[22] = {0};
    int left = 1, right = 1; //next
    while (true)
    {
        if (std::all_of(cnt, cnt + 22, [] (int x) { return x <= 1; }))
        {
            ans += right - left;
            if (right > N) break;
            else {
                for (int i = 0, v = A[right]; v > 0; i++, v >>= 1)
                    if (v & 1)
                        cnt[i] += 1;
                right += 1;
            }
        }
        else
        {
            for (int i = 0, v = A[left]; v > 0; i++, v >>= 1)
                if (v & 1)
                    cnt[i] -= 1;
            left += 1;
        }
    }
    return ans;
}

int main()
{
    input();
    printf("%lld", solve());
    return 0;
}

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

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

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

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

inline bool read(int& a){
    int s=0,w=1;
    char ch=getchar();
    if(ch==EOF){
		return false;
	}
    while(ch<'0'||ch>'9'){
        if(ch=='-')w=-1;ch=getchar();
    }
    while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
    a=s*w;
    return true;
}

inline void write(int x){
    if(x<0) putchar('-'),x=-x;
    if(x>9) write(x/10);
    putchar(x%10+'0');
}

inline void writeln(int x){
    if(x<0) putchar('-'),x=-x;
    if(x>9) write(x/10);
    putchar(x%10+'0');
    puts("");
}

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

Measured memory_bytes: 3620
n = int(input())
alist = list(map(int,input().split()))
asum = 0
for i in range(n):
    asum ^= alist[i]
anslist = []
for i in range(n):
    asum ^= alist[i]
    anslist.append(asum)
    asum ^= alist[i]
for ans in anslist:
    print(ans ,end = ' ')

Measured memory_bytes: 31504
#include<bits/stdc++.h>
#define ll long long
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;

int main()
{
    int n, k, i = 0;

    cin >> n >> k;

    while (n > 0)
    {
    	n = n/k;
    	i++;
    }

    cout << i;
	return 0;
}



Measured memory_bytes: 256
import java.io.*;

public class Main {
	public static void main(String args[]) {
		try {
			BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
			String s;
			int sum = 0;
			while((s = reader.readLine()) != null) {
				int x = Integer.parseInt(s);
				for(int i = 1;i*x < 600;i++) {
					sum += f(i*x)*x;
				}
				System.out.println(sum);
				sum = 0;
			}
		}
		catch(IOException e) {
			System.out.println(e);
		}
	}
	public static int f(int x) {
		return x*x;
	}
}

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

int main(){
	int a,b,d,c=0;
	scanf("%d%d%d",&a,&b,&d);
	for(int i=1;i<=b;i++){
		if(i*d>=a&&i*d<=b)
			c++;
	}
	cout << c;
	return 0;
}

Measured memory_bytes: 3760
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T, class U> using Pa = pair<T, U>;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll W,H;
    cin >> W >> H;
    struct edge{
        int i,j;
        ll c;
    };
    vec<edge> E;
    for(int i=0;i<W;i++){
        ll c;
        cin >> c;
        E.push_back({i,-1,c});
    }
    for(int i=0;i<H;i++){
        ll c;
        cin >> c;
        E.push_back({-1,i,c});
    }
    ll cntW = W+1,cntH = H+1;
    sort(E.begin(),E.end(),[](edge& a,edge& b){
        return a.c<b.c;
    });
    ll ans = 0;
    for(auto& e:E){
        if(e.j==-1){
            ans += e.c*cntH;
            cntW--;
        }else{
            ans += e.c*cntW;
            cntH--;
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 6512