akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
using namespace std;
 
int main() {
    fast();
    /*ll t;
    cin>>t;
    while(t--)
    {
       
    }*/
    ll flag=0;
    ll n;
    cin>>n;
    while(n!=0)
    {
        ll x=n%10;
        if(x==7)
        flag=1;
        n/=10;
    }
    if(flag)
    cout<<"Yes";
    else
    cout<<"No";
}


Measured memory_bytes: 3648
#include <stdio.h>
int main(void){
    int x, h, m, s;
    scanf("%d",&x);
    h = x/3600;
    m = (x-h*3600)/60;
    s = x-h*3600-m*60;
    printf("%d:%d:%d\n", h, m, s);
    return 0;
}


Measured memory_bytes: 2104
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll Max = 200005;
map <ll, ll> m;

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	ll n, a[Max], adun[Max], scad[Max];
	cin >> n;
	for (int i=1; i<=n; i++) {
		cin >> a[i];
		adun[i] = i + a[i];
		scad[i] = i - a[i];
		m[adun[i]]++;
	}
	ll ans = 0;
	for (int i=1; i<=n; i++) {
		ans += m[scad[i]];
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 30948
#!/usr/bin/env python3
import sys
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
# inf = float('inf') ;mod = 10**9+7
# mans = inf ;ans = 0 ;count = 0 ;pro = 1
from heapq import heappush,heappop

n,q=map(int,input().split())
STX=[tuple(map(int,input().split())) for i in range(n)]
D=[int(input()) for i in range(q)]
event=[]
for si,ti,xi in STX:
  event.append((si-xi,0,xi))
  event.append((ti-xi,-1,xi))
for di in D:
  event.append((di,1,di))
event.sort()
hq=[]; S=set()
for time, query, number in event:
  if query == 0:
    heappush(hq,number)
    S.add(number)
  elif query == -1:
    S.remove(number)
  else:
    while hq and hq[0] not in S:
      heappop(hq)
    if not hq:
      print(-1)
    else:
      print(hq[0])




Measured memory_bytes: 119740
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

int main(){
    int n,h,w;
    cin >>n >>h >>w;

    vector<int> b(w*n+1);
    rep(i,n){
        int x;
        cin >>x;

        int mul = 1;
        if(i%2 == 1) mul = -1;

        int pos = w*i + mul*x;
        ++b[pos];
        --b[pos+w];
    }

    rep(i,w*n) b[i+1] += b[i];

    int ans = 0;
    rep(i,w*n)if(b[i] == 0) ans += h;
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3116
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		double n = sc.nextInt();
		double d = sc.nextInt();
		sc.close();

		System.out.println((int) Math.ceil(n / (2 * d + 1)));
	}
}


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

int main(){
    int n;
    cin>>n;
    vector<int> a(n,0);
    int j;
    for(int i=0;i<n-1;i++){
        cin>>j;
        a[j-1]++;
    }
    for(int i=0;i<n;i++)cout<<a[i]<<endl;
    return 0;
}

Measured memory_bytes: 4004
# coding: utf-8
# Your code here!
N=int(input())
List = list(map(int, input().split()))

ans=0

L=0
while 1==1:
    R=L

    if sum(List)!=0 and List[L]==0:
        L=0
        while List[L]==0:
            L+=1


    #終了判断
    if sum(List)==0:
        break
    elif R==len(List)-1:
        #リストの端の時
        List[R]=List[R]-1
        ans+=1
        #print("処理1")
    elif List[L]>List[L+1]:
        List[L]=List[L]-1
        #回数
        ans+=1
        #print("処理2")
    else:
        checkMAX=1
        while 1==1:
            #print("マックスの表示")
            #print(checkMAX)
            
            R+=1
            if R==len(List)-1:
                #範囲が決まったとき
                for i in range(L,R+1):#R+1追加あああああああ
                    List[i]=List[i]-1
                #回数
                ans+=1
                #print("処理3")
                break
            elif checkMAX>List[R+1]:
                #print("次の数")
                #print(List[R+1])
                #範囲が決まったとき
                for i in range(L,R+1):#R+1追加あああああああ
                    List[i]=List[i]-1
                #回数
                ans+=1
                #print("処理4")
                break
            else:
                checkMAX=List[R+1]
                pass
            
    #デバッグ
    #print("Lを表示")
    #print(L)
    #print(List)
            
    #print(ans)
    if sum(List)!=0 and List[L]==0:
        L=0
        while List[L]==0:
            L+=1
    #L+=1
print(ans)

Measured memory_bytes: 3064
[N, K] = list(map(int, input().split()))
A_list = []
x = 0
for i in range(K):
  u = input()
  B_list = list(map(int, input().split()))
  A_list = A_list + B_list
for j in range(1,N+1):
  if not j in A_list:
    x = x + 1
print(x)    

Measured memory_bytes: 9192
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define MOD 1000000007
#define INF 1 << 30

using namespace std;
typedef long long ll;

int main(void) {
	ll num, ans = 0, x = 5;
	cin >> num;
	if (num & 1ll) {
		printf("0\n");
		return 0;
	}
	num >>= 1;
	while (num >= x) {
		ans += num / x;
		x *= 5;
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
a = sorted(a)
ans = 1
for i in range(n):
         ans *= a[i]
         if ans == 0:
                  print(ans)
                  exit()
         elif ans > (10 ** 18):
                  print(-1)
                  exit()
print(ans)


Measured memory_bytes: 21572
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using ll = long long;
using P = pair<int, int>;
#define debug(var) cout << "[" << #var << "] " << var << endl
const ll mod = 1000000007;

vector<P> ken[100005];

int main(){
    int n, m;
    cin >> n >> m;
    rep(i, m) {
        int p, y;
        cin >> p >> y;
        ken[p].emplace_back(y, i);
    }
    vector<string> ans(m);
    rep(i, n+1) {
        if (ken[i].size()==0) continue;
        sort(ken[i].begin(), ken[i].end());
        int x = 0;
        for (P p: ken[i]) {
            int id = p.second;
            int year = p.first;
            int now = i;
            string s = "";
            int z = 100000;
            while (z) {
                s += ('0' + now/z);
                now %= z;
                z /= 10;
            }
            x++;
            int nowx = x;
            z = 100000;
            while(z) {
                s += ('0' + nowx/z);
                nowx %= z;
                z /= 10;
            }
            ans[id] = s;
        }
    }
    
    
    
    rep(i, m) {
        cout << ans[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 13952
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int n, sum = 0, ma = 0;
	cin >> n;

	for(int i=0;i<n;i++){
		int l;
		cin >> l;
		sum += l;
		ma = max(ma, l);
	}
	if(sum-ma>ma) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>
#include <functional>
//#include <boost/multiprecision/cpp_int.hpp>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)
#define llrep(i, n) for(ll i = 0; i < n; ++i)
#define llREP(i, m, n) for(ll i = m; i < n; ++i)
#define llrrep(i,n) for(ll i = n; i >= 0; --i)
#define llRREP(i, m, n) for(ll i = n; i >= m; --i)

using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int, int>;
using pll = std::pair<long long, long long>;
using pil = std::pair<int, long long>;
using pli = std::pair<long long, int>;
using plpii = std::pair<long long, std::pair<int, int>>;
using pdd = std::pair<double, double>;

const long long INF = 1000000000000000001;
const long long _MOD = 1000000007;
const long long MOD = 998244353;
const int ALPHABET = 27;
const double pi = 3.14159265358979;

using namespace std;
//namespace mp = boost::multiprecision;

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

	int h, w, k;
	cin >> h >> w >> k;
	string* c = new string[h];
	rep(i, h) cin >> c[i];

	int ans = 0;
	rep(i, 1 << h) {
		rep(j, 1 << w) {
			//check
			int sum = 0;
			rep(p, h) {
				rep(q, w) {
					if (c[p][q] == '#' && (i&(1 << p)) == 0 && (j&(1 << q)) == 0) {
						++sum;
					}
				}
			}

			if (sum == k) ++ans;
		}
	}

	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 3660
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<long long> vll;
typedef pair<long long, long long> pll;

const ll INF = 1e9;
const ll MOD = 1e9 + 7;

int main(){
	ll N;
	vll A;
	cin >> N;
	ll i, j, k;
	for (i = 0; i < N; i++){
		ll a;
		cin >> a;
		A.push_back(a);
	}
	ll ans = 0;
	ll pos = 0;
	while (1){
		if (pos==N){
			break;
		}
		if (pos == N - 1){
			ans++;
			break;
		}
		if (A[pos] < A[pos + 1]){
			while (1){
				pos++;
				if (pos == N - 1 || A[pos]>A[pos + 1]){
					ans++;
					break;
				}
			}
			pos++;
			continue;
		}
		else if (A[pos]>A[pos + 1]){
			while (1){
				pos++;
				if (pos == N - 1 || A[pos] < A[pos + 1]){
					ans++;
					break;
				}
			}
			pos++;
			continue;
		}
		else{
			pos++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 1400
/*
 *       ~ AtCoder  Botay ~
 *        code by kazalika
 */

#include <bits/stdc++.h>

//#pragma GCC optimize("O3")

using namespace std;



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

  double a, b, h, m;
  cin >> a >> b >> h >> m;
  const double pi = acos(-1);
  double a1 = (h + m / 60) / 12 * 2 * pi;
  double a2 = m / 60 * 2 * pi;
  double r = abs(a1 - a2);
  if (r > pi)
    r = 2 * pi - r;
  cout << sqrt(a * a + b * b - 2 * a * b * cos(r));

}

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

int main(){
    int N, D;
    int X[20][20];

    cin >> N >> D;
    for(int n=0;n<N;n++){
        for(int d=0;d<D;d++){
            cin >> X[n][d];
        }
    }

    int ans = 0;
    for(int n=0;n<N;n++){
        for(int m=n+1;m<N;m++){
            double dist = 0.0;
            for(int d=0;d<D;d++){
                dist += pow(X[n][d] - X[m][d], 2);
            }
            dist = sqrt(dist);
            if(abs(dist - (long)dist) < 1e-6){
                ans++;
            }
        }
    }
    cout << ans << "\n";
    return 0;
}

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

#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")"<< endl
#define BINARY(x) static_cast<bitset<16> >(x)

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)

#define in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;
const int INF = 1e9;
typedef pair<int, int> PII;
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};

int p; 
vector<string> S;
int N;

int solve(int level)
{

    if (isdigit(S[p][level])) {
        return (S[p++][level] - '0');
    }

    while (true) {
        // DUMP2(p, level);
        if (p < N && S[p].size() < level) break;
        if (S[p][level] == '+') {
            p++; // skip '+'
            int tmp = 0;
            while (true) {
                if (p >= N || S[p].size() <= level+1) break;
                tmp += solve(level+1);
            }
            return tmp;
        } else if (S[p][level] == '*') {
            p++; // skip '*'
            int tmp = 1;
            while (true) {
                if (p >= N || S[p].size() <= level+1) break;
                tmp *= solve(level+1);
            }
            return tmp;
        }
    }

    return -1;
}

int main()
{
    while (cin >> N, N) {
        p = 0;
        S.resize(N);
        rep(i, N) cin >> S[i];
        cout << solve(0) << endl;
    }
}

Measured memory_bytes: 3240
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc=new Scanner(System.in);
        long N=sc.nextLong();
        long A=sc.nextLong();
        long B=sc.nextLong();
        
        long PAIR=N/(A+B);
        long mod=N-PAIR*(A+B);
        
        long ANS=PAIR*A;
        
        if(mod<A){
            ANS+=mod;
        }else{
            ANS+=A;
        }
        
        System.out.println(ANS);
    }
}


Measured memory_bytes: 23636
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func getNextLine(scanner *bufio.Reader) string {
	var buffer string
	for {
		line, isPrefix, _ := scanner.ReadLine()
		buffer += string(line)
		if isPrefix == false {
			break
		}
	}
	return buffer
}

func getIntList(scanner *bufio.Reader) []int {
	list := strings.Split(getNextLine(scanner), " ")
	l := len(list)
	result := make([]int, l)
	for i := 0; i < l; i++ {
		result[i], _ = strconv.Atoi(list[i])
	}
	return result
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := bufio.NewReader(fp)

	var n, k int
	var s string
	fmt.Sscan(getNextLine(scanner), &n)
	fmt.Sscan(getNextLine(scanner), &s)
	fmt.Sscan(getNextLine(scanner), &k)
	ans := ""
	for i := 0; i < n; i++ {
		if s[i] == s[k-1] {
			ans += string(s[i])
			continue
		}
		ans += "*"
	}
	fmt.Println(ans)
}


Measured memory_bytes: 640
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

H, W, N = mapint()
sy, sx = mapint()
S = list(str(input()))
T = list(str(input()))
L, R = sx-1, sx-1
U, D = sy-1, sy-1
for s, t in zip(S, T):
    if s=='L':
        L -= 1
        if L<0:
            print('NO')
            break
    elif s=='R':
        R += 1
        if R>=W:
            print('NO')
            break
    elif s=='U':
        U -= 1
        if U<0:
            print('NO')
            break
    else:
        D += 1
        if D>=H:
            print('NO')
            break
    if t=='L':
        R = max(R-1, 0)
    elif t=='R':
        L = min(L+1, W-1)
    elif t=='U':
        D = max(D-1, 0)
    else:
        U = min(U+1, H-1)
else:
    print('YES')

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

const long long int MOD = 998244353;
long long int f[500005];
long long int invf[500005];

long long int mypow(long long int x,long long int n)
{
	long long int res = 1;
	while(n>0)
	{
		if(n%2==1)
		{
			res = ((res%MOD)*(x%MOD)%MOD);
			res%=MOD;
		}
		x = ((x%MOD)*(x%MOD)%MOD);
		n/=2;
	}
	return res;
}

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

    long long int res = 0;
    long long int n,m,k;

    cin >> n >> m >> k;

    if(m==1)
    {
    	if(n-1==k)
    	{
    		cout << 1 << '\n';
    	}
    	else
    	{
    		cout << 0 << '\n';
    	}
    	return 0;
    }
    f[0] = 1;
    for(long long int i=1;i<500005;i++)
    {
    	f[i] = ((f[i-1]%MOD)*(i%MOD)%MOD);
    	f[i]%=MOD;
    }
    invf[500004] = mypow(f[500004],MOD-2);
    for(long long int i=500003;i>=0;i--)
    {
    	invf[i] = ((invf[i+1]%MOD)*((i+1)%MOD)%MOD);
    	invf[i]%=MOD;
    }

    long long int A = m;
    for(int i=1;i<n;i++)
    {
    	A = ((A%MOD)*((m-1)%MOD)%MOD);
    	A%=MOD;
    }

    res = A;
    long long int B = mypow(m-1,MOD-2);
    for(int i=1;i<=k;i++)
    {
    	long long int C = f[n-1];
    	C = ((C%MOD)*(invf[i]%MOD)%MOD);
    	C%=MOD;
    	C = ((C%MOD)*(invf[n-1-i]%MOD)%MOD);
    	A = ((A%MOD)*(B%MOD)%MOD);
    	A%=MOD;
    	C = ((C%MOD)*(A%MOD)%MOD);
    	C%=MOD;
    	res = ((res%MOD) + (C%MOD)%MOD);
    	res%=MOD;
    }

    cout << res << '\n';

    return 0;
}

Measured memory_bytes: 11468
#include <bits/stdc++.h>
#define repp(i,l,r)for(long long i=(l);i<(r);i++)
#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define per(i,n) for (long long i = (n); i >= 0; --i)
const int INF = 2147483647;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//ミョ(-ω- ?)
int main() {
    int a,b,c,k;
    cin >> a >> b >> c >> k;
    while(a >= b){
        k--;
        b *= 2;
    }
    while(b >= c){
        k--;
        c *= 2;
    }
    if(k >= 0 && a < b && b < c)cout << "Yes\n";
    else cout << "No\n";
    //if(k >= 0)cout << "Yes\n";
    //else cout << "No\n";
    return 0;
}

Measured memory_bytes: 3632
while True:
    n=int(input())
    x=1000-n
    a=x//500
    b=(x%500)//100
    c=((x%500)%100)//50
    d=(((x%500)%100)%50)//10
    e=((((x%500)%100)%50)%10)//5
    f=((((x%500)%100)%50)%10)%5  
    if n==0:
        break
    else:
        print(a+b+c+d+e+f)


Measured memory_bytes: 5588
#include <bits/stdc++.h>
using namespace std;
#define P pair<int,int>
int main() {
	int n;
	long long k;
	cin >> n >> k;
	int f, s;
	vector<P> vec;
	for (int i = 0; i < n; i++) {
		cin >> f >> s;
		vec.push_back(make_pair(f, s));
	}
	sort(vec.begin(), vec.end());
	int vsize = vec.size();
	long long sum = 0;
	for (int i = 0; i < vsize; i++) {
		sum += vec[i].second;
		if (sum >= k) {
			cout << vec[i].first << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 1400
#include <iostream>

using namespace std;

int main() {

    unsigned long long N;
    unsigned long long sum = 1;

    cin >> N;
    for(int i=2; i<=N; ++i){
        if(i%5 != 0 && i%3 !=0){
            sum +=i;
        }
    }

    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 3636
y = input()
ans = 0
count = 0
c = 0
for i in y:
    c += 1
    if i == 'A' or i == 'C' or i == 'T' or i == 'G':
        count += 1
        if c == len(y):
            if ans < count:
                ans = count
    else:
        if ans < count:
            ans = count
        count = 0

print(ans)

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

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;

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

struct Node {
  int id;
  int parent = -1;
  vi children;
  
  Node(): id(-1) {}
  Node(int id): id(id) {}
};

int main() {
  int n;
  cin >> n;
  
  unordered_map<int, Node> tree;
  rep(i, n) {
    int id, k;
    cin >> id >> k;
    
    if (!tree.count(id)) tree[id] = Node(id);
    auto &nd = tree[id];

    rep(j, k) {
      int cid;
      cin >> cid;
      
      if (!tree.count(cid)) tree[cid] = Node(cid);
      auto &cnd = tree[cid];

      cnd.parent = id;
      nd.children.push_back(cid);
    }
  }

  
  
  rep(i, n) {
    auto nd = tree[i];

    int depth = 0, parent = nd.parent;
    while (parent != -1) {
      depth++;
      parent = tree[parent].parent;
    }

    string type;
    if (!depth) type = "root";
    else if (!nd.children.size()) type = "leaf";
    else type = "internal node";

    string chd = "[";
    rep(i, nd.children.size()) {
      chd += to_string(nd.children[i]);
      chd += i != (int)nd.children.size() - 1 ? ", " : "";
    }
    chd += "]";

    printf("node %d: parent = %d, depth = %d, %s, %s\n", nd.id, nd.parent, depth, type.c_str(), chd.c_str());
  }
}



Measured memory_bytes: 12368
object Main {
  import scala.io.StdIn._
  import scala.annotation.tailrec
  import scala.collection.mutable.Queue
  def main(args: Array[String]): Unit = {
    var lunlunQueue = Queue((1L to 9L):_*)
    var k = readLine().toInt
    @tailrec
    def loop(i: Int): Unit =
      if (i == 1) println(lunlunQueue.head)
      else {
        val h = lunlunQueue.dequeue()
        val l = h % 10L
        if (l != 0L) lunlunQueue.enqueue(h * 10L + l - 1)
        lunlunQueue.enqueue(h * 10L + l)
        if (l != 9) lunlunQueue.enqueue(h * 10L + l + 1)
        loop(i - 1)
      }
    loop(k)
  }
}


Measured memory_bytes: 47824
#include <iostream>
#include <cmath>
#include <string.h>
using namespace std;

#define M 1000000
#define NIL (-1)
#define L 14

char H[M][L];

long long getkey(char *str) {
    long long sum = 0, p = 1, i;
    for(i=0; i<strlen(str); i++) {
        switch(str[i]) {
            case 'A':
                sum += 0 * p;
                break;
            case 'C':
                sum += 1 * p;
                break;
            case 'G':
                sum += 2 * p;
                break;
            case 'T':
                sum += 3 * p;
                break;
            default:
                break;
        }
        p *= 5;
    }
    return sum;
}

int h1(int key) {
    return key % M;
}

int h2(int key) {
    return 1 + (key % (M-1));
}

int find(char *str) {
    long long key, i, h;
    key = getkey(str);
    for(i=0;; i++) {
        h = (h1(key) + i * h2(key)) % M;
        if(strcmp(H[h], str)==0) {
            return 1;
        }
        else if(strlen(H[h])==0) {
            return 0;
        }
    }
    return 0;
}

int insert(char *str) {
    long long key, i, h;
    key = getkey(str);
    for(i=0;; i++) {
        h = (h1(key) + i * h2(key)) % M;
        if(strcmp(H[h], str)==0) {
            return 1;
        }
        else if(strlen(H[h])==0) {
            strcpy(H[h], str);
            return 0;
        }
    }
    return 0;
}

int main() {
    int n, h;
    char str[L], com[9];
    for(int i=0; i<M; i++) {
        H[i][0] = '\0';
    }
    cin >> n;
    for(int i=0; i<n; i++) {
        cin >> com;
        cin >> str;
        if(com[0]=='i') {
            insert(str);
        }
        else {
            if(find(str)) {
                cout << "yes\n";
            }
            else {
                cout << "no\n";
            }
        }
    }
    return 0;
}


Measured memory_bytes: 16748
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <functional>
#include <vector>
#include <queue>
#include <map>
#include <stack>
#include <string>

using namespace std;

typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)

ll const MOD = 1e9 + 7;

int N;
string S;

map<char, int> cc;
vector<char> keys;

int main() {
  scanf("%d", &N);
  cin >> S;

  rep(i, N) {
    char c = S[i];
    if (!cc[c]) keys.push_back(c);
    cc[c]++;
  }
  ll sum = 1;
  for (int key : keys) {
    sum = (sum * (cc[key] + 1)) % MOD;
  }
  printf("%lld\n", sum - 1);
}


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

using namespace std;

int main() {
  int n, h, w = 0, ans = 0;
  for (cin >> n; n--;) {
    cin >> h;
    if (h >= w) ans++;
    w = max(w, h);
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <cmath>

using namespace std;

double dp[12][1 << 12];

int main(){
	int width;
	while(cin >> width){
		for(int i = 0; i < 12; ++i){
			for(int j = 0; j < (1 << 12); ++j){ dp[i][j] = -1.0; }
		}
		string line;
		getline(cin, line);
		stringstream ss(line);
		vector<int> cakes;
		int r;
		while(ss >> r){
			cakes.push_back(r);
			int index = cakes.size() - 1;
			dp[index][1 << index] = static_cast<double>(r * 2);
		}
		int n = cakes.size();
		for(int j = 0; j < (1 << n); ++j){
			for(int i = 0; i < n; ++i){
				if(!(j & (1 << i))){ continue; }
				for(int k = 0; k < n; ++k){
					if(j & (1 << k)){ continue; }
					int mask = j | (1 << k);
					double c = cakes[i] + cakes[k];
					double a = cakes[i] - cakes[k];
					double b = sqrt(c * c - a * a);
					double p = dp[i][j] - cakes[i] + b + cakes[k];
					dp[k][mask] = (dp[k][mask] < 0.0 ? p : min(dp[k][mask], p));
				}
			}
		}
		bool flag = (n == 0);
		for(int i = 0; i < n; ++i){
			if(dp[i][(1 << n) - 1] <= width + 1e-6){ flag = true; }
		}
		cout << (flag ? "OK" : "NA") << endl;
	}
	return 0;
}

Measured memory_bytes: 1308
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>

#define lpsbd(i, s, b, d) for(size_t i = (s); i < (b); i+=(d))
#define lpsb(i, s, b) for(size_t i = (s); i < (b); i++)
#define lpn(i, n) for(size_t i = 0; i < (n); i++)
#define fa(i, x) for(auto &i: x)
#define vcd(t, n, d) vector<t>(n, d)
#define vc(t, n) vector<t>(n)
#define all(x) (x).begin(), (x).end()

using namespace std;
using ull = unsigned long long;

const ull MOD = 1000000007;

int main(void)
{
    int N;
    int p, sum=0, m=0;
    cin >> N;
    while (N--)
    {
        cin >> p;
        sum += p;
        m = max(m, p);
    }
    cout << sum - m / 2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //10^19 < 9223372036854775807
typedef unsigned long long ull; //10^20 < 18446744073709551615

#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
#define FORA(i,I) for(const auto& i:I)
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 

#define MOD 1000000007

int main(void)
{
    ll X,N,num;
    cin >> X >> N;

    if (N == 0) {
        cout << X << endl;
        return 0;
    }

    vector<bool> p(102,false);
    REP (i,N) {
        cin >> num;
        p[num] = true;
    }

    ll diff = 1000;
    REP (i,102) {
        if (p[i] == false) {
            diff = min (abs(X-i), diff);
        }
    }

    if (p[X-diff] == false) {
        cout << X-diff << endl;
    }
    else {
        cout << X+diff << endl;
    }


    return 0;
}


Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int n,x=0,y=0,z=0,a,b,t;
	scanf("%d",&n);
	while(n--)
	{
		scanf("%d%d%d",&t,&a,&b);
		int d=abs(a-x)+abs(b-y);
		if(d>t-z||(t-z-d)%2==1)return puts("No"),0;
		x=a;y=b;z=t;
	}
	return puts("Yes"),0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int n;  scanf("%d", &n);
    long long a[n+1], b[n], sum = 0;
    for(int i = 0; i < n+1; i++){
        scanf("%lld", &a[i]);
    }
    for(int i = 0; i < n; i++){
        scanf("%lld", &b[i]);
    }
    for(int i = 0; i < n+1; i++){
        if(i != 0){
            if(a[i] <= b[i-1]){
                sum += a[i];
                a[i] = 0;
            }else{
                sum += b[i-1];
                a[i] -= b[i-1];
            }
            // printf("before sum [%d]== %lld\n", i, sum);
        }
        if(i != n){
            if(a[i] <= b[i]){
                sum += a[i];
                b[i] -= a[i];
                a[i] = 0;
            }else{
                sum += b[i];
                a[i] -= b[i];
                b[i] = 0;
            }
            // printf("after sum [%d]== %lld\n", i, sum);
        }
    }
    // printf("sum == %lld\n", sum);
    printf("%lld\n", sum);
    return 0;
}

Measured memory_bytes: 1664
import sys
from math import sqrt
def input(): return sys.stdin.readline().strip()


def main():
    n = int(input())
    possible = True
    pre_t, pre_x, pre_y = 0, 0, 0
    for _ in range(n):
        t, x, y = map(int, input().split())
        dist = abs(x - pre_x) + abs(y - pre_y)
        time = t - pre_t
        #print("dist={}".format(dist))
        if dist <= time and (time - dist) % 2 == 0:
            pre_t, pre_x, pre_y = t, x, y
        else:
            possible = False
            break
    if possible:
        print("Yes")
    else:
        print("No")




if __name__ == "__main__":
    main()


Measured memory_bytes: 73960
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
public static class P
{
    public static void Main()
    {
        Console.WriteLine(int.Parse(Console.ReadLine()) < 30 ? "No" : "Yes");
    }
}

Measured memory_bytes: 27532
#include <stdio.h>
#include <math.h>

#define POW(x) ((x) * (x))

int main(){
  double x1, y1, x2, y2;
  scanf("%lf%lf%lf%lf", &x1, &y1, &x2, &y2);
  printf("%.8f\n", sqrt(POW(x2 - x1) + POW(y2 - y1)));
  return 0;
}

Measured memory_bytes: 656
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
const ll INF = 1e18;
#define print(x) cout << (x) << endl;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, L, answer = 0;
    cin >> N >> L;
    if (L * (L + N - 1) <= 0) {
        rep(i,L,N+L) {
            answer += i;
        }
    }
    else if (L < 0) {
        rep(i,L,N+L-1) {
            answer += i;
            }
    }
    else if (L > 0) {
        rep(i,L+1,N+L) {
            answer += i;
        }
    }
    print(answer);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
int n,a[100003],s=1,jie[100003],ans,sum[100003];
const int mod=1e9+7;
int poww(int x,int p)
{
	if(p==0)
		return 1;
	int tmp=poww(x,p/2)%mod;
	tmp=(tmp*tmp)%mod;
	if(p%2==1)
		tmp=(tmp*x)%mod;
	return tmp;
}
int aa(int n,int m)
{
	return jie[n]*poww(jie[n-m],mod-2)%mod;
}
signed main()
{
	scanf("%lld",&n);
	for(int i=1;i<=n;i++)
		scanf("%lld",&a[i]);
	for(int i=1;i<=n;++i)
		sum[i]=(sum[i-1]+a[i])%mod;
	jie[1]=1,jie[0]=1;
	for(int i=2;i<=100000;i++)
		jie[i]=jie[i-1]*i%mod;
	for(int i=1;i<=n-2;++i)
		ans=(ans+aa(i-1,i-1)*aa(n-1,n-1-(i+1))%mod*(sum[n-1]-sum[n-1-i]-sum[i])%mod)%mod;
	for(int i=1;i<n;++i)
		ans=(ans+aa(n-i-1,n-i-1)*aa(n-1,n-(n-i+1))%mod*(a[n]-a[i])%mod)%mod;
	cout<<ans;
	return 0;
}


Measured memory_bytes: 2560
import heapq

N, M = [int(x) for x in input().split()]
A = list([int(x) * - 1 for x in input().split()])
heapq.heapify(A)

for _ in range(M):
    target = heapq.heappop(A) * -1
    heapq.heappush(A, (target // 2) * -1)

print(sum(A) * -1)


Measured memory_bytes: 20312
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+10;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=200010;
const ll mod=1e9+7;

int main(){
  int n,sum=0; 
  cin >> n;
  vector<int> w(n);
  rep(i,n){ cin >> w[i]; sum += w[i];}
  int h=0,cnt;
  rep(i,n){ h += w[i]; if(h>=sum/2){cnt=i; break;}}
 
  cout << min(abs(h-(sum-h)),abs(h-w[cnt]-(sum-(h-w[cnt])))) << endl;
  return 0;
}


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

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

const int max_n = 400;
int N,M,L;
int fuel[max_n][max_n];
int dist[max_n][max_n];

int main(void) {
    cin>>N>>M>>L;
    
    
    int inf = TEN(9)+1;
    for(int i = 1;i <= N;i++) {
        for(int j = 1;j <= N;j++) {
            dist[i][j] = inf;
            fuel[i][j] = inf;
        }
        dist[i][i] = 0;
        fuel[i][i] = 0;
    }

    for(int i = 0;i < M;i++) {
        int a,b,c;
        cin>>a>>b>>c;
        dist[a][b] = c;
        dist[b][a] = c;
    }

    for(int k = 1;k <= N;k++) {
        for(int i = 1;i <= N;i++) {
            if(dist[i][k] == inf)
                continue;
            for(int j = 1;j <= N;j++) {
                if(dist[k][j] == inf)
                    continue;

                dist[i][j] = min(dist[i][j],dist[i][k]+dist[k][j]);
            }
        }
    }

    for(int i = 1;i <= N;i++) {
        for(int j = 1;j <= N;j++) {
            if(dist[i][j] <= L) {
                fuel[i][j] = 1;
            }
        }
    }

    for(int k = 1;k <= N;k++) {
        for(int i = 1;i <= N;i++) {
            if(fuel[i][k] == inf)
                continue;
            for(int j = 1;j <= N;j++) {
                if(fuel[j][k] == inf)
                    continue;
            
                fuel[i][j] = min(fuel[i][j],fuel[i][k]+fuel[k][j]);
            }
        }
    }
    
    int Q;
    cin>>Q;
    vector<int> ans;
    for(int i = 0;i < Q;i++) {
        int s,t;
        cin>>s>>t;
        
        if(fuel[s][t] == inf) {
            ans.push_back(-1);
        } else {
            ans.push_back(fuel[s][t]-1);
        }
    }

    for(auto u:ans) {
        cout<<u<<endl;
    }

    return 0;
}




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

int count_keta(ll data) {
    int ret = 0;
    // cout << "count_keta , input = " << data;
    while (data > 0) {
        data = data / 10;
        ret = ret + 1;
    }
    // cout << ", return = " << ret << endl;
    return ret;
}
int main() {
    ll n;
    cin >> n;
    // int ans = INT_MAX;
    int ans = count_keta(n);
    for(ll i = 1; i * i <= n; i++) {
        ll b = n / i;
        int ans_data;
        if (n % i == 0) {
            ans_data = max (count_keta(i), count_keta(b));
            // cout << "  i = " << i << endl;
            // cout << "  b = " << b << endl;
            ans = min(ans, ans_data);
        }
        
        // cout << "*** ans = " << ans << endl;
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
	char ori[20], rev[20];
	cin >> ori;
	
	int size = 0;

	for(int i = 0; ori[i] != 0; i++){
		size++;
	}

	
	for(int i = 0; i < size; i++){
		rev[i] = ori[size-1-i];
	}
	rev[size] = 0;
	
	cout << rev << endl;
	
	return(0);
}

Measured memory_bytes: 1140
(defun mean (n)
  (/ (* n (+ n 1)) 2.0d0 n))

(let* ((n (read))
       (k (read))
       (as (make-array n :element-type 'fixnum))
       (max)
       (val))
  (loop for i from 0 below n
        do (setf (aref as i) (read)))
  (setf max (loop for i from 0 below k summing (mean (aref as i))))
  (setf val max)
  (loop for i from k below n
        for mean = (mean (aref as i))
        for pmean = (mean (aref as (- i k)))
        do (progn
             (incf val (- mean pmean))
             (when (> val max)
               (setf max val))))
  (format t "~,10f~%" max))


Measured memory_bytes: 59752
#include <iostream>
#include <string>
using namespace std;
int main(void){
    int i=0,j=32;
    string str="";
    getline(cin, str);
    int str_len = str.size();
    while(1){
        if(i == str_len){
            break;
        }
        //cout<<(int)str[i];
        
        if((int)str[i] >= (int)'a' && (int)str[i]<= (int)'z'){
            cout<<(char)((int)str[i] - j);
        }else if( (int) str[i] >= 65 && (int) str[i] <= 90){
            cout<<(char)((int)str[i] + j);
        }else{
            cout<<str[i];
        }
        i++;
    }
    //cout<<str_len;
    cout<<endl;
    
    return 0;
}




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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;

const ll mod = 1e9+7;
const int maxn = 1e6 + 5;



ll n,m,d;

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

    cin>>n>>m>>d;
    double res = 0;
    if (d==0) {
	for (int i=0; i<m-1; i++) {
	    res += (1.0*n/(n*n));
	}
    } else {
	for (int i=0; i<m-1; i++) {
	    res += ((2.0*(n-d))/(n*n));
	}
    }


    cout<<fixed<<setprecision(9)<<res<<endl;    
    return 0;
}


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

const double pi  = 2 * acos(0.0);
const double eps = 1e-8;

#define REP(i,a,b) for(int i=(a); i<(b);++i)
#define rep(i,n) REP(i,0,n)
#define INF (1<<29)
#define INFLL (1LL<<62)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

typedef int Cost;
struct Edge {
  int src, dst; Cost cost;
  Edge(int s, int d, Cost c) : src(s), dst(d), cost(c) {}
};
typedef vector<Edge>  Edges;
typedef vector<Edges> Graph;
typedef vector<Cost>  Array;
typedef vector<Array> Matrix;

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

enum { INC, DEC, SAME };

int main(void) {
  ios_base::sync_with_stdio(false); cin.tie(0);
  int n; cin >> n;
  vector<int> A(n);
  rep(i, n) cin >> A[i];

  int state = SAME;
  int cnt = 0;
  rep(i, n - 1) {
    if (A[i+1] == A[i])
      continue;

    if (A[i+1] > A[i]) {
      if (state == DEC) {
        cnt++;
        state = SAME;
      } else {
        state = INC;
      }
    }

    if (A[i+1] < A[i]) {
      if (state == INC) {
        cnt++;
        state = SAME;
      } else {
        state = DEC;
      }
    }
  }

  cout << cnt + 1 << endl;

  return 0;
}

Measured memory_bytes: 640
import java.io.*;

import java.text.*;
import java.util.*;

public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		final int len = 4;
		int[] array = new int[len];
		int[] suc = {1,4,7,9};
		String msg = "NO";
		
		for (int i = 0; i < len; i++) {
			array[i] = sc.nextInt();
		}
		Arrays.sort(array);
		
		for (int i = 0; i < len; i++) {
			if (array[i] != suc[i]) {
				break;
			}
			if (i == len - 1) {
				msg = "YES";
			}
		}
		System.out.println(msg);
	}

}


Measured memory_bytes: 21716
package main

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

func main() {
	var n, k int
	n = readInt()
	k = readInt()

	check := make([]int, n)

	for i := 0; i < k; i++ {
		count := readInt()
		for j := 0; j < count; j++ {
			w := readInt()
			check[w-1]++
		}
	}

	result := 0
	for i := 0; i < n; i++ {
		if check[i] == 0 {
			result++
		}
	}

	fmt.Println(result)
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}


Measured memory_bytes: 1824
import sys
input = sys.stdin.buffer.readline

n, m, p = map(int, input().split())
es = []
for i in range(m):
    a, b, c = map(int, input().split())
    es.append([a-1, b-1, -(c-p)])


def find_negative_loop(s,n,w,es):
    # s: start
    # n: number of nodes
    # w: number of edges
    # es[i]: from, to, cost

    # d: shortest dist of s -> i
    inf = float('inf')
    d = [inf for _ in range(n)]
    d[s] = 0
    for i in range(2*n):
        for j in range(w):
            p, q, r = es[j]
            if d[p] != inf and (d[q] > d[p] + r):
                d[q] = d[p] + r
                if i >= n:
                    d[q] = (-1)*inf
        if i == n-1:
            temp = d[-1]
    return temp, d[-1]

temp, d = find_negative_loop(0, n, m, es)
if temp == d:
    if temp > 0:
        print(0)
    else:
        print(-temp)
else:
    print(-1)


Measured memory_bytes: 46044
#include <bits/stdc++.h>
#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long
#define pb push_back
#define mp make_pair
#define MAX 100010
using namespace std;
int C[MAX];
int main() {
  int N;
  cin >> N;
  rep(i,MAX) C[i] = 0;
  rep(i,N) {
    int tmp;
    cin >> tmp;
    C[tmp] += 1;
  }
  int ans = 0;
  REP(i,1,MAX) {
    int tmp = C[i-1] + C[i] + C[i+1];
    if (ans < tmp) ans = tmp;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

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

        public void Solve(ConsoleInput cin)
        {
            var N = cin.ReadInt;
            var Y = cin.ReadInt;
            for (int i = 0; i <= N; ++i)
            {
                for (int j = 0; j <= N - i; ++j)
                {
                    var k = N - i - j;
                    var sum = 10000 * i + 5000 * j + 1000 * k;
                    if (sum == Y)
                    {
                        WriteLine($"{i} {j} {k}");
                        return;
                    }
                }
            }
            WriteLine("-1 -1 -1");
        }
    }

    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
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}



int main() {
    ll n,d;
    std::cin >> n>>d;
    std::cout << (n+(2*d+1 -1))/(2*d+1) << std::endl;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
using namespace std;
using ll = long long;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;

int main() {

    int n;
    cin >> n;
    
    if (n % 2 == 0) cout << n << endl;
    else cout << 2 * n << endl;
    
    return 0;

}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
  int A,B;
      cin>>A>>B;              //外部入力読み込み方法

  if (A+B==3){
    cout <<3 ;
     } 
   else if(A+B==4){
    cout << 2;
   }
   else {
  cout<<1;
   } 
 return 0;
}


Measured memory_bytes: 256
import sys
from collections import Counter
N = int(input())
As = list(map(int,input().split()))
ct = Counter(As)
As =sorted(As)
max_dp = As[-1] +1
dp = [True] * max_dp
for key,count in ct.items():
	if count > 1:
		dp[key] = False
		i = 2
		while key*i < max_dp:
			dp[key*i] = False
			i+=1
for A in As:
	if dp[A] == True:
		i = 2
		while A*i < max_dp:
			dp[A*i] = False
			i+=1

ans = 0
# print(len(dp))
for A in As:
	# print(A)
	if dp[A]:
		ans+=1
print(ans)


Measured memory_bytes: 36776
#include<bits/stdc++.h>
using namespace std;
long int n,m,a,ans;
vector <long int> ss1,aa;

int main(){

    while(1){

    cin >> n >> m;
    if(n==0&&m==0)break;
    ans=0;
    ss1.clear();
    aa.clear();

    aa.push_back(0);
    for(int i=0;i<n;i++)cin >> a ,aa.push_back(a);
    sort(aa.begin(),aa.end());

    for(int i=0;i<=n;i++){
        for(int j=i;j<=n;j++){
            if(aa[i]+aa[j]<=m)ss1.push_back(aa[i]+aa[j]);
        }
    }
    sort(ss1.begin(),ss1.end());

    int cnt=ss1.size()-1;
    for(int i=0;i<ss1.size();i++){
        while(ss1[i]+ss1[cnt]>m)cnt--;
        if(ss1[cnt]+ss1[i]<=m)ans=max(ans,ss1[cnt]+ss1[i]);
    }

    cout << ans << endl;

    }

return 0;
}

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define ll long long

template<class T>
void changeMax(T&a, const T b){if(a < b) a = b;}
template<class T>
void changeMin(T&a, const T b){if(a > b) a = b;}


template<class T>
void changeIdxMax(T&a, const T b, int&i, int j){
  if(a < b){
    a = b;
    i = j;
  }
}
template<class T>
void changeIdxMin(T&a, const T b, int&i, int j){
  if(a > b){
    a = b;
    i = j;
  }
}

int n,d;

bool gooddis(vector<int>&a, vector<int>&b){
  double sum=0;
  for(int i =0;i < d; ++i)
    sum += pow(abs(a[i]-b[i]),2);
  double s =  sqrt(sum);
  return s == int(s);
}

int main(){
  cin >> n >> d;
  vector<vector<int>> v(n,vector<int>(d));
  for(auto&&e1:v)
    for(auto&&e2:e1)
      cin >> e2;
  int cnt = 0;
  for(int i = 0; i < n; ++i){
    for(int j = i + 1; j < n; ++j){
      if(gooddis(v[i],v[j]))
	cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll         long long int
#define co         cout
#define ci         cin
#define sf1(n)     scanf("%lld",&n)
#define sf2(n,m)   scanf("%lld %lld",&n,&m);
#define sf3(n,m,p) scanf("%lld %lld %lld",&n,&m,&p);
#define pf1(n)     printf("%lld\n",n);
#define mem(a,b)   memset(a,b,sizeof(a))
#define en         cout<<endl;
#define pb         push_back
#define gcd(n,m)   __gcd(n,m)
#define lcm(n,m)   ((n)/__gcd(n,m))*(m)
#define fi         first
#define se         second
#define coy        cout<< "YES"<<endl;
#define con        cout<< "NO"<<endl;
#define f(i,a,b)     for(ll i=a;i<b;i++)
#define all(x)     (x).begin(),(x).end()
#define allr(x)    (x).rbegin(),(x).rend()
#define pi         pair<ll,ll>
#define br         break;
#define i64        long long
#define PI         2*acos(0.0)
#define MAXN       3*100000
 
int main()
{
    ll n,m,k,g,mx,mn,res,c,x,y,z,w,p,q,r,l,s,t;
    string a,b;
    ci>>a>>b;
    res=10000000000;
    for(ll i=0;i<a.size()-b.size()+1;i++)
    {
        c=0;
        string ab=a.substr(i,b.size());
        for(ll j=0;j<b.size();j++)
        {
            if(ab[j]!=b[j]) c++;
        }
        res=min(res,c);
    }
    co<<res;
    return 0;
}

Measured memory_bytes: 3608
use proconio::input;

fn helper(mut a: usize) -> usize {
  if a <= 1 { return 0 }
  let mut count = 0;
  while 0 < a && a % 2 == 0 {
    a /= 2;
    count += 1;
  }
  count
}

fn main() {
  input! {
    n: usize,
    vals: [usize;n]
  }
  
  let mut result = 0;
  for v in vals {
    result += helper(v);
  }
  println!("{}", result);
}

Measured memory_bytes: 2308