akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) ((int)(x).size())
using namespace std;

vector<int> Eratos(int MAX) {
    vector<int> is_prime(MAX+1,1);
    is_prime[0] = 0; is_prime[1] = 0;
    for(int i = 2; i < MAX+1; ++i) {
        if(!is_prime[i]) continue;
        for(int j = i*2; j < MAX+1; j += i) is_prime[j] = 0;
    }
    return is_prime;
}

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

    vector<int> is_prime = Eratos(60000);
    vector<int> res;
    for(int i = 0; i <= 55555; i++) {
        if(sz(res) == n) break;
        if(is_prime[i] && i % 5 == 1) {
            res.push_back(i);
        }
    }

    rep(i,sz(res)) cout << res[i] << (i==n-1?"\n":" ");
    return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define ll long long
#define V vector<long long>
#define VV vector<vector<long long>>
#define VVV vector<vector<vector<long long>>>
#define P pair<ll,ll>
#define rep(i,n) for(ll (i)=0;(i)<(n);++(i))
using namespace std;

int main() {
    ll k;
    cin>>k;
    ll a,b;
    cin>>a>>b;
    for(ll i=a;i<=b;i++){
        if(i%k==0){
            cout<<"OK"<<endl;
            return 0;
        }
    }
    cout<<"NG"<<endl;
}


Measured memory_bytes: 3596
//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <iomanip>
#include <stack>
#include <bitset>

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

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(a>b){a=b;return 1;}return 0;}

ll a[1000100], sum[1000100];

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

  ll n;  
  cin >> n;
  REP(i,n) {
    cin >> a[i];
    if(i%2) {
      sum[i+1] = sum[i] - a[i];      
    }
    else {
      sum[i+1] = sum[i] + a[i];
    }
  }
  REP(i,n+1) {
    cerr << sum[i] << " ";
  }
  cerr << endl;
  REP(i,n) {
    if(i==0) {
      cout << sum[n] << endl;
    }
    else if(i%2) {
      cout << -sum[n] + 2*sum[i] << endl;;
    }
    else {
      cout << sum[n] - 2*sum[i] << endl;;
    }
  }
  
  return 0;
}


Measured memory_bytes: 6272
#include <bits/stdc++.h>
//#define int long long

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

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e18;
const int MOD = 1e9 + 7;

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

    string s;
    cin >> s;
    
    map<char, int> mp;
    REP(i, s.size()) mp[s[i]]++;
    
    int x = min({mp['a'], mp['b'], mp['c']});
    if(mp['a'] - x <= 1 && mp['b'] - x <= 1 && mp['c'] - x <= 1){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
using namespace std;
 
int main(void) {
    int N, K, p[200005], S[200005], i;
    double M, x;
    scanf("%d%d", &N, &K);
    for (i=0; i<N; i++) scanf("%d", &p[i]);
    S[0]=p[0];
    for (i=1; i<N; i++) S[i]=S[i-1]+p[i];
    M=0.0;
    for (i=0; i<N-K+1; i++) {
        if (i==0) x=S[K-1];
        else x=S[i+K-1]-S[i-1];
        if (x>M) M=x;
    }
    M=(M+(double)K)/2.0;
    printf("%.12f", M);
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main(void){
    string S,T;
    cin >> S >> T;
    int len = S.length();
    int ans = 0;
    for(int i=0;i<len;i++){
        if(S[i] != T[i])ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3904
#pragma GCC optimize(2)
#include<bits/stdc++.h>
using namespace std;
const int maxn=2e6+10;
typedef long long ll;
vector<int> ve[maxn];
int as[maxn];
int main()
{
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	string s;
	map<string,int> mp;
	for(int i=1;i<=n;i++)
	{
		cin>>s;
		sort(s.begin(),s.end());
		mp[s]++;
	}
	ll ans=0;
	for(auto v=mp.begin();v!=mp.end();v++)
	{
		int a=v->second;
		ans+=(ll)a*(a-1)/2;
	}
	cout<<ans<<endl;
	return 0;
}

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

typedef long long ll;

int main() {
    ll A, B, C, K;
    cin >> A >> B >> C >> K;
    if (A >= K) {
        cout << K << "\n";
    } else if (A + B >= K) {
        cout << A << "\n";
    } else {
        cout << A - (K - A - B) << "\n";
    }
}

Measured memory_bytes: 3636
#include<cstdio>
#define max(a,b) ((a)>(b)? (a):(b))
inline int read() {
	register int x=0,f=1;register char s=getchar();
	while(s>'9'||s<'0') {if(s=='-') f=-1;s=getchar();}
	while(s>='0'&&s<='9') {x=x*10+s-'0';s=getchar();}
	return x*f;
}
int main() {
	int sum=read(),n=read(),pre=0,fst,maxn=0;
	for(register int i=1;i<=n;++i) {
		int x=read();
		if(i>1) maxn=max(maxn,x-pre);
		else fst=x;
		pre=x;
	} 
	maxn=max(maxn,sum-pre+fst);
	printf("%d\n",sum-maxn);
	return 0;
}

Measured memory_bytes: 128
import java.io.BufferedReader; 
import java.io.IOException; 
import java.io.InputStreamReader; 
import java.util.Scanner; 
import java.util.StringTokenizer; 

public class Main
{ 
	static class FastScanner 
	{ 
		BufferedReader br; 
		StringTokenizer st; 
		
		public FastScanner() 
		{ 
			br = new BufferedReader(new
					InputStreamReader(System.in)); 
		} 
		
		String next() 
		{ 
			while (st == null || !st.hasMoreElements()) 
			{ 
				try
				{ 
					st = new StringTokenizer(br.readLine()); 
				} 
				catch (IOException  e) 
				{ 
					e.printStackTrace(); 
				} 
			} 
			return st.nextToken(); 
		} 
		
		int nextInt() 
		{ 
			return Integer.parseInt(next()); 
		} 
		
		long nextLong() 
		{ 
			return Long.parseLong(next()); 
		} 
		
		double nextDouble() 
		{ 
			return Double.parseDouble(next()); 
		} 
		
		String nextLine() 
		{ 
			String str = ""; 
			try
			{ 
				str = br.readLine(); 
			} 
			catch (IOException e) 
			{ 
				e.printStackTrace(); 
			} 
			return str; 
		} 
	}
	public static void main(String[] args)
	{
		FastScanner fc=new FastScanner();
		long a = fc.nextLong();
		long b = fc.nextLong();
		long c = fc.nextLong();
		long d = fc.nextLong();
		long res1 = Math.max((a*c), (a*d));
		long res2 = Math.max((b*c), (b*d));
		long res=Math.max(res1, res2);
		System.out.print(res);
	}
}



Measured memory_bytes: 32732
#include"iostream"
using namespace std;
int main(void) {
	int long long a, b, c;

	cin >> a >> b >> c;
	int long d, e, f;
	d = a - c;
	e = a + b - c;
	if (e <= 0) {
		cout << 0 << " " << 0;
	}
	else if (d <= 0 && e > 0) {
		cout << 0 << " " << e;
	}
	else {
		cout << d << " " << b;
	}


}


Measured memory_bytes: 256
#pragma comment(linker, "/STACK:512000000")
#define _CRT_SECURE_NO_WARNINGS
//#include "testlib.h"
#include <bits/stdc++.h>
#ifdef AIM
#include <sys/resource.h>
#endif
using namespace std;

#define all(a) a.begin(), a.end()
using li = long long;
using ld = long double;
void solve(bool);
void precalc();
clock_t start;
int main() {
#ifdef AIM
  freopen("/home/alexandero/CLionProjects/ACM/input.txt", "r", stdin);
  //freopen("/home/alexandero/CLionProjects/ACM/output.txt", "w", stdout);
//freopen("out.txt", "w", stdout);
#else
  //freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
#endif

#ifdef AIM
  const rlim_t kStackSize = 256 * 1024 * 1024;
  struct rlimit rl;
  int result;

  result = getrlimit(RLIMIT_STACK, &rl);
  if (result == 0) {
    if (rl.rlim_cur < kStackSize) {
      rl.rlim_cur = kStackSize;
      result = setrlimit(RLIMIT_STACK, &rl);
      if (result != 0) {
        fprintf(stderr, "setrlimit returned result = %d\n", result);
      }
    }
  }
#endif

  start = clock();
  int t = 1;
#ifndef AIM
  cout.sync_with_stdio(0);
  cin.tie(0);
#endif
  cout.precision(20);
  cout << fixed;
  //cin >> t;
  precalc();
  while (t--) {
    solve(true);
  }
  cout.flush();

#ifdef AIM1
  while (true) {
    solve(false);
  }
#endif

#ifdef AIM
  cerr << "\n\n time: " << (clock() - start) / 1.0 / CLOCKS_PER_SEC << "\n\n";
#endif
  return 0;
}

//BE CAREFUL: IS INT REALLY INT?

template<typename T>
T binpow(T q, T w, T mod) {
  if (!w)
    return 1 % mod;
  if (w & 1)
    return q * 1LL * binpow(q, w - 1, mod) % mod;
  return binpow(q * 1LL * q % mod, w / 2, mod);
}

template<typename T>
T gcd(T q, T w) {
  while (w) {
    q %= w;
    swap(q, w);
  }
  return q;
}
template<typename T>
T lcm(T q, T w) {
  return q / gcd(q, w) * w;
}

template <typename T>
void make_unique(vector<T>& vec) {
  sort(all(vec));
  vec.erase(unique(all(vec)), vec.end());
}

template<typename T>
void relax_min(T& cur, T val) {
  cur = min(cur, val);
}

template<typename T>
void relax_max(T& cur, T val) {
  cur = max(cur, val);
}

mt19937 rng((unsigned long long)chrono::steady_clock::now().time_since_epoch().count());

void precalc() {

}

//#define int li
//const li mod = 1000000007;
//const int mod = 998244353;
//using ull = unsigned long long;

void solve(__attribute__((unused)) bool read) {
  int n;
  cin >> n;
  vector<vector<int>> g(n);
  for (int i = 1; i < n; ++i) {
    int a, b;
    cin >> a >> b;
    --a; --b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  int st = 0;
  int res = 0;
  for (int w = 0; w < 2; ++w) {
    vector<int> dist(n, -1);
    dist[st] = 0;
    queue<int> q;
    q.push(st);
    while (!q.empty()) {
      int v = q.front();
      q.pop();
      for (int to : g[v]) {
        if (dist[to] == -1) {
          dist[to] = dist[v] + 1;
          q.push(to);
        }
      }
    }
    int max_id = 0;
    for (int i = 0; i < n; ++i) {
      if (dist[i] > dist[max_id]) {
        max_id = i;
      }
    }
    st = max_id;
    res = dist[max_id];
  }
  if (res % 3 == 1) {
    cout << "Second\n";
  } else {
    cout << "First\n";
  }

}

Measured memory_bytes: 13556
package main

import (
  "fmt"
  "bufio"
  "os"
)

type Op struct {
  x, y uint16
  step uint16
}

func main() {
  // constant
  const invalidValue uint16 = 0x8000
  dir4_x := [4]uint16{0xffff, 0, 1, 0}
  dir4_y := [4]uint16{0, 0xffff, 0, 1}
  
  // h, w
  var h, w uint16
  var x, y uint16
  fmt.Scan(&h)
  fmt.Scan(&w)

  // read grid
  reader := bufio.NewReaderSize(os.Stdin, 1024)
  grid := make([][]byte, h)
  for y = 0; y < h; y++ {
    line, _, _ := reader.ReadLine()
    grid[y] = make([]byte, len(line))
    copy(grid[y], line)
  }

  bfsQueue := make([]Op, 0, 1000*1000)
  var stepMap [1000][1000]uint16
  // Queue first step
  for y = 0; y < h; y++ {
    for x = 0; x < w; x++ {
      stepMap[y][x] = invalidValue
      // fmt.Printf("x%d y%d %c\n", x, y, grid[y][x])
      if grid[y][x] == '#' {
        bfsQueue = append(bfsQueue, Op{x, y, 1})
      }
    }
  }
  
  // bfs
  var op Op
  var nx, ny uint16
  for len(bfsQueue) > 0 {
    op, bfsQueue = bfsQueue[0], bfsQueue[1:]
    for i := range dir4_x {
      nx = op.x + dir4_x[i]
      ny = op.y + dir4_y[i]
      if nx >= w || ny >= h {
        continue
      }
      if grid[ny][nx] == '.' && stepMap[ny][nx] > op.step {
        stepMap[ny][nx] = op.step
        bfsQueue = append(bfsQueue, Op{nx, ny, op.step + 1})
        // fmt.Printf("%v nx%d ny%d\n", op, nx, ny)
      }
    }
  }
  
  // count
  var maxStep uint16 = 0
  var n uint16
  for y = 0; y < h; y++ {
    for x = 0; x < w; x++ {
      n = stepMap[y][x] & 0x7fff
      if n > maxStep {
        maxStep = n
      }
    }
  }

  fmt.Println(maxStep)
}


Measured memory_bytes: 9728
using System;
using System.Collections.Generic;
using System.Linq;
public class Hello{
    public static void Main(){
        var a = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        var N = a[0];
        var T = a[1];
        
        var t = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        long count = 0;
        for(var i = 1;i < N;i++){
            if(t[i] - t[i - 1] < T){
                count += t[i] - t[i - 1];
            }else{
                count += T;
            }
        }
        count += T;
        Console.WriteLine(count);
    }
}


Measured memory_bytes: 28704
#include<iostream>
using namespace std;
int h[100000];
int main()
{
int n,k,br=0;
cin >> n;
cin >> k;
for (int i=0;i<n;++i)
{
  cin >> h[i];
  if (h[i]>=k)
  	br=br+1;
}
cout << br;
}

Measured memory_bytes: 640
using System;
using System.IO;

class Program{
    static void Main(string[] args){
        var arr = Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
        long N = arr[0], K = arr[1];
        long answer;
        var mod = N % K;
        if (mod == 0) answer = 0;
        else { long abs = Math.Abs(mod - K); answer = mod < abs ? mod : abs; }
        var writer = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(writer);
        Console.WriteLine(answer);
        Console.Out.Flush();}}

Measured memory_bytes: 27520
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <queue>
#include <stack>
#include <stdlib.h>
using namespace std;
#define rep(i,n) for (int i = 0; i <n; i++) 
#include <math.h>
#include <bits/stdc++.h>
using namespace std;

using namespace std;
int main(){
    string s;std::cin >> s;
    int n=s.size();
    int a[n];
    rep(i,n){
        if((s.at(i)=='A')||(s.at(i)=='G')||(s.at(i)=='C')||(s.at(i)=='T'))a[i]=1;
        else a[i]=0;
    }
    int ans=0;int w=0;
    rep(i,n){
        if(a[i]==1)w++;
        else w=0;
        ans=max(w,ans);
    }
    std::cout << ans << std::endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <time.h>
#define first fi
#define second se


using namespace std;

typedef long long ll;
typedef double db;
int xx[4] = {1,-1,0,0};
int yy[4] = {0,0,1,-1};
const double eps = 1e-9;
typedef pair<int,int>  P;
const int maxn = 2e6 + 5000;
const ll mod = 1e9 + 7;
inline int sign(db a) {
    return a < -eps ? -1 : a > eps;
}
inline int cmp(db a,db b) {
    return sign(a - b);
}
ll mul(ll a,ll b,ll c) {
    ll res = 1;
    while(b) {
        if(b & 1) res *= a,res %= c;
        a *= a,a %= c,b >>= 1;
    }
    return res;
}
ll phi(ll x) {
    ll res = x;
    for(ll i = 2; i * i <= x; i++) {
        if(x % i == 0) res = x / i * (i - 1);
        while(x % i == 0) x /= i;
    }
    if(x > 1) res = res / x  * (x - 1);
    return res;
}
ll c,n,k,x,y;
string str;
ll a[maxn],b[maxn],r[maxn],fa[maxn];
ll Find(int x) {
    if(x == fa[x]) return fa[x];
//    int i = fa[x];
    fa[x] = Find(fa[x]);
//    r[x] += r[i];
    return fa[x];
}
int main() {
    int m;
    ios::sync_with_stdio(false);
    while(cin >> n >> m) {
        for(int i = 1; i <= n; i++) fa[i] = i,r[i] = 1;
        for(int i = 1; i <= m; i++) {
            cin >> a[i] >> b[i];
        }
        vector<ll>anss;
        ll ans = (n - 1) * (n)  / 2;
        for(int i = m; i >= 1; i--) {
                anss.push_back(ans);
            int X = Find(a[i]);
            int Y = Find(b[i]);
            if(X != Y) {
                fa[Y] = X;
                ans -= r[X] * r[Y];
                r[X] += r[Y];
            }
        }
        reverse(anss.begin(),anss.end());
        for(auto d:anss){
            cout << d <<endl;
        }

    }
    //cout << "time: " << (long long)clock() * 1000 / CLOCKS_PER_SEC << " ms" << endl;
    return 0;
}



Measured memory_bytes: 13300
#include <algorithm>
#include <cstdio>
#include <queue>
#include <tuple>
#include <vector>
#define repeat(i, n) for (int i = 0; (i) < int(n); ++(i))
#define whole(x) begin(x), end(x)
using namespace std;
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;

int main() {
    // input
    int n, m; scanf("%d%d", &n, &m);
    vector<pair<int, int> > lrs(n);
    repeat (i, n) {
        int l, r; scanf("%d%d", &l, &r); -- l; -- r;
        lrs[i] = { l, r };
    }
    // solve
    sort(whole(lrs));
    int left = 0;
    reversed_priority_queue<int> unused_rs;
    vector<int> rs;
    for (auto lr : lrs) {
        int l, r; tie(l, r) = lr;
        if (l == -1 and r == m) {
            // nop
        } else if (l == -1) {
            rs.push_back(r);
        } else {
            if (left <= l) {
                ++ left;
                unused_rs.push(r);
            } else {
                unused_rs.push(r);
                int min_r = unused_rs.top();
                unused_rs.pop();
                rs.push_back(min_r);
            }
        }
        if (left == m) {
            break;
        }
    }
    int right = m;
    sort(whole(rs));
    reverse(whole(rs));
    for (int r : rs) {
        if (left == right) {
            break;
        }
        if (r == m) {
            // nop
        } else {
            if (r < right) {
                -- right;
            }
        }
    }
    // output
    int used = left + (m - right);
    printf("%d\n", n - used);
    return 0;
}


Measured memory_bytes: 4728
h, w, k = map(int, input().split())
c = [list(input()) for _ in range(h)]
ans = 0
for i in range(1<<h):
    for j in range(1<<w):
        cnt = sum(c[k][l] == '#' for k in range(h) for l in range(w) if (i>>k & 1) and (j>>l & 1))
        if cnt == k:
            ans += 1
print(ans)


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

int main(){
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  
  int L = A + B;
  int R = C + D;
  
  if(L > R) cout << "Left" << endl;
  else if(L == R) cout << "Balanced" << endl;
  else cout << "Right" << endl;
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl
using namespace std;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
#define pb push_back
template<class T> void print(const T& x){cout << x << endl;}
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
typedef long long ll;
const int inf = 1000000001;
const ll INF = 1e18 * 4;

int main(){
    int N; cin >> N;
    int year=N;
    rep(i, N, 1000){
        string is = to_string(i);
        if(is[0] == is[1] && is[1] == is[2]){
            year = i;
            break;
        }
    }
    cout << year << endl;
    return 0;
}




Measured memory_bytes: 3640
import java.util.*;

public class Main {

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

        String result = sum-max > max ? "Yes" : "No";
        System.out.println(result);
    }
}

Measured memory_bytes: 21972
#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;
 
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<long long, long long> pl;
 
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define speedhack() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define form(i, n) for (size_t i = 0; i < size_t(n); ++i)
#define forn(i, n) for (size_t i = 1; i <= size_t(n); ++i)
template<class T> using ordered_set=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll mod(ll a, ll b) { return (a%b+b)%b; }
ll gcd(ll x, ll y) { return __gcd(x, y); }
ll lcm(ll x, ll y) { return x * 1ll * y / gcd(x, y); }
 
 
const ll MAXN = 1e18;
const ll SIZE = 1e5 + 5;
const ll MOD  = 1e9 + 7;


ull N, m = 1, arr[SIZE];
double sum;
bool ok = true;
bool ze = false;

int main() { speedhack()

	cin >> N;
	forn (i, N)
		cin >> arr[i];

	forn (i, N) {
		if (arr[i] == 0) {
			cout << 0;
			return 0;
		}
	}

	forn (i, N)
		sum += log10(arr[i]);

	if (sum > 18.0) {
		cout << -1;
		return 0;
	}

	forn (i, N) {
		m = m * arr[i];
		if (m > MAXN) {
			cout << -1 << endl;
			return 0;
		}
	}

	cout << m;



	return 0;
}


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

using namespace std;
using ll = long long;

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

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

  ll ans = 1000;
  for (int i = 0; i < n - 1; i++) {
    if (a[i] < a[i + 1]) {
      ll d = ans / a[i];
      ans = ans % a[i];
      ans += d * a[i + 1];
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3656
#include<stdio.h>

int main(){
    int  Num[100]={0};
    char Dir[100]={0};
    int i=0, imax=0, Upper, tmp=0, q=0, u[24]={0} ,f[24]={0}, Ans=0;
    
    scanf("%d %d %d %d %d %d", &Num[1], &Num[2], &Num[3], &Num[4], &Num[5], &Num[6]);
    scanf("%d",&q);
    for(i=0;i<q; i++){
        scanf("%d %d", &u[i], &f[i]);
    }
    
    
    //Num[1] = u[i]; 
    //Num[2] = f[i];
    
    for(i=0; i<q; i++){
        if(u[i] == Num[1]){
            if(f[i] == Num[2]){
                Ans = Num[3];
            }else if(f[i] == Num[3]){
                Ans = Num[5];
            }else if(f[i] == Num[4]){
                Ans = Num[2];
            }else if(f[i] == Num[5]){
                Ans = Num[4];
            }
        }else if(u[i] == Num[2]){
            if(f[i] == Num[1]){
                Ans = Num[4];
            }else if(f[i] == Num[3]){
                Ans = Num[1];
            }else if(f[i] == Num[4]){
                Ans = Num[6];
            }else if(f[i] == Num[6]){
                Ans = Num[3];
            }
        }else if(u[i] == Num[3]){
            if(f[i] == Num[1]){
                Ans = Num[2];
            }else if(f[i] == Num[2]){
                Ans = Num[6];
            }else if(f[i] == Num[5]){
                Ans = Num[1];
            }else if(f[i] == Num[6]){
                Ans = Num[5];
            }
        }else if(u[i] == Num[4]){
            if(f[i] == Num[1]){
                Ans = Num[5];
            }else if(f[i] == Num[2]){
                Ans = Num[1];
            }else if(f[i] == Num[6]){
                Ans = Num[2];
            }else if(f[i] == Num[5]){
                Ans = Num[6];
            }
        }else if(u[i] == Num[5]){
            if(f[i] == Num[1]){
                Ans = Num[3];
            }else if(f[i] == Num[3]){
                Ans = Num[6];
            }else if(f[i] == Num[4]){
                Ans = Num[1];
            }else if(f[i] == Num[6]){
                Ans = Num[4];
            }
        }else if(u[i] == Num[6]){
            if(f[i] == Num[2]){
                Ans = Num[4];
            }else if(f[i] == Num[3]){
                Ans = Num[2];
            }else if(f[i] == Num[4]){
                Ans = Num[5];
            }else if(f[i] == Num[5]){
                Ans = Num[3];
            }
        }
        printf("%d\n", Ans);
    }
    
    
return 0;
}


Measured memory_bytes: 2088
const combination = (nums, k) => {
    let ans = [];
    if (nums.length < k) {
        return []
    }
    if (k === 1) {
        for (let i = 0; i < nums.length; i++) {
            ans[i] = [nums[i]];
        }
    } else {
        for (let i = 0; i < nums.length - k + 1; i++) {
            let row = combination(nums.slice(i + 1), k - 1);
            for (let j = 0; j < row.length; j++) {
                ans.push([nums[i]].concat(row[j]));
            }
        }
    }
    return ans;
}
const main = (input) => {
 	const data = input.split('\n')
    const n = Number(data[0])
    const ds = data[1].split(' ').map(n => Number(n))
	const arr = combination(ds, 2)
    
    let result = 0;
  	arr.forEach(nums => {
    	result += nums.reduce((a, b) => a*b)
    })
  console.log(result)
 
 
 
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))

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

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		Fibonacci fibonacci = new Fibonacci(Integer.parseInt(in.readLine()));
		fibonacci.numberCulc();
	}
}

class Fibonacci {
	public int[] fibonacci;
	public int result;
	private int[] fibonacciResults;

	public Fibonacci(int fibonacci) {
		this.fibonacci = new int[fibonacci + 1];
		this.fibonacciResults = new int[fibonacci + 1];
	}

	public int fibFunc(int num) {
		if (num == 0 || num == 1) {
			return fibonacciResults[num] = 1;
		} else if (fibonacciResults[num] != 0) {
			return fibonacciResults[num];
		} else {
			return fibonacciResults[num] = fibFunc(num - 1) + fibFunc(num - 2);
		}
	}

	public void numberCulc() {
		for (int i = 0; i < fibonacci.length; i++) {
			fibonacci[i] = fibFunc(i);
		}
		result = fibonacci[fibonacci.length - 1];
		System.out.println(result);
	}
}

Measured memory_bytes: 24172
#include<iostream>
#include<cstdio>
using namespace std ;
int main(){
  int W,H;
  for( ; ; ){
    cin >> H >> W; 
    if(H==0 && W==0)break;
    for(int i=0;i<H;i++){
      for(int k=0;k<W;k++){
	if(i>0 && H-1>i && W-1>k && k>0){
	  printf(".");
	}else{
	  printf("#");
	} 
      }
    cout<<endl;
    }
cout<<endl;
  }

  return 0;
}

Measured memory_bytes: 3000
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

ll a[102];
int main() {
	ll n;
	cin>>n;
	ll ans=0;
	for(int i=0;i<n;i++){
		cin>>a[i];
		ans+=a[i];
	}
	if(ans%10!=0){
		cout <<ans;
		return 0;
	}
	ll ans2=0;
	for(int i=0;i<n;i++){
		if((ans-a[i])%10!=0){
			ans2=max(ans2,ans-a[i]);
		}
	}
	cout <<ans2;
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>

int main() {
    int max = -(int)2e9, min = (int)2e9;
    int n; scanf("%d", &n);
	for (int i = 0; i < n; i++){
		int tmp; scanf("%d", &tmp);
		if (max < tmp - min) max = tmp - min;
		if (min > tmp) min = tmp;
	}
	printf("%d\n", max);
	return 0;
}


Measured memory_bytes: 2712
def collatz(n):
    i=0
    while n != 1:
        
        if n%2==0:
            n = n/2
            i=i+1
        else:
            n=3*n+1
            i=i+1
    return(i)
    
while True:
    n=int(input())
    if n==0:
        break
    print(collatz(n))
    


Measured memory_bytes: 5604
#include <stdlib.h>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
   int a;
   double b,sum;
   string c;
   cin>>a;
   sum=0;
   rep(i,a){
       cin>>b>>c;
       if(c=="JPY"){
           sum+=b;
       }
       else{
           //cout<<b*380000<<endl;
           sum=sum+380000*b;
       }
   }
   cout<<sum<<endl;
}



Measured memory_bytes: 256
// #include <stack>
// #include <queue>
// #include <map>
// #include <set>
// #include <vector>
// #include <random>
// #include <cmath>
// #include <chrono>
// #include <cstring>
// #include <algorithm>
// #include <string>
// #include <iostream>
// #include <cstdio>
// #include <cstring>
// #include <cassert>
#include<bits/stdc++.h>
using namespace std;
using LL = long long;
#define eps 1e-8
#define fi first
#define se second
#define eb emplace_back
#define close std::ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
#define FOR(i, x, y) for (LL i = (x), _##i = (y); i < _##i; ++i)
#define FORD(i, x, y) for (LL i = (x), _##i = (y); i > _##i; --i)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define CASET int ___T; cin>>___T; for(int __CS=1;__CS<=___T;__CS++)
#define int long long 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
mt19937 dlsrand(random_device{}());
mt19937 mrand(std::chrono::system_clock::now().time_since_epoch().count()); 
int rnd(int x) { return mrand() % x;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
LL bin(LL x, LL n, LL MOD) {LL ret = MOD != 1;for (x %= MOD; n; n >>= 1, x = x * x % MOD)if (n & 1) ret = ret * x % MOD;return ret;}
inline LL get_inv(LL x, LL p) { return bin(x, p - 2, p); }
const double PI = acos(-1.0);
constexpr int maxn = 1e6+10;
constexpr int INF = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3f;
constexpr int mod = 1e9+7;
void add(int &a,int b) {a+=b; if(a>=mod) a-=mod;}
void dec(int &a,int b) {a-=b; if(a<0) a+=mod;}
int a[maxn],b[maxn];
int32_t main()
{
    close;
    int n;
    cin >> n;
    unordered_map<int , int > mp;
    for(int i = 1;i <= n; i++){
        cin >> a[i];b[i] = a[i];
        int m = sqrt(a[i]+0.5);
        for(int j = 2; j <= m; j++){
            if(a[i] % j == 0){
                int ret = 0;
                while(a[i] % j == 0){
                    a[i] /= j;
                    ret++;
                }
                if(mp.count(j)){
                    mp[j] = max(ret , mp[j]);
                }else mp[j] = ret;
            }
        }
        if(a[i] > 1){
            if(mp.count(a[i])){
                mp[a[i]] = max(1ll, mp[a[i]]);
            }else mp[a[i]] = 1;
        }
    }
    int ans = 0;
    // for(auto it : mp)cout << it.first << ' ';cout << endl;
    for(int i = 1; i <= n; i++){
        int zz = 1;
        for(auto p : mp){
            int cs = p.second;
            while(b[i] % p.first == 0) {
                b[i] /= p.first;
                cs--;
            }
            zz = zz * bin(p.first , cs , mod) % mod;
        }
        // cout << "i === " << i << "   zz == " << zz << endl;
        ans = (ans + zz ) % mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 2816
#include <bits/stdc++.h>
#define MODNum 1000000007
#define REP(type, i, a, b) for( type i = a; i < b; i++ )
typedef long long ll;

using namespace std;

int main (void) {
    ll N;
    string S,T;
    scanf("%lld", &N);
    cin >> S;
    cin >> T;
    REP(int, i, 0, N){
        cout << S.at(i) << T.at(i);
    }
    cout << endl;
    return 0;
}

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

//flagを用いたバブルソート
int bubbleSort(int A[], int N){
  int sw = 0;
  bool flag = 1;
  for ( int i = 0; flag; i++ ){
    flag = 0;
    for ( int j = N-1; j >= i+1; j--){
      if( A[j] < A[j-1]){
        swap(A[j],A[j-1]);
        flag = 1;
        sw++;
      }
    }
  }
  return sw;
}
int main(){
  int A[100],N,sw;
  cin >> N;
  for (int i = 0;i < N; i++) cin >> A[i];
  
  sw = bubbleSort(A,N);
  
  for (int i = 0; i < N ; i++){
    if (i) cout << " ";
    cout << A[i];
  }
  cout << endl;
  cout << sw << endl;
  
  return 0;
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;
struct Edge {
    ll to, cost;
};


class Dijkstra {
    ll vector_count;

    vector<ll> distances;
    vector<vector<Edge>> edges;

public:
    Dijkstra(ll n) {
        vector_count = n;
        distances.resize(n, INF);
        edges.resize(n);
    }

    void insertTowWay(ll from, ll to, ll cost) {
        edges[from].push_back({to, cost});
        edges[to].push_back({from, cost});
    }

    void insert(ll from, ll to, ll cost) {
        edges[from].push_back({to, cost});
    }

    void dijkstra(ll k) {
        distances[k] = 0;  // 始点sへの最短距離は0

        priority_queue<P, vector<P>, greater<P>> que;  // 距離が小さい順に取り出せるようgreater<P>を指定
        que.push(P(0, k));
        while (!que.empty()) {
            P p = que.top();
            que.pop();
            int v = p.second;  // 更新した頂点の中で距離が最小の頂点v
            if (distances[v] < p.first) {
                continue;
            }
            for (auto e : edges[v]) {  // 頂点vから出る辺eを走査
                if (distances[e.to] > distances[v] + e.cost) {
                    distances[e.to] = distances[v] + e.cost;
                    que.push(P(distances[e.to], e.to));
                }
            }
        }
    }

    ll distance(ll to) {
        return distances[to];
    }

};

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

    Dijkstra dijkstra(n);

    rep(i, n) {
        if (i == 0)continue;
        dijkstra.insert(i, i - 1, 0);
    }

    rep(_, m) {
        int l, r;
        ll cost;
        cin >> l >> r >> cost;

        l--;
        r--;

        dijkstra.insert(l, r, cost);
    }

    dijkstra.dijkstra(0);
    ll now = dijkstra.distance(n - 1);
    ll ans = (now == INF) ? -1 : now;
    cout << ans << endl;

}

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

#define select(_1, _2, x, ...) x

#define repn(i, n) for (int i = 0; i < (n); i++)
#define repr(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, ...) select(__VA_ARGS__, repr, repn)(i, __VA_ARGS__)

#define rrepn(i, n) for (int i = (n - 1); i >= 0; i--)
#define rrepr(i, a, b) for (int i = (b - 1); i >= (a); i--)
#define rrep(i, ...) select(__VA_ARGS__, rrepr, rrepn)(i, __VA_ARGS__)

#define umax(m, x) (m = max(m, x));
#define umin(m, x) (m = min(m, x));

#define rng(v) v.begin(), v.end()
#define rrng(v) v.rbegin(), v.rend()

#define debug(x) cerr << #x << " = " << x << endl

using namespace std;

using ll = long long int;

using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;

using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using vvs = vector<vector<string>>;

const int INF = 1e9;
const ll LINF = 1e18;

inline void yn(bool f) { cout << (f ? "Yes" : "No") << endl; }


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

    cout << r * 2 * 3.141592 << endl;

    return 0;
}


Measured memory_bytes: 3780
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<vector>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#define ll long long
#define F(i,a,b) for(int i=(a);i<=(b);i++)
#define mst(a,b) memset((a),(b),sizeof(a))
#define PII pair<int,int>
#define rep(i,x,y) for(auto i=(x);i<=(y);++i)
#define dep(i,x,y) for(auto i=(x);i>=(y);--i)
using namespace std;
template<class T>inline void rd(T &x) {
    x=0; int ch=getchar(),f=0;
    while(ch<'0'||ch>'9'){if (ch=='-') f=1;ch=getchar();}
    while (ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}
    if(f)x=-x;
}
const int inf=0x3f3f3f3f;
const int maxn=100050;
ll x,y,a,b,c;
ll p[maxn],q[maxn],r[maxn];
int main()
{
    cin>>x>>y>>a>>b>>c;
    rep(i,1,a) rd(p[i]);
    rep(i,1,b) rd(q[i]);
    rep(i,1,c) rd(r[i]);
    sort(p+1,p+a+1);
    sort(q+1,q+b+1);
    sort(r+1,r+c+1);
    reverse(r+1,r+c+1);
    ll ans=0;
    rep(i,a-x+1,a) ans+=p[i];
    rep(i,b-y+1,b) ans+=q[i];
    ll sum=0;
    ll i=a-x+1,j=b-y+1;
    ll idx=1;
    while((i<=a||j<=b)&&idx<=c)
    {
        ll t1,t2;
        t1=t2=0;
        if(i<=a) t1=r[idx]-p[i];
        if(j<=b) t2=r[idx]-q[j];
        if(t1<=0&&t2<=0) break;
        else 
        {
            if(t1>t2) 
            {
                ans+=t1;
                i++;
                idx++;
            }
            else 
            {
                ans+=t2;
                j++;
                idx++;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
const int N = 2e5;
#define fr(i,a,b) for(int i = a;i <= b; ++i)
#define nfr(i,a,b) for(int i = a;i >= b; --i)
#define less less1234567891
#define plus plus1234567891

inline void plus(int i,int j,int k){
   printf("+ %d %d %d\n",i,j,k);
}

inline void less(int i,int j,int k){
   printf("< %d %d %d\n",i,j,k);
}

int main(){
   // init for 1~2^30 in 3~33
   puts("6451");
  // freopen("ans.out","w",stdout);
   plus(0,1,165);
   fr(i,3,33){
      less(i,165,i);
      fr(j,4,i)plus(i,i,i);
   }
   // divide v[0] in 35~65 halves in 34, check in 66, vals in 67
   plus(0,3,0);
   nfr(i,30,0){
      plus(34,3+i,66);
      less(66,0,35+i);
      plus(2,35+i,67);
      fr(w,1,i)plus(67,67,67);
      plus(67,34,34);
   }
   // divide v[1] in 69~99 halves in 68, check in 100, vals in 101
   plus(1,3,1);
   nfr(i,30,0){
      plus(68,3+i,100);
      less(100,1,69+i);
      plus(2,69+i,101);
      fr(w,1,i)plus(101,101,101);
      plus(101,68,68);
   }
   // solve v[0] times v[1] in 102~162,val in 163
   fr(i,35,65)
      fr(j,69,99){
         plus(i,j,163);
         less(3,163,163);
         plus(163,i+j-2,i+j-2);
      }

   fr(i,102,162){
      fr(j,103,i)plus(i,i,i);
      plus(i,2,2);
   }
   return 0;
}


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

int main(){
  int n, h, w;
  cin >> n >> h >> w;
  cout << (n-h+1) * (n-w+1) << endl;
}


Measured memory_bytes: 256
n = int(input())
ls = list(map(int,input().split()))
lsb = [0 for i in range(n)]

for i in range(n):
    a = 0
    while  a == 0:
        if ls[i] % 2 == 0:
            lsb[i] += 1
            ls[i] = ls[i] // 2
        else:
            a = 1

ans = min(lsb)
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    int h, m, s;
    s = n;
    m = s / 60;
    s -= m * 60;
    h = m / 60;
    m -= h * 60;
    cout << h << ":" << m << ":" << s << endl;
}



Measured memory_bytes: 3088
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define Sort(a) sort(a.begin(), a.end())
const int INF = 1 << 30;
const ll MOD = 1000000007;

int N, M;
vector<int> swi;
vector<int> lights;
vector<vector<int>> conditions;

bool isValid(int bit) {
  for (int i = 0; i < M; i++) {
    int bitCount = 0;
    for (int j = 0; j < conditions[i].size(); j++) {
      if (bit & (1 << (conditions[i][j] - 1))) bitCount++;
    }
    if (bitCount % 2 != lights[i]) return false;
  }
  return true;
}

int main(void) {
  cin >> N >> M;
  swi.resize(N);
  lights.resize(M);
  conditions.resize(M);
  int count = 0;

  for (int i = 0; i < M; i++) {
    int k;
    cin >> k;
    conditions[i].resize(k);
    for (int j = 0; j < k; j++) {
      cin >> conditions[i][j];
    }
  }

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

  for (int bit = 0; bit < (1 << N); bit++) {
    if (isValid(bit)) count++;
  }

  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
fn check(marutas: &Vec<f64>, size: usize, k: usize) -> bool {
    let size = size as f64;
    let mut t = 0;
    for &m in marutas {
        if m > size {
            t += (m / size).floor() as usize;
        }
        // m をsize以下にしたい
    }
    // println!("{:?}", (t, size));
    t <= k
}

fn solve() {
    let n: usize = read();
    println!("{}", (1000 - n % 1000) % 1000);
}

fn main() {
    let stack_size = 104_857_600;
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}

// =========
#[allow(unused_imports)]
use std::cmp::{max, min, Reverse};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap, HashSet};
#[allow(unused_imports)]
use std::process::exit;

#[allow(dead_code)]
const MOD: usize = 1000000007;

fn read<T: std::str::FromStr>() -> T {
    use std::io::Read;
    let stdin = std::io::stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

// =========


Measured memory_bytes: 2268
import java.io.BufferedReader;
import java.io.InputStreamReader;
 
public class Main {
    public static void main(String[] args) throws Exception {
        
        int x = 0;
        int y = 0;
        
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = br.readLine();
        
        int n = Integer.parseInt(line);
        
        for (int i = 1;i <= n;i++){
            x = x + 800;
            
                if (i / 15 != 0 && i % 15 == 0){
                    y = y + 200;
            } 
        } 
        
		System.out.println(x - y);
	}
}

Measured memory_bytes: 22484
def primes(n):#nまでの素数を列挙
    is_prime = [True]*(n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2,int(n**(0.5)+1)):
        if not is_prime[i]:
            continue
        for j in range(i*2,n+1,i):
            is_prime[j] = False
    return [i for i in range(n+1) if is_prime[i]], is_prime
li_p, is_prime = primes(10**5+1)
li_p.reverse()
for i in li_p:
    if  is_prime[int((i+1)/2)]:
        continue
    else:
        is_prime[i] = False
res = [0] * (10**5+1)
for i in range(10**5+1):
    if i == 0:
        continue
    if is_prime[i]:
        res[i] = res[i-1] + 1
    else:
        res[i] = res[i-1]
q = int(input())
for _ in range(q):
    l, r = map(int, input().split())
    if l>0:
        print(res[r] - res[l-1])
    else:
        print(res[r])

Measured memory_bytes: 73504
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(n); ++i)
#define repr(i, a, b) for (int i=a; i<(b); ++i)
#define reprev(i, n) for (int i=n-1; i>=0; --i)
#define reprrev(i, a, b) for (int i=b-1; i>=(a); --i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    cout << fixed << setprecision(10);
    
    int N; cin >> N;
    string S; cin >> S;
    set<int> rp, gp, bp;
    rep(i, N) {
        if (S[i] == 'R') {
            rp.emplace(i);
        } else if (S[i] == 'G') {
            gp.emplace(i);
        } else {
            bp.emplace(i);
        }
    }
    if (rp.size() == 0 || gp.size() == 0 || bp.size() == 0) {
        cout << 0 << endl;
        return 0;
    }

    ll ans = 0;
    for (auto x: rp) {
        // cout << x << endl;
        for (auto y: gp) {
            ans += bp.size();
            // r g bの順番のとき
            int ng_pos = y + (y - x);
            if (bp.count(ng_pos)) {
                ans -= 1;
            }
            // r b gの順番のとき
            ng_pos = y+x;
            if (ng_pos % 2 == 0 && bp.count(ng_pos/2)) {
                ans -= 1;
            }
            ng_pos = x - (y - x);
            if (bp.count(ng_pos)) {
                ans -= 1;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3796
import std.algorithm;
import std.array;
import std.conv;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

int solve (int n)
{
	auto a = new int [] [n];
	foreach (j; 0..n - 1)
	{
		int u, v;
		readf (" %s %s", &u, &v);
		u -= 1;
		v -= 1;
		a[u] ~= v;
		a[v] ~= u;
	}

	auto p = new int [n];
	auto d = new int [n];

	void recur (int v, int w, int c)
	{
		p[v] = w;
		d[v] = c;
		foreach (u; a[v])
		{
			if (u != w)
			{
				recur (u, v, c + 1);
			}
		}
	}

	recur (0, -1, 0);

	auto e = new int [n];
	int h = d[n - 1];
	int [] path;
	for (int v = n - 1; v != 0; v = p[v])
	{
		path ~= v;
	}
	path ~= 0;
	reverse (path);
	while (true)
	{
		if (path.empty)
		{
			break;
		}
		e[path.front] = 1;
		path.popFront ();
		if (path.empty)
		{
			break;
		}
		e[path.back] = 2;
		path.popBack ();
	}

	void color (int v, int c)
	{
		foreach (u; a[v])
		{
			if (e[u] == 0)
			{
				e[u] = c;
				color (u, c);
			}
		}
	}

	foreach (v; 0..n)
	{
		if (e[v] != 0)
		{
			color (v, e[v]);
		}
	}

	foreach (v; 0..n)
	{
		if (e[v] == 0)
		{
			assert (false);
		}
	}

	return e.count (1) > e.count (2);
}

void main ()
{
	int n;
	while (readf (" %s", &n) > 0)
	{
		writeln (solve (n) ? "Fennec" : "Snuke");
	}
}


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

using namespace std;

const int md = 1e9 + 7;

using ll = long long;
ll solve(vector<vector<int>> &tree, int k, int cur = 0, int p = -1) {
  ll ans = 1, base = k - (p != -1);

  for (int i = 0, nth = 1; i < tree[cur].size(); ++i, ++nth) {
    if (tree[cur][i] == p) {
      nth--;
      continue;
    }

    ans = ans * (base - nth) % md;
    ans = ans * solve(tree, k, tree[cur][i], cur) % md;
  }

  return ans;
}

int main(int argc, const char *argv[]) {
  int n, k;
  cin >> n >> k;

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

  cout << solve(tree, k) * k % md << '\n';
  return 0;
}


Measured memory_bytes: 12800
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int digit(int N) {
  return floor(log10(N))+1;
}

int main() {
  int N;
  cin >> N;
  int ans = 0;
  REP(i, 1, N+1)
    if(digit(i) % 2 == 1)
      ans++;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin,(obj).end()
#define SORT(list) sort(ALL((list)));
using namespace std;
using ll = long long;
int main(){
    int n,k;
    cin >> n >> k;
    int ans = 1;
    REP(i,n)ans = min(ans+k,2*ans);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <utility>
using namespace std;

int main() {
  int s;
  cin>>s;
 
  set<int> st;
  
  while(st.count(s)==0){
    st.insert(s);
    if(s%2==0)
      s/=2;
    else
      s=3*s+1;
  }
  
  cout<<st.size()+1<<endl;
}


Measured memory_bytes: 256