akhauriyash/Code-Regression huggingface dataset:
using System.Linq;
using System.Collections.Generic;
using System;

public class hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(line[0]);
        var m = int.Parse(line[1]);
        var b0 = new List<int>();
        var b1 = new List<int>();
        line = Console.ReadLine().Trim().Split(' ');
        for (int i = 0; i < n; i++)
            if (line[i] == "0") b0.Add(i);
            else b1.Add(i);

        line = Console.ReadLine().Trim().Split(' ');
        var p0 = new List<int>();
        var p1 = new List<int>();
        var pos = 0;
        var wsum = 0;
        for (int i = 0; i < m; i++)
        {
            var w = int.Parse(line[i]);
            if (i % 2 == 0) getPos(p0, pos + wsum, w);
            else getPos(p1, pos + wsum, w);
            wsum += w;
        }
        var ans = new List<int>();
        if (b0.Count() == b1.Count())
        {
            if (b0.Count() == p0.Count()) ans.Add(getAns(b0, p0));
            if (b0.Count() == p1.Count()) ans.Add(getAns(b0, p1));
        }
        else
        {
            if (b0.Count() == p0.Count()) ans.Add(getAns(b0, p0));
            if (b0.Count() == p1.Count()) ans.Add(getAns(b0, p1));
            if (b1.Count() == p0.Count()) ans.Add(getAns(b1, p0));
            if (b1.Count() == p1.Count()) ans.Add(getAns(b1, p1));
        }
        Console.WriteLine(ans.Min());
    }
    public static int getAns(List<int> a, List<int> b)
    {
        var ret = 0;
        for (int i = 0; i < a.Count(); i++)
            ret += Math.Abs(a[i] - b[i]);
        return ret;
    }
    public static void getPos(List<int> a, int pos, int w)
    {
        for (int i = 0; i < w; i++)
            a.Add(i + pos);
    }
}


Measured memory_bytes: 8192
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef double ldb;

int main(void)
{
	ldb pi2 = 6.28318530717958623200;
	int r;
	scanf("%d",&r);
	printf("%.20lf",(double)(pi2*r));
	return 0;
}

Measured memory_bytes: 1736
#Aの倍数をBで割った余りがCとなる整数が存在するか
#Bで割った余りが0からB-1を循環することから
#Aの1倍からAのB倍までをテストすると求まる。



A, B, C = map(int, input().split())

for i in range(A, A * B + 1, A):
    if i % B == C:
        flg = True
        break
    else:
        flg = False

print("YES" if flg else "NO")


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define ALL(a) (a).begin(),(a).end()

using namespace std;
using ll = long long;

const double PI = 3.14159265358979;

void solve()
{
  ll n;
  cin >> n;
  string s;
  map<char, ll> mp;
  for(int i = 0; i < n; ++i)
  {
    cin >> s;
    mp[s[0]]++;
  }

  vector<ll> p;
  if (mp['M'] > 0) p.emplace_back(mp['M']);
  if (mp['A'] > 0) p.emplace_back(mp['A']);
  if (mp['R'] > 0) p.emplace_back(mp['R']);
  if (mp['C'] > 0) p.emplace_back(mp['C']);
  if (mp['H'] > 0) p.emplace_back(mp['H']);

  ll num = p.size();
  ll ans = 0;
  for(int i1 = 0; i1 < num - 2; ++i1)
  {
    for(int i2 = i1 + 1; i2 < num - 1; ++i2)
    {
      for(int i3 = i2 + 1; i3 < num; ++i3)
      {
        ans += p[i1] * p[i2] * p[i3];
      }
    }
  }
  cout << ans;
}

int main()
{
  fastio;
  solve();

  return 0;
}

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

int main(){
    ll n, x;
    cin >> n >> x;
    vector<ll> a(n);
    ll ans = 0;
    for(int i = 0; i < n; i++) cin >> a[i];
    for(int i = 0; i < n-1; i++){
        if(a[i]+a[i+1] > x){
            ans += a[i] + a[i+1] - x;
            a[i+1] -= min(a[i]+a[i+1]-x, a[i+1]);
            if(a[i] + a[i+1] - x > a[i+1]){
                a[i] -= x - a[i+1];
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
// In the name of God

#include <bits/stdc++.h>

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin >> s;
	if(s == "Sunny") cout << "Cloudy";
	if(s == "Cloudy") cout << "Rainy";
	if(s == "Rainy") cout << "Sunny";
	return 0;
}


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

int main() {
  int N, K, R, S, P;
  string T;
  cin >> N >> K >> R >> S >> P >> T;

  int ans = 0;

  for (int i = 0; i < N; i++) {
    if (i >= K && T.at(i) == T.at(i - K)) T.at(i) = 'a';
    else ans += (T.at(i) == 'r') ? P : (T.at(i) == 's') ? R : S;
  }

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

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

#define ios ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define rep(i,l,r) for (int i=l;i<=r;i++)
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define ll long long
#define mod 1000000007
#define random_jbt mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

using namespace std;

int d[100100][2];

int main(){
    string s;
    cin>>s;
    s=" "+s;
    memset(d,0,sizeof(d));
    for (int i=1;i<s.size();i++){
        if (s[i]=='0'){
            d[i][0]=d[i-1][1];
            d[i][1]=d[i-1][0]+1;
        }
        else{
            d[i][1]=d[i-1][0];
            d[i][0]=d[i-1][1]+1;
        }
    }
    cout<<min(d[s.size()-1][0],d[s.size()-1][1]);
    return 0;
}


Measured memory_bytes: 1276
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    string s;
    cin >> s;
    int n=s.size();
    if(s[n-1]=='1'||s[0]=='0'){
        print(-1);
        return 0;
    }
    string t;
    t=s.substr(0,n-1);
    reverse(all(t));
    if(s.substr(0,n-1)!=t){
        print(-1);
        return 0;
    }
    int par=1;
    repi(i,2,n+1){
        if(t[i-2]=='1'){
            cout << par << " " << i << endl;
            par=i;
        }
        else{
            cout << par << " " << i << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1744
use ::num::integer::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::iter::*;
#[allow(unused_imports)]
use std::*;

macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
#[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

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

macro_rules! stdin {
    () => {{
        use std::io::Read;
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }};
}

fn main() {
    println!("{}", solve(&stdin!()));
}
fn solve(src: &str) -> String {
    input! {
        source = src,
        k:usize,
    }
    let mut sum = 0;
    for a in 1..=k {
        for b in 1..=k {
            for c in 1..=k {
                sum += gcd(a, gcd(b, c));
            }
        }
    }
    sum.to_string()
}
test! {
    "2" => "9",
    "200" => "10813692",
}


Measured memory_bytes: 2144
#include <iostream>

int main() {
	int n = 0;
	int k = 0;
	int sum = 1;

	std::cin >> n;
	std::cin >> k;

	for (int i = 0; i < n; i++) {
		if ((sum * 2) <= (sum + k)) {
			sum = sum * 2;
		}
		else {
			sum += k;
		}
	}

	std::cout << sum;

	return 0;
}


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

using namespace std;

int main(void) {
    string s;
    cin >> s;
    string ans = "";
    for (int i = 0; i < s.length(); i++) {
        if (s[i] == 'B') {
            if (ans.length() > 0) {
                ans.erase(ans.length() - 1);
            }
        } else {
            ans += s[i];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>

using namespace std;

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

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

long long int N, M;

struct edge{
	int to;
	long long int S;
	int rev;
};

vector<edge> E[110000];
unordered_map<long long int, long long int> m;
long long int MUL = 1e10;

long long int func(int pos, int pre, int rev){
	
	long long int ret = 1;
	if(pre != -1 && E[pos][rev].S != -1 && m.find(pos * MUL + E[pos][rev].S) != m.end()){
		return m[pos * MUL + E[pos][rev].S];
	}
	
	bool flag = true;
	for(int i = 0; i < E[pos].size(); i++){
		if(E[pos][i].S == -1){
			flag = false;
		}
		if(pre == E[pos][i].to){
			continue;
		}
		if(E[pos][i].S == -1){
			E[pos][i].S = func(E[pos][i].to, pos, E[pos][i].rev);
		}
		ret *= (E[pos][i].S + 1);
		ret %= M;
	}
	
	if(flag){
		m[pos * MUL + E[pos][rev].S] = ret;
	}
	
	return ret;
}

int main(){
	
	cin >> N >> M;
	
	for(int i = 0; i < N - 1; i++){
		int x, y;
		cin >> x >> y;
		edge e;
		e.S = -1;
		e.to = y;
		E[x].push_back(e);
		e.to = x;
		E[y].push_back(e);
	}
	
	unordered_map<long long int, int> hoge;
	
	for(int i = 1; i <= N; i++){
		for(int j = 0; j < E[i].size(); j++){
			hoge[i * MUL + E[i][j].to] = j;
		}
	}
	
	for(int i = 1; i <= N; i++){
		for(int j = 0; j < E[i].size(); j++){
			E[i][j].rev = hoge[E[i][j].to * MUL + i];
		}
	}
	
	for(int i = 1; i <= N; i++){
		long long int ans = 1;
		for(int j = 0; j < E[i].size(); j++){
			if(E[i][j].S == -1){
				E[i][j].S = func(E[i][j].to, i, E[i][j].rev);
			}
			ans *= (E[i][j].S + 1);
			ans %= M;
		}
		cout << ans << endl;
	}
	
	return 0;
}


Measured memory_bytes: 27840
import itertools as itt

n, m = map(int, input().split())
l = set()
for i in range(m):
    a, b = map(int, input().split())
    l.add((a, b))
    l.add((b, a))

lis = [i for i in range(1, n+1)]
p_lis = list(itt.permutations(lis))

cnt = 0

for i in range(len(p_lis)):
    if p_lis[i][0] != 1:
        continue
    flg = [0]*(n-1)
    for j in range(n-1):
        x = (p_lis[i][j], p_lis[i][j+1])
        if x in l:
            flg[j] = 1
    if all(flg):
        cnt += 1

print(cnt)

Measured memory_bytes: 13948
#!/usr/bin/env python3

def main():
    n = int(input())
    xy = [list(map(int, input().split())) for i in range(n)]
    max_z, max_w, min_z, min_w = -10**20, -10**20, 10**20, 10**20
    ans = 0
    for p in xy:
        max_z, max_w = max(max_z, p[0] + p[1]), max(max_w, p[0] - p[1])
        min_z, min_w = min(min_z, p[0] + p[1]), min(min_w, p[0] - p[1])
    ans = max(max_z - min_z, max_w - min_w)
    print(ans)


if __name__ == "__main__":
    main()


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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long  ll; typedef vector<int> VI; typedef pair<int,int> pii; typedef vector<ll> VL; const int MD = 1e9 + 7;
void dbg(){cerr<<"\n";} template <class F,class ...S> void dbg(const F& f, const S&...s){cerr <<f <<": "; dbg(s...);}

map<ll, int> fctm( ll x ){
	map<ll, int> fmp;
	for( ;x>=4 && x%2==0; x/=2)  fmp[2]++;
	for(ll d=3, q=x/d; q>=d ; q=x/d){if(x%d==0) fmp[d]++, x=q; else d +=2;}
	if(x!=1) fmp[x]++;
	return fmp;
}


int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	ll n;
	cin >>n;
	
	ll ans =0;
	for(auto& x: fctm(n)){
		int p = x.second, su =0;
		for(int i=1; p >= i; i++){
			su ++; p -=i;
		}
		ans += su;
	}
	
	cout << ans <<"\n";
	return 0;
}


Measured memory_bytes: 3648
use std::io::*;
use std::str::*;


fn read<T: FromStr>(s: &mut StdinLock) -> Option<T> {
    let s = s.by_ref()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok()
}

pub fn main() {
    let stdin = stdin();
    let mut stdin = stdin.lock();

    let crement: String = read(&mut stdin).unwrap();
    let result = crement.chars().fold(0, |acc, x| if x == '+' {acc + 1} else {acc - 1});
    println!("{:?}", result);
}


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

using namespace std;

using ll = long long;

const ll MOD = 1000000007;

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

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    ll n, k; cin >> n >> k;
    ll ans = 0;
    while(n > 0){
        n /= k;
        ans++;
    }
    cout << ans << endl;
}

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

using namespace std;

using ll = long long;
using P = pair<ll,ll>;

#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = ((ll)(x) - 1); i >= 0; i--)

#define _upgrade ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define all(x) (x).begin(), (x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

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

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

const ll mod = 1e9 + 7;
const ll IMF = 1LL << 60;
const double PI = 3.14159265358979323846;


// ****************************************CODE***************************************//





int c[300300];

int main(){
        int n;
        cin >> n;
        vector<int> a;
        for(int i = 0; i < n; i++){
                int x;
                cin >> x;
                a.push_back(x);
        }

        int l = 0, r = 0;
        int now = 0;
        ll ans = 0;
        while(l < n){
                while(r < n && (now ^ a[r]) == now + a[r]){
                        now ^= a[r++], ans++;
                }
                now ^= a[l++];
                ans += r - l;
        }

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










































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

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

        int H, W, N;
        cin >> H >> W >> N;
        if (W > H) swap(W, H);
        int c = 0;
        if (N % H != 0) c = 1;
        cout << (N / H) + c << "\n";

        return 0;
}

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

void bin(int,int,int);

int n,f[100000],q,g[50000];
int x=0;

int main(){
	cin >> n;
	for(int i=0;i<n;i++) cin >> f[i];
	cin >> q;
	for(int i=0;i<q;i++) cin >> g[i];
	for(int i=0;i<q;i++) bin(0,n-1,g[i]);
	cout << x << endl;
	return 0;
}

void bin(int min,int max,int k){
		while(min<=max){
			int mid=(min+max)/2;
			if(f[mid]>k){
				max=mid-1;
			} else if(f[mid]<k){
				min=mid+1;
			} else{
				x++;
				break;
			}
		}
}

Measured memory_bytes: 1744
#include<iostream>
#include<vector>
using namespace std;
int main() {
	int i, j;
	char a[100][100];
	cin >> i >> j;
	for (int h = 0; h < i; h++) {
		for (int w = 0; w < j; w++) {
			cin >> a[h][w];
		}
	}
	for (int H = 0; H < i; H++) {
		for (int q = 0; q < 2; q++) {
			for (int W = 0; W < j; W++) {
				cout << a[H][W];
				if (W == j - 1)cout << endl;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main(){
    //入力
    ll n,m; cin>>n>>m;
    multiset<ll> a;
    for(int i=0;i<n;i++){
        ll tmp; cin>>tmp;
        a.insert(tmp);
    }
    vector<pair<ll,ll>> cb(m);
    for(int i=0;i<m;i++){
        ll b,c; cin>>b>>c;
        cb[i]=make_pair(c,b);
    }
    // bcをソート
    sort(cb.begin(),cb.end());
    //計算
    ll maxv=0;
    for(int i=0;i<m;i++){
        ll cnt=0;
        bool flag=true;
        ll c=cb[m-1-i].first;
        ll b=cb[m-1-i].second;
        maxv+=b;
        while(cnt<b&&flag){
            for(auto itr=a.begin();itr!=a.end();++itr){
                if(*itr<c){
                    itr=a.erase(itr);
                    a.insert(c);
                    cnt++;
                    break;
                }
                else if(*itr>=c){
                    flag=false;
                    break;
                }
            }
        }
        if(maxv>n) break;
    }
    //合計値
    ll sum=0;
    for(auto itr=a.begin();itr!=a.end();++itr) sum+=*itr;
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 8576
#include <stdio.h>
int main(void){
    int a,b,c,min=0;
    scanf("%d%d%d",&a,&b,&c);
    min=a+b;
    if(min>a+c) min=a+c;
    if(min>b+c) min=b+c;
    printf("%d",min);
    return 0;
}

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


long long a[300000+50];
vector <int> adj[300000+50];
bool vis[300000+50];

int main(){
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	long long xx=0;
	for(int i=0;i<n;i++){
		cin>>a[i];
		xx=xx^a[i];
	}
	if(xx==0){
		cout<<"Yes\n";
	}
	else{
		cout<<"No\n";
	}
	return 0;
}

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

int main(){
    int a,b;
    char op;
    while(true){
        cin>>a>>op>>b;
        if(op=='?'){
            break;
        }
        if(op=='+'){cout<<a+b<<endl;}
        else if(op=='-'){cout<<a-b<<endl;}
        else if(op=='*'){cout<<a*b<<endl;}
        else if(op=='/'){cout<<a/b<<endl;}
    }
}


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

struct Point {
    double x;
    double y;
};

void koch(int n, Point a, Point b) {
    if (n == 0) {
        return;
    }

    Point s, t, u;
    double th = M_PI * 60.0 / 180.0;
    s.x = (2.0 * a.x + 1.0 * b.x) / 3.0;
    s.y = (2.0 * a.y + 1.0 * b.y) / 3.0;
    t.x = (1.0 * a.x + 2.0 * b.x) / 3.0;
    t.y = (1.0 * a.y + 2.0 * b.y) / 3.0;
    u.x = (t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x;
    u.y = (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y;

    koch(n - 1, a, s);
    printf("%.8f %.8f\n", s.x, s.y);
    koch(n -1, s, u);
    printf("%.8f %.8f\n", u.x, u.y);
    koch(n -1, u, t);
    printf("%.8f %.8f\n", t.x, t.y);
    koch(n -1, t, b);
}

int main()
{
    Point a, b;
    int n;

    scanf("%d", &n);

    a.x = 0;
    a.y = 0;
    b.x = 100;
    b.y = 0;

    printf("%.8f %.8f\n", a.x, a.y);
    koch(n, a, b);
    printf("%.8f %.8f\n", b.x, b.y);

    return 0;
}


Measured memory_bytes: 3204
#include <iostream>
#include <cmath>
#include <iomanip>
#include <cstdio>
#include <string>
#include <sstream>
int fix()
{
    //example to format floating point numbers.
    double pi = 3.141592653589793;
    double r = 3.141592653589793 * 128;
    std::ios_base::fmtflags f(std::cout.flags()); //[1]
    std::cout << "default:\n  " << pi << " " << r << "\n";
    std::cout << std::setprecision(4) << "setprecision(4):\n  " //[2]
              << pi << " " << r << "\n";
    std::cout << std::setiosflags(std::ios::fixed) << "setiosflags(std::ios::fixed):\n  " //[2]
              << pi << " " << r << "\n";
    std::cout << std::setprecision(5) << "setprecision(5):\n  " //[2]
              << pi << " " << r << "\n";
    std::cout.flags(f);
    std::cout << "reset:\n  " << pi << " " << r << "\n";
    //[1] https://stackoverflow.com/questions/2273330/restore-the-state-of-stdcout-after-manipulating-it
    //[2] https://stackoverflow.com/questions/4217510/how-to-cout-the-correct-number-of-decimal-places-of-a-double-value
    return 0;
}
void multipleLines()
{
    //example to parse multiple lines input.
    std::istringstream isin("1 2 3\n3 2 4\n0 0 0");

    for (std::string str; std::getline(isin, str);)
    {
        std::istringstream tisin(str);
        int a, b, c;
        tisin >> a >> b >> c;
        std::cout << a << " " << b << " " << c << "\n";
    }
    //[1]  https://stackoverflow.com/questions/19767644/c-parsing-input-string-to-variables
}
#include <vector>
#include <set>
#include <map>

int main()
{
    int r, c;
    std::vector<int> vT;
    std::cin >> r >> c;
    vT.resize((r + 1) * (c + 1));
    for (int i = 0; i < r; i++)
    {
        for (int j = 0; j < c; j++)
        {
            int aij;
            std::cin >> aij;
            vT[i * (c + 1) + j] = aij;
            vT[r * (c + 1) + j] += aij;
        }
    }
    for (int i = 0; i <= r; i++)
    {
        for (int j = 0; j <= c; j++)
        {
            std::cout << vT[i * (c + 1) + j];
            if (j != c)
            {
                std::cout << " ";
                vT[i * (c + 1) + c] += vT[i * (c + 1) + j];
            }
        }
        std::cout << "\n";
    }
}


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

//namespace _1_A
//{
class Program
{
    static void Main(string[] args)
    {
        ArrayList harray = new ArrayList();
        ArrayList warray = new ArrayList();
        int dat = 0, hid = 0, mig = 0;
        int[] iarray = new int[2];
        string inp = Console.ReadLine();
        string[] oup = inp.Split(' ');
        iarray[0] = int.Parse(oup[0]);
        iarray[1] = int.Parse(oup[1]);

        while (dat < 300)
        {
            if (iarray[0] == 0 && iarray[1] == 0)
                break;
            harray.Add(iarray[0]);
            warray.Add(iarray[1]);
            dat++;
            inp = Console.ReadLine();
            oup = inp.Split(' ');
            iarray[0] = int.Parse(oup[0]);
            iarray[1] = int.Parse(oup[1]);
        }

        int cnt = 0;
        for (; cnt < dat; ++cnt)
        {
            hid = Convert.ToInt32(harray[cnt]);
            mig = Convert.ToInt32(warray[cnt]);
            for (int i = 0; i < hid; i++)
            {
                for (int j = 0; j < mig; j++)
                    Console.Write("#");
                Console.WriteLine();
            }
            Console.WriteLine();

        }

        //Console.Read();
    }
}
//}

Measured memory_bytes: 8912
#include<stdio.h>
int main()
{
    int a[3],sum=0,i,j,min;
    for(i=0;i<3;i++)
    scanf("%d",&a[i]);
    for(i=0;i<3;i++)
    {
        for(j=0;j<2;j++)
        {
            if(a[j]<a[j+1])
            {
                min=a[j];
                a[j]=a[j+1];
                a[j+1]=min;
            }
        }
    }
    sum=a[0]-a[1];
    sum=sum+(a[1]-a[2]);
    printf("%d",sum);
    return 0;
}


Measured memory_bytes: 128
import java.util.*;
import java.util.stream.*;
import static java.util.Comparator.*;

public class Main{
  public static void main(String[] args) throws Exception{
	Scanner sc = new Scanner(System.in);
	int N = sc.nextInt();
    List<Integer> numList = new ArrayList<>();
    while(sc.hasNextInt()){
        numList.add(sc.nextInt());
    }
    Map<Integer,Integer> mp = new HashMap<>();
    for(int x : numList){
        Integer a = mp.get(x);
        if(a != null){
            mp.put(x,++a);
        }else{
            mp.put(x,1);
        }
    }
    int result = 0;
    for(Map.Entry<Integer,Integer> entry : mp.entrySet()){
        int first = entry.getKey();
        int second = entry.getValue();
        if(first - second > 0){
            result += second;
        }else{
            result += second - first;
        }
    }
    System.out.println(result);
  }
}


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

main() {
  int N;
  cin >> N;
  for (int i=1; i<=9; i++) {
    if (N % i == 0) {
      if (N / i <= 9) {
        cout << "Yes";
        return 0;
      }
    }
  }
  cout << "No";
  return 0;
}


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

using namespace std;
using ll = long long;

int ctoi(const char c) {
    switch(c) {
        case '0': return 0;
        case '1': return 1;
        case '2': return 2;
        case '3': return 3;
        case '4': return 4;
        case '5': return 5;
        case '6': return 6;
        case '7': return 7;
        case '8': return 8;
        case '9': return 9;
        default : return -1;
    }
}

int main() {
    string s;
    cin >> s;
    size_t n = s.length();
    ll ans = 0;
    for (int bit = 0; bit < (1 << (n - 1)); ++bit) {
        ll t = ctoi(s.at(0));
        for (int i = 0; i < n - 1; ++i) {
            if (bit & (1 << i)) {
                ans += t;
                t = ctoi(s.at(i + 1));
            }
            else {
                t *= 10;
                t += ctoi(s.at(i + 1));
            }
        }
        ans += t;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <stack>
#include <set>
#include <cmath>
#include <map>
#include <time.h>
#include <vector>
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
//#include <memory.h>
#include <cstdlib>
#include <queue>
#include <iomanip>
#include <cassert>
#include <unordered_map>
#define P pair<int, int>
#define LL long long
#define LD long double
#define PLL pair<LL, LL>
#define mset(a, b) memset(a, b, sizeof(a))
#define rep(i, a, b) for (int i = a; i < b; i++)
#define PI acos(-1.0)
#define random(x) rand() % x
#define debug(x) cout << #x << " " << x << "\n"
using namespace std;
const int inf = 0x3f3f3f3f;
const LL __64inf = 0x3f3f3f3f3f3f3f3f;
#ifdef DEBUG
const int MAX = 2e3 + 50;
#else
const int MAX = 1e6 + 50;
#endif
const int mod = 1e9 + 7;
void file_read() {
#ifdef DEBUG
	freopen("in", "r", stdin);
	// freopen("out", "w", stdout);
#endif
}

LL a[MAX];
LL s[MAX];
int main() {
	file_read();
	int n;
	scanf("%d", &n);
	for(int i = 1; i <= n; i++) {
		scanf("%d", &a[i]);
		s[i] = (s[i-1] + a[i]) % mod;
	}
	LL ans = 0;
	for(int i = 2; i <= n; i++) {
		ans += a[i] * (s[i-1]) % mod;
		ans %= mod;
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 6932
def BaseM2Num(N):
    if N==0:
        return [0]
    else:
        List = []
        while abs(N)>0:
            if N%2==0:
                N //= (-2)
                List.append(0)
            else:
                N = (N-1)//(-2)
                List.append(1)
        return List[::-1]
      
List = BaseM2Num(int(input()))
print(''.join(str(T) for T in List))

Measured memory_bytes: 9148
#include <iostream>
#include <fstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <cstdio>
#include <stack>
#include <climits>

using namespace std;

int main() {

	int n, k = 0;
	cin >> n >> k;

	if (n%k == 0) cout << '0' << endl;
	else cout << '1' << endl;


	return 0;

}

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

#define fast() {ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);}
#define o(a) { cout << #a << ":" << (a) <<" ";}
#define ov(a) { cout << "["; \
	for(int i = 0; i < (a).size(); ++i){ \
		cout << i <<":" << a[i] <<" "; \
		if(i % 10 == 9) cout <<"\n"; \
		} \
	cout << "]"; \
}
#define ovv(a) { cout << "["; \
	for(int i = 0; i < a.size(); ++i){ \
		for(int j = 0; j < a[i].size(); ++j){ \
			cout << "(" << i <<"," <<j <<")" <<":" << a[i][j] <<" "; \
		} \
		cout << "\n"; \
	} \
	cout << "]"; \
}
#define op(a) { cout <<"[" << #a << ".fi:"<<a.first; \
					cout << " "<< #a << ".se:" << a.second <<"]"; }

#define ll long long
const int mod = 2019;
int main()
{
	fast();
	string s;
	cin >> s;
	int n = s.length();
	vector<int>pow_10(n + 1);
	int t = 1;
	pow_10[0] = 1;
	for(int i = 1; i <= n; ++i){
		pow_10[i] = (pow_10[i - 1] * 10) % mod;
	}
	vector<int> d(n + 1), tol(2020, 0);
	int rs = 0;
	d[n - 1] = s[n - 1] - '0';
	tol[d[n - 1]]++;
	tol[0] ++;
	for(int i = n - 2; i >= 0; --i){
		d[i] =  (d[i + 1] + (s[i] - '0') * pow_10[n - i - 1]) % mod;
		rs += tol[d[i]];
		tol[d[i]]++;
	}
	//ov(pow_10)
	//ov(d)
	cout << rs;
}



Measured memory_bytes: 5160
#include<stdio.h>
#include<stdlib.h>

int main(void)
{
    char s[5];
    int n=0;

    scanf("%s",s);
    for(int i=0;i<4;i++)
    {
        switch (s[i])
        {
        case '+':
            n++;
            break;
        
        case '-':
            n--;
            break;
        }
    }

    printf("%d",n);

    return 0;
}

Measured memory_bytes: 128
void main()
{
    long n = rdElem;

    void dfs(string s, long len, long cnt)
    {
        if (len == n)
        {
            s.writeln;
            return;
        }

        foreach (i; 0 .. cnt+2)
        {
            long num = max(cnt, (s[len-1] - 'a') + 1);
            if (i <= num) dfs(s~lowercase[i], len+1, num);
        }
    }

    dfs("a", 1, 0);
}

enum long mod = 10^^9 + 7;
enum long inf = 1L << 60;

T rdElem(T = long)()
if (!is(T == struct))
{
    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;
alias rdDchar = rdElem!(dchar[]);

T rdElem(T)()
if (is(T == struct))
{
    T result;
    string[] input = rdRow!string;
    assert(T.tupleof.length == input.length);
    foreach (i, ref x; result.tupleof)
    {
        x = input[i].to!(typeof(x));
    }
    return result;
}

T[] rdRow(T = long)()
{
    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    return iota(col).map!(x => rdRow!T).array;
}

void rdVals(T...)(ref T data)
{
    string[] input = rdRow!string;
    assert(data.length == input.length);
    foreach (i, ref x; data)
    {
        x = input[i].to!(typeof(x));
    }
}

void wrMat(T = long)(T[][] mat)
{
    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.mathspecial;
import std.traits;
import std.container;
import std.functional;
import std.typecons;
import std.ascii;
import std.uni;
import core.bitop;

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

int main() {
	int AB; int BC; int CA;
	cin>> AB>>BC>>CA;
	int first= AB+BC;
	int second= BC+CA;
	int third= AB+CA;
	if(first<=second && first<=third){
		cout<<first;
	}
	else if (second<=first && second<=third){
		cout<<second;
	}
	else{
		cout<<third;
	}
	return 0;
}

Measured memory_bytes: 3636
#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 rep(i,a,b) for(int i=a;i<b;++i)
#define Rep(i,a,b) for(int i=a;i<=b;++i)
#define Rrep(i,a,b) for(int i=a;i>b;--i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
#define sq(a) (a)*(a)
#define nitro std::ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
#define debug(x) std::cerr<<#x<<"="<<x<<'\n'
#define text std::cerr<<"SacredCoupoid08\n"
#define endl '\n'
#define all(c) (c).begin(),(c).end()
#define U 1000000007
#define N 100005
#define sz(c) (int)c.size()
#define pb push_back
#define pv(x) for(auto y:x)    cout<<y<<" ";    cout<<'\n';
#define fr first
#define sc second
#define ppb pop_back
#define Max(a,b) a=max(a,b)
#define Min(a,b) a=min(a,b)
#define int ll
#define tr(c,it) for(typeof(c.begin()) it= c.begin();it != c.end();it++)
#define ri(X) scanf("%lld", &(X))
#define rii(X, Y) scanf("%lld%lld", &(X), &(Y))
#define riii(X, Y, Z) scanf("%lld%lld%lld", &(X), &(Y), &(Z))
#define dri(X) ll (X); scanf("%lld", &X)
#define drii(X, Y) ll X, Y; scanf("%lld%lld", &X, &Y)
#define driii(X, Y, Z) int X, Y, Z; scanf("%lld%lld%lld", &X, &Y, &Z)
#define rs(X) scanf("%s", (X))
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
typedef long long ll;
typedef std::vector< ll > vi;
typedef std::pair<ll, ll> pi;
typedef tree<ll, null_type, less<ll>, rb_tree_tag,
        tree_order_statistics_node_update>
        pbds;
const double pie = 3.14159265358979323846;
auto _C=clock();
/*
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;         ;;    ;;     ;;;;;;;     ;;     ;;  ;;;;     ;;
 ;;       ;;   ;;  ;;   ;;    ;;    ;;     ;;  ;; ;;    ;;
  ;;     ;;   ;;    ;;  ;;    ;;    ;;     ;;  ;;  ;;   ;;
   ;;   ;;    ;;;;;;;;  ;;;;;;;     ;;     ;;  ;;   ;;  ;;
    ;; ;;     ;;    ;;  ;;   ;;      ;;   ;;   ;;    ;; ;;
     ;;;      ;;    ;;  ;;    ;;       ;;;     ;;     ;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
*/
signed main()
{		
	nitro;
	int CASE=1;
	//ri (CASE);
	//cin>>CASE;
	while(CASE--)
	{
		int a,b,c,d;
		cin>>a>>b>>c>>d;
		vi ans;
		ans.pb(a*c);
		ans.pb(a*d);
		ans.pb(b*c);
		ans.pb(b*d);
		cout<<*max_element(all(ans))<<endl;
		
	}
	
	
	
	

//cerr<<"\n\n\nTime elapsed: "<<(double)(clock()-_C)*1000.0/CLOCKS_PER_SEC<<"ms\n";		

	return 0;
}



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

using namespace std;

int main()
{
  int n;
  cin>>n;
  vector< int > a(n),b(n);
  for(int i =0;i<n;i++)
  {
    cin>>a[i];
    b[i] = a[i];
  }
  sort(a.begin(),a.end());
  int count = 0;
  for(int i = 0;i<n;i++)
  {
   if(a[i] != b[i]) count++;
  }
  if(count == 2 || count == 0)
    cout<<"YES"<<endl;
  else
    cout<<"NO"<<endl;
  return 0;
}

Measured memory_bytes: 256
s = input()
nq = int(input())
flg = 0
front = []
back = []
for i in range(nq):
    q = input()
    if len(q) == 1:
        #flg += 1
        flg = (flg+1)%2
    else:
        if flg == 0:
            if q[2] == '1':
                #front = [q[-1]] + front
                front.append(q[-1])
            else:
                #back = back + [q[-1]]
                back.append(q[-1])
        else:
            if q[2] == '1':
                #back = back + [q[-1]]
                back.append(q[-1])
            else:
                #front = [q[-1]] + front
                front.append(q[-1])
                

if flg % 2 == 1:
    s = ''.join(back)[::-1] + s[::-1] + ''.join(front)
else:
    s = ''.join(front)[::-1] + s + ''.join(back)
print(s)

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

int c[3][3], a[3], b[3];
string ans = "Yes";

int main() {
    for (int i = 0; i < 3; i++) {
        for (int j = 0 ; j < 3; j++) {
            cin >> c[i][j];
        }
    }
    // regard a[0] as 0
    for (int i = 0; i < 3; i++) b[i] = c[0][i];
    for (int i = 0; i < 3; i++) a[i] = c[i][0] - b[0];
    // check
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            if (a[i] + b[j] != c[i][j]) ans = "No";
        }
    }

    cout << ans << endl;

    return 0;
}

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

signed main() {
	int A[3]; cin >> A[0] >> A[1] >> A[2];
	sort(A, A + 3);
	int d = A[2] + A[2] - A[0] - A[1];
	if (d % 2 == 0)cout << d / 2 << endl;
	else cout << (d + 3) / 2 << endl;
}

Measured memory_bytes: 3556
#include <bits/stdc++.h>
// statics
using namespace std;
using int64 = long long;
using PAIR = pair<int64, int64>;
constexpr int INF = 1 << 30;
constexpr int64 LINF = 1LL << 60;
constexpr int MOD = 1e9 + 7;
constexpr int MAX_N = 3e5 + 1;

// init/input
#define int int64
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T &t) {cin>>t;}
template<typename First, typename...Rest> void MACRO_VAR_Scan(First &first, Rest&...rest) {cin>>first;MACRO_VAR_Scan(rest...);}
#define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i;

// out
#define OUT(dist) cout<<(dist);
#define FOUT(n, dist) cout<<fixed<<setprecision(n)<<(dist);
#define SP cout<<" ";
#define BR cout<<endl;
#define zero(n) cout<<setfill('0')<<right<<setw(n)
#define debug(x) cerr<<#x<<":"<< (x);BR;

// utility
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, a) for(auto &&i:(a))
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RFOR(i, a, b) for(int i=(b)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<(n);++i)
#define RREP(i, n) for(int i=(n)-1;i>=0;--i)
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; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

signed main() {
  INIT;
  VAR(int,n,h);
  vector<PAIR> d(n);
  int mx=0;
  REP(i,n){
    VAR(int,a,b);
    d[i] = make_pair(a,b);
    mx=max(mx,a);
  }

  sort(ALL(d), [](auto &d1, auto &d2){
                 return d1.second > d2.second;
               });
  
  int ans = 0,sm=0;
  REP(i,n){
    if(d[i].second>mx){
      sm += d[i].second;
      ++ans;
    }
    if(sm>=h) break;
  }

  if(sm<h) ans += (h-sm+mx-1)/mx;
  OUT(ans)BR;
  
  return 0;
}


Measured memory_bytes: 1920
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<string>
#define MOD 1000000007
#define enld endl
typedef long long ll;
using namespace std;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

const double pi = 3.141592653589793;
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    double A,B,H,M; cin >> A >> B >> H >> M;
    double h = (60*H+M) / 2;
    double m = 6 * M;
    double theta = min(360 - abs(h-m), abs(h-m));
    double rad = pi * theta/180;
    double ans = sqrt(pow(A,2)+pow(B,2) - 2*A*B*cos(rad));
    printf("%.18f\n", ans);
    return 0;
}

Measured memory_bytes: 4172
#include <iostream>
#include <vector>
#include <cmath>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, s, n) for(int i = s; i < n; i++)
using namespace std;

const int INF = 1000000000;
int main(){
  int n;
  cin >> n;
  vector<int> x(n);
  rep(i, n) cin >> x[i];
  int ans = INF;
  rep2(i, 1, 101){
    int temp = 0;
    rep(j, n){
      temp += (x[j] - i) * (x[j] - i);
    }
    ans = min(ans, temp);
  }
  cout << ans << endl;
  
  return 0;
}

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

int main(){
    ll N;
    cin >> N;
    vector<ll> A(10000001, 1);
    vector<ll> B(0);
    for (ll i = 0; i < 10000000; i++)
    {   
        B.push_back(i + 1);
        if (A.at(i) == N) {
             break;
        }
        else if (A.at(i) > N){
            B.erase(B.begin() + A.at(i)-N -1 );
            break;
        }
        A.at(i + 1) = A.at(i) + (i + 2);
     
        
    }
    for (ll i: B)
    {
        cout << i << endl;
    }
    
    
}

Measured memory_bytes: 78464
import sys

input = sys.stdin.readline


class AtCoder:
    def main(self):
        n = int(input())
        p = list(map(int, input().split()))

        ans = 0
        for i in range(1, n - 1):
            if sorted(p[i - 1:i + 2])[1] == p[i]:
                ans += 1
        print(ans)


# Run main
if __name__ == '__main__':
    AtCoder().main()


Measured memory_bytes: 38480
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class Main {
	public static void main(String[] args) throws IOException {
		try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
			String[] array = br.readLine().split(" ");
			int N = Integer.parseInt(array[0]);
			int C = Integer.parseInt(array[1]);

			List<TVData> list = new ArrayList<>();
			for (int i = 0; i < N; i++) {
				list.add(new TVData(br.readLine()));
			}
			final int[] table = new int[2 * 100_001];
			final boolean[] tmp = new boolean[2 * 100_001];
			for (int channel = 1; channel <= C; channel++, init(tmp)) {
				final int c = channel;
				list.stream().filter(data -> data.channel == c).forEach(data -> {
					for (int i = data.start * 2 - 1; i <= data.end * 2; i++) {
						tmp[i] = true;
					}
				});
				for (int i = 0; i < table.length; i++) {
					if (tmp[i]) {
						table[i]++;
					}
				}
			}

			System.out.println(Arrays.stream(table).max().getAsInt());
		}
	}

	private static void init(boolean[] tmp) {
		for (int i = 0; i < tmp.length; i++) {
			tmp[i] = false;
		}
	}

	public static class TVData {
		private final int channel;
		private final int start;
		private final int end;

		public TVData(String line) {
			int[] tmp = Arrays.stream(line.split(" ")).mapToInt(Integer::parseInt).toArray();
			start = tmp[0];
			end = tmp[1];
			channel = tmp[2];
		}
	}

}


Measured memory_bytes: 64572
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A, B;
  cin >> A >> B;
  int palin=0;
  for (int i=A;i<B+1;i++){
    int a , b , c , d, e;
    e=i%10;
    d=((i-e)/10)%10;
    c=((i-10*d-e)/100)%10;
    b=((i-100*c-10*d-e)/1000)%10;
    a=i/10000;
    if (a==e && b==d)
      palin++;
  }
  cout << palin << endl;
}

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

public class Main {

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		int a=sc.nextInt(), b=sc.nextInt();
		System.out.println((a+b)%24);
		out.close();
	}
	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public Scanner(String s) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(s));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			int[] ans = new int[n];
			for (int i = 0; i < n; i++)
				ans[i] = nextInt();
			return ans;
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

	}

}

Measured memory_bytes: 25196
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<functional>
#include<queue>
#include <iomanip>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>
 
#define DBG cerr << '!' << endl;
#define REP(i,n) for(int (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(int (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(int (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int i = 0;i < (n);i++)cerr << v[i] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
 
using namespace std;
 
typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;
 
int num[15];
 
int main()
{
	int n;cin >> n;
	vector<int> v;
	REP(i,n)
	{
		int tmp;cin >> tmp;
		v.PB(tmp);
		num[tmp]++;
	}
	
	n++;
	v.PB(0);
	
	if(n > 24 || num[0] > 0 || num[12]  > 1)
	{
		cout << 0 << endl;
		return 0;
	}
	for(int i = 1;i <= 11;i++)
	{
		if(num[i] > 2)
		{
			cout << 0 << endl;
			return 0;
		}
	}
	if(num[1] > 0 || (num[12] > 0 && num[11] > 0))
	{
		cout << 1 << endl;
		return 0;
	}
	for(int i = 1;i >= 11;i++)
	{
		if(num[i] = 2 &&(num[i+1] > 0 ||num[i-1] > 0))
		{
			cout << 1 << endl;
			return 0;
		}
	}
	int ans = 0;
	for(int now = 0;now < (1 << n);now++)
	{
		vector<int> vv;
		REP(i,n)
		{
			if(now & (1 << i))
			{
				vv.PB(24 - v[i]);
			}
			else
			{
				vv.PB(v[i]);
			}
		}
				
		int ret =100;
		REP(i,n)
		{
			REP(j,n)
			{
				if(i == j)continue;
				int tmp = abs(vv[i] - vv[j]);
				ret = min(ret,min(tmp,24-tmp));
			}
		}
		ans = max(ans,ret);
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
A = sorted(A) # とりあえず並び替えておく
tmp = 0
for i in range(N-1):
    while A[i]>0:
        tmp = A[i]
        A[i] = A[i+1] % A[i]
        A[i+1] = tmp
print(A[N-1])

Measured memory_bytes: 14252
#include <iostream>
#include <vector>

int main(void){
  using namespace std;
  
  std::vector <int> train; 
  
  int temp;
  
  while(1){
    cin >> temp;
    if(cin.eof()){break;}


    if(temp!=0){
      train.push_back(temp);
    }

    else if(temp==0)
    {
      int last=train.back();
      train.pop_back();
      cout << last << endl;
    }

  }

  return 0;
}

Measured memory_bytes: 3088
#include <stdio.h>

int main(void) {
  int n, i, j, x = 0, y;
  scanf("%d", &n);
  int a[n];
  for(i = 0; i < n; ++i) scanf("%d", &a[i]);
  for(i = 0; i < n; ++i) {
    for(j = i + 1; j < n; ++j) if(!((a[i] - a[j]) % (n - 1))) {
      x = a[i], y = a[j];
      break;
    }
    if(x) break;
  }
  printf("%d %d\n", x, y);
  return 0;
}


Measured memory_bytes: 2748
#include<stdio.h>
int main(void){
	int i,x,y,a;
	for(i=1;1;i++){
		scanf("%d %d",&x,&y);
		if(x==0&&y==0)break;
		if(x>y){
			a=x;
			x=y;
			y=a;
		}
		printf("%d %d\n",x,y);
		
	}
	return 0;
}

		

Measured memory_bytes: 600
open System
let n : int = int(Console.ReadLine())
let mutable res = n
let mutable i = 0
while i <= n do
    let mutable cc = 0
    let mutable t = i
    while t > 0 do
        cc <- cc + t % 6
        t <- t / 6
    t <- n - i
    while t > 0 do
        cc <- cc + t % 9
        t <- t / 9
    if res > cc then 
        res <- cc
    i <- i + 1
printfn "%d" res

Measured memory_bytes: 14040