akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
     
using namespace std;

int psum1[100001];
int psum2[100001];

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

	string s,t;
	int a,b,c,d;

	cin >> s;
	cin >> t;
	
	psum1[0] = 0;
	psum2[0] = 0;

	for(int i=1;i<=s.length();i++)
	{
		psum1[i] = psum1[i-1];
		if(s[i-1]=='A')
		{
			psum1[i] += 1;
		}
		else
		{
			psum1[i] += 2;
		}
	}

	for(int i=1;i<=t.length();i++)
	{
		psum2[i] = psum2[i-1];
		if(t[i-1]=='A')
		{
			psum2[i] += 1;
		}
		else
		{
			psum2[i] += 2;
		}
	}

	int q;

	cin >> q;

	for(int i=0;i<q;i++)
	{
		cin >> a >> b >> c >> d;
		int x = psum1[b] - psum1[a-1];
		int y = psum2[d] - psum2[c-1];
		x%=3;
		y%=3;
		if(x==y)
		{
			cout << "YES" << '\n';
		}
		else
		{
			cout << "NO" << '\n';
		}
	}

	return 0;
}


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

int main(){
    int n, a, b;cin >> n >> a >> b;
    vector<long long int> alis(n);
    for(int i = 0; i<n; i++){
        cin >> alis[i];
    }
    long long int ans = 0;
    for(int i = 1; i< n; i++){
        if(b < a*(alis[i]-alis[i-1])){
            ans += b;
        }else{
            ans += a*(alis[i]-alis[i-1]);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;
int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (b - a == c - b)
		cout << "YES" << "\n";
	else
		cout << "NO" << "\n";
}

Measured memory_bytes: 3568
import sys


def input():
    return sys.stdin.readline()[:-1]


def ii(t: type = int):
    return t(input())


def il(t: type = int):
    return list(map(t, input().split()))


def iml(N: int, t: type = int):
    return [t(input()) for _ in range(N)]


S = sorted(set(ii(str)))
for i in range(97, 97 + 26):
    if chr(i) not in S:
        print(chr(i))
        exit()
print("None")


Measured memory_bytes: 3188
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    int n,k;
    cin>>n>>k;
    ll a[n];
    rep(i,n)cin>>a[i];
    ll sum[n+1];
    sum[0]=0;
    rep(i,n)sum[i+1]=sum[i]+a[i];
    vector<ll> v;
    rep(i,n+1)rep(j,i){
        v.push_back(sum[i]-sum[j]);
    }
    int m=v.size();
    vector<int> ng(m+5);
    ll ans=0;
    int b=50;
    while(b>=0){
        ans<<=1;
        int cnt=0;
        rep(i,m){
            if(ng[i])continue;
            if(v[i]&(1LL<<b))++cnt;
            else ng[i]=2;
        }
        if(cnt>=k){
            ans+=1;
            rep(i,m)if(ng[i]==2)ng[i]=1;
        }
        else rep(i,m)if(ng[i]==2)ng[i]=0;
        --b;
    }
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;

typedef long long int ll;

#define fastIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define f(i,s,n) for(int i=s;i<n;i++)

int main() {
	
	fastIO
	ll n;
  	string s;
	cin>>n;
  	cin>>s;
  	int ct=1;
  	f(i,1,n)
    {
      if(s[i]!=s[i-1])
        ct++;
    }
  	cout<<ct;
	
	return 0;
}

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

int main() {
  int n,m,r;
  cin >> n >> m;
  vector<int> vec(n);
  for(int i = 0;i<2*m;i++){
    cin >> r;
    vec[r-1] += 1;
  }
  for(int i :vec){
    cout << i << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pa;
const int N=2e5+7;
const int inf=1e9+7;
const int mod=1e9+7;
ll dp[11][11][8];
ll a[N];
int main(){
    int n;
    ll s=0;
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        int j=i,t=i,s=0;
        int k=i%10;
        while(1){
            j/=10;
            s++;
            if(j==0) break;
            t=j;
        }
        //printf("%d %d %d %d\n",i,t,k,s);
        dp[t][k][s]++;
        //if(t>k) s--;
        ll sum=0;
        for(int g=1;g<=s;g++){
            sum+=dp[k][t][g];
        }
        if(sum){
            if(k==t){
                a[i]=(sum-1)*2+1;
            }
            else {
                a[i]=sum*2;
            }
        }
    }
    for(int i=1;i<=n;i++){
        s+=a[i];
        //printf("%d:%lld\n",i,a[i]);
    }
    printf("%lld\n",s);
    return 0;
}


Measured memory_bytes: 1792
#!/usr/local/bin python
# -*- coding: utf-8 -*-
#
# ~/PycharmProjects/atcoder/C-GuessTheNumber.py
#
import sys

n, m = map(int, input().split())
sc = [list(map(int, input().split())) for _ in range(m)]
# if input for s c is
# 1 7
# 3 2
# 1 7
# then sc is [[1, 7], [3, 2], [1, 7]]
if m == 0 and n != 1:  # m の条件がなく，2桁，3桁の場合10, 100を出力して終了
    print(10 ** (n - 1))
    exit()
elif m == 0 and n == 1:  # mの条件がなく，1桁の場合は0を出力して終了
    print(0)
    exit()
elif n == 1 and sc.count([1, 0]) == m:  # 1桁で，[s, c] == [1, 0] の数がmと等しいなら，つまり，[s, c]が全て[1, 0]なら
    print(0)
    exit()
for i in range(10 ** (n - 1), 1000):  # 1 or 10 or 100から1000 までイテレート
    i = str(i)
    for j in range(m):

        if i[sc[j][0] - 1] == str(sc[j][1]):
            pass
        else:
            break

        if j == m-1:
            print(i)
            exit()
print(-1)


Measured memory_bytes: 3064
N, M = map(int, input().split())
l = []
r = []
for i in range(M):
  L,R = map(int, input().split())
  l.append(L)
  r.append(R)
ans = min(r) - max(l) + 1
if ans >= 1:
  print(ans)
else:
  print(0)

Measured memory_bytes: 11020
#include "bits/stdc++.h"
#define pb push_back
#define mt make_tuple
#define all(a) (a).begin(),(a).end()
#define frep(i,a,n) for(int i=(a);i<(n);++i)
#define rep(i, n) for(int i=0;i<(n);++i)
#define rrep(i, n) for(int i=n-1;i>=0;--i)
#define debug(x) cout << #x << " : " << x << " ------------ " << endl;
using namespace std;
int main()
{
    int N = 1299710;
    bool tmp[N + 1];
    fill(tmp, tmp+N+1, true);
    vector<int> prime(100000);
    tmp[0] = tmp[1] = false;
    frep(i, 2, N) {
        if (tmp[i]) {
            for (int j = i + i; j < N; j += i) {
                tmp[j] = false;
            }
            prime.pb(i);
        }
    }
    
    int n;
    while (cin >> n, n) {
        auto it = upper_bound(all(prime), n);
        if (*(it-1) == n) 
            cout << 0 << endl;
        else 
            cout << (*it - *(it-1)) << endl;
    }
    
    return EXIT_SUCCESS;
}

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

using namespace std;
typedef long long ll;
//typedef unsigned long long ll;

#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
//typedef pair<ll, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX / 10;
//const ll INF = (1ll << 31) - 1;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
//typedef pair<int, int> P;
//typedef pair<double, double> P;

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

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);


void print_line(vector<ll> &line) {
    if (line.size() == 0ll) {
        cout << endl;
        return;
    }
    for (ll i = 0; i < line.size(); i++) {
        cout << line[i];
        if (i == line.size() - 1) cout << endl;
        else cout << ' ';
    }
}


typedef priority_queue<long long, vector<long long>, greater<long long>> PQ_ASK;
const int mod = 1000000007;

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

    vector<ll> numbers(n);
    rep(i, n) cin >> numbers[i];

    set<ll> used;
    multiset<ll> used_m;

    int r = 0;
    int shortness = INT_MAX;
    for (int l = 0; l < n; l++) {
        while (used.size() < k && r < n) {
            ll next = numbers[r];
            if (next <= k && used.find(next) == used.end()) {
                used.insert(next);
            }
            used_m.insert(next);
            r++;
        }
        if (used.size() < k) continue;
        int now = r - l;
        cmin(shortness, now);
        ll back = numbers[l];
        used_m.erase(used_m.find(back));
        if (used_m.count(back) == 0) {
            used.erase(back);
        }
    }

    if (shortness == INT_MAX) shortness = 0;
    cout << shortness << endl;

}



Measured memory_bytes: 12832
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define bit(n) (1<<(n))
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template < typename T > string tost( const T& n ) { ostringstream stm; stm << n; return stm.str();}
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;}
int const INF = 1001001001;



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

vector<string> fi(3);
rep(i,3) cin >> fi[i];
rep(i,3) cout << fi[i][i];
cout << endl;

return 0;
}

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

public class Main {
	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int T = sc.nextInt();
        final int INF = 2000000000;
        
        int[] start = new int[N+1];
        int[] end = new int[N+1];
        for(int i=0;i<N;i++){
        		start[i]=sc.nextInt();
        		end[i] = start[i]+T;
        }
        start[N]=INF;
        end[N]=INF;//avoid AIOOBException
        
        int s=0;
        int e=0;
        int time=0;
        int water=0;
        int ans=0;
        while(e<N){
        	if(start[s]==end[e]){
        		if(water>0){
        			ans += (start[s]-time);
        		}
        		time = start[s];
        		s++;
        		e++;
        	}else if(start[s]>end[e]){//end
        		if(water>0){
        			ans += (end[e]-time);
        		}
        		water--;
        		time = end[e];
        		e++;
        	}else{//start[s]<end[e] //start
        		if(water>0){
        			ans += (start[s]-time);
        		}
        		water++;
        		time = start[s];
        		s++;
        	}
        }
        
        System.out.println(ans);
    }
}

Measured memory_bytes: 63284
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip> 
#include <complex> 
#include <string>
#include <vector> 
#include <list>
#include <deque> 
#include <stack> 
#include <queue> 
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm> 
#include <numeric> 
#include <typeinfo> 
#include <cstdio>
#include <cstdlib> 
#include <cstring>
#include <cmath>
#include <climits> 
#include <ctime> 

using namespace std;
const int INF=10000000;
int maps[11][11];
int f,t,h;

void root(){
	int a,b;
	if(maps[f][t]>h)maps[f][t]=h;
	if(maps[t][f]>h)maps[t][f]=h;
	for(b=0;b<=10;b++){
		for(a=0;a<=10;a++){
			maps[a][b]=min(maps[a][b],maps[a][f]+maps[f][t]+maps[t][b]);
			maps[b][a]=min(maps[b][a],maps[a][f]+maps[f][t]+maps[t][b]);
		}
	}
}

int main(void){
	int a,b;
	int n;
	int town[11];
	int ans=INF*10;
	int ans3=0;
	while(1){
		for(b=0;b<=10;b++){
			town[b]=0;
			for(a=0;a<=10;a++){
				maps[a][b]=INF;
				if(a==b)maps[a][b]=0;
			}
		}
		ans=INF*10;
		ans3=0;
		cin >> n;
		if(n==0)break;
		for(a=0;a<n;a++){
			cin >> f >> t >> h;
			town[f]=1;
			town[t]=1;
			root();
		}
		for(b=0;b<=10;b++){
			int ans2=0;
			if(town[b]==1){
				for(a=0;a<=10;a++){
					if(town[a]==1)ans2+=maps[a][b];
				}
				if(ans>ans2)ans3=b,ans=min(ans,ans2);
			}
		}
		cout << ans3 << ' ' << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int64_t N, M, a, b, cnt = 0;
vector<int64_t> Tree(51, 0);
vector<pair<int64_t, int64_t>> vp;

void init(int N)
{
  for (int i = 1; i <= N; i++)
    Tree.at(i) = i;
}

int root(int x)
{
  if (Tree.at(x) == x)
    return x; // 根
  else
    return Tree.at(x) = root(Tree.at(x)); // 経路圧縮
}

bool same(int x, int y)
{
  return root(x) == root(y);
}

void unite(int x, int y)
{
  x = root(x);
  y = root(y);
  if (x == y)
    return;
  Tree.at(x) = y;
}

bool connected()
{
  bool connected = true;
  for (int j = 1; j < N; j++)
  {
    for (int k = j + 1; k <= N; k++)
    {
      if (!same(j, k))
      {
        connected = false;
        break;
      }
    }
  }
  return connected;
}

int main()
{

  cin >> N >> M;
  for (int i = 0; i < M; i++)
  {
    cin >> a >> b;
    vp.push_back(make_pair(a, b));
  }
  for (int i = 0; i < M; i++)
  {
    init(N);
    for (int j = 0; j < M; j++)
    {
      if (i != j)
        unite(vp.at(j).first, vp.at(j).second);
    }
    if (!connected())
    {
      cnt++;
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int hen = 0;
	int max = 0,min = 9999;
	int a = 0,i = 0;
	int sum = 0;
	int b[23];
	int j = 0;
	while(1){
		scanf("%d",&hen);
		if(hen == 0)break;
		
		for(i = 0;hen > i;i++){
			scanf("%d",&a);
			sum += a;
			if(a < min)min = a;
			if(a > max)max = a;
				
		}
		sum = sum -(max + min);
		b[j] = sum / (hen - 2);
		j++;
		max = 0;min = 9999;sum = 0;
		
	}
	for(i = 0;i < j;i++){
		printf("%d\n",b[i]);
	}
	return 0;
}

Measured memory_bytes: 600
#include <cstdint>
#include <algorithm>
#include <iostream>
#include <list>
#include <vector>
#include <string>



int main()
{
    int32_t n,m;

    std::cin >> n >> m;

    if ( n == m ) {
        std::cout << "Yes" << std::endl;
    } else {
        std::cout << "No" << std::endl;
    }
    return 0;
}


Measured memory_bytes: 888
#include <cstdio>
#include <iostream>
#include <algorithm>

using namespace std;

const int N = 1e5 + 5;

int n, m, ans;
int a[N], b[N];

int main() {
  scanf("%d%d", &m, &n);
  if (m >= n) {
    printf("0\n");
    return 0;
  }
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &a[i]);
  }
  sort(a + 1, a + 1 + n);
  for (int i = 1; i < n; ++i) {
    b[i] = a[i + 1] - a[i];
  }
  sort(b + 1, b + n);
  reverse(b + 1, b + n);
  ans = a[n] - a[1];
  for (int i = 1; i < m; ++i) {
    ans -= b[i];
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
using namespace std;
const int INF = 1001001001;

int main() {
	int h, w;
	cin >> h >> w;
	int c[10][10];
	for (int i = 0; i < 10; i++)
		for (int j = 0; j < 10; j++)
			cin >> c[j][i];
	int d1[10];
	int used[10];
	fill(d1, d1+10, INF);
	d1[1] = 0;
	fill(used, used+10, false);
	while (true) {
		int v = -1;
		for (int i = 0; i < 10; i++)
			if (!used[i] && (v == -1 || d1[i] < d1[v])) v = i;
		if (v == -1) break;
		used[v] = true;
		for (int i = 0; i < 10; i++) {
			if (d1[i] > d1[v] + c[v][i]) {
				d1[i] = d1[v] + c[v][i];
			}
		}
	}

	int ans = 0;
	for (int i = 0; i < h; i++)
		for (int j = 0; j < w; j++) {
			int a;
			cin >> a;
			if (a == -1) continue;
			ans += d1[a];
		}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep2(i,n) for (int i = 1; i < (n); ++i)
using namespace std;
typedef long long ll;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, K;
    cin >> N >> K;
    if(N%K==0) cout << 0 << endl;
    else cout << 1 << endl;
    return 0;
}


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

template <class T> using V = vector<T>;
template <class S, class T> using P = pair<S, T>;
template <class... T> using TP = tuple<T...>;

using ll = long long;
using db = double;
using ldb = long db;
using str = string;
using vll = V<ll>;
using vvll = V<V<ll>>;
using pll = P<ll,ll>;
using tpll = TP<ll,ll,ll>;
using vpll =V<pll>;
using vst = V<str>;
using vch = V<char>;

#define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++)
#define rFOR(i,a,b) for(ll i=(b);i>(ll)(a);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) __lcm(a,b)
#define co(a) cout<<a<<endl
#define ci(a) cin>>a
#define pb(a) push_back(a)
#define pob pop_back()
#define mp make_pair
#define mt make_tuple
#define pbmp(a,b) push_back(mp(a,b))
#define subs(a,b) substr(a,b)
#define cfs(a) cout<<fixed<<setprecision(a)
#define INF 1e16
#define mod 1e9+7


int main() {
  ll n,k;
  cin>>n>>k;
  if(k==1){
    co(0);
  }
  else{
    co(n-k);
  }
}


Measured memory_bytes: 256
from collections import Counter
N, K, Q = map(int, input().strip().split())
ansl = [int(input().strip()) for _ in range(Q)]
countl = Counter(ansl)
sumcountl = sum(countl.values())
for i in range(N):
    print('Yes') if sumcountl-countl[i+1] < K else print('No')

Measured memory_bytes: 11900
#include"bits/stdc++.h"
using namespace std;
int main(){
	
	/*
	int A,B,C,D,seconds,minutes;
	cin >> A >> B >> C >> D;
	seconds=A+B+C+D;
	minutes = seconds / 60;
	cout << minutes << seconds << endl;*/
	 
	/*int Q,P,R;
	cin >> Q >> P >>R;
	int answer;
	answer=Q*P/2;
	cout << answer << endl;*/

	/*int A,B;
	cin >> A >> B;
	int answer;
	answer=(A-1)*(B-1);
	cout << answer << endl;*/

	/*int A,A2,A3,Asecond,Aminutes,Ahour,Asecond2,Aminutes2,Ahour2;

    cin >>Ahour >> Aminutes>>Asecond>>Ahour2 >>Aminutes2>>Asecond2;
	A=Ahour2-Ahour;
	A2=Aminutes2-Aminutes;
	A3=Asecond2-Asecond;
	if(A3<0){
		A2=A2-1;
		A3=60+A3;

	}
	if(A2<0){
		A=A-1;
		A2=60+A2;

	}

	cout << A << " " << A2 << " " << A3 << endl;

	
	cin >>Ahour >> Aminutes>>Asecond>>Ahour2 >>Aminutes2>>Asecond2;
	A=Ahour2-Ahour;
	A2=Aminutes2-Aminutes;
	A3=Asecond2-Asecond;
	if(A3<0){
		A2=A2-1;
		A3=60+A3;

	}
	if(A2<0){
		A=A-1;
		A2=60+A2;

	}

	cout << A << " " << A2 << " " << A3 << endl;

	cin >>Ahour >> Aminutes>>Asecond>>Ahour2 >>Aminutes2>>Asecond2;
	A=Ahour2-Ahour;
	A2=Aminutes2-Aminutes;
	A3=Asecond2-Asecond;
	if(A3<0){
		A2=A2-1;
		A3=60+A3;

	}
	if(A2<0){
		A=A-1;
		A2=60+A2;

	}

	cout << A << " " << A2 << " " << A3 << endl;*/
	/*
	int A,B,C,D,E,F,G,answer;

	cin >>A;
	A=1000-A;
	B=A/500;
	A=A-500*B;
	C=A/100;
	A=A-100*C;
	D=A/50;
	A=A-50*D;
	E=A/10;
	A=A-10*E;
	F=A/5;
	A=A-5*F;
	G=A/1;

	answer=B+C+D+E+F+G;

	cout <<answer <<endl;
	*/

	/*int S,A1,A2,A3,A4,T,B1,B2,B3,B4,answer;

	cin >>A1 >> A2 >> A3 >>A4 >>B1 >>B2 >> B3 >> B4;
	S=A1+A2+A3+A4;
	T=B1+B2+B3+B4;
	if (S<T){
		answer=T;
	}
	else if(S>T){
		answer=S;
	}
	else if(S==T){
		answer=S;
	}
	cout <<answer <<endl;*/

	/*int A,B,C,D,E,P,J;
	cin >> A >> B >> C >> D >> E;
	P=min(A,B);
	P=min(P,C);
	J=min(D,E);
	
	int answer;
	answer=P+J-50;
	cout << answer << endl;*/

    /*int A,B,C,i,coin;
    cin >> A >> B >> C;
	i=0;
	coin=0;
	while(coin<C){
		i=i+1;
		coin=coin+A;
	    if(i%7==0){
			coin=coin+B;
		}
	}
	cout<< i << endl;*/

	/*int A,B,K;
	cin >> A >> B >> K;
	int j=A+B;
	int i=0;

    while(i < K){
		j--;
		if(A%j==0 && B%j==0){
			i++;
		}
	}
	cout<< j << endl;*/

	int N,L;
	cin >> N;
	int i = 0;
	int sum=0;
	int j=1;
	while(i < N){
		int tmp;
		cin >> tmp;
		
		if(j<tmp){
			j=tmp;
		}
		sum = sum+tmp;
		i++;
	}
	 int o=sum-j;

	 if(j<o){
		 cout << "Yes" << endl;
	 }
	 else{
		 cout << "No" << endl;
	 }


	 





	     



	







	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
  int N, K;
  int i, j;
  int temp;
  int flag;
  int S[100];
  while(1) {
    scanf("%d %d", &N, &K);
    if(N == 0 && K == 0) break;
    for(j = 0; j < K; j++) {
      scanf("%d", &S[j]);
    }
    flag = 0;
    for(i = 0; i < N; i++) {
      for(j = 0; j < K; j++) {
	scanf("%d", &temp);
	S[j] -= temp;
	if(S[j] < 0) flag = 1;
      }
    }
    if(flag) printf("No\n");
    else     printf("Yes\n");
  }
  return 0;
}

Measured memory_bytes: 0
#include "bits/stdc++.h"

// Begin Header {{{
using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

#define all(x) x.begin(), x.end()
#define rep(i, n) for (intmax_t i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, b, e) for (intmax_t i = (b), i##_limit = (e); i <= i##_limit; ++i)
#define repr(i, b, e) for (intmax_t i = (b), i##_limit = (e); i >= i##_limit; --i)
#define var(Type, ...) Type __VA_ARGS__; input(__VA_ARGS__)

constexpr size_t    operator""_zu(unsigned long long value) { return value; };
constexpr intmax_t  operator""_jd(unsigned long long value) { return value; };
constexpr uintmax_t operator""_ju(unsigned long long value) { return value; };

constexpr int INF = 0x3f3f3f3f;
constexpr intmax_t LINF = 0x3f3f3f3f3f3f3f3f_jd;

template <class T, class Compare = less<>>
using MaxHeap = priority_queue<T, vector<T>, Compare>;
template <class T, class Compare = greater<>>
using MinHeap = priority_queue<T, vector<T>, Compare>;

inline void input() {}
template <class Head, class... Tail>
inline void input(Head&& head, Tail&&... tail) {
    cin >> head;
    input(forward<Tail>(tail)...);
}

template <class T>
inline istream& operator>>(istream &is, vector<T> &vec) {
    for (auto &e: vec) {
        is >> e;
    }
    return is;
}

inline void output() { cout << "\n"; }
template <class Head, class... Tail>
inline void output(Head&& head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) {
        cout << " ";
    }
    output(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<<(ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = {" ", ""};
    for (const auto &e: vec) {
        os << e << delim[&e == &vec.back()];
    }
    return os;
}

template <class T>
inline vector<T> makeVector(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeVector(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeVector<T>(initValue, args...))>(sz, makeVector<T>(initValue, args...));
}

template <class Func>
class FixPoint : Func {
public:
    explicit constexpr FixPoint(Func&& f) noexcept : Func(forward<Func>(f)) {}

    template <class... Args>
    constexpr decltype(auto) operator()(Args&&... args) const {
        return Func::operator()(*this, std::forward<Args>(args)...);
    }
};

template <class Func>
static inline constexpr decltype(auto) makeFixPoint(Func&& f) noexcept {
    return FixPoint<Func>{forward<Func>(f)};
}

template <class T>
inline bool chmax(T &a, const T &b) noexcept {
    return b > a && (a = b, true);
}

template <class T>
inline bool chmin(T &a, const T &b) noexcept {
    return b < a && (a = b, true);
}

template <class T>
inline T diff(const T &a, const T &b) noexcept {
    return a < b ? b - a : a - b;
}
// End Header }}}

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

    var(size_t, N, K);

    vector<intmax_t> l(N);
    input(l);

    sort(l.begin(), l.end(), greater<>());

    intmax_t res = 0;
    rep(i, K) res += l[i];

    output(res);

    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
const int N = 1e5 + 5, M = 2 * N + 5;

int n, m;

int main()
{
    cin>>n>>m;
    int x,sum=0;
    for(int i=0;i<m;++i)
    {
        cin>>x;
        sum+=x;
    }
    if(n-sum>=0)
        cout<<n-sum<<endl;
    else
        cout<<-1<<endl;
	return 0;
}


Measured memory_bytes: 3684
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <iomanip>
using namespace std;
#define int long long

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

    int n; cin >> n;
    vector<int> b(n);
    for(int i = 0;i < n;i ++) cin >> b.at(i);

    for(int i = 0;i < n;i ++){
        if(b.at(i) > i+1){
            cout << -1 << endl;
            return 0;
        }
    }

    vector<int> a(n),done(n);
    vector<int> count(n);

    for(int i = 0;i < n;i ++){
        count.at(i) = i+1 - b.at(i);
    }

    for(int i = n-1;i >= 0;i --){
        for(int j = n-1;j >= 0;j --){
            if(count.at(j) == 0 && done.at(j) == 0){
                a.at(i) = b.at(j);
                for(int k = j+1;k < n;k ++) count.at(k) --;
                done.at(j) = 1;
                break;
            }
        }
    }

    for(int i = 0;i < n;i ++){
        cout << a.at(i) << endl;
    }
}

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


int main() {
	int M, D;
	cin >> M >> D;

	int n = 0;
	for (int m = 1; m <= M; ++m) {
		for (int d = 1; d <= D; ++d) {
			if (d % 10 >= 2 && d / 10 >= 2 && (d % 10) * (d / 10) == m) {
				++n;
			}
		}
	}

	cout << n << endl;
}

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

int main() {
    int n;
    cin >> n;
    vector<int> p(n);
    for (auto& e : p) cin >> e, e--;
    int ans = 0;
    for (int i = 0; i + 1 < n; i++) {
        if (p[i] == i) {
            swap(p[i], p[i+1]);
            ans++;
        }
    }
    if (p.back() == n-1) ans++;
    cout << ans << endl;
}


Measured memory_bytes: 640
n, q = gets.split.map &:to_i
lane = Array.new(n) { Queue.new }
q.times do
	com, x = gets.split.map &:to_i
	if com == 0
		puts lane[x - 1].pop
	elsif com == 1
		pos = lane.each_with_index.min_by { |v, i| v.size }[1]
		lane[pos].push(x)
	end
end



Measured memory_bytes: 7072
MOD = 10**9+7         # 問題に合わせて適宜書き換え
list_size = 10**6+100  # 問題に合わせて適宜書き換え

f_list = [1] * list_size
f_r_list = [1] * list_size

for i in range(list_size - 1):
	f_list[i + 1] = ((f_list[i] * (i+2)) % MOD)

f_r_list[-1] = pow(f_list[-1], MOD - 2, MOD)

for i in range(-2, -list_size-1, -1):
	f_r_list[i] = ((f_r_list[i+1] * (list_size + 2 + i)) % MOD)

def comb(n,r):
    if r == 0 or n == r:
        return 1
    return (((f_list[n - 1] * f_r_list[n - r - 1]) % MOD) * f_r_list[r - 1]) % MOD

X,Y = map(int,input().split())
if (X+Y) % 3 != 0:
    print(0)
    exit()
N = (X+Y)//3
X -= N
Y -= N
if X < 0 or Y < 0:
    print(0)
    exit()
print(comb(N,X))


Measured memory_bytes: 55660
#include <bits/stdc++.h>
#define mod 1000000007
#define pb push_back
#define ll long long
#define mp make_pair
using namespace std;
ll n;
vector<ll> a;
ll c[210000];
bool calc(ll k){
	vector<ll> pm;
	ll res = 0;
	for(int i=0;i<n;i++){
		if(a[i]<k)pm.pb(-1);
		else pm.pb(1);
	}
	for(int i=0;i<210000;i++){
		c[i]=0;
	}
	ll ze = 105000;
	ll pl = 0;
	for(int i=0;i<n;i++){
		if(pm[i] == -1){
			c[ze]++;
			ze++;
			pl -= c[ze];
			res += pl + c[ze];
		}
		else{
			c[ze]++;
			ze--;
			pl += c[ze+1];
			res += pl + c[ze];
		}
	}
	//cout<<k<<" "<<res<<endl;
	if(res >= ( n*n + n +2)/4) return true;
	else return false;
}
int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		ll x;
		cin>>x;
		a.pb(x);
	}
	ll lef = 1, rig = mod;
	while(rig-lef>1){
		ll mid = (lef+rig)/2;
		if( calc(mid) ){
			lef = mid;
		}
		else{
			rig = mid;
		}
	}
	cout<<lef<<endl;
	return 0;
}

Measured memory_bytes: 4536
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;
int main(int argc, char *argv[])
{
    int n, a, b;
    string str, command, buff;
    cin >> str >> n;
    while (n--)
    {
        cin >> command >> a >> b;
        if (command == "print")
        {
            cout << str.substr(a, b - a + 1) << endl;
        }
        else if (command == "reverse")
        {
            string sub = str.substr(a, b - a + 1);
            reverse(sub.begin(), sub.end());
            str = str.substr(0, a) + sub + str.substr(b + 1);
        }
        else if (command == "replace")
        {
            cin >> buff;
            str.replace(a, b - a + 1, buff);
        }
    }
    return 0;
}


Measured memory_bytes: 3148
#include<iostream>
#include<string>
using namespace std;
int main()
{
	int N,K;
	cin>>N>>K;
	string s;
	cin>>s;
	int M,k=0,l=s[0];
	for(int n=1;n<N;n++)
	{
	  	if(l!=s[n]){
	  	   k++;
	  	   l=s[n];}
	}
	M=N-k-1;
	int y;
	for(y=K;y>0;y--)
	{
		k-=2;
		if(k>=0) M+=2;
		else if(k==-1){
		     M+=1; 
		     break;} 
		     else {
			 M=M;
		     break;} 
	}
	cout<<M<<endl; 
	return 0;
 } 

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

using namespace std;

#define lc (1 + (idx << 1))
#define rc (2 + (idx << 1))
#define md ((st + nd) >> 1)
#define fi first
#define se second
#define pb push_back
typedef long long ll;

const int N = 16;
int a[N][N];
ll dp[1<<N], b[1<<N];

int main() {
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			scanf("%d", &a[i][j]);
		}
	}
	for (int j = 1; j < (1 << n); j++) {
		for (int u = 0; u < n; u++) {
			if (j & (1 << u)) {
				for (int v = u + 1; v < n; v++) {
					if (j & (1 << v)) {
						b[j] += a[u][v];
					}
				}
			}
		}
	}
	for (int j = 1; j < (1 << n); j++) {
		int hold = j;
		do {
			dp[j] = max(dp[j], dp[hold] + b[j^hold]);
			--hold;
			hold &= j;
		} while (hold != j);
	}
	printf("%lld", dp[(1<<n)-1]);
	return 0;
}


Measured memory_bytes: 1280
#include <numeric>
#include <iostream>
using namespace std;
int main() {
    int n; cin >> n;
    int a[n]; for (int i = 0; i < n; i++) cin >> a[i];
    long long dp[n+1][2][3] = {};
    long long INF = 1LL << 60;
    for (int j = 0; j < 2; j++) for (int k = 0; k < 3; k++) dp[0][j][k] = -INF;
    dp[0][0][0] = 0;
    long long sum = accumulate(a, a+n, 0LL), ans = sum;
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j < 2; j++)
            for (int k = 0; k < 3; k++) {
                if (a[i-1] % 2 == j) {
                    dp[i][j][k] = max(dp[i][j][k], (a[i-1] > 0 ? a[i-1] : j-2) + dp[i-1][j][k]);
                    if (k > 0) {
                        dp[i][j][k] = max(dp[i][j][k], (a[i-1] > 0 ? a[i-1] : j-2) + dp[i-1][1-j][k-1]);
                    }
                } else {
                    dp[i][j][k] = max(dp[i][j][k], (a[i-1] > 0 ? a[i-1] - 1 : j-2) + dp[i-1][j][k]);
                    if (k > 0) {
                        dp[i][j][k] = max(dp[i][j][k], (a[i-1] > 0 ? a[i-1] - 1 : j-2) + dp[i-1][1-j][k-1]);
                    }
                }
            }
        ans = min(ans, sum - max(dp[i][0][0], max(dp[i][0][2], dp[i][1][1])));
    }
    cout << ans << endl;
}


Measured memory_bytes: 10368
#include <stdio.h>
 
int main() {
    int a[100][100]={0};
    int b[100]={0};
    int d[100]={0};
    int i,j,n,m;
    int x;
    int sum=0;
    scanf("%d %d",&n,&m);
    for(j=0;j<n;j++){
        for(i=0;i<m;i++){
            scanf("%d",&x);
            a[j][i]=x;
        }
    }
    for(j=0;j<n;j++){
        for(i=0;i<m;i++){
            b[i] += a[j][i];
        }
    }
    for(j=0;j<n;j++){
        for(i=0;i<m;i++){
            d[j]+=a[j][i];
        }
    }
    for(j=0;j<n;j++){
        for(i=0;i<m;i++){
            printf("%d ",a[j][i]);
        }
        printf("%d\n",d[j]);
    }
    for(i=0;i<m;i++){
        printf("%d ",b[i]);
        sum+=b[i];
    }
    printf("%d\n",sum);
    return 0;
}


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

using namespace std;

#define sz(a) int(a.size())

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

	vector <int> V(n);
	for (int &t : V) cin >> t;

	int ans = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j <= n-i && i+j <= k; j++) {
			int rem = k-i-j;
			multiset <int> s;

			for (int id = 0; id < i; id++) s.insert(V[id]);
			for (int id = n-j; id < n; id++) s.insert(V[id]);

			while (rem && !s.empty() && *begin(s) < 0) {
				s.erase(begin(s));
				rem--;
			}
			int cur = 0;
			for (auto t : s) cur += t;
			ans = max(ans, cur);
		}
	}
	cout << ans << endl;
}



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

#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 INF 1e9


int main(){
  string S;
  cin >> S;
  char pre = 'A';
  int ans = 0;
  int add = 0;
  REP(i, S.size()){
    if(pre == S[i]){
      if(i+1 < S.size()){
        ans ++;
        pre = 'A';
        i++;
      }
      else{
        continue;
      }
    }
    else{
      pre = S[i];
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
int Max(int(a), int(b), int(c)) {
	return max(max(a, b), c);
}
int Min(int(a), int(b), int(c)) {
	return min(min(a, b), c);
}

int gcd(ll(a), ll(b)) {
	ll c = a;
	while (a % b != 0) {
		c = a % b;
		a = b;
		b = c;
	}
	return b;
}



int main() {
 
	
	ll N;
	cin >> N;
	string an = "Yes";
	set<string> S;
	vector<string> W(N);
	
	for (ll i = 0; i < N; i++) {
		
		cin >> W.at(i);
		
		
	}
	S.insert(W.at(0));
	for (ll i = 1; i < N; i++) {
		if (W.at(i).at(0) == W.at(i - 1).at(W.at(i - 1).size()-1) && not S.count(W.at(i))) {
			S.insert(W.at(i));
		}
		else {
			an = "No";
			break;
		}


	}
	
	cout <<an<< endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pr;
typedef priority_queue<pr> pq;

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

    vll a(n), b(n);
    pq q;
    for (ll i = 0; i < n; i++)
    {
        cin >> a[i] >> b[i];
        q.push(pr(-a[i], i));
    }

    ll money = 0;
    ll rest = m;
    while (rest > 0)
    {
        ll i = q.top().second;
        q.pop();

        ll price = a[i];
        ll amount = b[i];

        if (rest < amount)
        {
            amount = rest;
        }

        money += price * amount;
        rest -= amount;
    }

    cout << money << endl;

    return 0;
}

Measured memory_bytes: 3956
#include<stdio.h>
#include<string.h>

int main(void) {
  char s[3][102];
  int i;
  for(i=0;i<3;i++){
    scanf("%s", s[i]);
  }
  for(i=0;i<3;i++){
    printf("%c",s[i][0]);
  }
  printf("\n");
  
  return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int answer = 0;
		//int[] a = new int[n];
		int[] b = new int[n - 1];

		for (int i = 0; i < n - 1; i++) {
			b[i] = sc.nextInt();
		}
		answer += b[n - 2];
		for (int i = n - 2; i > 0; i--) {
			answer += Math.min(b[i - 1], b[i]);
		}

		answer += b[0];
		System.out.println(answer);
	}
}


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

using namespace std;

#define x first
#define y second
#define mp make_pair
#define pb push_back
#define sqr(a) ((a) * (a))
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define forn(i, n) for(int i = 0; i < int(n); i++) 
#define fore(i, l, r) for(int i = int(l); i < int(r); i++)

typedef long long li;
typedef long double ld;
typedef pair<int, int> pt;

template <class A, class B> ostream& operator << (ostream& out, const pair<A, B> &a) {
	return out << "(" << a.x << ", " << a.y << ")";
}

template <class A> ostream& operator << (ostream& out, const vector<A> &v) {
	out << "[";
	forn(i, sz(v)) {
		if(i) out << ", ";
		out << v[i];
	}
	return out << "]";
}

mt19937 rnd(time(NULL));

const int INF = int(1e9);
const li INF64 = li(1e18);
const int MOD = int(1e9) + 7;
const ld EPS = 1e-9;
const ld PI = acos(-1.0);

const int N = 500 + 7;

int n;
int a[N * N];

bool read () {
	if (scanf("%d", &n) != 1)
		return false;
	forn(i, n * n){
		scanf("%d", &a[i]);
		--a[i];
	}
	return true;
}

int d[N][N];
bool used[N][N];

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

bool in(int x, int y){
	return 0 <= x && x < n && 0 <= y && y < n;
}

void upd(int x, int y){
	forn(i, 4){
		int nx = x + dx[i];
		int ny = y + dy[i];
		if (!in(nx, ny) || d[nx][ny] <= d[x][y] + used[x][y])
			continue;
		d[nx][ny] = d[x][y] + used[x][y];
		upd(nx, ny);
	}
}

void solve(){
	forn(i, n) forn(j, n){
		d[i][j] = min({i, j, n - i - 1, n - j - 1});
		used[i][j] = true;
	}
	int ans = 0;
	forn(z, n * n){
		int x = a[z] / n;
		int y = a[z] % n;
		ans += d[x][y];
		used[x][y] = false;
		upd(x, y);
	}
	printf("%d\n", ans);
}

int main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
	
	int tt = clock();
#endif
	
	cerr.precision(15);
	cout.precision(15);
	cerr << fixed;
	cout << fixed;

#ifdef _DEBUG
	while(read()) {	
#else
	if(read()) {
#endif
		solve();
		
#ifdef _DEBUG
	cerr << "TIME = " << clock() - tt << endl;
	tt = clock();
#endif

	}
}

Measured memory_bytes: 24900
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

using namespace std;

typedef long long ll;

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

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

int main(void) {
    int x, y, z;
    cin >> x >> y >> z;
    if (x + y + z >= 22) {
        cout << "bust" << endl;
    } else {
        cout << "win" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	var input string
	if sc.Scan() {
		sc.Text()

	}
	if sc.Scan() {
		input = sc.Text()
	}
	arr := strings.Split(input, " ")
	var targets []int
	for _, i := range arr {
		ii, _ := strconv.Atoi(i)
		targets = append(targets, ii)
	}
	//fmt.Printf("target before func: %v\n", targets)

	total_count := 0
	count, result := getDivisionCount(targets)
	for count != 0 {
		total_count += count
		count, result = getDivisionCount(result)
	}
	fmt.Printf("%v\n", total_count)
}

// 入力配列がすべて割り切れれば回数と割った配列を返す
func getDivisionCount(inputs []int) (count int, result []int) {
	count = 0
	for _, input := range inputs {
		if input%2 == 0 {
			count += 1
			result = append(result, input/2)
		}
	}
	if count == len(inputs) {
		// fmt.Printf("return 1, count=%d, res=%v\n", count, result)
		return 1, result
	} else {
		return 0, result
	}
}

Measured memory_bytes: 768
#include <stdio.h>

int swap(int *a,int *b){
	int temp;
	temp=*a;
	*a=*b;
	*b=temp;
	return 0;
}

int sort(int num[]){
	int i,j,minIndex;
	for(i=0;i<5;i++){
		minIndex=i;
		for(j=i+1;j<5;j++){
			if(num[j]<num[minIndex]){
				minIndex=j;
			}
		}
		swap(&num[i],&num[minIndex]);
	}
	
	return 0;
}

int main(){
	int num[5];
	int i;
	for(i=0;i<5;i++){
		scanf("%d",&num[i]);
	}
	sort(num);
	
	for(i=4;i>=0;i--){
		printf("%d%c",num[i],(i==0)? '\n':' ');
	}
	
	return 0;
}

Measured memory_bytes: 0
from sys import stdin

N, S = map(int, stdin.readline().split())
A = list(map(int,stdin.readline().split()))
M = 998244353
V = max(max(A), S)

ans = 0
cs = [0 for _ in range(V + 1)]
for i, a in enumerate(A):
    dp = [0 for _ in range(V + 1)]
    dp[a] = i + 1
    for s in range(a + 1, S + 1):
        dp[s] = cs[s - a]
    cs = [(a + b) % M for a, b in zip(cs, dp)]
    ans = (ans + (N - i) * dp[S]) % M
print(ans)

Measured memory_bytes: 54876
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
    Scanner sc=new Scanner(System.in);

		int A=sc.nextInt();
		int B=sc.nextInt();
		
		System.out.println((A*B));
		
	}

}

Measured memory_bytes: 35628
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <ctime>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define fs first
#define sc second
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001


int main() {
    int N, K; cin >> N >> K;
    if(K==1) cout << 0 << endl;
    else cout << N - K << endl;
    
    return 0;
}



Measured memory_bytes: 764
from fractions import gcd
from functools import reduce


def product(a, b):
    return a*b


N = int(input())
A = [int(i) for i in input().split()]
# 公倍数-1を代入すると最大
max_m = reduce(product,A)-1
ans = 0
for a in A:
    ans += max_m%a
print(ans)


Measured memory_bytes: 64748
N, K = gets.chomp.split.map(&:to_i)
A = gets.chomp.split.map(&:to_i)

posi = []
nega = []
zeros = 0
A.each do |ai|
  if ai < 0
    nega << ai
  elsif ai > 0
    posi << ai
  else
    zeros += 1
  end
end

posi.sort!
nega.sort!.reverse!

posi_size = posi.size
nega_size = nega.size

zero_pairs = zeros * (zeros - 1) / 2 + zeros * (N - zeros)

ng = -(10**18 + 1)
ok = 10**18 + 1

a = (ng..ok).bsearch do |mid|
  # mid = (ok + ng) / 2
  cnt = 0
  
  cnt += zero_pairs if mid >= 0

  if mid > 0
    cnt += nega_size * posi_size
    [posi, nega].each do |a|
      l = 0
      r = a.size - 1
      while l < r
        r -= 1 while l < r && a[l] * a[r] > mid
        cnt += r - l
        l += 1
      end
    end
  else
    r = nega_size - 1
    posi.size.times do |l|
      r -= 1 while(r >= 0 && posi[l] * nega[r] <= mid)
      cnt += nega_size - r - 1
    end
  end

  cnt >= K
end

puts a


Measured memory_bytes: 22504
import math
from collections import deque
from collections import defaultdict

import bisect

#自作関数群
def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def fact(n):#階乗
	ans = 1
	m=n
	for _i in range(n-1):
		ans*=m
		m-=1
	return ans
def comb(n,r):#コンビネーション
	if n<r:
		return 0
	l = min(r,n-r)
	m=n
	u=1
	for _i in range(l):
		u*=m
		m-=1
	return u//fact(l)
def combmod(n,r,mod):
	return (fact(n)/fact(n-r)*pow(fact(r),mod-2,mod))%mod
def printQueue(q):
	r=copyQueue(q)
	ans=[0]*r.qsize()
	for i in range(r.qsize()-1,-1,-1):
		ans[i] = r.get()
	print(ans)
class UnionFind():
	def __init__(self, n):
		self.n = n
		self.parents = [-1]*n

	def find(self, x): # root
		if self.parents[x]<0:
			return x
		else:
			self.parents[x] = self.find(self.parents[x])
			return self.parents[x]

	def union(self,x,y):
		x = self.find(x)
		y = self.find(y)

		if x==y:
			return

		if self.parents[x]>self.parents[y]:
			x,y = y,x

		self.parents[x]+=self.parents[y]
		self.parents[y]=x

	def size(self,x):
		return -1*self.parents[self.find(x)]

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

	def members(self,x): # much time
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i)==root]

	def roots(self):
		return [i for i,x in enumerate(self.parents) if x<0]

	def group_count(self):
		return len(self.roots())

	def all_group_members(self):
		return {r: self.members(r) for r in self.roots()} # 1~n
def bitArr(n):#ビット全探索
	x = 1
	zero = "0"*n
	ans = []
	ans.append([0]*n)
	for i in range(2**n-1):
		ans.append(list(map(lambda x:int(x),list((zero+bin(x)[2:])[-1*n:]))))
		x+=1
	return ans;
def arrsSum(a1,a2):
	for i in range(len(a1)):
		a1[i]+=a2[i]
	return a1
def maxValue(a,b,v):
	v2 = v
	for i in range(v2,-1,-1):
		for j in range(v2//a+1): #j:aの個数
			k = i-a*j
			if k%b==0:
				return i
	return -1
def copyQueue(q):
	nq = queue.Queue()
	n = q.qsize()
	for i in range(n):
		x = q.get()
		q.put(x)
		nq.put(x)
	return nq
def get_sieve_of_eratosthenes(n):
	#data = [2]
	data = [0,0,0]
	for i in range(3,n+1,2):
		data.append(i)
		data.append(0)
	for i in range(len(data)):
		interval = data[i]
		if interval!=0:
			for j in range(i+interval,n-1,interval):
				data[j] = 0
	#ans = [x for x in data if x!=0]
	ans = data[:]
	return ans

n,k,q = readInts()
count = [0 for i in range(n)]
for i in range(q):
	count[readInt()-1]+=1

for i in count:
	if k-(q-i)>0:
		print("Yes")
	else:
		print("No")

Measured memory_bytes: 5116
#include <iostream>
#include <string>
#include <stdio.h>
using namespace std;
int main(void){
    double a;
    double max=0,min=999999999;
    while(~scanf("%lf",&a)){
        if(max<a)max=a;
        if(min>a)min=a;
    }
    printf("%lf\n",max-min);
}


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

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    sort(all(a), greater<int>());
    int sum = accumulate(all(a), 0);
    string ans = "No";
    if (sum > a[0] * 2)
        ans = "Yes";
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n = list(map(int, list(input())))

ans = 0
for i, e in enumerate(n):
    if i == 0:
        ans += n[i]
        continue

    if n[i] != 9:
        ans = ans - 1 + 9 * (len(n) - i)
        break

    ans += 9

print(ans)



Measured memory_bytes: 9168
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime> 
#include <memory.h>
#include <assert.h>

using namespace std;

using ll = long long;
using pii = pair<int, int>;
const int INF = 1e9 + 1;
const ll LLINF = 1e18 + 1;

int main() {
    int N;
    cin >> N;
    vector<int> V(N), C(N);
    for(int i = 0; i < N; i++) cin >> V[i];
    for(int i = 0; i < N; i++) cin >> C[i];

    int ans = 0;
    for(int i = 0; i < N; i++) {
        if (V[i] - C[i] > 0) {
            ans += (V[i] - C[i]);
        }
    }

    cout << ans << endl;

    return 0;
}

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


int main(){
  int n;
  cin >> n;
  long long a[n];
  for (int i = 0; i < n; i++)
    cin >> a[i];
  int sum = 0, right = 0;
  long long answer = 0;
  for (int i = 0; i < n; i++){
    while (right < n && (sum ^ a[right]) == sum + a[right]){
      sum += a[right];
      right++;
    }
    answer += right - i;
    if (i == right) right++;
    else sum -= a[i];
  }
  cout << answer << endl;
  return 0;
}


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

using namespace std;

int main(){
  int n,pow2 = 0,sum = 0,res = (1 << 29);
  cin >> n;
  for(int i = 0;i < n;i++){
    int x;cin >> x;
    pow2 += x * x;sum += x;
  }
  for(int i = 0;i <= 100;i++)res = min(res,pow2 - 2*i*sum + i*i*n);
  cout << res;
  return 0;
}

Measured memory_bytes: 256