akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str();}
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = INT_MAX/10;

const int MAX_V = 1000;

int V;
vvi G(MAX_V, vi());
vi match(MAX_V);
vi used(MAX_V);

void add_edge(int u, int v) {
	G[u].push_back(v);
	G[v].push_back(u);
}

bool dfs(int v) {
	used[v] = 1;
	int size = G[v].size();
	REP(i, size) {
		int u = G[v][i], w = match[u];
		if(w < 0 || !used[w] && dfs(w)) {
			match[v] = u;
			match[u] = v;
			return true;
		}
	}
	return false;
}

int bipartite_matching() {
	int res = 0;
	REP(i, MAX_V) {
		match[i] = -1;
	}
	REP(i, V) {
		if(match[i] < 0) {
			REP(j, MAX_V) {
				used[j] = 0;
			}
			if(dfs(i)) {
				res++;
			}
		}
	}
	return res;
}

int gcd(int a, int b) {
	if(b == 0) return a;
	return gcd(b, a%b);
}

int main() {
	int m, n;
	while(cin >> m >> n, m) {
		V = m+n;
		REP(i, MAX_V) {
			G[i].clear();
			match[i] = -1;
			used[i] = 0;
		}
		vi a(m), b(n);
		REP(i, m) {
			cin >> a[i];
		}
		REP(i, n) {
			cin >> b[i];
		}
		REP(i, m) {
			REP(j, n) {
				if(gcd(a[i], b[j]) != 1) {
					add_edge(i, m+j);
				}
			}
		}
		cout << bipartite_matching() << endl;
	}

	return 0;
}

Measured memory_bytes: 3424
import java.util.*;

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int otherN = N + 1;
    
    int noTax = (int)Math.round(N / 1.08);
    int otherNoTax = (int)Math.round(otherN / 1.08);
    int inTax = (int)Math.floor(noTax * 1.08);
    int otherInTax = (int)Math.floor(otherNoTax * 1.08);
    if(inTax == N) {
      System.out.println(noTax);
    } else if(otherInTax == N) {
      System.out.println(otherNoTax);
    } else {
      System.out.println(":(");
    }
  }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    int n;
    cin>>n;
    vector<int>a(n);
    rep(i,n)cin>>a[i];
    int ans=1;
    bool u=false,d=false;
    for(int i=0; i<n-1; ++i){
        if(a[i]<a[i+1])u=true;
        if(a[i]>a[i+1])d=true;
        if(u&d)u=false,d=false,ans++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 640
import java.util.Arrays;
import java.util.Scanner;

public class Main {

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

		
		while(sc.hasNext()){
			Arrays.fill(couner, 0);
			f=true;
			while(true){
				a=sc.nextInt();
				b=sc.nextInt();
				if(a+b==0){
					break;
				}
				couner[a]++;
				couner[b]++;
			}
			if(couner[1]%2==0) f=false;
			if(couner[2]%2==0) f=false;
			for(int i=3;i<101;i++){
				if(couner[i]%2!=0){
					f=false;
					break;
				}
			}
			if(f){
				System.out.println("OK");
			}
			else{
				System.out.println("NG");
			}
		}
	}
}

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

int main(){
 
 int N;
 cin >> N;
 int D[2][N];
 for(int i=0; i<N ; i++){
   cin >> D[0][i] >> D[1][i];
 }
  
  int res=0;
  int key=0;
   for(int i=0; i<N ; i++){
   if(D[0][i]==D[1][i]) ++res;
   else res=0;
   if(res==3)break;
 }

  if (res==3) cout << "Yes";
  else cout << "No";

  
}

Measured memory_bytes: 3104
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   all(a) (a.begin(),a.end())
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

int n,ans=0; 
int h[3]={3,5,7}; 

bool helper(int n){
    set<int> s;
    while (n){
        s.insert(n%10);
        n /= 10;
    }
    return  (sz(s)==3);
}

void fun(int num){ 
    if (num>n)  return ; 
    if (helper(num)) ans++;
    for (int i=0;i<3;i++){ 
        fun(num*10+h[i]); 
    } 
} 

inline void solve(){
    ans = 0;
    cin >> n ; 
    fun(0);
    cout << ans << endl;
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


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

using namespace std;
/**
********************************************************************
******************* Author:Bisnu sarkar ****************************
********************************************************************
**/

#define ull            unsigned long long
#define ll             long long
#define vi             vector<int>
#define pb             push_back
#define mp             make_pair
#define pii            pair<int,int>
#define vit            vector<int> :: iterator
#define sit            set<int> :: iterator
#define vrit           vector<int> :: reverse iterator
#define ff             first
#define ss             second

#define what_is(x)     cerr << #x << " is " << x << endl;

///*....Debugger....*/

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it)
{
    cout << endl ;
}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
    cerr << *it << " = " << a << ' ' ;
    err(++it, args...);
}

int dx[8]= {1,0,-1,0,-1,-1,1,1};
int dy[8]= {0,1,0,-1,-1,1,-1,1};
int ini()
{
    int x;
    scanf("%d",&x);
    return x;
}
long long inl()
{
    long long x;
    scanf("%lld",&x);
    return x;
}

const int N = (int) 1e6 + 5;
const int M = (int) 1e9 + 7;
const double pi=2* acos(0.0);
string s;
int main()
{
  cin>>s;
  ll k;
  cin>>k;
  ll sum=0;
  for(int i=0;s[i];i++){
    int n=(s[i]-'0');
    if(n==1){
      sum+=1ll;
    }
    else{
      cout<<s[i]<<endl;
      return 0;
    }

    if(sum >= k){
      cout<<s[i]<<endl;
      break;
    }
  }

   return 0;
}


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

int calc(string &s,int &i){
  int res=0;
  while(1){
    if(isdigit(s[i]))res=s[i++]-'0';
    else if(s[i]=='('){res=calc(s,++i),i++;}
    else if(s[i]=='+')res+=calc(s,++i);
    else if(s[i]=='-')res-=calc(s,++i);
    else break;
  }
  return res;
}

unordered_map<string,int> mem[2];
int dfs(string s,int f){
  if(mem[f].count(s))return mem[f][s];

  int j=0,res=calc(s,j),n=s.size(),d=-1;
  for(int i=0;i<n;i++) d+=(s[i]=='+'||s[i]=='-');
  
  for(int i=0,c=0,cnt=0;i<n;i++,cnt++,d--){
    while(1){
      while(s[i]=='('||s[i]==')')c+=(s[i]=='(')-(s[i]==')'),i++;
      if(i>=n||s[i]=='+'||s[i]=='-') break;
      i++;
    }
    if(i>=n||(cnt&&s[i-2]=='(')||(d&&s[i+2]==')'))continue;
    string a=s.substr(0,i),b=s.substr(i+1,n-i-1);
    int t=c,ch=s[i];
    while(t--)a+=')',b='('+b;
    int mxa=dfs(a,0),mna=dfs(a,1);
    int mxb=dfs(b,0),mnb=dfs(b,1);
    if(f==0&&ch=='+') res=max(res, mxa+mxb);
    if(f==0&&ch=='-') res=max(res, mxa-mnb);
    if(f==1&&ch=='+') res=min(res, mna+mnb);
    if(f==1&&ch=='-') res=min(res, mna-mxb);
  }
  return mem[f][s]=res;
}

int main(){
  string S;
  cin>>S;
  cout <<dfs(S,0)<<endl;
  return 0;
}

Measured memory_bytes: 4444
n=int(input())
if n==2:
  print(1)
  exit()
nn=n-1
ans=set([nn])
for i in range(2,int(nn**0.5)+1):
  if nn%i==0:
    ans.add(i)
    ans.add(nn//i)
l=set()
l.add(n)
for i in range(2,int(n**0.5)+1):
  if n%i==0:
    l.add(i)
    l.add(n//i)
for j in l:
  m=n
  while m%j==0:
    m//=j
  if m%j==1:
    ans.add(j)
print(len(ans))

Measured memory_bytes: 40044
#include <iostream>

using namespace std;

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

Measured memory_bytes: 3620
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <algorithm>
#include <set>
#include <vector>
#include <queue>
#define pb push_back
using namespace std;
typedef pair<int,int> pii;

int main(){
  int a,b;
  cin>>a>>b;
  if(a+b==15) cout<<"+"<<endl;
  else if(a*b==15) cout<<"*"<<endl;
  else cout<<"x"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
using namespace std;
int n, k;
long long int a[200005], s[200005], ps = 0;
const long long MOD = 1e9 + 7;
int main() {
  scanf("%d %d", &n, &k);
  long long res = 1;
  for (int i = 0; i < n; ++i) {
    scanf("%lld", &a[i]);
  }
  sort(a, a + n);

  if (k % 2) {
    res = a[n - 1];
    int w = res > 0 ? 1 : -1;
    int l = 0, r = n - 2, cnt = 1;
    while (cnt < k && l < r) {
      if (w * a[l] * a[l + 1] > w * a[r] * a[r - 1]) {
        s[ps++] = a[l++];
        s[ps++] = a[l++];
        cnt += 2;
      } else {
        s[ps++] = a[r--];
        s[ps++] = a[r--];
        cnt += 2;
      }
    }
  } else {
    res = 1;
    int l = 0, r = n - 1, cnt = 0;
    while (cnt < k && l < r) {
      if (a[l] * a[l + 1] > a[r] * a[r - 1]) {
        s[ps++] = a[l++];
        s[ps++] = a[l++];
        cnt += 2;
      } else {
        s[ps++] = a[r--];
        s[ps++] = a[r--];
        cnt += 2;
      }
    }
  }
  for (int i = 0; i < ps; ++i) {
    res = (1l * (s[i] % MOD) * (res % MOD) + MOD) % MOD;
  }
  res = (res % MOD + MOD) % MOD;
  printf("%lld\n", res);
  return 0;
}


Measured memory_bytes: 4860
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
using namespace std;
char a[1005];
unsigned long long k,n,tmp,len;
int main(){
	scanf("%s",a+1);
	cin>>k;
	len=strlen(a+1);
    for(unsigned long long i=1;i<=k;i++){
    	if(a[i]!='1'){
    		printf("%d\n",a[i]-'0');
    		return 0;
		}
	}
	printf("1");
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
using namespace std;

int main()
{
    fastio;
    int A, B, M;
    vector<int> as, bs, xs, ys, cs;
    cin >> A >> B >> M;
    copy_n(istream_iterator<int>(cin), A, back_inserter(as));
    copy_n(istream_iterator<int>(cin), B, back_inserter(bs));
    for (int i = 0; i < M; ++i)
    {
        int x, y, c;
        cin >> x >> y >> c;
        xs.push_back(x);
        ys.push_back(y);
        cs.push_back(c);
    }

    vector<int> plices;
    for (int i = 0; i < M; ++i)
    {
        // 割引セットの値段
        plices.push_back(as[xs[i] - 1] + bs[ys[i] - 1] - cs[i]);
    }

    auto min_a = *min_element(as.begin(), as.end());
    auto min_b = *min_element(bs.begin(), bs.end());

    // 割引を使わない最も安い組み合わせ
    plices.push_back(min_a + min_b);

    cout << *min_element(plices.begin(), plices.end()) << endl;

    return 0;
}


Measured memory_bytes: 2936
package main

import (
	"fmt"
	"os"
)

func main() {
	var b string
	fp := os.Stdin

	fmt.Fscan(fp, &b)
	switch b {
	case "A":
		fmt.Println("T")
	case "C":
		fmt.Println("G")
	case "G":
		fmt.Println("C")
	case "T":
		fmt.Println("A")
	}
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>
#include <ctime>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cassert>
#include <bitset>
#include <list>
#include <cstdio>
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <cmath>
#define rep(i,m,n) for(int i=m; i<(n); i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
typedef long long ll;
using namespace std;

const int INF = 1001001001;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x, y;
    cin >> x >> y;
    int a, b, c;
    cin >> a >> b >> c;
    vector<int> p(a), q(b), r(c);
    rep(i,0,a) cin >> p[i];
    rep(i,0,b) cin >> q[i];
    rep(i,0,c) cin >> r[i];
    sort(p.rbegin(), p.rend());
    sort(q.rbegin(), q.rend());
    vector<int> d;
    rep(i,0,x) d.push_back(p[i]);
    rep(i,0,y) d.push_back(q[i]);
    rep(i,0,c) d.push_back(r[i]);
    sort(d.rbegin(), d.rend());
    ll ans = 0;
    rep(i,0,x+y) ans += d[i];
    cout << ans << endl;
    return 0;
}


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

int main() {
	ios_base::sync_with_stdio(false);
	int N; cin >> N;

	vector<int> players(N);
	for (int &x: players)
		cin >> x;

	sort(players.rbegin(), players.rend());

	int64_t ans = 0;
	for (int i = 0, t = 0; t < N - 1; i += (++t & 1))
		ans += players[i];

	cout << ans << endl;
}


Measured memory_bytes: 4056
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main(){
    int N,M,X;
    cin>>N>>M>>X;
    vector<int>A(M);
    for(int i=0;i<M;i++){
        cin>>A.at(i);
    }
    int sumb=0;int sums=0;

        for(int j=0;j<M;j++){
         if(A.at(j)<X){sums++;}
         else{sumb++;}
    }
    cout<<min(sumb,sums)<<endl;
   
    return 0;
}

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

int main(){
    int a,b,k;
    cin >> a >> b >> k;
    if((b-a)<k*2){
        for(int i=a; i<=b; i++)
        cout << i << endl;
    }
    else{
        for(int i=a; i<a+k; i++)
        cout << i << endl;
        for(int i=b-k+1; i<=b; i++)
        cout << i << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <string>

using namespace std;

int main() {

	string w;
	cin >> w;

	int A[26] = {};

	for (int i = 0; i < w.size(); i++) {
		A[w[i] - 'a']++;
	}

	for (int i = 0; i < 26; i++) {
		if (A[i] % 2 != 0) {
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define MAX(x,y) ((x>y)?x:y)

int comp(const void *a,const void *b){
	return *(int *)a-*(int *)b;
}
int a[65005];
int b[65005];
int main(){
	int n,i;
	long long ans,sum;
	
	while(1){
		scanf("%d",&n);
		if(n==0)break;
		ans=sum=0;
		for(i=0;i<n;i++){scanf("%lld",&a[i]);sum+=a[i];}
		for(i=0;i<n-1;i++){scanf("%lld",&b[i]);sum+=b[i];}
		ans=sum;
		qsort(b,n-1,sizeof(int),comp);
		for(i=0;i<n-1;i++){
			sum-=b[i];
			ans=MAX(ans,sum*(i+2));
			//printf("%d %lld\n",b[i],ans);
		}
		printf("%lld\n",ans);
	}
	
	return 0;
}

Measured memory_bytes: 1288
#include<stdio.h>
int main(){
    int x;
    scanf("%d",&x);
    x=x%7;
    if(x==0)printf("thu\n");
    if(x==1)printf("fri\n");
    if(x==2)printf("sat\n");
    if(x==3)printf("sun\n");
    if(x==4)printf("mon\n");
    if(x==5)printf("tue\n");
    if(x==6)printf("wed\n");
    return 0;
}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const int N=2e5+5;

void solve()
{	
	string str;
	cin>>str;
	for(int i=0;i<=2;i++)
		cout<<str[i];
}

int main()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	
	IOS;

	int t=1;
	//cin>>t;
	while(t--)
		solve();

}

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

int main(){
    ll N; cin>>N;
    vector<ll> H(N);
    for(ll i=0;i<N;i++) cin>>H[i];
    ll n=0;
    for(ll i=0;i<N;i++){
        n=max(n,H[i]);
        if(n-H[i]>=2){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
}

Measured memory_bytes: 4052
#include<iostream>
#include<bits/stdc++.h>
#define ll long long int

using namespace std;
#define mod 1000000007

int main()
{
    ll n,budget;
    cin >> n >> budget;
    vector<pair<ll,ll> >a;
  	a.push_back({0,0});
  	ll valmax = 0;
    for(ll i = 0 ; i < n;i++)
    {
        ll wt, val;
        cin >> wt >> val;
        a.push_back({wt,val});
        valmax += val;
    }
    ll dp[a.size()][valmax+1];
    for(ll i =0;i < a.size();i++)
        dp[i][0] = 0;
    for(ll i = 1 ;i <= valmax;i++)
        dp[0][i] = INT_MAX;
    for(ll i = 1;i < a.size();i++)
    {
        for(ll j = 1;j <= valmax;j++)
        {
            dp[i][j] = dp[i-1][j];
            if(a[i].second <= j)
            {
                if(dp[i-1][j-a[i].second] != INT_MAX)
                {
                    dp[i][j] = min(dp[i][j],a[i].first + dp[i-1][j-a[i].second]);
                }
            }
        }
    }
    for(ll i = valmax;i >= 0;i--)
    {
        if(dp[a.size()-1][i] <= budget)
        {
            cout << i;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 82444
s=input()
abc="ABCD"
n=len(s)
mod=10**9+7
dp=[[0]*4 for i in range(n+1)]
dp[n][3]=1
for i in range(n-1,-1,-1):
    for j in range(4):
        if s[i]=='?' :
            if j==3:
                dp[i][j]=3*dp[i+1][j]
            else :
                dp[i][j]=3*dp[i+1][j]+dp[i+1][j+1]
        elif s[i]==abc[j]:
            if j!=3:
                dp[i][j]=dp[i+1][j]+dp[i+1][j+1]
            else :
                dp[i][j]=dp[i+1][j]
        else :
            dp[i][j]=dp[i+1][j]
        dp[i][j]%=mod
print(dp[0][0])

Measured memory_bytes: 27600
N = int(input())
PList = list(map(int, input().split()))

tmp = -1
count = 0
for i in range(0, N):
    if i == 0:
        tmp = PList[i]
        count += 1
    elif tmp > PList[i]:
        tmp = PList[i]
        count += 1
        
print(count)


Measured memory_bytes: 24744
# 2019/04/06
# AtCoder Beginner Contest 123 - B

# Input
sum = 0
cl = list()
hmin = 99
minidx = -1

for i in range(5):
    wt = int(input())
    t = int((wt + 9) / 10) * 10
    sum += t
    cl.append(wt)
    wh = wt % 10
    if wh > 0 and wh < hmin:
        hmin = wt % 10
        minidx = i

if hmin < 99:
    sum = sum - (10 - hmin)

# Output
print(sum)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define FOR(x,n) for(int x = 0; x < n; x++)
#define ALL(a) (a).begin(), (a).end()
#define FIN ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using namespace std;
typedef long long ll;

const char ROCK = 'g';
const char PAPER = 'p';

int main() {
  FIN;
  string s; cin >> s;
  cout << s.size()/2 - count(s.begin(),s.end(),PAPER) << "\n";
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>

using ll = long long;

using namespace std;

using P = pair<ll, ll>;
#define fi first
#define se second

int main() {
    int n;
    ll d, a;
    cin >> n >> d >> a;
    P mons[n];
    for (auto &mi:mons) cin >> mi.fi >> mi.se;
    sort(mons, mons+n);
    queue<P> boms;
    ll bomsum = 0, ans = 0;
    for (int i=0; i<n; i++) {
        ll xi = mons[i].fi, hi = mons[i].se;
        while (!boms.empty() && boms.front().fi < xi) {
            bomsum -= boms.front().se;
            boms.pop();
        }
        hi -= bomsum;
        if (hi <= 0) continue;
        ll cnt = (hi + a - 1) / a;
        ans += cnt;
        bomsum += cnt * a;
        boms.push({xi + 2*d, cnt*a});
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 4992
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
#include <climits>
#include <utility>

typedef long long ll;
using namespace std;

int main(void){
  string s,t;
  int n;

  cin>>n;
  cin>>s>>t;

  for(int i=0;i<n;i++){
    cout<<s[i]<<t[i];
  }

  cout<<endl;


  return 0;
}


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

int main() {
    cin.tie(0)->sync_with_stdio(false);

    int x;
    cin >> x;

    vector<bool> dp(x + 1, false);

    dp[0] = true;
    REP(i, x + 1) {
        if (i - 100 >= 0 && dp[i - 100]) dp[i] = true;
        if (i - 101 >= 0 && dp[i - 101]) dp[i] = true;
        if (i - 102 >= 0 && dp[i - 102]) dp[i] = true;
        if (i - 103 >= 0 && dp[i - 103]) dp[i] = true;
        if (i - 104 >= 0 && dp[i - 104]) dp[i] = true;
        if (i - 105 >= 0 && dp[i - 105]) dp[i] = true;
    }

    if (dp[x]) cout << 1 << '\n';
    else cout << 0 << '\n';
    return 0;
}

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

const int mex = 3005;
vector< vector<long long> > dp(mex, vector<long long>(mex, 0));
long long func(vector<int> &a , int l, int r){
	if(dp[l][r] == 0){
		if(l == r){
			return a[l];
		}
		else if(abs(l-r) == 1){
			return max(a[l], a[r]);
		}
		else{
			dp[l][r] = max(a[l]+min(func(a, l+1, r-1), func(a, l+2, r)), a[r] + min(func(a,l, r-2), func(a, l+1, r-1) ) );
			return dp[l][r];
		}
	}
	else
		return dp[l][r];
}

int main() {
	int n;
	cin >> n;
	vector<int> a(n+1);
	long long sum = 0;
	for(int i = 1; i<=n ; i++){
		cin >> a[i];
		sum += a[i];
	}
	
	long long res = func(a, 1, n);
	cout<<(2*res-sum)<<endl;
	
	return 0;
}

Measured memory_bytes: 71040
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    while(1){
        int a,b,c,d,e;
        cin>>a;
        if(a==0)break;
        cin>>b>>c>>d>>e;
        if(b<c+d*(a-1)){
            puts("NA");
            continue;
        }
        for(int i=e;1<=i;i--){
            if(a<i){
                if(c*i<=b){
                    cout<<i<<' '<<(b-c*i)/d<<endl;
                    break;
                }
            }
            else{
                if(c*i+d*(a-i)<=b){
                    cout<<i<<' '<<(b-c*i)/d<<endl;
                    break;
                }
            }
        }
    }
    return 0;
}

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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl

typedef long long ll;

using namespace std;

const int INF = 1e9,MOD = 1e9 + 7,ohara = 1e6;
const ll LINF = 1e18;
long long int n,cnt=0,ans=0,a,b,c,d,cmp,cmpp,m,h,w,x,y,sum=0,pos;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

int main(void){
  
       cin.tie(0);
    ios::sync_with_stdio(false);
      
      cin>>n>>m;
      pos=m/n;
      rrrep(i,pos,1){
        if(m%i==0){
          Cout(i);
          return 0;
        }
      }
    
       
return 0;
}


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

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define REV(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }

void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}
 
//Write From this Line

//const ll mod = 1e9+7;
//const ll mod = 998244353;
int main()
{
	int n, d;
	cin >> n >> d;
	int ans = 0;
	int dist = 0;
	while(dist < n){
		dist += (2*d+1);
		ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 3600
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx2")
#pragma GCC optimize("Os")
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);
#define FO cout.tie(NULL);
#define FI cin.tie(NULL);
#define IN cin>>
#define OUT cout<<
#define loop(i,a,n) for(int i=a; i<n; i++)
#define rloop(i,a,n) for(int i=a; i>=n; i--)
#define endl "\n";
#define pb push_back
#define mp make_pair
#define set_bits(a) __builtin_popcountll(a)
#define ll long long int
#define ld long double
#define vll vector<long long int>
#define pll pair<long long int, long long int>
#define mod 1000000007
#define M 998244353
using namespace std;
ll gcd(ll a, ll b)
{
    return (b?gcd(b,a%b):a);
}
ll P(ll B, ll power, ll modulo)
{
    ll ans=1LL;
    while(power>0LL)
    {
        if(power%2LL==1LL)
        {
            ans=(ans*B)%modulo;
        }
        B=(B*B)%modulo;
        power/=2LL;
    }
    return ans;
}
bool isPrime(ll n)
{
    if(n<=1LL)
    {
        return false;
    }
    if(n<=3LL)
    {
        return true;
    }
    if(n%2==0LL || n%3==0LL)
    {
        return false;
    }
    for(ll i=5LL; (i*i)<=n; i+=6LL)
    {
        if(n%i==0LL || n%(i+2LL)==0LL)
        {
            return false;
        }
    }
    return true;
}
void vok()
{
    FAST
    FO
    FI
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
        freopen("error.txt","w",stderr);
    #endif
}
int main()
{
    vok();
    ll n,k;
    IN n>>k;
    vll a(n);
    loop(i,0,n)
    {
        IN a[i];
    }
    sort(a.begin(),a.end());
    ll ans=1LL;
    if(a[n-1]==0 && k%2)
    {
        OUT 0<<endl
        return 0;
    }
    if(a[n-1]<=0 && k%2)
    {
        rloop(i,n-1,n-k)
        {
            ans*=a[i];
            ans%=mod;
            ans+=mod;
            ans%=mod;
        }
        ans+=mod;
        ans%=mod;
        OUT ans<<endl
        return 0;
    }
    int i=0, j=n-1;
    if(k%2)
    {
        ans*=a[j];
        ans%=mod;
        ans+=mod;
        ans%=mod;
        j--;
        k--;
    }
    k/=2;
    loop(ptr,0,k)
    {
        ll left=a[i]*a[i+1];
        ll right=a[j]*a[j-1];
        if(left>right)
        {
            left%=mod;
            left+=mod;
            left%=mod;
            ans*=left;
            ans%=mod;
            ans+=mod;
            ans%=mod;
            i+=2;
        }
        else
        {
            right%=mod;
            right+=mod;
            right%=mod;
            ans*=right;
            ans%=mod;
            ans+=mod;
            ans%=mod;   
            j-=2;
        }
    }
    ans+=mod;
    ans%=mod;
    OUT ans<<endl
    return 0;
}

Measured memory_bytes: 4784
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define debug(x) cerr << #x << ": " << x << '\n'
#define INF 999999999
typedef long long int Int;
using ll = long long;
using VI = vector<int>;

int main(){
  string s,t;cin >> s >> t;
  bool ans = false;
  for(int i=0;i<s.size();i++){
    if(s==t){
      ans = true;
      break;
    }
    s=s.back()+s.substr(0,s.size()-1);
  }
  cout << (ans?"Yes":"No") << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int totalPlayingCards = sc.nextInt();
        int numList[] = new int[totalPlayingCards];
        for(int i = 0; i<totalPlayingCards; i++){
            int PlayingCardsNum = sc.nextInt();
            numList[i] = PlayingCardsNum;
        }
        for(int i = 0; i<totalPlayingCards; i++){
            int v = numList[i];
            int j = i - 1;
            while(j >= 0 && numList[j] > v){
                numList[j+1] = numList[j];
                j--;
                numList[j+1] = v;
            }
            for(int k = 0; k<totalPlayingCards; k++){
                if(k == totalPlayingCards-1){
                    System.out.print(numList[k]);
                }else{
                    System.out.print(numList[k] + " ");
                }
            }
            System.out.println("");
        }
    }
}


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

class Program
{
	static int n;
	static int m;
	static int[] cs;
	static int[] minCounts;

	static void Main(string[] args)
	{
		string[] first = Console.ReadLine().Split();

		n = int.Parse(first[0]);
		m = int.Parse(first[1]);

		cs = Console.ReadLine().Split().Select(str => int.Parse(str)).ToArray();

		minCounts = new int[50001];

		// 1から順番に辿る
		for (int i = 1; i <= n; i++)
		{
			minCounts[i] = GetMinCounts(i);
		}
		System.Console.WriteLine(minCounts[n]);
	}

	// Kを実現する最小コイン枚数を返す
	static int GetMinCounts(int k)
	{
		// 記録済み
		if (minCounts[k] > 0) return minCounts[k];

		// コイン持っているか
		for (int ci = 0; ci < m; ci++)
		{
			if (cs[ci] == k) return 1;
		}

		// 頭と後ろからの組み合わせで最小値を計算
		int min = k;
		for (int j = 1; j < k; j++)
		{
			if (k - j < j) return min;
			int current = minCounts[k - j] + minCounts[j];
			if (current < min) min = current;
		}
		return min;
	}
}



Measured memory_bytes: 9836
uses crt;
var dp:array[0..100009,0..5] of int64;
cost:array[1..100004,1..5] of longint;
i,o,p,l,m,n,a,b,c,k:longint;
rs:int64;
function max(a,b:int64):int64;
begin
if a>b then max:=a
else max:=b;
end;
begin
rs:=-1;
read(n);
for i:=1 to n do begin
        for l:=1 to 3 do begin
                read(cost[i,l]);
                end;
        end;
for i:=1 to n do begin
        dp[1,i]:=cost[1,i];
        end;
for i:=2 to n do begin
        dp[i,1]:=max(dp[i-1,2],dp[i-1,3])+cost[i,1];
        dp[i,2]:=max(dp[i-1,3],dp[i-1,1])+cost[i,2];
        dp[i,3]:=max(dp[i-1,2],dp[i-1,1])+cost[i,3];
        end;
for i:=1 to 3 do begin
        if dp[n,i]> rs then rs:=dp[n,i]
        end;
write(rs);
readln;
readln;
end.




Measured memory_bytes: 6784
N = int(input())
A = list(map(int, input().split()))

ans = 0
bitcnt = [0] * 60
for Ai in A:
    Ai_tmp = Ai
    for j in range(60):
        bitcnt[j] += (Ai_tmp % 2)
        Ai_tmp >>= 1

# table_tmp = 1
# table = []
# for i in range(64):
#     table.append(table_tmp)
#     table_tmp = (table_tmp << 1) % (10 ** 9 + 7)

ans = 0
for i in range(60):
    ans_cnt = (bitcnt[i] * (N - bitcnt[i])) % (10 ** 9 + 7)
    ans_lvl = (1 << i) % (10 ** 9 + 7)
    ans_tmp = (ans_cnt * ans_lvl) % (10 ** 9 + 7)
    ans = (ans + ans_tmp) % (10 ** 9 + 7)

print(ans)


Measured memory_bytes: 122808
while(1):
    try:
        a = [int(i) for i in list(input())]
        for i in range(9):
            a_ = [i % 10 for i in [k+l for k,l in zip(a[1:], a[:9-i])]]
            a = a_
        print(a[0])
    except EOFError:
        break


Measured memory_bytes: 5604
main = do
  s <- getContents
  let v = map (map read . words) . lines $ s
  let w = map solve v
  let x = map (\x-> if x then "YES" else "NO") $ w
  mapM_ putStrLn x

solve::[Double] -> Bool
solve [xa,ya,xb,yb,xc,yc,xd,yd] =
  abs(dot u v)/len(u)/len(v) < eps
  where u = (xb-xa, yb-ya)
        v = (xd-xc, yd-yc)
        dot (a,b) (c,d) = a*c + b*d
        len (a,b) = sqrt(a^2+b^2)
        eps=1e-8

Measured memory_bytes: 4280
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
// *テンプレート*
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
#define sz(x) x.size()
// aよりbの方が小さかったら、aの値をbの値に置き換える。(swapではない！)
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
// aよりbの方が大きかったら、aの値をbの値に置き換える。
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
//最大公約数
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
//最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
// 素数かどうか判定
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1LL << 60;
// *テンプレートここまで*

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))

int s[35];

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, m; cin >> n >> m;
	rep(i, n) {
		int k; cin >> k;
		
		rep(j, k) {
			int tmp; cin >> tmp;
			s[tmp]++;
		}
	}
	int ans = 0;
	rep(i, 35) {
		if (s[i]==n)ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
n=int(input())
s=input()
cnt1=0
for i in range(n):
    if s[i]=="(":
        cnt1+=1
    else:
        if cnt1>0:
            cnt1-=1
        else:
            pass

cnt2=0
for i in range(n-1,-1,-1):
    if s[i]==")":
        cnt2+=1
    else:
        if cnt2>0:
            cnt2-=1
        else:
            pass

print(cnt2*"("+s+cnt1*")")


Measured memory_bytes: 38384
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};

#[fastout]
fn main() {
    input! {n:usize,
        h:[usize;n],
    a:[u64;n],}
    let mut bt = BIT::<SUM>::new(n + 3);
    for i in 0..n {
        let p = bt.sum(h[i]);
        bt.add(h[i], &(p + a[i]));
    }
    println!("{}", bt.sum(n + 1));
}
pub trait Monoid {
    type T: Clone;
    fn id() -> Self::T;
    fn op(a: &Self::T, b: &Self::T) -> Self::T;
}
pub struct SUM {}
impl Monoid for SUM {
    type T = u64;
    fn id() -> Self::T {
        0
    }
    fn op(a: &Self::T, b: &Self::T) -> Self::T {
        max(*a, *b)
    }
}
/// Generic Binary Indexed Tree
pub struct BIT<M: Monoid> {
    buf: Vec<M::T>,
}
impl<M: Monoid> BIT<M> {
    pub fn new(n: usize) -> Self {
        Self {
            buf: vec![M::id(); n + 1],
        }
    }
    pub fn sum(&self, i: usize) -> M::T {
        let mut i = i;
        let mut s = M::id();
        while i > 0 {
            s = M::op(&s, &self.buf[i]);
            i &= i - 1;
        }
        s
    }
    pub fn add(&mut self, i: usize, x: &M::T) {
        let mut i = i as i64;
        while i < self.buf.len() as i64 {
            let t = &mut self.buf[i as usize];
            *t = M::op(&t, x);
            i += i & -i;
        }
    }
}


Measured memory_bytes: 10072
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin>>s;
	reverse(s.begin(),s.end());
	while(1){
		if(s.substr(0,5)=="maerd")s=s.substr(5,s.size()-5);
		else if(s.substr(0,7)=="remaerd")s=s.substr(7,s.size()-7);
		else if(s.substr(0,5)=="esare")s=s.substr(5,s.size()-5);
		else if(s.substr(0,6)=="resare")s=s.substr(6,s.size()-6
		);
		else if(s=="")break;
		else {
			cout<<"NO"<<endl;
			return 0;
		}
	}
	cout<<"YES"<<endl;
}

Measured memory_bytes: 512
/*

Author : 5hifaT

github:https://github.com/jspw

linkedin : https://www.linkedin.com/in/mehedi-hasan-shifat-2b10a4172/

Stackoverflow : https://stackoverflow.com/story/jspw 


*/

#include <iostream>

using namespace std;
int main()
{
    int n, x, t;
    cin >> n >> x >> t;
    if (n % x == 0)
    {
        cout << (n / x) * t << endl;
    }
    else
        cout << ((n / x) + 1) * t << endl;

    return 0;
}

Measured memory_bytes: 3608
import java.util.Scanner;

public class Main {
	  
	public static void main(String args[]) {
		    Scanner scanner = new Scanner(System.in);
		    
		    int x = scanner.nextInt();
		    int t = scanner.nextInt();
		    
		    if( x - t < 0 ) 
		    {
		    	System.out.println( 0 );
		    }
		    else 
		    {
		    	System.out.println( x - t );
		    }
		    
		    scanner.close(); }
		  }

Measured memory_bytes: 21712
#include<iostream>
#include<cmath>

using namespace std;

bool isprime(long int n){
  for(int i = 2 ; i <= sqrt(n); i++){
    if(n % i == 0)
      return false;
  }
  return true;
}

int main(){
  int N, count = 0;
  cin >> N;
  while(N--){
    int m;
    cin >> m;
    if(isprime(m))
      count++;
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
const int NMAX=1e5+5;
int n,x,y,nr,ng,nc;
int a[NMAX],b[NMAX],c[NMAX],d[3*NMAX],sz;
long long sol;
int main()
{
    cin>>x>>y;
    cin>>nr>>ng>>nc;
    for(int i=1;i<=nr;i++)
        cin>>a[i];
    for(int i=1;i<=ng;i++)
        cin>>b[i];
    for(int i=1;i<=nc;i++)
        cin>>c[i];
    sort(a+1,a+nr+1);
    sort(b+1,b+ng+1);
    sort(c+1,c+nc+1);
    int cnt=x;
    for(int i=nr;i>=1 && cnt>0;i--)
    {
        d[++sz]=a[i];
        cnt--;
    }
    cnt=y;
    for(int i=ng;i>=1 && cnt>0;i--)
    {
        d[++sz]=b[i];
        cnt--;
    }
    cnt=x+y;
    for(int i=nc;i>=1 && cnt>0;i--)
    {
        d[++sz]=c[i];
        cnt--;
    }
    sort(d+1,d+sz+1);
    cnt=x+y;
    for(int i=sz;i>=1 && cnt>0;i--)
    {
        sol+=1LL*d[i];
        cnt--;
    }
    cout<<sol;
    return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define V vector
#define VI vector<int>
#define VVI vector<vector<int>>
#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 MOD 1000000007
#define INF 1e9
#define F first
#define S second
#define All(x) (x).begin(),(x).end()
using namespace std;
const double PI = acos(-1);
typedef long long ll;

int main(void) {
  int N;cin>>N;
  double sum=0.0;
  VI x(N,0),y(N,0);
  REP(i,N){
    cin>>x[i]>>y[i];
  }
  int nc=1;
  FOR(i,1,N+1)nc*=i;

  REP(i,N){
    FOR(j,i+1,N){
      sum+=sqrt(pow(x[i]-x[j],2)+pow(y[i]-y[j],2));
    }
  }


  //cout<<nc*7641.9817824387<<endl;
  printf("%lf \n",sum*2/N);
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int s[3],n,m,a,b;
int main(void){
    cin>>n>>m;
    for(int i=0;i<3;i++)s[i]=-1;
    for(int i=0;i<m;i++){
        cin>>a>>b;
        a--;
        if(s[a]!=-1&&s[a]!=b){cout<<-1<<endl;return 0;}
        s[a]=b;
    }
    if(n!=1&&s[0]==0){cout<<-1<<endl;return 0;}
    if(s[0]==-1){
        if(n==1)s[0]=0;
        else s[0]=1;
    }
    if(s[1]==-1)s[1]=0;
    if(s[2]==-1)s[2]=0;
    for(int i=0;i<n;i++){
        cout<<s[i];
    }
    cout<<endl;
}


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

using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,n,m) for(ll i=n; i>(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define cinv(v,n,m) FOR(i,n,m) cin>>v.at(i)
#define coutv(v,n,m) FOR(i,n,m) cout<<v.at(i) <<" "
#define cout(n) cout<<fixed<<setprecision(n)
int main(){
  ll N,K;
  cin>>N>>K;
  ll left=0,center=0,right=0;
  ll li=0,ri=N-1;
  vector<ll> v(N);
  cinv(v,0,N);

  FOR(i,0,N){
    if(v[i]<0) left++;
    else if(v[i]==0) center++;
    else right++;

    if(v[i]<0) li=i;
  }
  FORr(i,N-1,-1){
    if(v[i]>0) ri=i;
  }

  ll res=1e9;
  ll lef=0;
  FOR(i,li,ri+K){
    lef=i-K+1;
    if(0<=lef && i<N){
      if(v[i]*v[lef]<0){
        if(res>2*v[i]-v[lef]) res=2*v[i]-v[lef];
        if(res>v[i]-2*v[lef]) res=v[i]-2*v[lef];
      }
      else if(v[i]*v[lef]>0){
        if(i==li && res>-v[lef]) res=-v[lef];
        if(i!=li && res>v[i]) res=v[i];
      }
      else if(v[i]==0){
        if(res>-v[lef]) res=-v[lef];
      }
      else if(v[lef]==0){
        if(res>v[i]) res=v[i];
      }
    }
  }
  if(K==0) cout<<0<<endl;
  else cout<<res<<endl;

  //cout<<center<<K<<endl;


}


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

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

#define pb push_back
#define ff first
#define ss second
#define SIZE 100010
#define INF 2e9 + 9
#define acmpIN "input.txt"
#define acmpOUT "output.txt"

//#pragma GCC optimize("Ofast")

int n, m;
string s;



void solve()
{
    ld ans;
    cin >> n;
    n = n * n * n;
    ans = ld(n) / 27.0;
    cout << fixed << setprecision(12) << ans;
}


int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
//    freopen(acmpIN, "r", stdin);
//    freopen(acmpOUT, "w", stdout);

    solve();

    return 0;
}


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

//#define int long long
//using ll = boost::multiprecision::cpp_int;
using ll = long long;
//const int INF = 1e9;//INT_MAX=1<<31-1=2147483647
const ll INF = (ll)1e18;//1<<63-1=9223372036854775807
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
#ifdef LOCAL_ENV
	#define debug(var) std::cout<<#var" = "<<var<<std::endl
#else
	#define debug(var)
#endif
#define p(var) std::cout<<var<<std::endl
#define PI (acos(-1))
#define rep(i, n)   for(ll i=0, i##_length=(n); i< i##_length; ++i)
#define repeq(i, n) for(ll i=1, i##_length=(n); i<=i##_length; ++i)
#define all(a) (a).begin(), (a).end()
#define pb push_back
inline bool isnatural(double a) { return a>=0 && ceil(a)==floor(a); }
template<typename T> inline T gcd(T a, T b) { return b ? gcd(b,a%b) : a; }
template<typename T> inline T lcm(T a, T b) { return a / gcd(a,  b) * b; }
template<typename T1, typename T2>inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template<typename T1, typename T2>inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
	for (int i = 0, len = v.size(); i < len; ++i){
		s << v[i]; if (i < len - 1) s << "\t";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
	for (int i = 0, len = vv.size(); i < len; ++i){
		s << vv[i] << endl;
	}
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const map<T1, T2>& m) {
	s << "{" << endl;
	for (typeof(m.begin()) itr = m.begin(); itr != m.end(); ++itr){
		s << "\t" << (*itr).first << " : " << (*itr).second << endl;
	}
	s << "}" << endl;
	return s;
}

/*-----8<-----8<-----*/



signed main() {
	vector<ll> a(5,0);
	rep(i,5)cin >> a[i];
	sort(all(a));
	ll minval=INF;
	do {
		ll t=0;
		for (int i = 0; i < 5; i++) {
			if(i==4)t+=a[i];
			else {
				t+=a[i];
				if(a[i]%10)t+=10-a[i]%10;
			}
		}
		chmin(minval,t);
	} while (std::next_permutation(a.begin(), a.end()));
		
	p(minval);
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    int N,M;
    cin >> N >> M;
    auto n2q = [](int n){//数字ｰ>必要な本数
        switch (n)
        {
        case 1: return 2; break;
        case 2: case 3: case 5: return 5; break;
        case 6: case 9: return 6; break;
        case 4: return 4; break;
        case 7: return 3; break;
        case 8: return 7; break;
        }
    };
    vector<int> A(M);
    vector<pii> AP;
    REP(i, M){
        int a;
        cin >> a;
        A[i] = a;
        AP.pb(pii(a, n2q(a)));
    }
    RSORT(AP);

    vector<int> dp(N+1, -INF);
    dp[0] = 0;
    REP(i, N+1){
        if(dp[i] < 0) continue;
        REP(j, M){
           if(i+AP[j].se <= N){
               chmax(dp[i+AP[j].se], dp[i] + 1);
           }
       } 
    }
    int i = N;
    while(i > 0){
        REP(j, M){
            if(i-AP[j].se >= 0 && dp[i] - dp[i-AP[j].se] == 1){
                cout << AP[j].fi;
                i -= AP[j].se;
                break;
            }
        }
    }
    cout << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>



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

using namespace std;
int a,b,c;

int main(){
  cin >> a >> b >> c;
  if(a==b) cout << c <<endl;
  else if(c==b) cout << a <<endl;
  else cout << b <<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
struct city{
	int p;
	int y;
	int bian1;
	int bian2;
}c[100005];
bool cmp1(city a,city b)
{
	if(a.p!=b.p)
	{
		return a.p<b.p;
	}
	else
	{
		return a.y<b.y;
	}
}
bool cmp2(city a,city b)
{
	return a.bian1<b.bian1;
}
int main()
{
	int n,m,i,x,s=0,j=0,z,t=0,k;
	cin>>n>>m;
	for(i=1;i<=m;i++)
	{
		cin>>c[i].p>>c[i].y;
		c[i].bian1=i;
	}
	sort(c+1,c+m+1,cmp1);
	int y=c[1].p;
	for(i=1;i<=m;i++)
	{
		if(c[i].p==y)
		{
			j++;
			c[i].bian2=j;
		}
		else
		{
			j=1;
			y=c[i].p;
			c[i].bian2=j;
		}
	}
	sort(c+1,c+m+1,cmp2);
	/*
	////////////begin
	for(i=1;i<=m;i++)
	{
		cout<<c[i].p<<' '<<c[i].y<<' '<<c[i].bian1<<' '<<c[i].bian2<<endl;
	}
	////////////end
	*/
	for(i=1;i<=m;i++)
	{
		x=c[i].p;
		while(x!=0)
		{
			x=x/10;
			s++;
		}
		for(k=1;k<=6-s;k++)
		{
			cout<<'0';
		} 
		cout<<c[i].p;
		s=0;
		z=c[i].bian2;
		while(z!=0)
		{
			z=z/10;
			t++;
		}
		for(k=1;k<=6-t;k++)
		{
			cout<<'0';
		} 
		cout<<c[i].bian2<<endl;
		t=0;
	}
	return 0;
}

Measured memory_bytes: 3072
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int N;
int A[200000];
int last[20], last2[20];
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N;
  rep(i, N) cin >> A[i];
  rep(i, 20) last[i] = N, last2[i] = N;
  long long sum = 0;
  for (int i=N-1; i>=0; i--) {
    int r = N-1;
    rep(b, 20) if ((A[i]>>b)&1) last2[b] = last[b], last[b] = i;
    rep(b, 20) r = min(r, last2[b]-1);
    //cout<<"l="<<i<<", r="<<r<<"\n";
    sum += r-i+1;
  }
  cout << sum << "\n";
  return 0;
}


Measured memory_bytes: 1024