akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) { vec.resize(len); for (auto &v : vec) ndarray(v, args...); }
template<typename T> bool mmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool mmin(T &m, const T q) { if (m > q) {m = q; return true;} else return false; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first - r.first, l.second - r.second); }
#define dbg(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl;
#define FI first
#define SE second
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))


int main()
{
    lint a;
    cin >> a;
    string s;
    cin >> s;
    cout << (a >= 3200 ? s : "red") << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long double PI = acos(-1);
typedef long long ll;
typedef pair<int64_t,int64_t> pll;
int dx[]={1,-1,0,0,1,-1,1,-1};
int dy[]={0,0,1,-1,1,-1,-1,1};
#define INF (2147483647)
#define mod (1000000007)
#define limit (7368791)
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define ALL(a) begin(a),end(a)
#define sz(s) (s).size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second


void solve()
{
	ll n;cin>>n;vector<ll>a(n);REP(i,n){cin>>a[i];a[i]-=i+1;}
	sort(ALL(a));
	ll ans=0;
	REP(i,n){
		ans+=abs(a[n/2]-a[i]);
	}
	cout<<ans<<endl;
}
int main()
{
    cin.tie(0);
	ios::sync_with_stdio(false);
    solve();
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <stdio.h>
#include <math.h>
#include <queue>
#include <algorithm>
#include <utility>
#include <vector>
#include <tuple>
#include <numeric>
using namespace std;

struct UnionFind{
	vector<int> parent;
	int N;
//	UnionFind(int n) : parent(n), N(n){ //メンバイニシャライザを実行している
//		for(int i=0; i<n; i++){
//			parent[i] = i;
//		}
//	}
	UnionFind(int n){ //メンバイニシャライザを実行している
		parent.resize(n);
		N = n;
		for(int i=0; i<n; i++){
			parent[i] = i;
		}
	}	int getParent(int x){
		return parent[x];
	}

	int root(int x){
		if(parent[x]==x){
			return x;
		}else{
			parent[x] = root(parent[x]); //親の付け替え(ならし)
			return parent[x];
		}
	}
	void unite(int x, int y){
		int rx = root(x);
		int ry = root(y);
		if(rx!=ry){
			parent[ry] = rx;
		}
	}
	bool same(int x, int y){
		int rx = root(x);
		int ry = root(y);
		return rx==ry;
	}
};

int main(int argc, char* argv[]){
	int N,M;
	scanf("%d %d", &N, &M);
	vector<int>A(M);
	vector<int>B(M);
	UnionFind tree(N);
	for(int i=0; i<M; i++){
		scanf("%d %d", &A[i], &B[i]);
		if(A[i]>B[i]){
			int tmp;
			tmp =  B[i];
			B[i] = A[i];
			A[i] = tmp;
		}
		tree.unite(A[i]-1, B[i]-1);
	}
	int count = 0;
	for(int i=0; i<N; i++){
		if(tree.getParent(i)==i){
			count++;
		}
	}
	printf("%d\n", count-1);

}



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

public class Main {

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		while(true) {

		    String str = br.readLine();
		    StringTokenizer st = new StringTokenizer(str, " ");
			int a  = Integer.parseInt(st.nextToken());
			int b  = Integer.parseInt(st.nextToken());

			if(a == 0 && b == 0){
				break;
			}else if (a < b) {
				System.out.println(a + " " +  b);
			}else {
				System.out.println(b + " " +  a);
			}
		}
	}
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())
#define rsort(v) sort(all(v)); reverse(all(v))

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template<typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template<typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template<typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template<typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template<typename T> inline T power(T x, i64 n) { T r = 1; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template<typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }

void solve() {
  int n, k; cin >> n >> k;
  vi32 d(k); cin >> d;
  while (true) {
    int nn = n;
    bool b = true;
    while (nn) {
      int keta = nn % 10;
      nn /= 10;
      bool f = true;
      rep(i, k) if (d[i] == keta) f = false;
      if (!f) {
        b = false;
        break;
      }
    }
    if (b) {
      cout << n << '\n';
      return;
    }
    n++;
  }
}


Measured memory_bytes: 256
package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)

	var N, X int
	scanner.Scan()
	fmt.Sscanf(scanner.Text(), "%d", &N)
	scanner.Scan()
	fmt.Sscanf(scanner.Text(), "%d", &X)

	xs := make([]int, N+1)
	for i := 0; i < N; i++ {
		scanner.Scan()
		fmt.Sscanf(scanner.Text(), "%d", &xs[i])
	}
	xs[N] = X

	sort.Sort(sort.IntSlice(xs))

	ws := make([]int, N)
	for i := 0; i < N; i++ {
		ws[i] = xs[i+1] - xs[i]
	}

	ans := ws[0]
	for i := 1; i < N; i++ {
		ans = gcd(ans, ws[i])
	}
	fmt.Println(ans)
}

func gcd(a, b int) int {
	if a < b {
		a, b = b, a
	}
	for b != 0 {
		tmp := a % b
		a, b = b, tmp
	}
	return a
}


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

typedef long long ll;

#define int long long 

int32_t main()
{
	ios::sync_with_stdio(false);

	int n, m;
	cin >> n >> m;
	string s, t;
	cin >> s >> t;
	int an = n * m / __gcd(n, m);
	if (n > m)
		swap(n, m), swap(s, t);
	for (int i=0; i<n; i++)
		if (i * (an / n) % (an / m) == 0)
			if (s[i] != t[i * (an / n) / (an / m)])
			{
				cout << -1 << "\n";
				return 0;
			}
	cout << an << "\n";

	return 0;
}

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

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

  vector<int> data(N);
  for(int i=0; i<N; i++){
    cin >> data.at(i);
  }

  int cumgcd= data.at(0);
  for(int i=0; i<N; i++){
    cumgcd= gcd(cumgcd, data.at(i));
  }

  if(cumgcd != 1){
    cout << "not coprime" << endl;
  }
  else{
    constexpr int Vmax= 1'000'000;
    vector<int> smallest_factors(Vmax+1);
    iota(smallest_factors.begin(), smallest_factors.end(), 0);
    for(int p=2; p<= Vmax; p++){
      if(smallest_factors.at(p)==p){
        for(int m= 2*p; m<= Vmax; m+=p){
          smallest_factors.at(m)= min(smallest_factors.at(m), p);
        }
      }
    }

    bool pairwise_coprime= true;
    unordered_set<int> factors;
    for(auto num:data){
      unordered_set<int> factors_num;
      while(num > 1){
        int p= smallest_factors.at(num);
        factors_num.insert(p);
        num/= p;
      }

      for(auto p:factors_num){
        if(factors.count(p)){
          pairwise_coprime= false;
          break;
        }
        else{
          factors.insert(p);
        }
      }
      
      if(!pairwise_coprime){ break; }
    }

    string ans= pairwise_coprime ? "pairwise coprime"
                                 : "setwise coprime";
    cout << ans << endl;
  }
}

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

int main() {
	int a, b;
	scanf("%d %d", &a, &b);
  	bool flag=false;
	if (a<10&&b<10)
		flag=true;

	if (flag) printf("%d\n", a*b);
	else printf("-1\n");
	
	return 0;
}

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

using namespace std;

#define FASTER ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pi acos(-1.0)
#define scan(a) scanf("%d",&a)
#define scanll(a) scanf("%lld",&a)
#define print(a) printf("%d\n",a)
#define printll(a) printf("%lld\n",a)
#define stll(a) stoll(a,nullptr,10)
#define PII pair<ll,ll>
#define mp(a,b) make_pair(a,b)

typedef long long ll;
typedef unsigned long long ull;

priority_queue<double>ar;

int main()
{
    ll n;
    double tmp,a,b;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>tmp;
        ar.push(-1*tmp);
    }
    for(int i=1;i<n;i++)
    {
        a=ar.top()*-1;
        ar.pop();
        b=ar.top()*-1;
        ar.pop();
        a= ((a+b)*1.0)/2.0;
        ar.push(a*-1);
    }
    a=ar.top()*-1;
    cout<<a<<endl;


}






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

struct dat {
	int x, y, z;
};

int main() {
	int N;
	cin >> N;
	vector<int>A(3 * N + 2);
	for (int i = 0; i < 3 * N; ++i) {
		int n;
		cin >> n;
		n--;
		A[i] = n;
	}
	A[3 * N] = N;
	A[3 * N + 1] = N;
	vector<vector<int>> dp(N + 1, vector<int>(N + 1, -1e9));
	vector<int> dp2(N + 1, -1e9);
	dp[A[0]][A[1]] = 0;
	dp[A[1]][A[0]] = 0;
	dp2[A[0]] = 0;
	dp2[A[1]] = 0;

	int add = 0;
	int premax = 0;

	for (int i = 0; i < 3 * N; i += 3) {
		vector<dat>upd;
		vector<int>B{ A[i + 2],A[i + 3],A[i + 4] };
		sort(B.begin(), B.end());
		if (B[0] == B[2]) {//aaa
			add++;
			continue;
		}
		if (B[0] == B[1]) {//aab
			for (int j = 0; j < N; ++j) {
				upd.push_back({ j,B[2] , dp[B[0]][j] + 1 });
			}
			upd.push_back({ B[0],B[1] , dp[B[2]][B[2]] + 1 });
		}
		else if (B[1] == B[2]) {//abb
			for (int j = 0; j < N; ++j) {
				upd.push_back({ j,B[0] , dp[B[1]][j] + 1 });
			}
			upd.push_back({ B[1],B[2] , dp[B[0]][B[0]] + 1 });
		}
		else {
			//abc
			upd.push_back({ B[1],B[2] , dp[B[0]][B[0]] + 1 });
			upd.push_back({ B[0],B[2] , dp[B[1]][B[1]] + 1 });
			upd.push_back({ B[0],B[1] , dp[B[2]][B[2]] + 1 });
		}
		for (int j = 0; j < N; ++j) {
			upd.push_back({ j, B[0], dp2[j] });
			upd.push_back({ j, B[1], dp2[j] });
			upd.push_back({ j, B[2], dp2[j] });
		}
		for (int j = 0; j < 3; j++) {
			for (int k = 0; k < 3; k++) {
				if (j != k) {
					dp[B[j]][B[k]] = max(dp[B[j]][B[k]], premax);
					dp2[B[j]] = max(dp2[B[j]], premax);
					dp2[B[k]] = max(dp2[B[k]], premax);
				}
			}
		}
		for (int i = 0; i < upd.size(); ++i) {
			int x = upd[i].x;
			int y = upd[i].y;
			int z = upd[i].z;
			dp[x][y] = max(dp[x][y], z);
			dp[y][x] = max(dp[y][x], z);
			premax = max(premax, z);
			dp2[x] = max(dp2[x], z);
			dp2[y] = max(dp2[y], z);
		}
	}
	cout << premax + add << endl;
	return 0;
}


Measured memory_bytes: 19476
N, W = map(int, input().split())
weight = [0]*N
value = [0]*N
for i in range(N):
    weight[i], value[i] = map(int, input().split())

max_value = 10**5+10
INF = 10**9+1
dp = [[INF for _ in range(max_value)] for _ in range(N+1)]
dp[0][0] = 0
for i in range(N):
    for j in range(max_value):
        if j - value[i] >= 0:
            dp[i+1][j] = min(dp[i][j-value[i]]+weight[i], dp[i][j])
        else:
            dp[i+1][j] = min(dp[i+1][j], dp[i][j]) 

ans = 0
for j in range(max_value):
    if dp[N][j] <= W:
        ans = j

print(ans)


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

int main()
{
  int N,K;
  cin>>N>>K;
  int ans=0;
  int a[100010]={0};
  for(int i=0;i<N;i++){
    cin>>a[i];
    if(a[i]>=K) ans+=1;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 640
#! -*- coding: utf-8-unix -*-
import sys

# if __name__=='__main__':
#   lines = [int(x.strip()) for x in sys.stdin.readlines()]
#   print lines
#   n = lines[0]
# for i in xrange(n):
#     # a, b  = int(lines[i+1]), int(lines[i+2])
#     a, b  = lines[2*i+1], lines[2*i+2]
#     if len(str(a+b)) > 80:
#       print 'overflow'
#     else:
#       print a+b

if __name__=='__main__':
  # lines = [int(x.strip()) for x in sys.stdin.readlines()]
  # n = lines[0]
  n = input()
for i in xrange(n):
    # a, b  = int(lines[i+1]), int(lines[i+2])
    # a, b  = lines[2*i+1], lines[2*i+2]
    a, b  = input(), input()
    if len(str(a+b)) > 80:
      print 'overflow'
    else:
      print a+b

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

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int, int> P;

const int MOD = 1000000007;
const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;

/*
左から見ていったときの最大値と右から見ていったときの最大値を比較する

*/
int main()
{
    ll L, R;
    cin >> L >> R;
    ll ans = 2019;
    ll modL = L % 2019;
    ll modR = R % 2019;
    if (R - L >= 2018) {
        ans = 0;
    } else if (modL >= modR) {
        ans = 0;
    } else {
        for (ll i = L; i <= R; i++) {
            for (ll j = i + 1; j <= R; j++) {
                ll modi = i % 2019;
                ll modj = j % 2019;
                ans = min(ans, (modi * modj) % 2019);
            }
        }
    }

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

最小値は非負

2050 4040
31 - 2018, 0, 1, 2

0 1 ... 2017

1 .... 2019
- j-i>=2018 -> 0
- j-i<2018
modi >= modj -> 0
    32 ..... 0 1

- j-i<2018 && modi < modj:
     32, 33, ...., 2016
     2000 の中で探して一番小さくなるものを選ぶ
31 - 51


*/

Measured memory_bytes: 3612
#include<stdio.h>
int main(void)
{
    int stage[3]={0};
    char a[100]={0};
    int out = 0;
    int ans = 0;
    int i;
    int x,n;
    int mint;

    scanf("%d",&n);

    for(mint = 0;mint < n; mint++){

    for(;;){
    if(out == 3){
        printf("%d\n",ans);
        break;
    }
    scanf("%s",a);
    if(a[0] == 'H' && a[1] == 'I'){
        ans += stage[2];
        x = stage[1];
        stage[2] = x;
        x = stage[0];
        stage[1] = x;
        stage[0] = 1;
    }
    else if(a[0] == 'H'){
        for(i = 0;i < 3; i++)if(stage[i] == 1){
            ans += 1;
            stage[i] = 0;
        }
        ans += 1;

    }
    if(a[0] == 'O'){
        out += 1;
    }
    }
    for(i = 0; i < 3; i++)stage[i] = 0;
    out = 0,ans = 0;
    }
   return 0;
}

Measured memory_bytes: 596
// ALDS1_12_A - MST (Kruskal's)

import java.util.*;

class UF {
  int[] A;

  UF(int n) {
    A = new int[n];
    Arrays.fill(A, -1);
  }

  int find(int k) {
    if (A[k] < 0) {
      return k;
    } else {
      A[k] = find(A[k]);
      return A[k];
    }
  }

  void union(int k, int j) {
    int rk = find(k);
    int rj = find(j);
    if (A[rk] < A[rj]) { // rk has more elements
      A[rk] += A[rj]; // update rk's size
      A[rj] = rk; // point the set rk to rj
    } else {
      A[rj] += A[rk];
      A[rk] = rj;
    }
  }
}

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    UF uf = new UF(n);
    List<int[]> edges = new ArrayList<int[]>();
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        int weight = sc.nextInt();
        if (weight != -1) {
          edges.add(new int[] {i, j, weight});
        }
      }
    }
    Collections.sort(
        edges,
        new Comparator<int[]>() {
          public int compare(int[] e1, int[] e2) {
            return Integer.compare(e1[2], e2[2]);
          }
        });
    int w = 0;
    for (int[] e : edges) {
      int f1 = uf.find(e[0]);
      int f2 = uf.find(e[1]);
      if (f1 != f2) {
        w += e[2];
        uf.union(f1, f2);
      }
    }
    System.out.println(w);
  }
}


Measured memory_bytes: 41492
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <numeric>

template <class T, class U>
inline bool chmin(T &lhs, const U &rhs) {
  if (lhs > rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

template <class T, class U>
inline bool chmax(T &lhs, const U &rhs) {
  if (lhs < rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

// [l, r) from l to r
struct range {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { ++i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr l, r;
  constexpr range(int l_, int r_): l(l_), r(std::max(l_, r_)) { }
  constexpr itr begin() const { return l; }
  constexpr itr end() const { return r; }
};

// [l, r) from r to l
struct revrange {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { --i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr l, r;
  constexpr revrange(int l_, int r_): l(l_ - 1), r(std::max(l_, r_) - 1) { }
  constexpr itr begin() const { return r; }
  constexpr itr end() const { return l; }
};

int main() {
  int K, N;
  std::cin >> K >> N;
  std::vector<int> A(N);
  for (int &x: A) {
    std::cin >> x;
  }
  int ans = K;
  for (int i: range(0, N - 1)) {
    chmin(ans, K - (A[i + 1] - A[i])); 
  }
  chmin(ans, K - (A[0] + K - A[N - 1]));
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner

object Main {
    def main(args: Array[String]): Unit = {
        val scanner = new Scanner(System.in)
        val n: Int = scanner.nextInt
        val k: Int = scanner.nextInt
        val hates: List[Int] = List.fill(k)(scanner.nextInt)

        println(calc(n, hates))
    }

    def calc( n: Int, hates: List[Int]): Int ={
      (n to (10*n) toStream).find(p => p >= n && !isIncludingHateNum(p, hates)).get
    }

    def isIncludingHateNum(payment: Int, hates: List[Int]): Boolean ={
      val pays:List[Int] = (payment.toString.grouped(1)).toList.map(_.toInt)
      pays.exists(hates.contains(_))
    }
}


Measured memory_bytes: 108620
package main

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

const pi = math.Pi

var mod int = pow(10, 9) + 7
var Umod uint64 = 1000000007
var ans, sum, cnt int = 1, 0, 0

func main() {
	var S, s, s_bef string
	fmt.Scan(&S)
	s_bef = string(S[0])
	for i := 1; i < len(S); i++ {
		s = s + string(S[i])
		if s != s_bef {
			ans++
			s_bef = s
			s = ""
		}
	}
	fmt.Println(ans)
}

/*  ----------------------------------------  */

var reader = bufio.NewScanner(os.Stdin)

func read() string {
	reader.Scan()
	return reader.Text()
}

func lcm(x, y int) int {
	return (x / gcd(x, y)) * y
}

func gcd(x, y int) int {
	if x%y == 0 {
		return y
	} else {
		r := x % y
		return gcd(y, r)
	}
}

var fac [1000000]int
var finv [1000000]int
var inv [1000000]int

func combination_init() {
	fac[0], fac[1] = 1, 1
	finv[0], finv[1] = 1, 1
	inv[1] = 1

	// invは a^(-1) mod p
	// pをaで割ることを考える

	// p/a*(a) + p%a = p
	// p/a*(a) + p%a = 0          (mod p)
	// -p%a = p/a*(a)             (mod p)
	// -p%a *a^(-1)= p/a          (mod p)
	// a^(-1)= p/a * (-p%a)^(-1)  (mod p)
	// a^(-1) =

	for i := 2; i < 1000000; i++ {
		fac[i] = fac[i-1] * i % mod
		inv[i] = mod - inv[mod%i]*(mod/i)%mod
		finv[i] = finv[i-1] * inv[i] % mod
	}
}

func combination(x, y int) int {
	if x < y {
		return 0
	}
	if fac[0] != 1 {
		combination_init()
	}
	return fac[x] * (finv[y] * finv[x-y] % mod) % mod
	//return fac[x] / (fac[y] * fac[x-y])
}

func permutation(x, y int) int {
	if x < y {
		return 0
	}
	if fac[0] != 1 {
		combination_init()
	}
	return fac[x] * (finv[x-y] % mod) % mod
	//return fac[x] / fac[x-y]
}

func max(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Max(float64(x[i]), float64(res)))
	}
	return res
}

func min(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Min(float64(x[i]), float64(res)))
	}
	return res
}
func pow(x, y int) int { return int(math.Pow(float64(x), float64(y))) }
func abs(x int) int    { return int(math.Abs(float64(x))) }
func floor(x int) int  { return int(math.Floor(float64(x))) }
func ceil(x int) int   { return int(math.Ceil(float64(x))) }

type SortBy [][]int

func (a SortBy) Len() int      { return len(a) }
func (a SortBy) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a SortBy) Less(i, j int) bool {
	return a[i][1] < a[j][1]
}

type PriorityQueue []int

func (h PriorityQueue) Len() int            { return len(h) }
func (h PriorityQueue) Less(i, j int) bool  { return h[i] < h[j] }
func (h PriorityQueue) Swap(i, j int)       { h[i], h[j] = h[j], h[i] }
func (h *PriorityQueue) Push(x interface{}) { *h = append(*h, x.(int)) }
func (h *PriorityQueue) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}


Measured memory_bytes: 2304
#include <stdio.h>
#include <stdlib.h>
#define VMAX 10000


void CountingSort(unsigned short *A,unsigned short * B,int  n){//入力用・ソート後の配列
  int i;
  int C[VMAX+1]={0}; //メモ
  
  /* C[i] に i の出現数を記録する */
  for (i = 0;i< n;i++)C[A[i]]++;

  /* C[i] に i 以下の数の出現数を記録する*/
  for (i = 1;i<VMAX+1;i++){
    C[i] += C[i-1];
  }
  
  for (i = n-1;i>=0;i--){//後ろから選んでいるので安全
    B[C[A[i]]] = A[i];
    C[A[i]]--;
  }
}


int main(){
  unsigned short *A, *B;
  int C[VMAX+1];
  int n, i, j;

  scanf("%d", &n);

  A = malloc(sizeof(short)*n+1);//入力用
  B = malloc(sizeof(short)*n+1);//ソート後

  for(i=0;i<n;i++)scanf("%hd",&A[i]);
  
  CountingSort(A, B, n);//入力用・ソート後の配列
  
  for(i=1;i<=n;i++){
    if(i!=1)printf(" ");
    printf("%hd",B[i]);
  }
  printf("\n");
 
  return 0;
}



Measured memory_bytes: 9572
#include <iostream>

using namespace std;
using ll = long long;

#define OUT(v) cout<<v<<"\n"

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  ll N;
  scanf("%lld", &N);

  OUT((ll)(N-1)*(N)/2);

  return 0;
}


Measured memory_bytes: 256
A,B = map(int,input().split())
S = input()
ans = 'Yes'
if S[A] == '-':
    for i in range(A):
        if not S[i].isdecimal():
            ans = 'No'
    for i in range(A+1,A+B+1):
        if not S[i].isdecimal():
            ans = 'No'
else:
    ans = 'No'
print(ans)

Measured memory_bytes: 9132
//Never stop trying
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
//s.order_of_key(), *s.find_by_order()

using namespace std;
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

typedef string str;
typedef long long ll;
#define int ll
typedef double db;
typedef long double ld;

typedef pair<int,int> pi;
#define fi first
#define se second

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<pi> vpi;

#define pb push_back
#define eb emplace_back
#define pf push_front

#define lb lower_bound
#define ub upper_bound

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define endl "\n"

const int MOD = 1e9+7; //998244353
const ll INF = 1e18;
const int nx[4]={0,0,1,-1}, ny[4]={1,-1,0,0}; //right left down up

vi v,vv;

int32_t main(){
   boost;
   int N,M,K; cin>>N>>M>>K;

	for(int i=0; i<N; i++){
      int x; cin>>x;
      v.pb(x);
	}
	for(int i=0; i<M; i++){
      int x; cin>>x;
      vv.pb(x);
	}


	/*int res=0,sum=0;
	while(1){
      if(v.empty()&&vv.empty()) break;

      if(v.empty()){
         res+=vv[sz(vv)-1]; sum++;
         if(res>K){sum--; break;}
         vv.pop_back();
      }
      else if(vv.empty()){
         res+=v[sz(v)-1]; sum++;
         if(res>K){sum--; break;}
         v.pop_back();
      }
      else{
         if(v[sz(v)-1]>vv[sz(vv)-1]){
            res+=vv[sz(vv)-1]; sum++;
            if(res>K){sum--; break;}
            vv.pop_back();
         }
         else{
            res+=v[sz(v)-1]; sum++;
            if(res>K){sum--; break;}
            v.pop_back();
         }
      }
	}
	cout << sum << endl;*/

	for(int i=1; i<N; i++) v[i]+=v[i-1];
	for(int i=1; i<M; i++) vv[i]+=vv[i-1];

	int res=0;
	for(int i=0; i<N && v[i]<=K; i++){
      int x=K-v[i];
      auto it=upper_bound(all(vv),x)-vv.begin();
      int nb=i+1+(int)it;
      res=max(res,nb);
	}
	for(int i=0; i<M && vv[i]<=K; i++){
      int x=K-vv[i];
      auto it=upper_bound(all(v),x)-v.begin();
      int nb=i+1+it;
      res=max(res,nb);
	}
	cout << res << endl;

   return 0;
}


Measured memory_bytes: 7940
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Math;
using static System.Array;
using static AtCoderSolve.Tool;

namespace AtCoderSolve
{
    class Solve
    {
        const int mod = 1000000007;
        const int INF = int.MaxValue / 2;
        const long SINF = long.MaxValue / 2;


        static void Main(string[] args)
        {
            //var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            //Console.SetOut(sw);
            var cin = new Scanner();

            string s = Console.ReadLine();
            string ans = "Sunny";
            if (s == "Sunny")
            {
                ans = "Cloudy";
            }
            else if (s == "Cloudy")
            {
                ans = "Rainy";
            }

            Console.WriteLine(ans);

            //Console.Out.Flush();
        }

    }

    public class Scanner
    {
        public int[] SplitReader()
        {
            int[] array = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return array;
        }
        public long[] SplitReaderL()
        {
            long[] array = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return array;
        }
    }

    public static class Tool
    {
        static public void Initialize<T>(ref T[] array, T initialvalue)
        {
            for(var i = 0; i < array.Length; i++)
            {
                array[i] = initialvalue;
            }
        }
        static public long ModuloP(long value,long mod)
        {
            long r = value % mod;
            
            if (r * mod < 0)
            {
                r += mod;
            }
            return r;
        }

    }

    struct Pair<T> : IComparable<Pair<T>> where T : IComparable<T>
    {
        public T variable;
        public int index;

        public Pair(T val, int i)
        {
            variable = val;
            index = i;
        }

        public int CompareTo(Pair<T> otherPair)
        {
            return variable.CompareTo(otherPair.variable);
        }

        public int CompareIndex(Pair<T> otherPair)
        {
            return index.CompareTo(otherPair.index);
        }
    }



}






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

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

    int ans = x % 1000;
    if(ans == 0)
        cout << ans << endl;
    else
    {
        ans = 1000 - ans;
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 3624
//
//  9_B.cpp
//  
//
//  Created by 杵鞭俊 on 2018/07/13.
//

#include <iostream>
using namespace std;
#define MAX 2000000

int H,A[MAX + 1];

void maxHeapify(int i){
    int l,r,largest;
    l = 2 * i;
    r = 2 * i + 1;
    
    if(l <= H && A[l] > A[i] ) largest = l;
    else largest = i;
    
    if(r <= H && A[r] > A[largest] ) largest = r;
    
    if(largest != i){
        swap( A[i],A[largest]);
        maxHeapify(largest);
    }
}


int main(){
    cin >> H;
    
    for(int i = 1; i <= H; i++) cin >> A[i];
    
    for(int i = H/2;i>=1;i--) maxHeapify(i);
    
    for(int i = 1; i <= H; i++) {
        cout << " " << A[i];
    }
    cout << endl;
    return 0;
}



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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    string s;
    while (n != 0) {
        int r = n % 2;
        if (r < 0) {
            r += 2; // rがマイナスにならないように
        }
        n = (n - r) / (-2);
        s += (char)('0' + r);
    }
    reverse(s.begin(), s.end());
    if (s == "") {
        s = "0";
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
 
 
public class Main implements Runnable {
 
  public void run() {
    BetterScanner scanner = new BetterScanner(System.in);
    long x = scanner.nextLong();
    long y = scanner.nextLong();
    
    long result = 0;
    while (true) {
      x *= 2;
      result ++;
      if (x > y) {
        System.out.println(result);
        return;
      }
    } 
  }
 
  public static void main(String[] args) {
    Main main = new Main();
    main.run();
  }
 
  // scanner slightly faster than usual ones
  public static class BetterScanner {
 
    private InputStream stream;
    private byte[] buffer = new byte[1024];
    private int pointer = 0;
    private int bufferLength = 0;
 
    public BetterScanner(InputStream stream) {
      this.stream = stream;
    }
 
    private boolean updateBuffer() {
      if (pointer >= bufferLength) {
        pointer = 0;
        try {
          bufferLength = stream.read(buffer);
        } catch (IOException exception) {
          exception.printStackTrace();
        }
        return bufferLength > 0;
      } else {
        return true;
      }
    }
 
    private int read() {
      if (updateBuffer()) {
        return buffer[pointer ++];
      } else {
        return -1;
      }
    }
 
    public boolean hasNext() {
      skipUnprintable();
      return updateBuffer();
    }
 
    private void skipUnprintable() { 
      while (updateBuffer() && !isPrintableChar(buffer[pointer])) {
        pointer ++;
      }
    }
 
    public String next() {
      if (hasNext()) {
        StringBuilder builder = new StringBuilder();
        int codePoint = read();
        while (isPrintableChar(codePoint)) {
          builder.appendCodePoint(codePoint);
          codePoint = read();
        }
        return builder.toString();
      } else {
        throw new NoSuchElementException();
      }
    }
 
    public long nextLong() {
      if (hasNext()) {
        long number = 0;
        boolean minus = false;
        int codePoint = read();
        if (codePoint == '-') {
          minus = true;
          codePoint = read();
        }
        if (codePoint >= '0' && codePoint <= '9') {
          while (true) {
            if (codePoint >= '0' && codePoint <= '9') {
              number *= 10;
              number += codePoint - '0';
            } else if (codePoint < 0 || !isPrintableChar(codePoint)) {
              return (minus) ? -number : number;
            } else {
              throw new NumberFormatException();
            }
            codePoint = read();
          }
        } else {
          throw new NumberFormatException();
        }
      } else {
        throw new NoSuchElementException();
      }
    }
 
    public int nextInt() {
      long number = nextLong();
      if (number >= Integer.MIN_VALUE && number <= Integer.MAX_VALUE) {
        return (int)number;
      } else {
        throw new NumberFormatException();
      }
    }
 
    private boolean isPrintableChar(int codePoint) {
      return codePoint >= 33 && codePoint <= 126;
    }
 
  }
 
}

Measured memory_bytes: 22868
//
//  main.cpp
//  ITP1_2-B
//
//  Created by Saicj on 2015/07/13.
//  Copyright (c) 2015??´ saicj. All rights reserved.
//

#include <iostream>

int main(int argc, const char * argv[])
{

    int a,b,c;
    std::cin >> a >> b >> c;
    
    if (a < b && b < c){
        std::cout << "Yes" << "\n";
    }else{
        std::cout << "No" << "\n";
    }
    
    return 0;
}

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

int main() {
	int n; cin >> n;
	int ans = 100000;
	int tmp;
	for (int i=0; i<n; i++) {
		ans *= 1.05;
		tmp = ans / 1000 * 1000;
		if (tmp != ans) 
                     ans = tmp + 1000;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3012
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <vector>
#include <stack>
#include <bitset>

using namespace std;

#define FSIO  ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define DEBUG(a)   cout<<"DEBUG: "<<(a)<<endl;
#define ll long long
#define ull unsigned long long
#define ld long double
#define pb push_back
#define MP make_pair
#define X  first
#define Y  second
#define REP(i,st,ed)    for(int i=st;i<=ed;++i)
#define IREP(i,st,ed)   for(int i=st;i>=ed;--i)
#define TCASE(T)    cin>>T;while(T--)

const int MAXN = 100005;
const ll MOD = 1e9+7 ;
const ll LINF = 0x3f3f3f3f3f3f3f3f;
const int INF = 1e9+7;
const double PI = acos(-1.0);
const double EPS = 1e-8;

int _;

using namespace std;




int main()
{
    //freopen("test.in","r+",stdin);
    //freopen("test.out","w+",stdout);
    FSIO;
    ll K, A, B;
    while(cin>>K>>A>>B)
    {
        if(A>=B)
        {
            cout<<K+1<<endl;
            continue;
        }
        ll res = 1;
        for(int i=1;i<=K;++i)
        {
            if(i+1<=K)
            {
                if(res>=A&&B-A>2LL)
                {
                    i++;
                    res += B-A;
                }
                else    res++;
            }
            else res++;
        }
        cout<<res<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#pragma GCC optimize("Ofast")
#define rep(i,a,n) for(int i=a; i<n; i++)
typedef long long ll;
typedef pair<int,int> P;
const ll MOD = (int)1e9+7;
const ll INF = MOD*MOD;
const ll powll = 1LL<<1;
 
int main(){
	double a;cin >> a;
    cout << M_PI*a*2.00 << "\n";
}


Measured memory_bytes: 3780
#include <iostream>
#include <string>
#include <map>
#include <stdio.h>
#include <cmath>

using namespace std;

int main()
{
    string options;
    cin >> options;
    int count = 0;
    if(options[0] == 'o') ++count;
    if(options[1] == 'o') ++count;
    if(options[2] == 'o') ++count;
    int optionTotal = count * 100;
    int res = optionTotal + 700;
    cout << res << endl;
}

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

int main(){ 
  int A, B, C, D, E, F;
  cin >> A >> B >> C >> D >> E >> F;
  vector<int> ab;

  for (int a = 0; a * A * 100 <= F; a++) {
    for (int b = 0; b * B * 100 + a * A * 100 <= F; b++) {
      ab.emplace_back(a*A*100 + b*B*100);
    }
  }
  vector<int> cd;
  for (int c = 0; c * C <= F; c++) {
    for (int d = 0; d * D <= F; d++) {
      cd.emplace_back(c*C + d*D);
    }
  }

  sort(ab.begin(), ab.end());
  sort(cd.begin(), cd.end());

  double mx = -1;
  P res;
  res.first = 100*A;
  res.second = 0;
  for (int i = 1; i < ab.size(); i++) {
    for (int j = 1; j < cd.size(); j++) {
      if (ab[i] + cd[j] > F) break;
      if (100 * cd[j] > ab[i] * E) break;
      double tmp = (1.0 * cd[j]) / (1.0 * (ab[i] + cd[j]));
      if (mx < tmp) {
        res.first = ab[i] + cd[j];
        res.second = cd[j];
        mx = tmp;
      }
    }
  }
  cout << res.first << " " << res.second << endl;
} 

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


int main(){
	int n,x,t;
	int tmp;
	long long int time = 0;
	cin >> n>> x>> t;
	tmp = 0;
	while(tmp < n){
		time += t;
		tmp += x;
	}

	cout << time<<endl;
}

Measured memory_bytes: 3492
#include<stdio.h>

int main(void){
  int i,n,count=0;
    scanf("%d",&n);
  int p[n];
  for(i=0;i<n;i++){
    scanf("%d",&p[i]);
  }

  for(i=0;i<n-2;i++){
    if((p[i]<p[i+1])&&(p[i+1]<p[i+2])){
      count+=1;
    }
    else if((p[i]>p[i+1])&&(p[i+1]>p[i+2])){
      count+=1;
    }
  }

  printf("%d\n",count);

  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i < (n); ++i)
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; }
template<class T> inline bool change(T& a, T b) { if (a != b) { a = b; return 1; } return 0; }
using namespace std;
typedef long long ll;

bool a[1000];

int main(){
    int x,n; cin >> x >> n;
    rep(i,n){
        int p;cin >> p;
        a[p+500]=true;
    }
    int ans=-1;
    int mina=1000000;
    for(int i=-500;i<500;i++){
        if(!a[i+500]){
           if(chmin(mina,abs(x-i))){
               ans=i;
           }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#include <math.h>
#include <list>
#include <cmath>
#include <queue>
using namespace std;

#define ll long long
void sor(vector<ll> &x)
{
    sort(x.begin(), x.end());
}

list<ll> a[5];
void bfs(int src)
{
    queue<int> q;
    bool *vis = new bool[5 + 1]{0};
    q.push(src);
    vis[src] = true;
    while (!q.empty())
    {
        int node = q.front();
        cout << node << " ";
        q.pop();
        for (int n : a[node])
        {
            if (!vis[n])
            {
                q.push(n);
                vis[n] = true;
            }
        }
    }
}

ll min(ll x, ll y)
{
    if (x > y)
    {
        return y;
    }
    else
    {
        return x;
    }
}

int main()
{

    int n;
    cin >> n;
    vector<ll> a(2 * n);
    for (int i = 0; i < 2 * n; i++)
    {
        cin >> a[i];
    }
    ll ans = 0;
    sort(a.begin(), a.end());
    for (int i = 0; i < 2 * n; i += 2)
    {
        ans += a[i];
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3604
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int X = sc.nextInt();
		int A = sc.nextInt();
        if (X < A) {
		  System.out.println(0);
        } else {
		  System.out.println(10);
        }
		// 出力
	}
}

Measured memory_bytes: 21972
#include <stdio.h>

int main(){
  int n,f=0;
  scanf("%d",&n);
  int a[n+1];
  for(int i=1;i<=n;i++)scanf("%d",&a[i]);
  
  for(int i=1;i<=n;i++){
    if(a[i]%2==0 && a[i]%3!=0 && a[i]%5!=0){
      printf("DENIED");
      f=1;
      break;
    }
  }
  if(f==0)printf("APPROVED");
  return 0;
}



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



int main()
{
  ll n,a[10000];
  cin >> n;
  for(int i = 0;i < n;i++){
    cin >> a[i];
  }
  ll sum = 0;
  for(int i = 0;i < n;i++){
    ll cnt = 0;
    bool flag = true;
    while(flag){
      if(a[i]%2 == 0){
        cnt++;
        a[i] = a[i] / 2;
      } else {
        flag = false;
      }
    }
    sum += cnt;
  }
  cout << sum << endl;
}


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

int main() {
    int n, k;
    cin >> n >> k;
    const int MOD = 998244353;
    vector<int>dp(n+10, 0),a(n+10, 0);
    vector<int>left(k), right(k);
    rep(i,0,k) cin >> left[i] >> right[i];
    dp[1] = 1;
    a[1] = 1;
    rep(i,2,n+10){
        rep(j,0,k){
            int r = i - left[j];
            int l = max(i - right[j], 1);
            if (r < 0) continue;
            dp[i] = (dp[i] + a[r] - a[l-1]) % MOD;
            if (dp[i] < 0) dp[i] += MOD;
        }
        a[i] = (a[i-1] + dp[i]) % MOD;
    }
    cout << dp[n] << endl;
}

Measured memory_bytes: 4812
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
#include<list>

using namespace std;

typedef  long long int lint;

#define rep(i, n) for (lint i = 0; i < n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
#define mp make_pair
#define P pair<int,int>
#define enld endl

lint extgcd(lint a, lint b, lint& x, lint& y) {
	//x,yをax+by-gcd(a,b)の解にする
	//gcd(a,b)を返す
	lint d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1; y = 0;
	}
	return d;
}

int main() {
	lint a, b;
	cin >> a >> b;
	lint x = 0, y = 0;
	extgcd(a, b, x, y);
	cout << x << ' ' << y << endl;
}


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

using namespace std;

typedef long long int ll;
typedef pair<int, int> P;
#define INF 10000000000000
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i < (int)(n); i++)
#define repN_1(i, n) for(int i = 0; i < (int)(n - 1); i++)
#define repM(i, n) for(int i = (int)(n - 1); i >= 0; i--)
template<class T>bool chmax(T & a, const T & b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

int main()
{
	static int food[3005][3005];
	P p[3005];
	int n, t;
	int ans = 0;
	
	memset(food, 0, sizeof(food));

	cin >> n >> t;

	rep(i, n)
		cin >> p[i].first >> p[i].second;

	sort(p, p + n);

	rep(i, n)
	{
		rep(j, t)
		{
			if (j < p[i].first)
			{
				food[i + 1][j] = food[i][j];
			}
			else
			{
				food[i + 1][j] = max(food[i][j], food[i][j - p[i].first] + p[i].second);
			}
		}
	}

	rep(i, n)
		ans = max(ans, food[i][t - 1] + p[i].second);

	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 35584
import math

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

def powd(x, n, m):
  ans = 1
  while(n > 0):
    if(bin(n & 1) == bin(1)):
      ans = (ans*x)%m
    x = x*x % m
    n = n >> 1 #ビットシフト
  return ans

mod = 1000000007

#a = list(map(int, input().split()))
X,Y = list(map(int, input().split()))

com=[1 for i in range(1000002)]
inv=[1 for i in range(1000002)]

for ii in range(1000000):
    i = ii+1
    com[i+1] = (com[i]*(i+1))%mod



#print(com[0:8])
#print(inv[0:8])

def invc(n,mo):
    return powd(com[n],mo-2,mo)

#print("a",com[4],invc(4,mod),com[4]*invc(4,mod)%mod)

if((X+Y)%3 != 0 or Y/X <0.49999999 or Y/X > 2.00000001):
    print(0)
else:
    level = (X+Y)//3
    b = (level-abs(X-Y))//2
    #print(level,b)
    ans= com[level] * powd(com[level-b],mod-2,mod) * powd(com[b],mod-2,mod) % mod
    print(ans)

Measured memory_bytes: 115728
#include <cstdio>
#include <iostream>
using namespace std;
typedef long long LL;

int main()
{

	
	string s;
	cin>>s;
	int len=s.length();
	if(len==1)
	{
		cout<<(LL)(s[0]-'0')<<endl;
	}
	else if(len>1)
	{
		int q=0;
		for(int i=1;i<len;i++)
		{
			if(s[i]=='9')
			{
				q=1;
			}
			else
			{
				q=0;break;
			} 
			
		}
		
		if(q) cout<<(LL)(s[0]-'0')+9*(len-1)<<endl;
		else
		cout<<(LL)(s[0]-'0')-1+(len-1)*9<<endl;	
	}

 	return 0;
}


Measured memory_bytes: 256
import itertools

def main():
    # やり直し
    cnt = 0
    mod = 10
    for i in range(5):
        A = int(input())
        if A % 10 == 0:
            cnt += A
        else:
            cnt += 10 - (A % 10)
            cnt += A
            mod = min(mod, A % 10)

    if mod == 10:
        print(cnt)
    else:
        print(cnt - (10 - mod))

main()

Measured memory_bytes: 38256
using System;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void Main()
    {
        var list = new List<int>();
        list.Add(1);
        for (int i = 1; i <= 6; i++) list.Add((int)Math.Pow(6, i));
        for (int i = 1; i <= 5; i++) list.Add((int)Math.Pow(9, i));
        list = list.OrderByDescending(x => x).ToList();
        var ans = Enumerable.Repeat(int.MaxValue, 100001).ToArray();
        for (int i = 0; i < list.Count(); i++) ans[list[i]] = 1;
        for (int i = 0; i < 70; i++)
        {
            for (int j = 0; j <= 100001; j++)
            {
                for (int k = 0; k < list.Count(); k++)
                {
                    if (j + list[k] < 100001 && ans[j + list[k]] > ans[j]) ans[j + list[k]] = ans[j] + 1;
                }
            }
        }
        int n = int.Parse(Console.ReadLine());
        Console.WriteLine(ans[n]);
    }
}

Measured memory_bytes: 13352
local function combination(x,y)
    if y==0 then
        return 1
    else
        return x*combination(x-1,y-1)//y
    end
end

n,p=io.read("*n","*n")
local co=0
local ce=0
for i=1,n do
    if io.read("*n")%2==1 then
        co=co+1
    end
end
ce=n-co

local cootal=0
local ceotal=0
for i=p,co,2 do
    cootal=cootal+combination(co,i)
end
for i=0,ce do
    ceotal=ceotal+combination(ce,i)
end
print(cootal*ceotal)

Measured memory_bytes: 256