akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cctype>
#include<iostream>
#include<string>
#include<sstream>
#include<set>
#include<map>
#include<vector>
#include<algorithm>
#include<queue>
#include<utility>
using namespace std;

#define i64 long long int
// #define i128 __int128_t

struct modular_arithmetic{
	int mod;

	modular_arithmetic(){
		mod = 998244353;
	}
	//No specific settings.
	int add(int x,int y){return (x+=y)<mod?x:x-mod;}
	int mul(int x,int y){return (int)((long long int)x*y%mod);}
	int pw(int base, int p) {
		int res = 1, mu = base%mod;
		for(;p>0;p/=2) {
			if (p&1) res = mul(res, mu);
			mu = mul(mu, mu);
		}
		return res;
	}
};
modular_arithmetic ma;

#define ran 2022
int n, lim;
int dp[ran][ran], sigma[ran][ran];
int c[ran*2][ran*2];

int cc(int choice, int slot) {
	if (choice==0 && slot == 0) return 1;
	if (choice==0) return 0;
	return c[slot+choice-1][choice-1];
}

/*
int calc(int X) {
	int res = 0;
	for(int i=0;i<=n;i++) { // 分给成组的i个
		if (X==n+1&&i!=n) continue;
		int v = 0;
		if (X%2==0) {
			v = DP(i, ccc(X, n));
			if (i>0)
				v = ma.add(v, DP(i-1, ccc(X, n)));
		} else {
			v=DP(i, ccc(X, n));
		}
		if (X<=n) v = ma.mul(v, cc(n-X+1, n-i));
		if (X>n+1) v = ma.mul(v, cc(X-n-1, n-i));
		res = ma.add(res, v);
	}
	return res;
}*/
int f(int A,int B,int n){
	int res = 0;
	for(int i=0; i<=n; i++){
		res = ma.add(res, ma.mul(dp[A][i], cc(B,n-i)));
	}
	return res;
}
int calc(int X){
	int L = max(X-lim, 1), R = min(X-1, lim);
	int A = (R-L+1) / 2, B;
	if(X%2==1){
		B = lim - 2*A;
		return f(A,B, n);
	}
	else{
		B = lim - 2*A-1;
		return ma.add(f(A,B,n),f(A,B,n-1));
	}
}

int main() {
	scanf("%d%d", &lim, &n);

	if (lim==1) {
		if (n==1) puts("1");
		else puts("0");
		return 0;
	}

	for(int i=0;i<ran*2;i++)
	for(int j=0;j<=i;j++) {
		if (j==0 || j==i) c[i][j] = 1;
		else c[i][j] = ma.add(c[i-1][j], c[i-1][j-1]);
	}
	
	memset(dp, 0, sizeof dp);
	memset(sigma, 0, sizeof sigma);
	dp[0][0] = 1;
	for(int i=0;i<=n;i++) sigma[0][i] = 1;
	for(int i=1;i<=lim;i++) {
		for(int j=0;j<=n;j++) {
			dp[i][j] = dp[i-1][j];
			if (j>0)
				dp[i][j] = ma.add(dp[i][j], ma.mul(sigma[i-1][j-1], 2));
		}
		sigma[i][0] = dp[i][0];
		for(int j=1;j<=n;j++)
			sigma[i][j] = ma.add(sigma[i][j-1], dp[i][j]);
	}
	
	for(int i=2;i<=lim*2;i++)
		printf("%d\n", calc(i));
	
	return 0;
}

Measured memory_bytes: 94592
from math import gcd
n = int(input())
s = list(map(int, input().split()))
s.sort()
dp = [0] * ((10 ** 6) + 100)

res = s[0]
for ss in s:
    dp[ss] += 1
    res = gcd(res, ss)

A = max(s)
pairwise = True

for i in range(2, A + 1):
    cnt = 0
    for j in range(i, A + 1, i):
        cnt += dp[j]
    if cnt > 1:
        pairwise = False

if pairwise:
    print("pairwise coprime")
elif res == 1:
    print("setwise coprime")
else:
    print("not coprime")


Measured memory_bytes: 194308
import sys


INF = 1 << 32 - 1
S = sys.stdin.readlines()
N, M, L = map(int, S[0].split())

dp = [[INF] * N for _ in range(N)]

for i in range(1, M + 1):
    A, B, C = map(int, S[i].split())
    dp[A - 1][B - 1] = C
    dp[B - 1][A - 1] = C
for i in range(N):
    dp[i][i] = 0

for k in range(N):
    for i in range(N):
        for j in range(N):
            dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j])


dp2 = [[INF] * N for _ in range(N)]
for i in range(N):
    for j in range(N):
        if dp[i][j] <= L:
            dp2[i][j] = 1
# for i in range(N):
#     dp2[i][i] = 0

for k in range(N):
    for i in range(N):
        for j in range(N):
            dp2[i][j] = min(dp2[i][j], dp2[i][k] + dp2[k][j])


Q = int(S[M + 1])
for i in range(M + 2, M + 2 + Q):
    s, t = map(int, S[i].split())
    refuel = dp2[s - 1][t - 1]
    if refuel >= 10 ** 3:
        print(-1)
    else:
        print(refuel - 1)


Measured memory_bytes: 72540
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mp make_pair
#define pb push_back
#define vll vector<ll>
#define mod(n) n % 1000000007
#define sp << " "
#define precision(n) cout << fixed << setprecision(n);
#define startTime time_t start, end;time(&start);
#define endTime time(&end);double tt = double(end-start);cout<<"Time taken : "<<fixed<<tt<<setprecision(5);cout <<" sec"<< endl;
 
using namespace std; 

int main() { 
    IOS;
    ll N, W;
    cin >> N >> W;
    vll w(N + 1, 0);
    vll v(N + 1, 0);
    ll sum = 0;
    for (int i = 1; i < N + 1; i++) {
    	cin >> w[i] >> v[i];
    	sum += v[i];
    }
    vector<vll> dp(N + 1, vll (sum + 1, -1));
    ll ans = 0, cumw = 0, cumv = 0;

    ll mn = 100000000;
    for (int i = 1; i < N + 1; i++) {
    	mn = min(mn, w[i]);
    	dp[i][1] = w[i];
    }

    for (ll i = 1; i < N + 1; i++) {
    	cumw += w[i];
    	cumv += v[i];
    	for (ll j = 2; j < sum + 1; j++) {
    		ll a = (dp[i - 1][j] == -1)? ((cumv >= j)? cumw: -1): dp[i - 1][j];
    		ll b = w[i] + ((j - v[i] < 1)? 0: dp[i - 1][j - v[i]]);
    		dp[i][j] = min(a, b);
    		if (dp[i][j] <= W && dp[i][j] != -1) ans = max(ans, j);
    	}
    }
    cout << ans << endl;
}   

Measured memory_bytes: 80256
#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	int N;
	cin >> N;
	int ans = INF32;
	int cost;
	vector<int> data(N);

	for (int i = 0; i < N; i++)
	{
		cin >> data[i];
	}
	for (int i = -100; i <= 100; i++)
	{
		cost = 0;
		for (int j = 0; j < N; j++)
		{
			cost += (data[j] - i) * (data[j] - i);
		}
		ans = min(ans, cost);
	}
	cout << ans << endl;
	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
using ll=long long;
using P=pair<ll,ll>;
using PP=tuple<ll,ll,ll>;
using S=multiset<ll>;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
void decimal(int x){cout<<fixed<<setprecision(x);}
ll GCD(ll a,ll b){if(b==0) return a; return GCD(b,a%b);}
ll LCM(ll a,ll b){return(a/GCD(a,b))*(b/GCD(a,b))*GCD(a,b);}
ll POW(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*POW(a,b-1)%mod;ll k=POW(a,b/2);return k*k%mod;}
vi calc(ll x){vi res;while(x>0){res.eb(x%10);x/=10;}reverse(all(res));return res;}

void solve() {
  ll n;
  cin>>n;
  if(n%2){
    out(0); return;
  }
  n/=2;
  ll m=n;
  ll a=n,b=0;
  while(n>0){
    n/=2; a+=n;
  }
  while(m>0){
    m/=5; b+=m;
  }
  out(min(a,b));
}

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


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <utility>
#include <algorithm>
#define llint long long

using namespace std;
typedef pair<llint, llint> P;

llint n;
llint p[100005], qcnt[100005];
set<P> S;
set<llint> T;
bool used[100005];

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

	cin >> n;
	for(int i = 1; i <= n; i++) cin >> p[i], qcnt[p[i]]++;
	if(n == 2){
		cout << -1 << endl;
		return 0;
	}

	for(llint i = 1; i <= n; i++) S.insert(P(qcnt[i], i)), T.insert(i);
	int v = 0;
	for(int i = 1; i <= n; i++){
		while(1){
			auto it = S.end(); it--;
			if(used[it->second]) S.erase(it);
			else break;
		}
		auto it = S.end(); it--;
		if(it->first == n-i){
			v = it->second;
			//cout << it->first << " " << it->second << endl;
			cout << v << " ";
			used[v] = true;
			T.erase(v);
			S.erase(P(qcnt[p[v]], p[v]));
			qcnt[p[v]]--;
			S.insert(P(qcnt[p[v]], p[v]));
			S.erase(it);
			continue;
		}
		for(auto it = T.begin(); it != T.end(); it++){
			if(*it == p[v]) continue;
			if(T.size() == 3){
				vector<llint> tmp;
				for(auto it2 = T.begin(); it2 != T.end(); it2++){
					if(*it != *it2) tmp.push_back(*it2);
				}
				if(p[tmp[0]] == tmp[1] && p[tmp[1]] == tmp[0]) continue;
			}
			v = *it;
			cout << v << " ";
			used[v] = true;
			T.erase(v);
			S.erase(P(qcnt[p[v]], p[v]));
			qcnt[p[v]]--;
			S.insert(P(qcnt[p[v]], p[v]));
			break;
		}
	}
	cout << endl;

	return 0;
}


Measured memory_bytes: 13440
#include <iostream>

using namespace std;

const int maxn = 1e5 + 10;

int n;
int a[maxn];

int main() {
	ios_base::sync_with_stdio(0);
	cin >> n;
	for (int i = 1; i <= n; ++i) cin >> a[i];

	int answer = 1, cur = 0;
	for (int i = 2; i <= n; ++i) {
		if (a[i] > a[i - 1] && cur == -1) {
			answer++;
			cur = 0;
		} else if (a[i] < a[i - 1] && cur == 1) {
			answer++;
			cur = 0;
		} else if (a[i] > a[i - 1]) {
			cur = 1;
		} else if (a[i] < a[i - 1]) {
			cur = -1;
		}
	}
	cout << answer << endl;
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
using ll = long long;
using ld = long double;
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
using pll = pair<long long,long long>;
#define cY cout<<"Yes"<<endl
#define cN cout<<"No"<<endl
const long long INF = 1LL << 60;
const long long MOD = 1000000007;
const long double pi = (acos(-1));
#define pb push_back
#define vs vector<string>

//最大最小の入れ替え
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;
}

//約数列挙
vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}
//コンビネーション
ll nCr(ll n, ll r) {
    ll ans = 1;
    for (ll i = n; i > n - r; --i) {
        ans = ans*i;
    }
    for (ll i = 1 ; i < r + 1; ++i) {
        ans = ans / i;
    }
    return ans;
}
//素因数分解
map< ll, ll > prime_factor(ll n) {
  map< ll, ll > ret;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

//切り上げの割り算は(a + b - 1) / bでできる

//ここから
int main(){
    ll sx,sy,tx,ty;
    cin>>sx>>sy>>tx>>ty;
    rep(i,tx-sx){
        cout<<'R';
    }
    rep(i,ty-sy){
        cout<<'U';
    }
    rep(i,tx-sx){
        cout<<'L';
    }
    rep(i,ty-sy){
        cout<<'D';
    }
    cout<<'D';
    rep(i,tx-sx+1){
        cout<<'R';
    }
    rep(i,ty-sy+1){
        cout<<'U';
    }
    cout<<"LU";
    rep(i,tx-sx+1){
        cout<<'L';
    }
    rep(i,ty-sy+1){
        cout<<'D';
    }
    cout<<'R'<<endl;
}


Measured memory_bytes: 256
h, w = gets.split.map(&:to_i)
arr = readlines.map(&:chomp).map(&:chars)

arr.map do |i|
  if i.include?("#")
    i
  else
    arr.delete(i)
  end
end

arr2 = arr.transpose

arr2.map do |i|
  if i.include?("#")
    i
  else
    arr2.delete(i)
  end
end

arr3 = arr2.transpose
arr3.map do |i|
  puts i.join
end


Measured memory_bytes: 2300
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <iterator>
#include <cmath>
#include <set>
#include <deque> 
#include <string>


using namespace std;

int n;

int a[110];
int b[110];

int main()
{
	scanf("%d", &n);
	
	for (int i = 1 ; i <= n - 1 ; i++)
		scanf("%d", &(b[i]));

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


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

int main() {
  int n;
  cin >> n;
  map<int, int> mp;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    mp[a]++;
  }

  ll cnt = 0;
  for (auto mpp : mp) {
    int x, y;
    x = mpp.first;
    y = mpp.second;
    if (x > y) {
      cnt += y;
    } else {
      cnt += y - x;
    }
  }

  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 4736
#include <iostream>
#include <utility>
#include <tuple>
#include <vector>
#include <string>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <algorithm>
#include <functional>
#include <climits>
#include <numeric>
#include <queue>
#include <cmath>
#include <iomanip>
#include <array>
#include <string>
#include <stack>
#include <cassert>
#include <memory>

bool hate(int value, const std::vector<bool>& is_hate) {
	if (value < 10) return is_hate[value];
	else return is_hate[value % 10] || hate(value / 10, is_hate);
}
int main() {
	std::cin.tie(nullptr); std::cin.sync_with_stdio(false);
	int n, k; std::cin >> n >> k;
	std::vector<bool> is_hate(10, false);
	for (auto i = 0; i < k; ++i) {
		int d; std::cin >> d;
		is_hate[d] = true;
	}
	int price{ n };
	while (hate(price, is_hate)) ++price;
	std::cout << price << '\n';
}

Measured memory_bytes: 256
while True:
    n = int(input())
    if n == 0: break
    result = [input().split() for _ in range(n)]
    result = [[r[0], r.count('0'), r.count('1')] for r in result]
    result.sort(key=lambda x: [-x[1], x[2]])
    result = [r[0] for r in result]
    print('\n'.join(result))


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

using namespace std;

int n,m,t;
int a[100001];
int s[100001];

int main()
{
    scanf("%d%d",&n,&m);
    memset(a,0,sizeof(a));
    int flag = 0;
    for(int i = 1;i <= m;i++)
    {
        scanf("%d",&t);
        a[t] = 1;
        if(a[t - 1] == 1)
        {
            flag = 1;
        }
    }
    if(flag)
    {
        printf("0\n");
        return 0;
    }
    if(a[1] != 1)
        s[1] = 1;
    else
        s[1] = 0;
    if(a[2] != 1 && a[1] != 1)
        s[2] = 2;
    else if(a[2] == 1)
        s[2] = 0;
    else if(a[1] == 1 && a[2] != 1)
        s[2] = 1;
    for(int i = 3;i <= n;i++)
    {
        if(a[i] != 1)
            s[i] = (s[i - 2] + s[i - 1]) % 1000000007;
    }
    printf("%d\n",s[n]);
    return 0;
}


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

using namespace std;

int X[100];

int main() {

	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);

	int n;
	cin >> n;
	for (int i = 0; i < n; ++i) cin >> X[i];
	int stamina, min_stamina = 10000000;
	for (int i = 1; i <= 100; ++i) {
		stamina = 0;
		for (int j = 0; j < n; ++j) {
			stamina += ((X[j] - i) * (X[j] - i));
		}
		min_stamina = min(min_stamina, stamina);
	}
	cout << min_stamina << '\n';
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N= sc.nextInt();
        sc.nextLine();

        int p[]=new int[N];
        for (int i=0;i<N;i++){
            p[i]=sc.nextInt();
        }
        int count=0;

        for (int i=0; i<N;i++){
            if (p[i] != i+1){
                count++;
            }
        }
        if (count==0||count==2){
            System.out.println("YES");
        }else{
            System.out.println("NO");
        }


    }




}


Measured memory_bytes: 22484
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner scanner=new Scanner(System.in);
        int N=scanner.nextInt();
        int[] a=new int[N];
        long result=0;
        for(int i=0;i<N;i++){
            result+=scanner.nextInt()-1;
        }
        System.out.println(result);
    }
}


Measured memory_bytes: 27352
N = int(input())
S = [input() for i in range(N)]

MARCH_dic = {'M': 0, 'A': 0, 'R': 0, 'C': 0, 'H': 0}
MARCH_list = ['M', 'A', 'R', 'C', 'H']

for i in range(N):
  if S[i][0] in MARCH_list:
    MARCH_dic[S[i][0]] += 1
    
p_01 = MARCH_dic['M'] * MARCH_dic['A'] * MARCH_dic['R']
p_02 = MARCH_dic['M'] * MARCH_dic['A'] * MARCH_dic['C']
p_03 = MARCH_dic['M'] * MARCH_dic['A'] * MARCH_dic['H']
p_04 = MARCH_dic['M'] * MARCH_dic['R'] * MARCH_dic['C']
p_05 = MARCH_dic['M'] * MARCH_dic['R'] * MARCH_dic['H']
p_06 = MARCH_dic['M'] * MARCH_dic['C'] * MARCH_dic['H']
p_07 = MARCH_dic['A'] * MARCH_dic['R'] * MARCH_dic['C']
p_08 = MARCH_dic['A'] * MARCH_dic['R'] * MARCH_dic['H']
p_09 = MARCH_dic['A'] * MARCH_dic['C'] * MARCH_dic['H']
p_10 = MARCH_dic['R'] * MARCH_dic['C'] * MARCH_dic['H']

ans = 0

for i in range(10):
  ans += eval(f"p_{str(i+1).zfill(2)}")
  
print(ans)
  

Measured memory_bytes: 16108
n = int(input())
ans = list()
for i in range(n):
    tmp = list()
    for j in range(n):
        tmp.append(0)
    ans.append(tmp)

for i in range(n):
    l = [int(i) for i in input().split()]
    for li in l[2:]:
        # print(i, li)
        ans[i][li - 1] = 1

for i in ans:
    print(" ".join([str(x) for x in i]))



Measured memory_bytes: 5680
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    int n;
    cin>>n>>s;
    for(int i=0;i<s.length();i++){
        int c=s[i]-'A';
        c=(c+n)%26;
        s[i]='A'+c;
        printf("%c",s[i]);
}
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define N 1000000007
 
typedef unsigned long long int ulli;
 
ulli power(ulli,ulli);
 
int main(void){
    ulli m,n;
    scanf("%llu %llu",&m,&n);
    printf("%llu\n",power(m,n));
    return 0;
}
 
ulli power(ulli x,ulli y){
    ulli A;
    if(y==0) return 1;
    if(y==1) return x;
    if(y%2==0){
        A=power(x,y/2);
        return ((A%N)*(A%N))%N;
    }else{
        A=power(x,(y-1)/2);
        return (( (A%N)*(A%N) )%N*(x%N))%N;
    }
}

Measured memory_bytes: 2700
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int tmp_total = 0;
  int min_total = 0;
  int A;
  for (int i=0; i < N; i++){
    cin >> A;
    while (A % 2 == 0){
      tmp_total += 1;
      A /= 2;
    }
    if (i == 0 || (tmp_total < min_total)){
      min_total = tmp_total;
    }
    tmp_total = 0;
  }
  cout << min_total << endl;
}

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

int  main()
{
	int a,b,c,d; cin >> a >> b >> c >> d;
	if (a+b > c+d)
		cout << "Left\n";
	else if (a+b < c+d)
		cout << "Right\n";
	else 
		cout << "Balanced\n";
	return (0);
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,b,c,d,e;
    int counter=0;
    cin>>a>>b>>c>>d>>e;
    counter=a;
    if(counter>=b)
    {
        counter=b;
    }
    if(counter>=c)
    {
        counter=c;
    }
    if(d<=e)
    {
        counter=counter+d;
    }
    if(d>e)
    {
        counter=counter+e;
    }
    cout<<counter-50<<endl;
    return 0;
}



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

using pii = pair<int,int>;
using ll = long long;
#define rep(i, j) for(int i=0; i < (int)(j); i++)
#define repeat(i, j, k) for(int i = (j); i < (int)(k); i++)
#define all(v) v.begin(),v.end()
#define debug(x) cerr << #x << " : " << x << endl

template<class T> bool set_min(T &a, const T &b) { return a > b  ? a = b, true : false; }
template<class T> bool set_max(T &a, const T &b) { return a < b  ? a = b, true : false; }
// vector
template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
template<class T> ostream& operator << (ostream &os , const vector<T> &v) { for(const T &t : v) os << "\t" << t; return os << endl; }
// pair
template<class T, class U> ostream& operator << (ostream &os , const pair<T, U> &v) { return os << "<" << v.first << ", " << v.second << ">"; }

const int INF = 1 << 30;
const ll INFL = 1LL << 60;
const int IMAX = 80*160*2+100;
const int IC = 80*160+50;
int dp[81][81][IMAX];

class Solver {
  public:
    bool solve() {
        int H, W; cin >> H >> W;
        vector<vector<int>> A(H, vector<int>(W)); cin >> A;
        vector<vector<int>> B(H, vector<int>(W)); cin >> B;

        rep(y, H+1) rep(x, W+1) rep(i, IMAX) dp[y][x][i] = false;
        dp[0][0][IC] = true;
        rep(y, H) {
            rep(x, W) {
                int diff = A[y][x] - B[y][x];
                rep(i, IMAX) {
                    if(dp[y][x][i]) {
                        dp[y + 1][x][i + diff] = true;
                        dp[y + 1][x][i - diff] = true;
                        dp[y][x + 1][i + diff] = true;
                        dp[y][x + 1][i - diff] = true;
                    }
                }
            }
        }
        int ans = INF;
        rep(i, IMAX) {
            if(dp[H][W-1][i]) set_min(ans, abs(i - IC));
            if(dp[H-1][W][i]) set_min(ans, abs(i - IC));
        }
        cout << ans << endl;
        return 0;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    Solver s;
    s.solve();
    return 0;
}


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

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

using namespace std;

using ll = long long;
using P = pair<int , int>;
  
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  int n; cin >> n;
  string s; cin >> s;
  rep(i, s.size()) {
    cout << char('A' + (s[i]+n-'A')%26);
  }
}


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


/* エイリアス */
#define ll long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vpi vector<pii>
#define vpll vector<pll>
#define endl '\n'

#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define em emplace


/* 関数マクロ */
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep2(i, n, m) for (ll i = n; i <= m; ++i)
#define rep3(i, n, m) for (ll i = n; i >= m; --i)
#define all(v) v.begin(), v.end()
#define si(v) int(v.size())
#define UNIQUE(v) sort(all(v)), v.erase(unique(all(v)),v.end())


/* 定数 */
const ll mod = 1e9 + 7;
const ll infll = (1LL << 62) - 1;
const ll inf = (1LL << 30) - 1;


/* その他 */
template<class S, class T> inline bool chmax(S &a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class S, class T> inline bool chmin(S &a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> using pq = priority_queue<T>;
template<class T> using pqg = priority_queue<T, vector<T>, greater<T>>;


signed main()
{
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);
  
  ll n, m; cin >> n >> m;
  ll v = m / n;

  while (v >= 1) {
    ll x = v * n;
    ll a = m - x;

    if (x <= m && a % v == 0) {
      cout << v << endl;
      return 0;
    }

    --v;
  }
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
#define int           long long
#define pb            push_back
#define ppb           pop_back
#define si            set <int>
#define endl          '\n'
#define fr            first
#define sc            second
#define mii           map<int ,int >
#define msi           map<string,int >
#define mis           map<int , string>
#define mci       	  map<char,int>  	
#define rep(i,a,b)    for(int  i=a;i<b;i++)
#define repr(i,a,b)	  for(int i=b-1;i>=a;i--)
#define trav(it,v)	  for(auto it=v.begin();it!=v.end();it++)
#define all(v)        v.begin(),v.end()
#define srt(v)        sort(all(v))
#define pii           pair<int ,int >
#define vi            vector<int >
#define vii           vector<pair<int , int >>
#define vs            vector<string>
#define sz(x)         (int )x.size()
#define M             1000000007
#define bs            binary_search
#define mp            make_pair
#define sp(n)         setprecision(n)
#define spl           " "
#define arr(a,n)      rep(i,0,n) cin>>a[i]
#define mod           998244353
#define MAXN   		  1000000
#define f(n) for(int i=0;i<n;i++)
using namespace std;
 
//vector<int> adj[101];
int prime[10000000]={0};
int vis[150001]={0};
//int visi[101][101]={0};
 
bool sortinrev(const pair<int,int> &a,  
               const pair<int,int> &b) 
{ 
       return (a.first > b.first); 
} 
 
int isPrime(int n) 
{ 
 
    if (n <= 1) 
        return 0; 
  
    for (int i = 2; i < n; i++) 
        if (n % i == 0) 
            return 0; 
  
    return 1; 
} 

int power(int x, unsigned int y, int p) 
{ 
    int res = 1; 
  
    x = x % p;  
  
    while (y > 0) 
    {
        if (y & 1) 
            res = (res*x) % p; 
  
        y = y>>1; 
        x = (x*x) % p;   
    } 
    return res; 
} 

 
 
 
void solve()
{
	int n,ans=1;
	cin>>n;
	string s;
	cin>>s;
	char c;
	c=s[0];
	rep(i,1,n)
	{
		if(s[i]==c)
			continue;
		else
		{
			c=s[i];
			ans++;
		}
	}
	cout<<ans;



 
}
 
 
 
signed main()
{
		ios_base::sync_with_stdio(false);
		cin.tie(0);
		cout.tie(0);
		/*#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
		#endif*/
		int t=1;
		//cin>>t;
		while(t--)
			solve();
		return 0;
}
 

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <string>
#include <stack>
#include <iomanip>
#include <numeric>
#include <queue>
#include <climits>
#include <complex>
#include <cmath>
#include <map>
using namespace std;
using ll = long long;
#define MOD 1000000007
#define INF 1LL << 59

bool sieve[100010];
int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    //cout << fixed << setprecision(3);

    for (int i = 0; i < 100010; ++i)
        sieve[i] = true;

    sieve[0] = sieve[1] = false;

    for (int i = 2; i * i < 100010; ++i)
    {
        if (sieve[i])
        {
            for (int j = 2; i * j < 100010; ++j)
            {
                sieve[i * j] = false;
            }
        }
    }
    int n;
    while (cin >> n)
    {
        for (int i = n - 1; i >= 0; --i)
        {
            if (sieve[i])
            {
                cout << i << " ";
                break;
            }
        }
        for (int i = n + 1; i < 100010; ++i)
        {
            if (sieve[i])
            {
                cout << i << endl;
                break;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3176
//g++ -std=c++14 test.cpp -o test.out

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <map> 
#include <unordered_map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

//https://github.com/atcoder-live/library/blob/master/mint.cpp
#define LL long long int
struct mint {
  LL x; 
  mint(LL x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(LL t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};
 
struct combination {
  vector<mint> fact, ifact;//factに階乗を計算、ifactはその各々に対する逆元
  combination(LL n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (LL i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (LL i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(LL n,LL k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

//xを素因数分解する
//例えば60 = 5*3*2*2 であれば[(5,1),(3,1),(2,2)]を返す
vector<pair<LL,LL>> factorial(LL x){
	vector<pair<LL,LL>> ret;
	for(LL i=2;i*i<=x;i++){
		if(x%i==0){
			LL counter = 0;
			while(1){
				if(x%i!=0) break;
				x /= i;
				counter++;
			}
			ret.push_back(make_pair(i,counter));
		}
	}
	if(x!=1) ret.push_back(make_pair(x,1));
	return ret;
}

LL N,M;

mint ans = 1;

void solve(){
	combination c(200000);
	vector<pair<LL,LL>> div = factorial(M);
	for(int i=0;i<div.size();i++){
		//各約数について仕切りを入れて配置法の数を考えていく
		LL num = div[i].second;//約数の数
		ans *= c(num+N-1,num);
	}
}

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

    solve();

    cout << ans.x << endl;
    return 0;
}

Measured memory_bytes: 3328
import sys
from fractions import gcd

input=sys.stdin.readline

N,K=map(int,input().split())
A=list(map(int,input().split()))

g=A[0]
for i in range(0,N):
    g=gcd(g,A[i])

m=max(A)
if K%g==0 and m>=K:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Measured memory_bytes: 84332
N, W = map(int, input().split())

w, v = [0] * N, [0] * N

for i in range(N):
	w[i], v[i] = map(int, input().split())

dp = [[0] * (W + 1) for _ in range(N + 1)]

for i in range(N):
	for j in range(W + 1):
		if j - w[i] >= 0:
			dp[i + 1][j] = max(dp[i][j], dp[i][j - w[i]] + v[i])
		else:
		    dp[i + 1][j] = dp[i][j] 

print(dp[N][W])

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

#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 ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000000
#define MOD 1000000007
#define MAXR 100000
#define _GLIBCXX_DEBUG

int threemax(int a, int b, int c) {
	if (a >= b && a >= c) {
		return a;
	}
	else if (b >= a && b >= c) {
		return b;
	}
	else {
		return c;
	}
}

int threemin(int a, int b, int c) {
	if (a <= b && a <= c) {
		return a;
	}
	else if (b <= a && b <= c) {
		return b;
	}
	else {
		return c;
	}
}

void chmaxl(ll &a,ll b){
	if(a<b){
		a=b;
	}
	return;
}

void chminl(ll &a,ll b){
	if(a>b){
		a=b;
	}
	return;
}

void chmaxi(int &a,int b){
	if(a<b){
		a=b;
	}
	return;
}

void chmini(int &a,int b){
	if(a>b){
		a = b;
	}
	return;
}



int main() {
  string S,T;
  cin >> S >> T;
  
  int ans = T.size();
  
  for(int i=0;i<=S.size()-T.size();i++){
    int dif = 0;
    for(int j = 0;j<T.size();j++){
      if(T.at(j)!=S.at(i+j)){
        dif++;
      }
    }
    ans = min(ans,dif);
  }
  cout << ans;
}

Measured memory_bytes: 3604
#include <iostream>
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <string>
#include <algorithm>
#include <time.h>
#include <assert.h>

using namespace::std;

int ri()
{
        int x;
        scanf("%d", &x);

        return x;
}

int64_t ri64()
{
        int64_t x;
        scanf("%lld", &x);

        return x;
}

void wi(int x)
{
        printf("%d\n", x);
}

void wi64(int64_t x)
{
        printf("%lld\n", x);
}

int main()
{
        int N = ri();

        vector<int64_t> A(N);
        int64_t sm = 0;

        for (int i = 0; i < N; i++)
        {
                A[i] = ri64();
                sm += A[i];
        }

        int64_t ans = -1;
        int64_t curr = 0;
        int64_t rem = sm;

        for (int i = 0; i < (N - 1); i++)
        {
                curr += A[i];
                rem -= A[i];

                int64_t z = curr - rem;
                if (z < 0)
                        z = -z;

                if (ans == -1 || z < ans)
                        ans = z;
        }

        wi64(ans);
        return 0;
}


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

//1
int main(int argc, const char * argv[]) {
    int r = 0;
    int D = 0;
    int x = 0;
    cin >> r;
    cin >> D;
    cin >> x;
    for(int i = 0; i < 10; i++){
        x = r * x - D;
        cout << x << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(N: int, L: int):
    scores = [L + i   for i in range(N)]
    ans = sum(scores)
    mi = min([abs(x) for x in scores])
    if ans > 0:
        ans -= mi
    else:
        ans += mi
    print(ans)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    L = int(next(tokens))  # type: int
    solve(N, L)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <algorithm>
#include<iostream>
#include<stdio.h>
#include<iostream>
#include<stdio.h>
#include<vector>
#include<set>
#include<string>
#include<iomanip>
#include<queue>
#include<functional>
#include<cmath>
#include<map>
#define rep(i,n) for(int i=0; i<(int)n; i++)//n回繰り返す
using namespace std;
using ll = long long;
using P = pair<int, int>;
using graph = vector<vector<int>>;

int N;
string S;
map<string, int> cnt;
int main() {
    cin >> N;
    rep(i, N) {
        cin >> S;
        cnt[S] ++;
    }
    int maxn = 0;
    for (const auto& n : cnt) {
        maxn = max(maxn, n.second);
    }
    for (const auto& n : cnt) {
        if (n.second == maxn) {
            cout << n.first << endl;
        }
    }
}

Measured memory_bytes: 25216
// itne me hi thakk gaye?
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize ("-O3")
#define ll long long 
#define ull unsigned long long
using ld = long double;
const ll mod = 1e9 + 7;
const ll inf = 1e18;
const ll rk = 256;
const ld PI = 3.141592653589793;
#define pb push_back
#define mp make_pair
#define vc vector
#define fs first
#define sec second
#define pq priority_queue
#define lb lower_bound
#define ub upper_bound
#define pll pair<ll,ll> 
#define pls pair<ll,string>
#define psl pair<string,ll>
#define plc pair<ll,char>
#define pcl pair<char,ll>
#define pss pair<string,string>
#define all(x) (x).begin(), (x).end()
#define tol(s) transform(s.begin(),s.end(),s.begin(),::tolower);
#define tou(s) transform(s.begin(),s.end(),s.begin(),::toupper);
#define print(a) for(auto j:a) {cout<<j<<",";} cout << "\n";
#define endl '\n'
#define whatis(x) cout << "> "<<#x << " ==> " << x << endl;
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
 
// // Printing pair
ostream & operator << (ostream & os, pair <ll, ll> const& x) {
    os << x.first << "," << x.second;
    return os;
}
 
// printing vector
template <class T>
ostream & operator << (ostream & os, vector <T> const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ";
    return os << "}";
}
 
// printing set
template <class T>
ostream & operator << (ostream & os, set <T> const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ";
    return os << "}";
}
 
template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ";
    return os << "}";
}
 
template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) {
    return os << "[ " << p.first << ", " << p.second << "]" ;
}
const int mxn = 1e5+5;
int32_t main(){
    FastIO;
    int n; cin >> n;
    vc <double> arr(n);
    for(int i=0; i<n; i++) cin >> arr[i];
    vc < vc <double> > dp(n+1, vc <double> (n+1,0));
    dp[0][0] = 1;
    for(int i=1; i<=n; i++) {
        dp[i][i] = dp[i-1][i-1] * arr[i-1];
        dp[i][0] = dp[i-1][0] * (1- arr[i-1]);
    }
    for(int i=1; i<= n; i++) {
        for(int j=1; j<=i; j++) {
            dp[i][j] = (dp[i-1][j-1] * arr[i-1]) + (dp[i-1][j] * (1-arr[i-1]));
        }
    }
    double ans = 0;
    for(int i=n/2+1; i<=n; i++) {
        ans += dp[n][i];
    }
    cout << setprecision(10) << ans << endl;
    return 0;
}


Measured memory_bytes: 70784
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <climits>

void testprint(std::vector<long long> & input)
{
    int size = input.size();
    for(int i = 0; i < size ; i ++)
    {
        std::cout<<input[i]<<std::endl;
    }
}

long long min_search(std::vector<long long> & input)
{
    int size = input.size();

    long long min = LLONG_MAX;

    for(int i = 0 ; i < size ; i ++)
    {
        if(input[i] <= min)
        {
            min = input[i];
        }
    }

    return min;
}

int main(void)
{

     int N, X;
    std::cin >> N >> X;
    std::vector<long long> p(N);
    for (int i = 0; i < N; i++)
    {
        std::cin >> p[i];
  }
  

  std::vector<long long> distance (N);

  for(int i = 0 ; i < N ; i ++)
  {
      distance[i] = std::abs(p[i] - X);
  }

  long long min ;

  min = min_search(distance);

    long long object = 0;
    int check = 1;
    int Q = 0;


  for (int i = 1 ; i <= min ; i ++)
  {

      if(min%i == 0)
      {
      Q = min/i;
      check = 1;

      for (int j = 0 ; j <N ; j ++)
      {
        if(distance[j] % (long long)(Q) != 0)
        {
            check = 0;
        }
      }

      if(check == 1)
      {
          object = Q;

          break;
      }

      
    }
  }

    std::cout<<object<<std::endl;

    fflush(stdout);

  return 0;
}

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

#ifdef DEBUG
#define debug(...) fprintf(stderr, __VA_ARGS__)
#else
#define debug(...)
#endif

#ifdef __WIN32
#define LLFORMAT "I64"
#define Rand() ((rand() << 15) + rand())
#else
#define LLFORMAT "ll"
#define Rand() (rand())
#endif

using namespace std;

const int maxn = 3e5 + 10;

int n, L, x[maxn], t[maxn], L2, cnt1, cnt2, cnt12, new_cnt2, lst;
bool f1[maxn], f2[maxn];
long long ans;

int main() {
	scanf("%d%d", &n, &L);
	L2 = L * 2;
	for (int i = 1; i <= n; ++i) {
		scanf("%d", x + i);
	}
	for (int i = 1; i <= n; ++i) {
		scanf("%d", t + i);
		ans += t[i] / L2;
		t[i] %= L2;
		if(!t[i]) {
			--ans;
			t[i] = L2;
		}
		f1[i] = 2 * (L - x[i]) >= t[i];
		f2[i] = 2 * x[i] >= t[i];
		if(f1[i]) {
			lst = i;
			if(cnt1) {
				if(!cnt2) {
					--cnt1;
					++cnt2;
					if(cnt12) {
						--cnt12;
						++cnt2;
					}
				}
				--cnt2;
			}
			++cnt1;
			if(f2[i]) {
				++cnt12;
			}
			cnt2 += new_cnt2;
			new_cnt2 = 0;
		}
		else if(f2[i]) {
			++new_cnt2;
		}
		debug("%d %d\n", f1[i], f2[i]);
		debug("%d %d %d\n", cnt1, cnt2, cnt12);
	}
	debug("%d %d\n", cnt1, cnt2);
	if(cnt1 && !cnt2 && cnt1 * 2 - 1 < n && lst < n) {
		--cnt1;
	}
	ans += cnt1 * 1 + (n - cnt1) * 2 - (n - 1);
	printf("%"LLFORMAT"d\n", ans * L2);
	return 0;
}


Measured memory_bytes: 3200
import java.util.*;

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

        String A =scanner.next();
        String B =scanner.next();

        Long t = Long.parseLong(A+B);


        HashSet<Long> hashSet = new HashSet<>();
        for(int i=1; i<1000; i++){
            hashSet.add((long)i * (long)i);
        }

        if(hashSet.contains(t)){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }


    }
}


Measured memory_bytes: 22612
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;

int X, Y, A, B, C;
//vector<int> red, green, colorless;
priority_queue<pii> pq;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> X >> Y >> A >> B >> C;
//	red.resize(A), green.resize(B), colorless.resize(C);
	for (int i = 0; i < A; i++) {
		int a; cin >> a;
		pq.push({ a, 2 });
	}
	for (int i = 0; i < B; i++) {
		int a; cin >> a;
		pq.push({ a, 1 });
	}
	for (int i = 0; i < C; i++) {
		int a; cin >> a;
		pq.push({ a, 0 });
	}

	int red = 0, green = 0, rest = 0;
	ll sum = 0;
	while (pq.size()) {
		if (red <= X && green <= Y && red + green + rest == X + Y) break;
		pii cur = pq.top();
		pq.pop();
		if (cur.second == 2 && red != X) {
			red++;
			sum += cur.first;
		}
		else if (cur.second == 1 && green != Y) {
			green++;
			sum += cur.first;
		}
		else if (cur.second == 0){
			rest++;
			sum += cur.first;
		}
	}
	cout << sum << '\n';
	return 0;
}

Measured memory_bytes: 6512
#include<bits/stdc++.h>
#define start_routine cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false); int begtime = clock();
#define end_routine int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0;
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define int long long
#define mp make_pair
#define fr(i,a,b) for(i=a;i<b;i++)
#define inf 1000000007
#define FILEIO freopen("C:/Users/Aman/Desktop/kachda/input.txt", "r", stdin); freopen("C:/Users/Aman/Desktop/kachda/output.txt", "w", stdout);

using namespace std;
int n,W, dp[101][100001], w[101], v[101];

signed main()
{
	//FILEIO
 	start_routine

	cin>>n>>W;
	int i;
	fr(i,1,n + 1)
	{
		cin>>w[i]>>v[i];
	}

	int j;
	memset(dp, inf, sizeof dp);

	dp[1][v[1]] = w[1];

	dp[1][0] = 0;

	fr(i,2,n + 1)
	{
		fr(j,0,100001)
		{
			dp[i][j] = dp[i - 1][j];
			if(j >= v[i])
			{
				dp[i][j] = min(dp[i][j], dp[i - 1][j - v[i]] + w[i]);
			}
		}
	}
	

	int ans = 0;
	fr(i,1,100001)
	{
		if(dp[n][i] <= W) ans = i;
	}
	cout<<ans<<'\n';
	
 	end_routine
}

Measured memory_bytes: 79232
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
from collections import deque
from fractions import gcd
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#############
# Main Code #
#############

A,B,C = inputIL()

print(min(C,B//A))

Measured memory_bytes: 64876
class PriorityQueue
  
  def initialize
    @heap = Array.new
    @sz = 0
  end
  
  def push x
    i = @sz
    @sz += 1
    while i > 0 do
      p = ( i - 1 ) / 2
      break if @heap[p] <= x
      @heap[i] = @heap[p]
      i = p
    end
    @heap[i] = x
  end
  
  def pop
    
    ret = @heap[0]
    x = @heap[@sz-=1]
    
    i = 0
    while i * 2 + 1 < @sz do
      a = i * 2 + 1
      b = i * 2 + 2
      a = b if b < @sz && @heap[b] < @heap[a]
      break if @heap[a] >= x
      @heap[i] = @heap[a]
      i = a
    end
    
    @heap[i] = x
    @heap.delete_at(-1)
    ret
  end
  
  def top
    @heap[0]
  end
  
  def empty?
    @sz == 0
  end
  
  def all
    @heap
  end
end

N = gets.to_i
A = gets.split.map(&:to_i)

fpq = PriorityQueue.new
spq = PriorityQueue.new

f_sum = Array.new( N + 1 )
s_sum = Array.new( N + 1 )

fa = A[0, N]
sa = A[2 * N, N]

f_sum[0] = fa.inject(:+)
s_sum[0] = sa.inject(:+)

A[0, N].each do |a|
  fpq.push( a )
end

N.times do |i|
  a = A[N+i]
  fpq.push( a )
  m = fpq.pop
  f_sum[i+1] = f_sum[i] + a - m
end

# p f_sum

A[2 * N, N].each do |a|
  spq.push( -a )
end

N.times do |i|
  a = A[2*N-i-1]
  spq.push( -a )
  m = -spq.pop
  s_sum[i+1] = s_sum[i] + a - m
end

s_sum.reverse!

ans = nil
(N+1).times do |i|
  v = f_sum[i] - s_sum[i]
  ans = v if ans.nil?
  ans = v if ans < v
end

puts ans


Measured memory_bytes: 26344
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<string.h>
using namespace std;
int main()
{
	int a,b,x,A,B;
	cin >>x>>a>>b;
		A=abs(x-a);
	B=abs(x-b);
	if(A>B)
	cout<<"B";
	else
	cout<<"A";
	return 0;
 }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long aa[100000];
int main()
{
	int a,b,c,d,e,f,g=0;
	cin>>a>>b>>c;
	if(a==b&&b==c&&a%2==0){
		cout<<"-1"<<endl;
		return 0;
	}
	while(a%2==0&&b%2==0&&c%2==0){
		d=a/2;e=b/2;f=c/2;
		a=e+f;b=d+f;c=d+e;
		g++;
	}
	cout<<g<<endl;
}

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

int main(){
	// sengen
	long long n;
	// nyuryoku
	cin >> n;
	long long a[n];
	long long c[n] = {};
	for(long i=1;i<n;i++){
		cin >> a[i];
		c[a[i]-1]++;
	}
	// keisan
	for(long i=0;i<n;i++){
		cout << c[i] << endl;
	}
	// syutsuryoku
}

Measured memory_bytes: 6760
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;

template<typename T, typename Q>
istream &operator>>(istream &is, pair<T, Q> &p) {
	return is >> p.first >> p.second;
}

template<typename T>
istream &operator>>(istream &is, vector<T> &v) {
	for (auto &x : v) is >> x;
	return is;
}

template<typename T, typename Q>
ostream &operator<<(ostream &os, pair<T, Q> p) {
	return os << "(" << p.first << ", " << p.second << ")";
}

template<typename T>
ostream &operator<<(ostream &os, vector<T> v) {
	os << "[";
	for (auto it = v.begin(); it != v.end(); it++)
		os << (it == v.begin() ? "" : ", ") << *it;
	return os << "]";
}

template<typename T, typename Q>
ostream &operator<<(ostream &os, map<T, Q> m) {
	os << "[";
	for (auto it = m.begin(); it != m.end(); it++) 
		os << (it == m.begin() ? "" : ", ") << *it;
	return os;
}
#define imie(...) " [" << #__VA_ARGS__": " << (__VA_ARGS__) << "] "

int main() {
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n, l; cin >> n >> l;
	long long sum = 0;
	for (int i = 1; i <= n; i++) {
		sum += l + i - 1;
	}
	long long ans = 1e18;
	long long ans2;
	for (int i = 1; i <= n; i++) {
		if (ans > abs(sum - (sum - (l + i - 1)))) {
			ans = abs(sum - (sum - (l + i - 1)));
			ans2 = sum - (l + i - 1);
		}
	}
	cout << ans2 << '\n';
}


Measured memory_bytes: 3544