akhauriyash/Code-Regression huggingface dataset:
/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-03-14 20:55:12
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <iomanip>
#include <random>
#include <utility>
#include <chrono>

using namespace std;

using int64 = long long;

template<class T> using binary_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;
template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) { os << '{'; size_t n = vec.size(); for (size_t i = 0; i < n; ++i) { os << vec[i]; if (i != n - 1) os << ','; } os << '}'; return os; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) { os << '{'; for (auto it = mp.begin(); it != mp.end(); ++it) { os << '{' << it->first << ':' << it->second << '}'; if (it != --mp.end()) os << ','; } os << '}'; return os; }
template<class T> std::ostream& operator<<(std::ostream& os, const std::set<T>& st) { os << '{'; for (auto it = st.begin(); it != st.end(); ++it) { os << *it; if (it != --st.end()) os << ','; } os << '}'; return os; }
template<class T> std::istream& operator>>(std::istream& is, std::vector<T>& vec) { size_t n = vec.size(); for (size_t i = 0; i < n; ++i) is >> vec[i]; return is; }

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...) 1728
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}

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

  int64 h, w; cin >> h >> w;

  if (h == 1LL || w == 1LL) {
    cout << 1 << endl; return 0;
  }

  if ((h & 1) && (w & 1)) {
    cout << h * w / 2LL + 1LL << endl;
  } else if ((h & 1) || (w & 1)) {
    cout << h * w / 2LL << endl;
  } else {
    cout << h * w / 2LL << endl;
  }

  return 0;
}


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

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

#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>
#define vi vector<int>
#define vii vector<vi>

const double pi = 3.14159265358979323846264;
const int mod=1000000007;

int main(){
	 //cin.tie(0);
	//ios::sync_with_stdio(false);
	//std::cout << std::fixed;
	//std::cout << std::setprecision(12);
	//std::cout << std::defaultfloat;
	int cnt=0;
	int n,d;
	cin>>n>>d;
	vii x(n,vi(d,0));
	FOR(i,0,n){
		FOR(j,0,d){
			cin>>x[i][j];
		}
	}
	FOR(i,0,n){
		FOR(j,i+1,n){
			int ss=0;
			FOR(k,0,d){
				ss+=(x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
			}
			FOR(ii,0,5000){
				if(ii*ii==ss)cnt++;
			}
		}
	}
	cout<<cnt<<endl;


	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL (-1)
#define LL long long
using namespace std;
const int64_t MOD = 1e9 + 7;
const int INF = INT_MAX;

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

	vector<int> v(N);
	int b1, b2;
	b1 = NIL; b2 = NIL;

	for (int i = 0; i < N; i++) {
		int n;
		cin >> n;
		v[i] = n;
		if (n >= b1) {
			b2 = b1;
			b1 = n;
		}
		else if (n >= b2) {
			b2 = n;
		}
	}

	for (int i = 0; i < N; i++) {
		int n = v[i];
		if (n == b1) cout << b2 << endl;
		else cout << b1 << endl;
	}
}

Measured memory_bytes: 3968
#include<iostream>
#include<vector>
#include<math.h>
#include<algorithm>
#include<memory>
#include<string>

int main() {
	char *N = new char[3];
	std::cin >> N;
	if (*N == '7' || *(N+1) == '7' || *(N+2) == '7') {
		std::cout << "Yes" << std::endl;
	}
	else {
		std::cout << "No" << std::endl;
	}
	return 0;
}

Measured memory_bytes: 3628
#include<stdio.h>
typedef struct{
  int a,b,c,d;
}Node;
Node SEA[100001];
int rec(int,int);
int main(){
  int e,f;
  int id,g,h,k,m;
  int i,j;
  scanf("%d",&e);
  for(i=0;i<e;i++){
    SEA[i].a=SEA[i].b=SEA[i].c=-1;
  }
  for(i=0;i<e;i++){
    scanf("%d%d",&id,&f);
    for(j=0;j<f;j++){
	scanf("%d",&g);
	if(j==0)SEA[id].b = g;
	else SEA[h].c=g;
	h = g;
	SEA[g].a = id;
      }
  }
  for(i=0;i<e;i++) if(SEA[i].a==-1)k = i;
  rec(k,0);

  for(i=0;i<e;i++){
    printf("node %d: parent = %d, depth = %d, ",i,SEA[i].a,SEA[i].d);
    if(SEA[i].a==-1)printf("root, ");
    else if(SEA[i].b!=-1)printf("internal node, ");
    else printf("leaf, ");
    printf("[");
    if(SEA[i].b!=-1){
      printf("%d",SEA[i].b);
      m = SEA[i].b;
      while(1){
	if(SEA[m].c==-1)break;
	else printf(", %d",SEA[m].c);
	m = SEA[m].c;
      }
    }
    printf("]\n");
  }
  return 0;
}
int rec(int r,int p){
  SEA[r].d = p;
  if(SEA[r].c!=-1)rec(SEA[r].c,p);
  if(SEA[r].b!=-1)rec(SEA[r].b,p+1);
}


Measured memory_bytes: 6384
using System;

namespace codefestival_2016_qualA_c
{
    class Program
    {
        static void Main()
        {
            char[] s = Console.ReadLine().ToCharArray();
            long k = long.Parse(Console.ReadLine());
            for (int i = 0; i < s.Length - 1; i++)
            {
                if (s[i] != 'a' && s[i] + k > 'z')
                {
                    k -= 'z' + 1 - s[i];
                    s[i] = 'a';
                }
            }
            k %= 26;
            long x = s[s.Length - 1] + k;
            if (x > 'z') x -= 26;
            s[s.Length - 1] = (char)x;
            Console.WriteLine(s);
        }
    }
}

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

public class Main {
    void run() {
        int N = readInt();
        for (int i = 1; i <= N; i++) {
            int x = i;
            if (x % 3 == 0) {
                sysout.print(" " + i);
                continue;
            }
            while (x > 0) {
                boolean end = false;
                if (x % 10 == 3) {
                    sysout.print(" " + i);
                    end = true;
                }
                if (end) break;
                x /= 10;
            }
        }
        sysout.println();
    }

    public static void main(String[] args) {
        new Main().run();
    }

    // flush automatically iff you call `println` or `printf` or `format`.
    PrintWriter sysout = new PrintWriter(System.out, true);

    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer buffer = null;

    String readLine() {
        buffer = null;
        try {
            return in.readLine();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    String read() {
        if (buffer == null || !buffer.hasMoreTokens()) {
            buffer = new StringTokenizer(readLine());
        }
        return buffer.nextToken();
    }

    int readInt() {
        return Integer.parseInt(read());
    }

    long readLong() {
        return Long.parseLong(read());
    }

    double readDouble() {
        return Double.parseDouble(read());
    }
}

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

using namespace std;

vector<int> MP (string S) {
  vector<int> A(S.size() + 1);
  A[0] = -1;
  int j = -1;
  for(int i=0; i < (int) S.size() ; i++) {
    while (j >= 0 && S[i] != S[j]) j = A[j];
    j++;
    A[i+1] = j;
  }
  return A;
}

// shortest cycle length
vector<int> cycle(string S) {
  auto mp = MP(S);
  vector<int> A(S.size());
  for(int i = 0; i < (int) S.size() ; i++) {
    A[i] = i + 1 - mp[i + 1];
  }
  return A;
}

int main() {
  string s;
  cin >> s;
  string rev = s;
  reverse(begin(rev), end(rev));

  auto A = cycle(s);
  auto rA = cycle(rev);

  if(A.back() == 1) {
    cout << s.size() << endl << 1 << endl;
  } else if(A.back() != (int) s.size() && s.size() % A.back() == 0) {
    int ans = 0;
    for(int i = 0; i < (int) s.size()-1; i++) {
      int t = s.size() - 2 - i;
      if(A[i] != i+1 && (i+1) % A[i] == 0) continue;
      if(rA[t] != t+1 && (t+1) % rA[t] == 0) continue;
      ans++;
    }
    cout << 2 << endl;
    cout << ans << endl;
  } else {
    cout << 1 << endl << 1 << endl;
  }
}




Measured memory_bytes: 7548
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define mod 1000000007
#define all(v)  v.begin(),v.end()
#define pb push_back
#define size(v)  (int) v.size()
#define fast ios_base:: sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
ll power_mod(ll a,ll x){if(x==0) return 1;ll y=power_mod(a,x/2);ll ans=(y*y)%mod; if(x%2) ans=(ans*a)%mod;return ans;}
ll inv(ll a){return power_mod(a,mod-2);}    
ll power(ll a, ll x){ if(x==0) return 1; ll y= power(a,x/2); ll ans=(y*y); if(x%2) ans*=a; return ans;}

int main() {

 int n;
 cin >> n;
 ll a[n+1];
 map<ll,ll> hash;
 ll sum = 0;
 for(int i = 1; i <= n; i++) {
 	cin >> a[i];
 	hash[a[i]]++;
 	sum += a[i];
 }		 	

 int q;
 cin >> q;
 
 while(q--) {
 	ll b,c;
 	cin >> b >> c;
 	ll cntb = hash[b];
 	ll diff = c - b;
 	ll change = diff* cntb;
 	sum += change;
 	hash[c] += cntb;
 	hash[b] -= cntb;
 	cout << sum << endl;
 }

}

Measured memory_bytes: 10200
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = int(A); I < int(B); ++I)
#define FORR(I,A,B) for(ll I = int((B)-1); I >= int(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;

ll X[4][4];
bool ch(){
	//FOR(i,1,4)FOR(j,1,4)if(X[i][j]<0)return false;
	ll s=X[1][3]+X[2][2]+X[3][1];
	ll t=X[1][1]+X[2][2]+X[3][3];
	if(s!=t)return false;
	FOR(i,1,4){
		ll a=0,b=0;
		FOR(j,1,4){
			a+=X[i][j];
			b+=X[j][i];
		}
		if(a!=s || b!=s)return false;
	}
	return true;
}


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

	ll x;
	cin >> x;
	ll ans = 2;
	FOR(i,0,x){
		ans = 2*ans+2;
	}
	cout << ans << endl;
}

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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
typedef double DOUBLE;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

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

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const ll LL_INF = 1e17 + 10;
const int INF = 1e9 + 10;
const ll MOD = 1e9 + 7;

const int MAXN = 2e5 + 5;

vi g[MAXN];

int col[MAXN];
int cnt[3];
int ans[MAXN];
int per[MAXN];

void dfs(int s, int cl) {
	col[s] = cl;
	REP(i, 0, SZ(g[s])) {
		int to = g[s][i];
		if (!col[to]) {
			dfs(to, 3 - cl);
		}
	}
}

void solve(){
	int n;
	scanf("%d", &n);
	REP(i, 1, n) {
		int a, b;
		scanf("%d%d", &a, &b);
		g[a].pb(b);
		g[b].pb(a);
	}
	dfs(1, 1);
	REPN(i, 1, n) {
		//printf("%d %d\n", i, col[i]);
		cnt[col[i]]++;
	}
	if (cnt[1] * 3 <= n || cnt[2] * 3 <= n) {
		int c = 3;
		REPN(i, 1, n) {
			if (cnt[col[i]] * 3 <= n) {
				ans[c] = i;
				c += 3;
			}
		}
		int top = 1;
		REPN(i, 1, n) {
			if (cnt[col[i]] * 3 > n) {
				for(; ans[top]; top++);
				ans[top] = i;
			}
		}
	} else {
		int c1 = 1, c2 = 2, c3 = 3;
		REPN(i, 1, n) {
			if (col[i] == 1) {
				if (c1 <= n) {
					ans[c1] = i;
					c1 += 3;
				} else {
					ans[c3] = i;
					c3 += 3;
				}
			} else {
				if (c2 <= n) {
					ans[c2] = i;
					c2 += 3;
				} else {
					ans[c3] = i;
					c3 += 3;
				}
			}
		}
	}
	REPN(i, 1, n) {
		per[ans[i]] = i;
	}
	REPN(i, 1, n) {
		printf("%d ", per[i]);
	}
	putchar('\n');
}

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 19840
#include <iostream>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <string>
#include <set>
#include <iomanip>
#include <map>
#define REP(i,n) for (int i=0;i<(n);++i)
using namespace std;
using ll = long long;

int main(){
    int n;
    cin >> n;
    vector<int> d(n);
    REP(i, n) cin >> d[i];

    sort(d.begin(), d.end());
    //REP(i, n) cout <<  d[i] << " ";
    //cout << endl;

    int s = d[n/2-1];
    int e = d[n/2];

    //cout << s << " " << e << endl;

    cout << e - s  << endl;
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define all(v) v.begin(),v.end()
#define inf (int)(3e18)
#define P pair<int,int>
#define mod (int)(1e9+7)
#define mod2 998244353

template<class T> inline void chmin(T &a, T b) {
	a = min(a, b);
}
template<class T> inline void chmax(T &a, T b) {
	a = max(a, b);
}

set<int>st;
void f(int x,int y){
	if(x==11)return;
	int z=y%10;
	for(int i=z-1;i<=z+1;i++){
		if(i<0||i>9)continue;
		int nex=y*10+i;
		if(st.find(nex)==st.end()){
			st.insert(nex);
			f(x+1,nex);
		}
	}
}
signed main(){
	int K;cin>>K;
	rep(i,10){
		st.insert(i);
		f(1,i);
	}
	auto it=st.begin();
	rep(i,K){
		it++;
	}
	cout<<*it<<endl;
}


Measured memory_bytes: 25984
# coding: utf-8
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

H, N = lr()
INF = 10 ** 15
limit = H + 100
dp = [INF] * limit
dp[0] = 0
for _ in range(N):
    a, b = lr()
    for i in range(limit):
        index = i+a
        if index > limit - 1:
            index = limit - 1
        dp[index] = min(dp[index], dp[i] + b)

dp = dp[H:]
answer = min(dp)
print(answer)


Measured memory_bytes: 44368
use std::collections::HashSet;
use std::borrow::Borrow;
use std::ops::IndexMut;
use std::cmp::{min, max};
use std::mem::swap;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn main() {
    let v: Vec<i32> = read_vec();
    let w = v[0];
    let mut a = v[1];
    let mut b = v[2];

    if b < a {
        swap(&mut a, &mut b);
    }

    let ans = max(b - (a + w), 0);

    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <iostream>
#include <cmath> 
using namespace std;
int main() {
  	int a,b,v,w,t;
  	cin>>a>>v>>b>>w>>t;
  		
  	if(v<=w){
      	cout<<"NO"<<endl;
      	return 0;
    }
  	
  	if(fabs(a-b)<=(fabs(v-w)*t)){
      	cout<<"YES"<<endl;
    }else{
      	cout<<"NO"<<endl;
    }
  	return 0;
}

Measured memory_bytes: 3620
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000000000000
#define MOD 1000000007
typedef pair<int, int> P;

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
	if (p == 0) return 1;
	if (p % 2 == 0) {
		int t = mod_pow(n, p / 2, m);
		return (t * t) % m;
	}
	return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}
int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int digit(int x) {
	int cnt = 0;
	while (x > 0) {
		cnt += x % 10;
		x /= 10;
	}
	return cnt;
}
int read() {
	int tmp;
	cin >> tmp;
	return tmp;
}
int xor128() {
	static int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
	int t = (x xor (x << 11));
	x = y; y = z; z = w;
	return (w = (w xor (w >> 19)) xor (t xor (t >> 8)));
}

int dp[45][500][500];

signed main() {
	int n, A, B;
	cin >> n >> A >> B;
	int a[45], b[45], c[45];
	int asum = 0, bsum = 0;
	rep(i, n) {
		cin >> a[i + 1] >> b[i + 1] >> c[i + 1];
		asum += a[i + 1];
		bsum += b[i + 1];
	}
	rep(i, n + 1) {
		rep(j, asum + 1) {
			rep(k, bsum + 1) {
				dp[i][j][k] = INF;
			}
		}
	}
	dp[0][0][0] = 0;
	for (int i = 1; i <= n; i++) {
		rep(j, asum + 1) {
			rep(k, bsum + 1) {
				if (a[i] > j || b[i] > k) {
					dp[i][j][k] = dp[i - 1][j][k];
				}
				else {
					dp[i][j][k] = min(dp[i - 1][j][k], dp[i - 1][j - a[i]][k - b[i]] + c[i]);
				}
			}
		}
	}
	int ans = INF, nowa = A, nowb = B;
	while (nowa <= asum && nowb <= bsum) {
		ans = min(ans, dp[n][nowa][nowb]);
		nowa += A, nowb += B;
	}
	if (ans == INF) cout << -1 << endl;
	else cout << ans << endl;
	
	return 0;
}


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

int main(){
	int n;
	cin >> n;
	vector<int> ina(n);
	vector<int> a(1000002);
	rep(i, n){
		cin >> ina[i];
		a[ina[i]]++;
	}
	int ans = 0;
	rep(i, n){
		int n_ya = ina[i];//in
		a[ina[i]]--;
		int f = 0;
		for(int i_ya = 1; i_ya * i_ya <= n_ya; i_ya++){
			if(n_ya % i_ya == 0){
//				cout << i_ya << ' ';//out
				if(a[i_ya] != 0) f = 1;
				if(i_ya != n_ya/i_ya){
//					cout << n_ya/i_ya;//out
					if(a[n_ya/i_ya] != 0) f = 1;
				}
//				cout << endl;
			}
		}
		if(f == 0) ans++;
		a[ina[i]]++;
	}
	cout << ans << endl;
	return 0;
}

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

int main()
{
    ll n,m;
    cin>>n>>m;
    ll a[m],flag=0;
    for(ll i=0;i<m;i++)
    {
        cin>>a[i];
        flag+=a[i];
    }
    if(flag>n)
        cout<<"-1"<<endl;
    else
        cout<<(n-flag)<<endl;

}


Measured memory_bytes: 3704
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int N; ll A, B; cin >> N >> A >> B;
	vector<ll> X(N, 0LL);
	rep (i, N){
		cin >> X[i];
	} // end  rep

	ll res = 0LL;
	for (int i = 1; i < N; ++i){
		ll diff = X[i] - X[i-1];
//		cerr << "diff: " << diff << endl;
		if (diff * A <= B){
			res += diff * A;
		}else{
			res += B;
		} // end if
	} // end for

	cout << res << endl;

	return 0;
}

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

long long int fun(int n,vector<long long int> &w,vector<long long int> &v,int k){
	vector<vector<long long int>> dp(n+1,vector<long long int>(k+1,0));
	for(int i=1;i<=n;i++){
	    for(int j=1;j<=k;j++){
	        if(j>=w[i-1]){
	            dp[i][j] = max(v[i-1]+dp[i-1][j-w[i-1]],dp[i-1][j]);
	        }
	        else{
	            dp[i][j] = dp[i-1][j];
	        }
	    }
	}
	return dp[n][k];
}
int main(){
	long long int n,x,k,y;
	cin>>n>>k;
	vector<long long int> w,v;
	for(int i=0;i<n;i++){
		cin>>x>>y;
		w.push_back(x);
		v.push_back(y);
	}
	cout<<fun(n,w,v,k)<<endl;
}

Measured memory_bytes: 83156
import math

while True:
    n = float(input())
    aan = 0
    if n == 0:
        break
    scores = list(map(float, input().split()))
    total = sum(scores)
    avg = total / len(scores)
    for score in scores:
        aan += (score - avg)**2
    aa = aan / len(scores)
    a = math.sqrt(aa)
    print(a)


Measured memory_bytes: 5672
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	string s;
	cin >> s;
	bool cft = true;
	for(int i = 0; i < s.size(); i++){
		if(i%2 == 0 && s[i] == 'L')cft = false;
		if(i%2 == 1 && s[i] == 'R')cft = false;
	}
	string ans = "Yes";
	if(cft == false) ans = "No";
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,minj,num=0;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++)
    cin>>a[i];
  for(int i=0;i<n;i++){
    minj=i;
    for(int j=i;j<n;j++){
      if(a[j]<a[minj])
	minj=j;
    }
    if(minj!=i){
      int tmp=a[i];
      a[i]=a[minj];
      a[minj]=tmp;
      num++;
    }
  }
  for(int i=0;i<n;i++){
    cout<<a[i];
    if(i!=n-1)
      cout<<" ";
  }
  cout<<endl;
  cout<<num<<endl;
  return 0;
}

Measured memory_bytes: 3096
use std::vec::Vec;
use std::cmp;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}


fn abs(x: i64) -> i64 {
    if x < 0  {
        return -x;
    } else {
        return x;
    }
}

fn main() {
    let n: usize = read();
    let mut a: Vec<i64> = read_vec();

    // solve1(n, &a);
    solve2(n, &mut a);
}

fn solve1(n: usize, v: &Vec<i64>) {
  let mut minus: u64 = 0;

  for i in 0..n {
      if v[i] < 0 {
          minus += 1;
      }
  }
  let mut ans: i64 = 0;

  if minus % 2 == 0 {
      for i in 0..n {
          ans += abs(v[i]);
      }
  } else {
      let mut minabs = 10000000000;
      for i in 0..n {
          if abs(v[i]) < minabs {
              minabs = abs(v[i]);
          }
          ans += abs(v[i]);
      }
      ans += -2*minabs;
  }
  println!("{}", ans);
}


fn solve2(n: usize, v: &mut Vec<i64>) {
  let mut dp: Vec<Vec<i64>> = [vec![0; n], vec![0; n]].to_vec();
  dp[0][0] = v[0];
  dp[1][0] = std::i64::MIN/2;
  for i in 1..n {
    dp[0][i] = cmp::max(dp[0][i-1], dp[1][i-1]) + v[i];
    dp[1][i] = cmp::max(dp[0][i-1] - 2*v[i-1], dp[1][i-1] + 2*v[i-1]) - v[i];
  }

  println!("{:?}", cmp::max(dp[0][n-1], dp[1][n-1]));
}


Measured memory_bytes: 10492
import java.util.Scanner;
import java.util.TreeSet;
import java.util.Arrays;
public class Main {
 
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
       int [] a=new int[3];
       for(int i=0;i<3;i++){
        a[i]=sc.nextInt();
       }
       Arrays.sort(a);
       for(int i=0;i<3;i++){
           if(i==2)System.out.printf("%d\n",a[i]);
       else System.out.print(a[i]+" ");
       }

}
}



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

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

    int K;
    cin>>K;

    for (int i = 0; i < K; i++)
    {
       if(A>=B)
       {
           B*=2;
           continue;
       }
       else if(B>=C)
       {
           C*=2;
           continue;
       }
       else
       {
           C*=2;
       }       
    }
    if(B>A&&C>B)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 3616
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int a,x,p[6]={500,100,50,10,5,1},ans=0;
	while(1){
		ans=0;
		cin>>a;
		if(a==0)
		break;
		x=1000-a;
		for(int i=0;i<6;i++){
			while(1){
				if(x>=p[i]){
				x-=p[i];
				ans++;
				}else
				break;
			}
		}
		cout<<ans<<endl;
	}
return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define LOOP(n) for (int _i = 0; _i < (n); _i++)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define FOR(i, r, n) for (int i = (r); i < (n); ++i)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;
using ull = unsigned long long;

const int INF = 2100100100;
const int MOD = 1e9 + 7;

// 多次元 vector 生成
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
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 N, M;

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

    cin >> N >> M;
    vector<int> a(M), b(M);
    vector<pair<int, int>> p(M);
    REP(i, M) {
        cin >> a.at(i) >> b.at(i);
        p[i] = make_pair(b[i], a[i]);
    }

    sort(ALL(p));

    int ans = 0;
    int now = 0;
    REP(i, M) {
        if (p[i].second < now) continue;
        now = p[i].first;
        ans++;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main (){
  string n;
  cin >> n;
  if(n[0]==n[1]&&n[1]==n[2]||n[1]==n[2]&&n[2]==n[3]){
    cout << "Yes";
  }else{
    cout << "No";
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define VI vector<int>
#define VVI vector<vector<int>>
#define UM unordered_map
#define MP map
#define ST set
#define US unordered_set
#define V vector
#define S string
#define D deque
#define L list
#define Q queue
#define PQ priority_queue
#define DB double
#define LDB long double
#define FOR(i, n) for (int(i) = 0; (i) < (n); ++(i))
#define FFOR(i, n) for (int(i) = 0; (i) <= (n); ++(i))
#define RFOR(i, n) for (int(i) = (n)-1; (i) >= 0; --(i))
#define all(v) (v).begin(), (v).end()

const int dr[] = {0, 1, 0, -1};
const int dc[] = {1, 0, -1, 0};

int nxt()
{
    int n;
    cin >> n;
    return n;
}

LL llnxt()
{
    LL l;
    cin >> l;
    return l;
}

LDB ldbnxt()
{
    LDB n;
    cin >> n;
    return n;
}

DB dbnxt()
{
    DB n;
    cin >> n;
    return n;
}

void bfs(VVI &graph, int start)
{
    int n = graph.size();
    Q<int> q;
    V<bool> visited(n);
    q.push(start);
    visited[start] = true;
    while (not q.empty())
    {
        auto curr = q.front();
        q.pop();
        for (auto i : graph[curr])
        {
            if (not visited[i])
            {
                q.push(i);
                visited[i] = true;
            }
        }
    }
}

int main()
{
    int n;
    cin >> n;
    VI v(n);
    int x = 0;
    FOR(i, n)
    {
        cin >> v[i];
        x ^= v[i];
    }
    FOR(i, n)
    {
        cout << (v[i] ^ x) << " ";
    }
}

Measured memory_bytes: 4060
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(){
  char a[]="6 7 8 9 5 4 3 2 1 0 1 2 3 4 5 6 7 8 9";
  char *b,*c,*d;
  int f,g,h,i,j;
  scanf("%d",&h);
  for(i=0;i<h;i++){
    scanf("%d %d",&f,&g);
    b=strchr(a,'0'+f);
    c=strchr(b+1,'0'+f);
    d=strchr(b+1,'0'+g);
    if(c==NULL || c>d)c=b;
    for(;c<=d;c++) printf("%c",c[0]);
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
void Main();

using i8  = int8_t;   /* -128 ~ 127 */
using u8  = uint8_t;  /* 0 ~ 255 */
using i16 = int16_t;  /* -32,768 ~ 32,767 */
using u16 = uint16_t; /* 0 ~ 65,535 */
using i32 = int32_t;  /* -2,147,483,648 ~ 2,147,483,647 */
using u32 = uint32_t; /* 0 ~ 4,294,967,295 */
using i64 = int64_t;  /* -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 */
using u64 = uint64_t; /* 0 ~ 18,446,744,073,709,551,615 */
using f32 = float;    /* (-3.4 * 10^38) ~ (3.4 * 10^38) */
using f64 = double;   /* (-1.7 * 10^308) ~ (1.7 * 10^308) */
using f80 = __float80;
template <class T> using Vec = vector<T>;
constexpr i64 INF = 1010000000000000017;
constexpr i64 MOD = 1e9 + 7;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define ALL(v) v.begin(), v.end()
#define YN(a, b, c) ((c)? a : b)
#define GCD(a, b) __gcd(a, b) /* 最大公約数 */
#define LCM(a, b) (i64)(a / (f64)__gcd(a, b) * b) /* 最小公倍数 */

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

void Main() {
    i32 N, K;
    cin >> N >> K;
    Vec<i32> A(N);
    for (i32 i = 0; i < N; i++) cin >> A[i];
    if (K == N) {
        cout << 1 << endl;
        return;
    }
    i32 index = distance(A.begin(), min_element(ALL(A)));
    i32 min_v = 1000001;
    i32 a1 = 0;
    i32 i = 0;
    while (i + K <= index) {
        a1++;
        i += K - 1;
    }
    i += K;
    a1++;
    while (i < N) {
        i += K - 1;
        a1++;
    }
    i32 a2 = 0;
    i = N - 1;
    while (i - K >= index) {
        a2++;
        i -= K - 1;
    }
    i -= K;
    while (i >= 0) {
        i -= K - 1;
        a2++;
    }
    cout << max(a1, a2) << endl;
}


Measured memory_bytes: 3708
MAXN = 2 ** 17

ide_ele = 2 ** 31 - 1

n,q = map(int,input().split())

num = 2**(n-1).bit_length()
seg = [ide_ele] * 2 * num

def init(init_val):
    for i in range(n):
        seg[i+num-1] = init_val[i]
    for i in range(num-2 ,-1, -1) :
        seg[i] = segfunc(seg[2*i+1],seg[2*i+2])
        
def update(k,x):
    k += num-1
    seg[k] = x
    while k:
        k = (k-1)//2
        seg[k] = min(seg[k*2+1] , seg[k*2+2])
        
def query(p,q):
    p += num
    q += num
    res = ide_ele
    
    while q-p > 0:
        if p&1 == 1:
            res = min(res,seg[p-1])
            p += 1
            
        if q&1 == 1:
            q -= 1
            res = min(res,seg[q-1])
            
        p >>= 1
        q >>= 1
    return res

for i in range(q):
    com = input().split()
    if com[0] == "0":
        x,y = int(com[1]),int(com[2])
        update(x,y)
    else:
        x,y = int(com[1]),int(com[2])+1
        print(query(x,y))


Measured memory_bytes: 8692
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<cmath>
#include<math.h>
#include<algorithm>
#include<string.h>
#include <iomanip>
#include <sstream>
using namespace std;

int main() {
  int N, Q;
  int ans = 0;
  string s;

  cin >> s;
  cin >> Q;

  vector<int> f(Q);
  vector<int> t(Q);
  vector<string> c(Q);
  for(int i = 0; i < Q; i++){
    cin >> t[i];
    if(t[i] == 2){
      cin >> f[i] >> c[i];
    }
  }

  N = 0;
  string tmp = "";
  string h = "";
  string b = "";
  for(int i = 0; i < Q; i++){
    if(t[i] == 1){
      N++;
    }else{
      if(f[i] == 1){
        if(N%2 == 1){
          b = b + c[i];
        }else{
          h = c[i] + h;
        }
      }else{
        if(N%2 == 1){
          h = c[i] + h;
        }else{
          b = b + c[i];
        }
      }
    }
    // cout << "N = " << N << ", h = " << h << ", b = " << b << endl;
  }

  if(N%2 == 1){
    reverse(s.begin(), s.end());
    reverse(h.begin(), h.end());
    reverse(b.begin(), b.end());
    s = b + s + h;
  }else{
    s = h + s + b;
  }
  cout << s << endl;


}



Measured memory_bytes: 13852
import java.util.*;
import java.io.*;
import java.awt.geom.*;
import java.math.*;

public class Main {

	static final Scanner in = new Scanner(System.in);
	static final PrintWriter out = new PrintWriter(System.out,false);
	static boolean debug = false;

	static boolean solve() {
		int w = in.nextInt();
		int d = in.nextInt();
		if (w + d == 0) return false;

		int[] h1 = new int[w+1];
		int[] h2 = new int[d+1];
		for (int i=0; i<w; i++) {
			h1[i] = in.nextInt();
		}
		for (int i=0; i<d; i++) {
			h2[i] = in.nextInt();
		}
		h1[w] = h2[d] = 1<<30;

		Arrays.sort(h1);
		Arrays.sort(h2);
		int pos1 = 0, pos2 = 0, ans = 0;
		while (pos1 < w || pos2 < d) {
			if (pos1 == w || h1[pos1] > h2[pos2]) {
				ans += h2[pos2];
				pos2++;
			} else if (pos2 == d || h1[pos1] < h2[pos2]) {
				ans += h1[pos1];
				pos1++;
			} else if (h1[pos1] == h2[pos2]) {
				ans += h1[pos1];
				pos1++; pos2++;
			}
		}

		out.println(ans);

		return true;
	}

	public static void main(String[] args) {
		debug = args.length > 0;
		long start = System.nanoTime();

		while(solve());
		out.flush();

		long end = System.nanoTime();
		dump((end - start) / 1000000 + " ms");
		in.close();
		out.close();
	}

	static void dump(Object... o) { if (debug) System.err.println(Arrays.deepToString(o)); }
}

Measured memory_bytes: 30168
date = gets
date.gsub!("\n", '')
y,m,d = date.split('/').map(&:to_i)

if y <= 2019
  if m <= 4
    if d <= 30
      puts 'Heisei'
    else
      puts 'TBD'
    end
  else
    puts 'TBD'
  end
else
  puts 'TBD'
  return
end


Measured memory_bytes: 1788
#include <iostream>
#include <map>
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;
int n,m;
int sum;
int cnt;
int fa[100001];
int x[100001],y[100001];
int find(int x){
	if(fa[x]==x){
		return fa[x];
	}
	return fa[x]=find(fa[x]); 
}
struct t{
	int x,y,z;
}a[300001],e[100001];
bool cmp1(t l,t r){
	if(l.x!=r.x){
		return l.x<r.x;
	}
	return l.y<r.y;
}
bool cmp2(t l,t r){
	if(l.y!=r.y){
		return l.y<r.y;
	}
	return l.x<r.x;
}
bool cmp(t x,t y){
	return x.z<y.z;
}
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		fa[i]=i;
	}
	for(int i=1;i<=n;i++){
		cin>>e[i].x>>e[i].y;
		e[i].z=i;
	}
	sort(e+1,e+n+1,cmp1);
	for(int i=2;i<=n;i++){
		cnt++;
		a[cnt].x=e[i].z;
		a[cnt].y=e[i-1].z;
		a[cnt].z=e[i].x-e[i-1].x;
	}
	sort(e+1,e+n+1,cmp2);
	for(int i=2;i<=n;i++){
		cnt++;
		a[cnt].x=e[i].z;
		a[cnt].y=e[i-1].z;
		a[cnt].z=e[i].y-e[i-1].y;
	}
	sort(a+1,a+cnt+1,cmp);
	for(int i=1;i<=cnt;i++){
		int x1=find(a[i].x);
		int y1=find(a[i].y);
		if(x1!=y1){
			fa[x1]=y1;
			sum+=a[i].z;
		}
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
typedef int64_t ll;
using P = pair<ll, ll>;
#define MAX_V 122551
#define MAX_C 2450
#define INF 1e16
vector<vector<P>> Graph(MAX_V,vector<P>());
vector<ll> D(MAX_V,INF);

void dijkstra(int s) {
  priority_queue<P, vector<P>, greater<P>> que;
  D[s] = 0;
  que.push(P(0, s));
  while (!que.empty()) {
    P p = que.top();
    que.pop();
    int v = p.second;
    if (D[v] < p.first) continue;
    for (int i=0; i<(int)Graph[v].size(); ++i) {
      P e = Graph[v][i];
      if (D[e.first] > D[v] + e.second) {
        D[e.first] = D[v] + e.second;
        que.push(P(D[e.first], e.first));
      }
    }
  }
}

int main() {
  int n,m,s;
  cin >> n >> m >> s;
  if(s>MAX_C) s=MAX_C;
  int u,v,a,b;
  for(int i=0;i<m;i++){
    cin >> u >> v >> a >> b;
    for(int j=0;j<=MAX_C;j++){
      if (j-a >= 0){
        Graph[50*j+u].push_back(P(50*(j-a)+v,b));
        Graph[50*j+v].push_back(P(50*(j-a)+u,b));
      }
    }
  }
  int c,d,tmp;
  for(int i=1;i<=n;i++){
    cin >> c >> d;
    for(int j=0;j<=MAX_C;j++){
      tmp = j+c;
      if(tmp > MAX_C) tmp = MAX_C;
      Graph[50*j+i].push_back(P(50*tmp+i,d));
    }
  }
  dijkstra(50*s+1);
  ll mn;
  for(int i=2;i<=n;i++){
    mn = INF;
    for(int j=0;j<=MAX_C;j++){
      mn = min(mn,D[50*j+i]);
    }
    cout << mn << endl;
  }
}


Measured memory_bytes: 23380
N, M = map(int, input().split())

class UnionFind(object):
    def __init__(self, size):
        self.parent = [i for i in range(size)]
        self.rank = [0 for _ in range(size)]

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

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return

        if self.rank[x] < self.rank[y]:
            self.parent[x] = y
        else:
            self.parent[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    def same(self, x, y):
        return self.find(x) == self.find(y)

u = UnionFind(N)
p_list = list(map(int, input().split()))

for _ in range(M):
    x, y = map(int, input().split())
    u.unite(x-1, y-1)

res = 0
for i in range(N):
    res += int(u.same(i, p_list[i]-1))
print(res)


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

int main(){
	string s;
	cin >> s;
	int day = 7;
	if(s == "SUN"){
		day -=0;
	}else if(s == "MON"){
		day -=1;
	}else if(s =="TUE"){
		day -=2;
	}else if(s == "WED"){
		day -= 3;
	}else if(s == "THU"){
		day -= 4;
	}else if(s == "FRI"){
		day -= 5;
	}else {
		day -= 6;
	}
	cout << day <<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <stdio.h>
#include <cmath>
#include <sstream>
#include <algorithm>
#include <iomanip>

#define ll long long
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define vi vector<int>
#define vl vector<long long>
#define sz size()
#define x first
#define y second
#define pii pair<int, int>
#define pll pair<ll, ll>


using namespace std;

int n, m;
char a[200][200];

int main() {
	
	cin >> n >> m;
	for(int i = 1; i <= n; i++) {
		string s;
		cin >> s;
		for(int j = 1; j <= m; j++) {
			a[i][j] = s[j-1];
		}
	}
	
	for(int i = 0; i <= n + 1; i++) {
		for(int j = 0; j <= m + 1; j++) {
			if(i == 0 || j == 0 || i == n + 1 || j == m + 1) cout << "#";
			else cout << a[i][j];
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 256
import java.util.BitSet;
import java.util.Scanner;

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

		BitSet bit = new BitSet();
		bit.set(s);

		int count = 1;
		boolean check = true;
		while(check) {
			if(s % 2 == 0) s /= 2;
			else s = s * 3 + 1;
			count += 1;

			if(bit.get(s)) check = false;
			else bit.set(s);
		}

		System.out.print(count);
	}
}

Measured memory_bytes: 21844
using System;

namespace AOJ.Volume0
{
    class SortingFiveNumbers
    {
        public static void Main()
        {
            var input = Console.ReadLine().Trim().Split(' ');
            int[] sorted = new int[5];
            // 挿入ソート
            for (int i = 0; i < 5; i++)
            {
                int tmp = int.Parse(input[i]);
                int pos = i - 1;
                while (pos >= 0 && tmp > sorted[pos])
                {
                    sorted[pos + 1] = sorted[pos];
                    pos--;
                }
                sorted[pos + 1] = tmp;
            }
            // 出力
            string output = "";
            foreach (var i in sorted) { output += i + " "; }
            output = output.Trim();
            Console.WriteLine(output);
        }
    }
}

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

const int N = 200010;

double s[N], t[N];

int main(){
	s[1] = t[1] = 0.5;
	for (int i = 2; i < N; ++ i){
		s[i] = 0.5 + s[i - 1] * (i + 1) / i;
		t[i] = (i + 1) / 4.0 + (s[i - 1] + (2 * i + 4) * t[i - 1]) / (2 * i);
	}
	int n, d, x;
	scanf("%d%d%d", &n, &d, &x);
	double ans = (2 * d - 3 * x) * s[n] + 4 * x * t[n];
	printf("%.10lf\n", ans);
	return 0;
}

Measured memory_bytes: 3328
import sys
def main():
    input=sys.stdin.readline
    N,K=map(int,input().split())
    D=list(map(int,input().split()))
    L=[]
    for i in range(10):
        if i not in D:
            L.append(i)
    for p in L:
        if len(str(N))==1:
            if p>=N:
                print(p)
                return
        else:
            for q in L:
                if len(str(N))==2:
                    pay=p*10+q
                    if pay>=N:
                        print(pay)
                        return
                else:
                    for r in L:
                        if len(str(N))==3:
                            pay=p*100+q*10+r
                            if pay>=N:
                                print(pay)
                                return
                        else:
                            for s in L:
                                pay=p*1000+q*100+r*10+s
                                if pay>=N:
                                    print(pay)
                                    return
    if L[0]==0:
        print(L[1]*10**len(str(N)))
    else:
        print("".join([str(L[0]) for _ in range(1+len(str(N)))]))
    return
            

if __name__=="__main__":
    main()

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

int main() {
  vector<int> num(3);
  cin >>num.at(0) >> num.at(1)>>num.at(2);
  sort(num.begin(), num.end());
  int a = num.at(2)-num.at(1);
  int b = num.at(1)-num.at(0);
    cout << a + b <<endl;
}


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

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {

            var r = cin.Read;
            var g = cin.Read;
            var b = cin.Read;
            
            Console.WriteLine(int.Parse(r + g + b) % 4 == 0 ? "YES" : "NO");

            
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}




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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  int n,q; cin>>n>>q;
  vi a(n); rep(i,n) cin>>a[i];
  
  rep(_,q){
    ll x; cin>>x;
    
    ll ans=0;
    ll sum=0;
    int r=0;
    rep(l,n){
      while(r<n&&sum+a[r]<=x){
        sum+=a[r];
        r++;
      }
      ans+=r-l;
      if(r==l) r++;
      else sum-=a[l];
    }
    cout<<ans<<endl;
  }
}


Measured memory_bytes: 3376
#include <cstdio>           // printf(), scanf()
#include <cmath>            // fabs(), sqrt()
#include <vector>
#include <utility>          // pair
#include <algorithm>        // min(), sort(), inplace_merge()

using namespace std;
typedef pair<double, double> P; // first ??? x ??§?¨????second ??? y ??§?¨?

static const int MAX_N = 100000;
static const int INF = 1000000000;

P A[MAX_N];
int N;

bool
cmp_func(P a, P b)
{
	return a.second < b.second;
}

double
closest_pair(P* a, int n)
{
	if (n <= 1)
		return INF;

	int m = n / 2;
	double x = a[m].first;
	double d = min(closest_pair(a, m), closest_pair(a + m, n - m)); // (1)
	inplace_merge(a, a + m, a + n, cmp_func); // ??????????????????????????????????????????
	// ??????????????§ a ??? y ??§?¨??????????????????£?????????

	//x (2')
	vector<P> b; // ??´??????????????¢ d ????????????????????\????????????
	for (int i = 0; i < n; ++i)
	{
		if (fabs(a[i].first - x) >= d)
			continue;

		// b ?????\??£?????????????????????????°??????????y ??§?¨?????????? d ??\?????????????????§????????????
		for (unsigned int j = 0; j < b.size(); ++j)
		{
			double dx = a[i].first - b[b.size() - j - 1].first;
			double dy = a[i].second - b[b.size() - j - 1].second;
			if (dy >= d)
				break;

			d = min(d, sqrt(dx * dx + dy * dy));
		}

		b.push_back(a[i]);
	}

	return d;
}

int
main(int argc, char** argv)
{
	scanf("%d", &N);
	for (int i = 0; i < N; ++i)
		scanf("%lf %lf", &A[i].first, &A[i].second);

	sort(A, A + N);
	printf("%.10f\n", closest_pair(A, N));
	return 0;
}

Measured memory_bytes: 7412
a=int(input())
b=int(input())
c=int(input())
x=int(input())

cnt=0
for i500 in range(a+1):
    for i100 in range(b+1):
        for i_50 in range(c+1):
            if x==500*i500+100*i100+50*i_50:
                cnt+=1
            elif x<500*i500+100*i100+50*i_50:break
print(cnt)

Measured memory_bytes: 3064
import sys
A, V = map(int, input().split())
B, W = map(int, input().split())
T = int(input())
x = 0

if A > B:
    x = A
    A = B
    B = x

# Bが逃げ切るとき
if V <= W:
    print('NO')
    sys.exit()

if T*V+A-B >= T*W:
    print('YES')
else:
    print('NO')


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

int main() {  
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	int n,k;
	cin>>n>>k;
	vector<int> h(n,0);
	vector<int> dp(n,1e9);
	dp[0]=0;
	for(int i=0;i<n;i++){
		cin>>h[i];
	}
	for(int i=0;i<n-1;i++){
		for(int j=1;j<=k && i + j < n;j++){
			dp[i + j] = min(dp[i] + abs(h[i] - h[i+j]), dp[i+j]);
		}
	}
	cout<<dp[n-1]<<endl;
	return 0;  
}


Measured memory_bytes: 1024
import sys
import math
import itertools
import bisect
from copy import copy,deepcopy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

N = i()
ans = 0
for i in range(1,N+1):
    ans += (N-1)//i
print(ans)

Measured memory_bytes: 72744