akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
using namespace std;
#define INF 110000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<ll,int> P;

int dp[11000];

int main(){
  vector<ll> A[3],AB,ans;
  ll temp;
  int X[3],K;

  for(int i=0;i<3;i++) cin>>X[i];

  cin>>K;

  for(int i=0;i<3;i++){
    for(int j=0;j<X[i];j++){
      cin>>temp;
      A[i].push_back(temp);
      //cout<<temp<<endl;
    }
  }

  for(int i=0;i<X[0];i++){
    for(int j=0;j<X[1];j++){
      AB.push_back(A[0][i]+A[1][j]);
      //cout<<A[0][i]+A[1][j]<<endl;
    }
  }

  sort(AB.begin(),AB.end(),greater<ll>());

  for(int i=0;i<min(K,X[0]*X[1]);i++){
    for(int j=0;j<X[2];j++){
      ans.push_back(AB[i]+A[2][j]);
      
    }
  }
  sort(ans.begin(),ans.end(),greater<ll>());
  for(int i=0;i<K;i++) cout<<ans[i]<<endl;
}


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

using ll = long long;
#define ALL(c) (c).begin(), (c).end()
const int MOD = 1000000007;

int main() {
    int n, m;
    cin >> n >> m;
    set<int> f;
    vector<int> s;
    int a, b;
    for (int i = 0; i < m; i++) {
        cin >> a >> b;
        if (a == 1) {
            f.insert(b);
        }
        if (b == n) {
            s.push_back(a);
        }
    }
    for (const int i : s) {
        if (f.count(i) == 1) {
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }
    cout << "IMPOSSIBLE" << endl;
}


Measured memory_bytes: 5368
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

int main()
{
    string s;
    cin >> s;

    for(int i = 0; i <= s.size(); i++){
        for(int j = i; j <= s.size(); j++){
            string res;
            for(int k = 0; k < i; k++){
                res += s[k];
            }
            for(int k = j+1; k < s.size(); k++){
                res += s[k];
            }

            if(res == "keyence"){
                cout << "YES" << endl;
                return 0;
            }
        }
    }

    cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007LL
#define all(x) x.begin() , x.end()

void solve()
{
	ll n; cin >> n;
	if (n <= 599) cout << 8;
	else if (n <= 799) cout << 7;
	else if (n <= 999) cout << 6;
	else if (n <= 1199) cout << 5;
	else if (n <= 1399) cout << 4;
	else if (n <= 1599) cout << 3;
	else if (n <= 1799) cout << 2;
	else cout << 1;
}
int32_t main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	ll t = 1; //cin >> t;
	while (t--)
		solve();
	return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <map>
#include <string>
#include <cmath>

using namespace std;

#define ll long long
#define vi vector<int>

map<string, int> MP_P, MP_N;

ll N, M;
int ans=0;
string s[105], t[105];

int main(){
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> s[i];
        MP_P[s[i]]++;
    } 
    cin >> M;
    for(int i = 0; i < M; i++) {
        cin >> t[i];
        MP_N[t[i]]++;
    }

    for(int i = 0; i < N; i++){
        string buff = s[i];
        ans = max(ans, MP_P[buff]-MP_N[buff]);
    }

    cout << ans << endl;
}


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

int main(){
//srandom((unsigned long)time(NULL));
string s;
cin>>s;
int n=s.size();
int x=1;
for(int i=0;i<n/2;i++){
    if(s[i]!=s[n-1-i])x=0;
}
for(int i=0;i<(n-1)/2/2;i++){
    if(s[i]!=s[(n-1)/2-1-i])x=0;
}
for(int i=0;i<(n-3)/2/2;i++){
    if(s[(n+3)/2-1+i]!=s[n-1-i])x=0;
}
//s0 s1 s2 s3     s6
//5kara7ha4kara6
//n-(n+3)/2=(n-3)/2


if(x==1)cout<<"Yes"<<endl;
else cout<<"No"<<endl;

return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef pair<ii, int> ri3;
#define mp make_pair
#define pb push_back
#define fi first
#define sc second
#define SZ(x) (int)(x).size()
#define ALL(x) begin(x), end(x) 
#define REP(i, n) for (int i = 0; i < n; ++i) 
#define FOR(i, a, b) for (int i = a; i <= b; ++i)
#define RFOR(i, a, b) for (int i = a; i >= b; --i)

int main() {
    //freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);

    int N; cin >> N;
    int brk = 0;
    FOR(i,0,N-1){
        int A; cin >> A;
        if (A != (i-brk+1)) ++brk;
    }
    if (brk == N) cout << -1;
    else cout << brk;
}



Measured memory_bytes: 256
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, U, V = lr()
graph = [[] for _ in range(N+1)] # 1-indexed
for _ in range(N-1):
    a, b = lr()
    graph[a].append(b)
    graph[b].append(a)

def dfs(start): # 木グラフの時
    dist = [-1] * (N+1)
    dist[start] = 0
    stack = [start]
    while stack:
        s = stack.pop()
        for x in graph[s]:
            if dist[x] != -1:
                continue
            dist[x] = dist[s] + 1
            stack.append(x)
    return dist

dist_U = dfs(U); dist_V = dfs(V)
answer = 0
for u, v in zip(dist_U[1:], dist_V[1:]):
    if v > u:
        x = v - 1
        if x > answer:
            answer = x

print(answer)


Measured memory_bytes: 62136
s = str(input())
list_s = list(s)
alp_list = list("abcdefghijklmnopqrstuvwxyz")
dict_alp = {}
ans = 0
for i in range(26):
    dict_alp[alp_list[i]] = i+1
if len(list_s) == 26:
    i = 25
    while True:
        try:
            if dict_alp[list_s[i]] > dict_alp[list_s[i-1]]:
                list_s = list_s[:i]
                x = list_s.pop()
                break
            else:
                i -= 1
        except IndexError:
            ans = -1
            break
    if ans != -1:
        alp_set = []
        for alp in alp_list:
            if not alp in list_s:
                if dict_alp[alp] > dict_alp[x]:
                    alp_set.append(alp)
        alp_set.sort()
        list_s.append(alp_set[0])
else:
    for alp in alp_list:
        if not alp in list_s:
            list_s.append(alp)
            break
if ans == -1:
    print(ans)
else:
    print("".join(list_s))


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
const int mod=998244353;
inline void Add(int &a,int b){a=a+b>=mod?a+b-mod:a+b;}
int n,a[3010],s,ans=0;
int f[3010][3010];
int main()
{
	cin>>n>>s;
	for(int i=1;i<=n;i++) cin>>a[i];
	for(int i=1;i<=n;i++) for(int j=1;j<=3000;j++)
	{
		if(j==a[i]) Add(f[i][j],i);
		Add(f[i][j],f[i-1][j]);
		if(j>=a[i]) Add(f[i][j],f[i-1][j-a[i]]);
		if(j==s) Add(ans,1ll*(f[i][j]+mod-f[i-1][j])%mod*(n-i+1)%mod);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 35584
#include <iostream>
#include <stdlib.h>
using namespace std;
#define limit 50010

int main(void){
  int* table=(int*)malloc(sizeof(int)*limit);
  for(int i=0;i<limit;i++){
    table[i]=1;
  }
  table[0]=0;
  table[1]=0;
  int k;
  for(int i=0;i<limit;i++){
    if(table[i]==0)continue;
      k=2;
      while(k*i<=limit){
        table[k*i]=0;
        k++;
      }
  }
  int n;
  while(1){
    cin>>n;
    if(n==0)break;
    int retval=0;
    for(int i=1;i<=n/2;i++){
      if(table[i]==1 && table[n-i]==1){
        retval++;
      }
    }
    cout<<retval<<endl;
  }

  return 0;
}



Measured memory_bytes: 3200
/// i thought of single state not possible because
/*#include <bits/stdc++.h>
using namespace std;
#define pb push_back
typedef long long ll;
ll a[505];
ll s[505];
ll dp[505];
int main(){
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        if(i==1) s[i] = a[i];
        else{
            s[i] = s[i-1]+a[i];
        }
    }
    for(int i=1;i<=n;i++){
        dp[i] = 1000000000;
    }
    dp[0] = 0;
    for(int i=1;i<=n;i++){
        for(int j=0;j<=i;j++){
            ll sum = 0;

            for(int k=j;k<=i;k++){
                sum+=s[k]-s[max(0,j-1)];
            }
            dp[i] = min(sum+dp[j],dp[i]);
        }
    }
    cout<<dp[1]<<" "<<dp[2]<<" "<<dp[3]<<endl;
    ll sum = 0;
    for(int i=1;i<=n;i++)
        sum+=dp[i];
    cout<<sum<<endl;
}
*/
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
typedef long long ll;
ll dp[405][405];
ll sum[405];
ll a[405];
int main(){
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        if(i==1)
            sum[i] = a[i];
        else
            sum[i] = sum[i-1]+a[i];
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            dp[i][j] = 1000000000000000000;
        }
    }
    for(int i=1;i<=n;i++)
        dp[i][i] = 0;
    for(int len = 2;len<=n;len++){
        for(int i=1,j=i+len-1;j<=n;i++,j++){
            for(int k=i;k<j;k++){
                dp[i][j] = min(dp[i][j],dp[i][k]+dp[k+1][j]+sum[j]-sum[i-1]);
            }
        }
    }
    cout<<dp[1][n]<<endl;
}


Measured memory_bytes: 1536
import kotlin.math.min

fun main() = Thread(null, ::abc174d, "(^o^)", 128 * 1024 * 1024).apply { start() }.join()

@OptIn(ExperimentalStdlibApi::class)
fun abc174d() {
    val n = readLine()!!.toInt()
    val line = readLine()!!.toCharArray()

    val sorted = line.sortedArray()
    var rToW = 0
    var wToR = 0

    for (i in 0 until n) {
        if (line[i] != sorted[i]) if (line[i] == 'R') rToW++ else wToR++
    }

    val answer = rToW + wToR - min(rToW, wToR)

    println(answer)
}


Measured memory_bytes: 44468
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    int N;
    cin >> N;
    int a;
    vector<int> A(N+1);
    rep(i,N){
        cin >> a;
        A[a]=i;
    }
    rep(i,N){
        cout << A[i+1]+1 << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>
#include <list>

using namespace std;
typedef long long ll;
#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define all(x) x.begin(),x.end()


int main()
{
    ll n;cin>>n;
    if(n%2==1)cout<<0<<endl;
    else{
        n/=2;
        ll res = 0;
        ll d = 5;
        while(n>0){
            res += n/d;
            n/=5;
        }
        cout<<res<<endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h> 
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp> 
#define mod 1000000007
#define mod2 998244353
#define int long long
#define endl "\n"
#define p_b push_back
#define m_p make_pair
#define fastIO ios_base::sync_with_stdio(false),cin.tie(NULL)
using namespace std;
using namespace __gnu_pbds;
template <class T> 
using _ost = tree<
		T, 
		null_type, 
		less<T>, 
		rb_tree_tag, 
        tree_order_statistics_node_update>;

// char alphabet[26] = {'a','b','c','d','e','f','g','h','i',
//        'j','k','l','m','n','o','p','q','r','s','t','u','v',
//        'w','x','y','z'};


int32_t main(){
 	fastIO;
	int k;cin>>k;
	int cur=100;
	for(int i=1;i<=200000;i++){
		cur+=cur/100;
		if(cur>=k){
			cout<<i<<endl;
			break;
		}
	}
}		



Measured memory_bytes: 3648
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
using namespace std;
using ll = long long;
int main(){
  int a, b;
  cin >> a >> b;
  double ans = 1;
  while(ans < 100000){
    if((int)(ans * 0.08) == a && (int)(ans * 0.1) == b){
      cout << ans << "\n";
      return 0;
    }
    ans++;
  }
  cout << -1 << "\n";

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
using namespace std;
using ll = long long;
const ll INF = 1LL << 60;

int main(void) {
  int n, m;
  cin >> n >> m;
  vector<pair<int, int>> p(m);
  rep(i, m) cin >> p[i].first >> p[i].second;
  rep(x, 1000) {
    int digit = 1;
    int nx = x / 10;
    vector<int> d(1, x % 10);
    while (nx) {
      digit++;
      d.push_back(nx % 10);
      nx /= 10;
    }
    if (digit != n) continue;
    bool ok = true;
    reverse(d.begin(), d.end());
    rep(i, m) {
      if (d[p[i].first - 1] != p[i].second) ok = false;
    }
    if (ok) {
      cout << x << '\n';
      return 0;
    }
  }
  cout << -1 << '\n';
  return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) cin >> a[i];

    vector<int> dp(n + 1, INT32_MAX);
    for (int i = 0; i < n; ++i) {
        *lower_bound(dp.begin(), dp.end(), a[i]) = a[i];
    }

    cout << distance(dp.begin(), lower_bound(dp.begin(), dp.end(), INT32_MAX)) << endl;
}


Measured memory_bytes: 3608
#include <iostream>
#include <algorithm>
using namespace std;
#define INF 2147483647
//static const double INF = (1 << 31)-1;

int n,q;
double d[400000];

void update(int k,double a){
	k += n - 1;
	d[k] = a;
	while(k > 0){
		k = (k - 1)/2;
		d[k] = min(d[k*2+1], d[k*2+2]);
	}
}


double query(int a, int b, int k, int l, int r){
	if(r <= a || b <= l){
		return INF;
	}
	else if(a <= l && r <= b){
		return d[k];
	}

	double vl = query(a, b, k*2+1, l, (l + r)/2);
	double vr = query(a, b, k*2+2, (l + r)/2, r);
	return min(vl, vr);
}


double findMin(int a, int b){
	return query(a, b+1, 0, 0, n);
}

int main(){
	int n_;
	cin >> n_ >> q;

	n=1;
	while(n<n_){
		n*=2;
	}
	for(int i = 0;i < n*2-1;i++){
		d[i] = INF;
	}

	double s,x,y;
	for(int i = 0;i < q;i++){
		cin >> s >> x >> y;
		if(s == 0){
			update(x,y);
		}
		else{
			printf("%.0f\n",findMin(x,y));
		}
	}
	return 0;
}



Measured memory_bytes: 5260
#include<stdio.h>
int main(void)
{
int a,b;
	char op;
    while(1){
    	scanf("%d %c %d",&a,&op,&b);
		if(op=='+'){
			printf("%d\n",a+b);
		}else if(op=='-'){
			printf("%d\n",a-b);
			}else if(op=='*'){
			printf("%d\n",a*b);
			}else if(op=='/'){
			printf("%d\n",(int)a/b);
			}else if(op=='?'){
				break;}
    }
	return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
#define mx 1000000007
#define ll long long int

using namespace std;

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	string s,t;
    cin>> s >> t;
    string ans="";
    ll dp[s.size()+1][t.size()+1];
    memset(dp,0,sizeof(dp));
    ll n=s.size(),w=t.size();
    for(ll i=1;i<=n;++i){
    	for(ll j=1;j<=w;++j){
    		if(s[i-1]==t[j-1])
    			dp[i][j]=1+dp[i-1][j-1];
    		else
    			dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
    	}
    }
    ll i=n,j=w;
    while( i && j){
		if(s[i-1]==t[j-1]){
			ans.append(1,s[i-1]);
			--i;
			--j;
		}else{
			if(dp[i-1][j]>dp[i][j-1])
				--i;
			else
				--j;
		}
    }
    reverse(ans.begin(),ans.end());
    cout<< ans << "\n";
	return 0;
}


Measured memory_bytes: 73904
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    int m1,m2,d1,d2;
    cin >> m1 >> d1;
    cin >> m2 >> d2;
    if(m1!=m2){
        cout << 1 << endl;
    }else{
        cout << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
N = int(input())
x_y_h = [tuple(map(int, input().split())) for _ in range(N)]

for cx in range(101):
    for cy in range(101):
        try_H = 0
        for x, y, h in x_y_h:
            if h > 0:
                try_H = h + abs(x - cx) + abs(y - cy)
                break

        wrong = False
        for x, y, h in x_y_h:
            tmp_H = max(try_H - abs(x - cx) - abs(y - cy), 0)
            if tmp_H != h:
                wrong = True
                break
        if wrong:
            continue
        print(cx, cy, try_H)
        exit()


Measured memory_bytes: 3064
import java.io.*;
import java.util.Arrays;
import java.util.HashSet;

public class Main{
	public static int count = 0;
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		int[] a = new int[n];
		String[] str = (br.readLine()).split(" ");
		for (int i = 0; i<n ; i++ ) {
			a[i] = Integer.parseInt(str[i]);
		}
		mergeSort(a,0,n);
		for (int i = 0; i<n ; i++ ) {
			if (i == n-1) {
				System.out.println(a[i]);
			}else{
				System.out.print(a[i] + " ");
			}
		}
		System.out.println(count);

	}

	public static void merge(int[] a , int left , int mid , int right){
		int n1 = mid - left;
		int n2 = right - mid;
		int[] l = new int[n1+1];
		int[] r = new int[n2+1];
		for (int i = 0; i<n1 ; i++ ) {
			l[i] = a[left + i];
		}
		for (int i = 0; i<n2 ; i++ ) {
			r[i] = a[mid + i];
		}
		l[n1] = Integer.MAX_VALUE;
		r[n2] = Integer.MAX_VALUE;
		int i = 0;
		int j = 0;
		for (int k = left; k<right ; k++ ) {
			if (l[i] <= r[j]) {
				a[k] = l[i];
				i = i + 1;
				count++;
			}else{
				a[k] = r[j];
				j = j + 1;
				count++;
			}
		}
	}
	public static void mergeSort(int[] a ,int left,int right){
		if (left + 1 < right) {
			int mid = (left + right)/2;
			mergeSort(a,left,mid);
			mergeSort(a,mid,right);
			merge(a,left,mid,right);
		}
	}
}

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

typedef long long ll;
using namespace std;

#define _overload(_1, _2, _3, name, ...) name
#define _rep(i, n) for(ll i = 0; i < (ll)n; i++)
#define _repi(i, s, n) for(ll i = (ll)(s); i < (ll)n; i++)
#define REP(...) _overload(__VA_ARGS__, _repi, _rep,)(__VA_ARGS__)
#define all(v) (v).begin(),(v).end()
#define UNIQUE(v) (v).erase( unique( all(v) ), (v).end() );
#define MOD 1000000007

int main(){
	ll d, t, s;	cin >> d >> t >> s;

	if( s * t >= d )	cout << "Yes" << endl;
	else				cout << "No" << endl;

	return 0;
}


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

using namespace std;

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

    int A[N];
    for(int i = 0; i < N; ++i) cin >> A[i];

    int Alice = 0;
    int Bob = 0;

    sort(A, A + N, greater<int>());

    for (int i = 0; i < N; ++i){

        if(i % 2 == 0) Alice += A[i];
        else Bob += A[i];
    }
    cout << abs(Alice - Bob) << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;


void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    string s;
    cin >>s;
    sort(s.begin(),s.end());
    rep(i,2){
        if(s[2*i]==s[2*i+1]){
            continue;
        }
        else{
            cout << "No";
            return 0;
        }
    }
    if(s[1]==s[2]){
        cout << "No";
    }
    else{
        cout << "Yes";
    }

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define big 1152921504606846976
int main(void) {
	//ansはプラスはそのまま、マイナスは０で総和
	//そこからKのマイナス分をとる
	//連続が黒->Mの総和を足す
	//連続が白->Pの総和を引く
	//補正はどのみちマイナス
	long long int N,K,i,a,ans=0,hosei=-big;//補正を大きくする
	static long long int P[100010] = { 0 };//プラス 総和をとる
	static long long int M[100010] = { 0 };//マイナス総和をとる
	scanf("%lld %lld", &N, &K);
	for (i = 1; i <= N; i++) {
		scanf("%lld", &a);
		P[i] = P[i - 1];
		M[i] = M[i - 1];
		if (a > 0) { P[i] += a; ans += a; }
		else { M[i] += a; }
	}
	for (i = 1; i <= N - K + 1; i++) {
		if (hosei < P[i - 1] - P[i - 1 + K]) {hosei = P[i - 1] - P[i - 1 + K];}
		if (hosei < -M[i - 1] + M[i - 1 + K]) { hosei = -M[i - 1] + M[i - 1 + K]; }
	}
	printf("%lld", ans+hosei);
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <algorithm>
#include <bitset>
#include <tuple>
#include <set>
#include <map>
#define range(i, r) for(int i=0;i<r;i++)
#define ranges(i, l, r) for(int i=l;i<r;i++)
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
#define MODs 1000000007;
#define MODn 1000000009;
typedef long long int ll;
using namespace std;

int main(int argc, char const *argv[]) {
  int X, A;
  std::cin >> X >> A;
  std::cout << (X>=A?10:0) << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < (int)n; i++)
#define pb push_back
#define fastIO ios::sync_with_stdio(0), cin.tie(0);
#define endl '\n'
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
int main() {
#ifdef LOCAL
    // freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
#else
    fastIO;
#endif
    ll a, b, x;
    cin >> a >> b >> x;
    cout << b / x - (a == 0 ? -1 : (a - 1) / x) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
#define pb push_back
#define ll long long
#define ld long double
#define llu ll unsigned
#define ft first
#define sd second
using namespace std;
 
string to_string(string s){return '"'+s+'"';}string to_string(const char* s){return to_string((string)s);}template <typename A, typename B>string to_string(pair<A, B> p){return "("+to_string(p.first)+", "+to_string(p.second)+")";}template<typename A>string to_string(A v){bool first=true;string res="{";for(const auto&x:v){if(!first){res+=", ";}first = false;res+=to_string(x);}res += "}";return res;}void debug_out(){cerr<<endl;}template<typename Head,typename... Tail>void debug_out(Head H,Tail... T){cerr<<" "<<to_string(H);debug_out(T...);}
#ifdef LOCAL
#define err(...)cerr<<"["<<#__VA_ARGS__<<"]:",debug_out(__VA_ARGS__)
#else
#define err(...) 42
#endif
 
const ld eps = 1e-12;
const int N = 1e5+9;

int a[N];


signed main() {
 
    // freopen("out.txt","w",stdout); 
    ios::sync_with_stdio(false); cin.tie(0);
    
    int n, k; cin >> n >> k; int mn = -1;
    for(int i=1; i<=n; i++) {
    	cin >> a[i];
    	if(mn == -1 || a[mn] > a[i]) mn = i;
    }
    if(n == 1) return cout << "1\n", 0;
    int ans = 0;
    // if(mn != 1) 
	ans += (n + k - 3) / (k - 1);
    // if(mn != n) ans += (n - mn + k - 2) / (k - 1);
    cout << ans << endl;

    return 0; 
    
}  


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
#define e_b emplace_back
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
using namespace std;
using ll = long long;
using ld = long double;
template<class T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<class T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}

vector<ll> dis;
void dfs(vector<vector<pair<int,ll>>> &graph,int now,int pa){
  if(pa==-1)  dis.at(now)=0;
  for(int i=0;i<sz(graph.at(now));i++){
    int next_v=graph.at(now).at(i).fi;
    ll next_c=graph.at(now).at(i).se;
    if(next_v==pa)  continue;

    dis.at(next_v)=dis.at(now)+next_c;
    dfs(graph,next_v,now);
  }
}

int main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  int N;
  cin >> N;
  vector<vector<pair<int,ll>>> graph(N);
  for(int i=0;i<N-1;i++){
    int a,b,c;
    cin >> a >> b >> c;
    a--;
    b--;
    graph.at(a).p_b(m_p(b,c));
    graph.at(b).p_b(m_p(a,c));
  }

  int Q,K;
  cin >> Q >> K;
  K--;
  dis.resize(N,-1e9);
  dfs(graph,K,-1);
  for(int _=0;_<Q;_++){
    int x,y;
    cin >> x >> y;
    x--;
    y--;
    cout << dis.at(x)+dis.at(y) << endl;
  }

  return 0;
}

Measured memory_bytes: 18588
n=int(input())
s=list(map(int,input().split()))

i=1
cnt=0
cnt_max=0
while i<n:
  if s[i]<=s[i-1]:
    cnt+=1
  else:
    cnt=0
  cnt_max=max(cnt,cnt_max)
  
  i+=1
print(cnt_max)
  
  

Measured memory_bytes: 63984
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c,d;
    double f;
    cin>>a>>b;
    c=a/b;
    d=a%b;
    f=(double)a/(double)b;
    cout<<c<<" "<<d<<" "<<fixed<<setprecision(6)<<f<<endl;
}


Measured memory_bytes: 3264
/*   ꧁༒☬महाकाल☬༒꧂ ꧁༒ঔमहाकालঔ༒꧂
                   
                   ঔৣ۝महाकालᴳᵒᵈ۝ঔৣ            
 
 */ 
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template <typename T, typename cmp=less<T>> using oset =tree<T, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define ll long long 
#define mod 1000000007
#define inf 100000000000000000
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define _it iterator
#define all(_x) _x.begin(),_x.end()
#define f first
#define s second
#define pb push_back
void mahakal(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	freopen("error.txt","w",stderr);
	#endif
}
int main(){
	//mahakal(),fast;
	
	ll n , k ;
	cin>>n >> k ;
	ll arr[n];
	ll ans =0;
	for(ll i=0;i<n ;i++){
		cin>>arr[i];
		if(arr[i]>=k)ans++;
	}
	cout<<ans<<endl;

	return 0;
}

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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

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




signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n; cin>>n;
  vll a(n);
  rep(i,n) cin>>a[i];
  vsort(a);
  vll s(n+1);
  rep(i,n){
    s[i+1]=s[i]+a[i];
  }
  
  ll ans=1;
  rrep(i,n){
    if(s[i]*2>=a[i]) ans++;
    else break;
  }
  cout<<ans<<endl;
}

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


namespace Test1 {

    class ClassMain {


        public static void rikuSearch(int[,] map, int y, int x) {
            if (y < 0 || map.GetLength(0) <= y || x < 0 || map.GetLength(1)<=x) { return; }
            if (map[y, x] == 0) { return; }
            map[y, x] = 0;
            rikuSearch(map, y + 1, x);
            rikuSearch(map, y - 1, x);
            rikuSearch(map, y , x+1);
            rikuSearch(map, y , x-1);
            rikuSearch(map, y + 1, x+1);
            rikuSearch(map, y + 1, x-1);
            rikuSearch(map, y - 1, x+1);
            rikuSearch(map, y - 1, x-1);        
        }

        public static void Main(String[] args) {
            string line;
            while ((line = Console.ReadLine()) != null) {
                int[] ints = line.Split(' ').Select(int.Parse).ToArray();
                int n = ints[0]; 
                //int n = int.Parse(line);                
                if(n==0){break;}
                int y = ints[1];

                int[,] map = new int[y, n];
                for (int i = 0; i < y; i++) {
                    ints = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
                    for (int j = 0; j < n; j++) {
                        map[i, j] = ints[j];
                    }
                }

                int cnt = 0;
                for (int i = 0; i < y; i++) {
                    for (int j = 0; j < n; j++) {
                        if (map[i, j] == 1) {
                            cnt++;
                            rikuSearch(map, i, j);
                        }
                    }
                }
                
                Console.WriteLine(cnt);

            }   
        }   
    }
}

Measured memory_bytes: 6356
using System;

class Program {
  static void Main() {
    int n = int.Parse(Console.ReadLine());
    for (int i = 0; i <= 25; i++) {
      for (int j = 0; j <= 14; j++) {
        if (i * 4 + j * 7 == n) {
          Console.WriteLine("Yes");
          return;
        }
      }
    }
    Console.WriteLine("No");
  }
}

Measured memory_bytes: 13140
#include<cstdio>
#include<cstring>
#include<algorithm>
#define MAXN 200000
using namespace std;
struct Point
{
	int x,y;
	Point(){};
	Point(int _x,int _y):x(_x),y(_y){};
}ft[MAXN+5],P1,P2;
int N;
int B[MAXN+5];
bool cmp1(const Point &a,const Point &b)
{return a.x<b.x;}
bool cmp2(const Point &a,const Point &b)
{return a.x>b.x;}
int main()
{
	scanf("%d %d %d %d",&P1.x,&P1.y,&P2.x,&P2.y);
	if(P1.x>P2.x)
		swap(P1,P2);
	double ans=0;
	if(P1.y<P2.y)
	{
		scanf("%d",&N);
		for(int i=1;i<=N;i++)
		{
			scanf("%d %d",&ft[i].x,&ft[i].y);
			if(ft[i].x<P1.x||ft[i].y<P1.y||ft[i].x>P2.x||ft[i].y>P2.y)
			{
				i--,N--;
				continue;
			}
		}
		sort(ft+1,ft+1+N,cmp1);
	}
	else if(P1.y>=P2.y)
	{
		scanf("%d",&N);
		for(int i=1;i<=N;i++)
		{
			scanf("%d %d",&ft[i].x,&ft[i].y);
			if(ft[i].x<P1.x||ft[i].y>P1.y||ft[i].x>P2.x||ft[i].y<P2.y)
			{
				i--,N--;
				continue;
			}
		}
		sort(ft+1,ft+1+N,cmp2);
	}
	if(N==0)
		ans=(1.0*abs(P1.x-P2.x)+1.0*abs(P1.y-P2.y))*100.0;
	else
	{
		int maxl=1;
		B[1]=ft[1].y;
		for(int i=1;i<=N;i++)
		{
			int p=lower_bound(B+1,B+1+maxl,ft[i].y)-B;
			B[p]=ft[i].y;
			maxl=max(maxl,p);
		}
		int lim=min(abs(P1.x-P2.x),abs(P1.y-P2.y));
		int rl=min(maxl,lim);
		double del=-4.2920367320510338;
		double add=11.41592653589793238;
		ans=(1.0*abs(P1.x-P2.x)+1.0*abs(P1.y-P2.y))*100.0+1.0*rl*del;
		if(maxl>lim)
			ans+=(1.0*maxl-1.0*lim)*add;
 	}
	printf("%.15f\n",ans);
	return 0;
}

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

//{ START
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i > (n); --i)
#define arep(i, x) for (auto &&i : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
// gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1LL << (n))
#define pcnt(x) __builtin_popcountll(x)
//配列内等要素削除
#define unique(x) (x).erase(unique((x).begin(), (x).end()), (x).end())
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) ((n) * ((n) + 1)) / 2
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).push_front(a)
#define eb(x, a) (x).emplace_back(a)
#define F first
#define S second
#define cauto const auto &
using P = pair<int, int>;
using Graph = vector<vector<P>>;
template <class T>  //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T>  //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {  //多次元初期化
  std::fill((T *)array, (T *)(array + N), val);
}
template <class T>
bool chmax(T &a, const T &b) {  //最大値更新 返り値はbool
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {  //最小値更新 返り値はbool
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9 + 7;
constexpr int mod2 = 998244353;
//} END

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

  string s;
  cin >> s;

  rep(i, 0, s.size()) {
    if (i == 0) {
      if (s[i] == '?') s[i] = 'D';
    } else {
      if (s[i] == '?') {
        if (s[i - 1] == 'P')
          s[i] = 'D';
        else {
          s[i] = 'D';
        }
      }
    }
  }

  cout << s << '\n';
  return 0;
}

Measured memory_bytes: 3740
K = int(input())
ans = -1
cnt = 0
a = 7
jdg = False
if a%K == 0:ans = 1
else:
    a = 7%K
    cnt += a
    for i in range(1, K+3):
        a = (a*10) % K
        cnt += a
        if cnt % K == 0:
            ans = i + 1
            break
        elif a == 0:
            break
print(ans)


Measured memory_bytes: 9108
#include<bits/stdc++.h>
#define eps 1e-6
#define ll long long
#define IOS cin.sync_with_stdio(false);cin.tie(0);cout.tie(0);
//#define int long long
#define MEM(x,y) memset(x,y,sizeof(x))
#define rep(i,a,n) for (ll i=a;i<n;i++)
#define fi first
#define se second
#define endl "\n"
const ll mod=1000000007;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;
ll Max(ll a,ll b)
{
    return a>=b?a:b;
}
ll Min(ll a,ll b)
{
    return a<=b?a:b;
}
ll qpow(ll a,ll b)
{
    ll s=1;
    while(b>0)
    {
        if(b%2==1)
        {
            s=s*a;
        }
        a=a*a;
        b=b>>1;
    }
    return s;
}
ll qpowmod(ll a, ll b, ll c)
{
    ll res,t;
    res=1;
    t=a%c;
    while(b)
    {
        if(b&1)
        {
            res=res*t%c;
        }
        t=t*t%c;
        b>>=1;
    }
    return res;
}
ll gcd(ll a,ll b)
{
    return b?gcd(b,a%b):a;
}
ll lcm(ll a,ll b)
{
    return a/gcd(a,b)*b;
}
inline long long read()
{
    long long k=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9')
    {
        if(ch=='-')
            f=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9')
    {
        k=k*10+ch-'0';
        ch=getchar();
    }
    return k*f;
}
inline void write(long long x)
{
    if(x<0)
        x=-x,putchar('-');
    if(x>9)
        write(x/10);
    putchar(x%10+'0');
}
using namespace std;
ll n;
void scan()
{
    cin>>n;
}
//head file
int main()
{
    IOS;
    scan();
    ll a[n+1],x[n+1],y[n+1],tt=0;
    for(ll i=1; i<=n; i++)
    {
        cin>>a[i];
        x[i]=i + a[i];
        y[i]=i - a[i];
        if(a[i]==0)
            tt++;
    }
    ll ans =0 ;
    sort(x+1,x+n+1);
    sort(y+1,y+n+1);
    for(ll i=1,j=1; i<=n && j<=n;)
    {
        if(x[i] < y[j] )
            i++;
        else if(x[i] > y[j])
            j++;
        else
        {
            ll aa=1,bb=1;
            while(x[i+1]==y[j])
            {
                aa++;
                i++;
            }
            while(y[j+1]==x[i])
            {
                bb++;
                j++;
            }
            ans+=aa*bb;
            i++;
            j++;
        }
    }
    cout<<ans - tt<<endl;
    return 0;
}



Measured memory_bytes: 8348
#include<bits/stdc++.h>
using namespace std;
 
#define rep(i, a, n) for(int i=a; i<n; i++)
#define ll long long
#define all(x) begin(x), end(x)
#define toInt(x) (x - '0')
#define pll pair<ll, ll>
#define pli pair<ll, int>
// #define int long long

#define INF 1e+9
#define MAX_V 100008

vector<pair<ll, int>> factrized(ll num){
  vector<pair<ll, int>>  res;
 
  for(ll i = 2; i * i <= num; i++){
    if(num % i)continue;
    res.emplace_back(i, 0);
    while(num % i == 0){
          num /= i;
      res.back().second++;
    }
  }
  if(num != 1) res.emplace_back(num, 1);
  return res;
}

int main(){
    int x, n;
    cin >> x >> n;
    vector<int> p(105, 0);
    rep(i, 0, n){
        int c;
        cin >> c;
        p[c] = 1;
    }
    for(int i=0; i<=100; i++){
        if(p[x - i] == 0){
            cout << x - i << endl;
            return 0;
        }else if(p[x + i] == 0){
            cout << x + i << endl;
            return 0;
        }
    }
    
}


Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <queue>
#include <cassert>
using namespace std; typedef long long ll; const int INF=1e9; typedef pair<ll,ll> P;

int main() {
  int n; cin>>n;
  ll a[n]; for(int i=0;i<n;i++) cin>>a[i];
  ll b[n]; b[0]=a[0]; for(int i=1;i<n;i++) b[i]=b[i-1]+a[i];
  ll c[n]; c[n-1]=a[n-1]; for(int i=n-2;i>=0;i--) c[i]=c[i+1]+a[i];

  //for(ll x:b) cout<<x<<" "; cout<<endl;
  //for(ll x:c) cout<<x<<" "; cout<<endl;

  ll an=1e18;
  for(int i=1;i<=n-1;i++) {
    an=min(an, abs(b[i-1]-c[i]));
  }
  cout<<an<<endl;
}

Measured memory_bytes: 4992
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
using namespace std;


int N,M;
int graph[100][100];

bool friendly(vector<int>& u, int k)
{
	for(int i=0; i<u.size(); i++) 
		if(graph[u[i]][k] == 0) return false;

	return true;
}

int solve(vector<int>& u, int k)
{
	int res = 0;
	for(int i=k; i<N; i++) {
		if(!friendly(u, i)) continue;

		int tc = 0;
		u.push_back(i);

		if(u.size() > 1) {
			for(int j=0; j<u.size(); j++) {
				int v = (1<<28);
				for(int k=0; k<u.size(); k++) {
					if(j==k) continue;
					v = min(v, graph[u[j]][u[k]]);
				}
				tc += v;
			}
		}

		res = max(res, tc);
		res = max(res, solve(u,i+1));

		u.pop_back();
	}

	return res;
}

int main()
{
	memset(graph,0,sizeof(graph));

	cin >> N >> M;
	for(int i=0; i<M; i++) {
		int s,t,c;
		cin >> s >> t >> c;
		s--; t--;

		graph[s][t] = graph[t][s] = c;
	}

	vector<int> a;
	cout << solve(a, 0) << endl;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int n,i,A[100001],cost[100001];
int main(){
  cin>>n;
  for(i=0;i<n;i++)
    cin>>A[i];
  cost[0]=0;
  for(i=1;i<n;i++){
    if(i-2>=0)
      cost[i]=min(cost[i-1]+abs(A[i]-A[i-1]), cost[i-2]+abs(A[i]-A[i-2]));
     else
                  cost[i]=cost[i-1]+abs(A[i]-A[i-1]);
                                        }
                                        cout<<cost[n-1];}

Measured memory_bytes: 1024
foods = [int(input()) for i in range(5)]
time = 0
minmod = 10

for i in foods:
  time += i
  mod = i % 10
  if mod != 0:
    time += 10 - mod
    if mod < minmod or minmod == 10:
      minmod = mod

print(time - 10 + minmod)

Measured memory_bytes: 3060
# -*- coding: utf-8 -*-
import math
import itertools
a = int(input())
b = []


def dist(p1,p2):
    return(math.sqrt((p1[0]-p2[0])**2 + (p1[1]-p2[1])**2))


def calc_dist(l):
    r = 0
    for i in range(len(l)-1):
        r += dist(l[i],l[i+1])
    return(r)


for i in range(a):
    c = input().split()
    c[0],c[1] = int(c[0]),int(c[1])
    b.append(c)


r = 0

for l in list(itertools.permutations(b)):
    r += calc_dist(l)

print(r/math.factorial(a))

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

int main()
{
  int W,H = 0;

  while(1)
    {
      cin >> H >> W;

      if(H == 0 && W == 0)
	{
	  break;
	}

      for(int i = 0;i< H;i++)
	{
	  for(int j = 0;j < W;j++)
	    {
	      if(( i % 2 == 0 && j % 2 == 0 )||( i % 2 == 1 && j % 2 == 1 ))
		{
		  cout << "#";
		}
	      else
		{
		  cout << ".";
		}
	    }
	  cout << endl;
	}
      cout << endl;
    }
}



Measured memory_bytes: 3088
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <set>
#include <map>
#include <iterator>
#include <stack>
#include <string.h>
#include <cstdlib>
#include <queue>
#include <list>
#include <string>
#define rep(i,n) for(int i = 0; i < (n); i++) 
using namespace std; 

int main() {
	int n;
	float ans, syo;
	cin >> n;
	if (n%2 == 0) {
		syo = n/2;
	} else {
		syo = (n/2) + 1;
	}
	ans = syo/n;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
from collections import deque

d= deque()

N = int(input())
L = map(int,input().split())
L = sorted(list(L))[::-1]
import heapq
ans = 0
ideal = []
ans += L[0]
del L[0]
heapq.heappush(ideal, -L[0])
heapq.heappush(ideal, -L[0])
del L[0]

for x in L:
    ans += -1 * heapq.heappop(ideal)
    heapq.heappush(ideal, -x)
    heapq.heappush(ideal, -x)

print(ans)

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

typedef long long ll;

int n, a;
ll x[51], dp[51][51][2501], ans;

int main()
{
    cin >> n >> a;
    for (int i = 1; i <= n; i++)
        cin >> x[i];
    dp[0][0][0] = 1;
    for (int i = 1; i <= n; i++)
    {
        for (int parts = 0; parts <= n; parts++)
        {
            for (int total = 0; total <= 2500; total++)
            {
                dp[i][parts][total] = dp[i-1][parts][total];
                if (parts && total - x[i] >= 0) dp[i][parts][total] += dp[i-1][parts-1][total-x[i]];
            }
        }
    }
    for (int parts = 1; parts <= n; parts++)
        ans += dp[n][parts][a*parts];
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 50048
#include<iostream>

using namespace std;
using ll = long long;

int main() {
	ll  N, M;
	ll x;
	ll sum = 0;
	cin>>N>>M;
	for (int i = 0;i < M;++i) {
		cin>>x;
		sum += x;
	}

	if (sum <= N) {
		cout<<N-sum<<endl;
	}
	else {
		cout<<-1<<endl;
	}

	return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> PII;


// chmax, chmin
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
function<T(T, T)> op_max = [](T a, T b) -> T { return max(a, b); };
template <typename T>
function<T(T, T)> op_min = [](T a, T b) -> T { return min(a, b); };

template <typename T>
function<T(T, T)> op_sum = [](T a, T b) -> T { return a + b; };

namespace detail {
template <typename T, std::size_t NDIMS>
struct vector_builder {
  using type = std::vector<typename vector_builder<T, NDIMS - 1>::type>;

  static type make(std::vector<std::size_t> dims, const T& v = {}) {
    const auto vec = std::vector<T>(dims.empty() ? 0 : dims.back(), v);
    if (!dims.empty()) dims.pop_back();
    return vector_builder<std::vector<T>, NDIMS - 1>::make(dims, vec);
  }
};

template <typename T>
struct vector_builder<T, 1> {
  using type = std::vector<T>;

  static type make(std::vector<std::size_t> dims, const T& v = {}) {
    return type(dims.empty() ? 0 : dims.back(), v);
  }
};
}  // namespace detail

template <typename T, typename... SIZE_T>
auto exvector(const T& v, SIZE_T... dims) {
  static_assert(sizeof...(dims) != 0, "invalid dimension");
  std::vector<std::size_t> vec_dims{dims...};
  return detail::vector_builder<T, sizeof...(dims)>::make(vec_dims, v);
}

using namespace std;
//********************  dumps ************************//

template <typename T>
void dump(const T& data, vector<int>& iter) {
  cout << data << " ";
}
template <typename T>
void dump(const vector<T>& data, vector<int>& iter) {
  for (auto elem : data) dump(elem, iter);
  cout << endl;
}

template <typename T>
void dump(const vector<vector<T>>& data, vector<int>& iter) {
  for (auto elem : iter) {
    cout << "[" << elem << "]";
  }
  cout << endl;
  for (int i = 0; i < data.size(); i++) {
    iter.push_back(i);
    dump(data[i], iter);
    iter.pop_back();
  }
  cout << endl;
}

template <typename T>
void dump(const vector<T>& data, int dummy) {
  for (int i = 0; i < data.size(); i++) {
    cout << "[" << i << "] " << data[i] << endl;
  }
}
template <typename T>
void dump(const T& data) {  // T : data, U = base type val.
  vector<int> iter;
  dump(data, iter);
}
///////////////////////////////////////////////


void solve(long long N, long long A, long long B, long long C, long long D, long long E){
  vector<LL> vals = {A, B, C, D, E};

  LL ans = 0;
  for(auto val: vals) {
    chmax(ans, (N-1) / val + 1);
  }
  cout << ans + 4 <<endl;
}

int main(){ 
    cout << setprecision(10);
    long long N;
    scanf("%lld",&N);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    long long D;
    scanf("%lld",&D);
    long long E;
    scanf("%lld",&E);
    solve(N, A, B, C, D, E);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ini(a,i) memset(a,i,sizeof(a))
#define pb push_back
#define ll long long

int main()
{
	std::ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	//ll tt;	cin>>tt;	while(tt--)
	{
		ll n,c,i,j;
		cin>>n>>c;	
		ll w[n+1],v[n+1];

		for(i=0;i<n;i++)	{cin>>w[i]>>v[i];}

		ll dp[n+2][c+2];
		ini(dp,0);

		for(i=0;i<=n;i++)	
		{
			for(j=0;j<=c;j++)
			{
				if(i==0 or j==0)	continue;
				else if(w[i-1]<=j)	dp[i][j]=max(dp[i-1][j],v[i-1]+dp[i-1][j-w[i-1]]);
				else	dp[i][j]=dp[i-1][j];
			}
		}
		
		cout<<dp[n][c];
 	
 	}
	cerr<<" Execution : "<<(1.0*clock())/CLOCKS_PER_SEC<<"s \n";
		
		
return 0;
}

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

int n, a[200000], b[200000];

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

	int index = 0, s = n - 1;
	for (int i = 0; i < n; i++) {
		b[index] = a[n-(i+1)];
		
		if (i % 2 == 0) {
			index += s;
		}
		else {
			index -= s;
		}
		s--;
	}

	for (int i = 0; i < n; i++) {
		cout << b[i];
		if (i != n - 1)cout << " ";
	}
	cout << endl;
}

Measured memory_bytes: 3712
n = int(input())
a = input().split()
min = int(a[0])
max = int(a[0])
sum = 0
for i in a:
    if min > int(i):
        min = int(i)
    if max < int(i):
        max = int(i)
    sum += int(i)
print("{0} {1} {2}".format(min, max, sum))

Measured memory_bytes: 8340
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <chrono>

using namespace std;

int main(int argc, const char * argv[]) {
    
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int q; cin >> q;
    for (int m = 0; m < q; m++) {
        string s, t; cin >> s >> t;
        vector<vector<int>> dp(s.size() + 1, vector<int>(t.size() + 1, 0));
        
        for (int i = 0; i < s.size(); i++) {
            for (int j = 0; j < t.size(); j++) {
                if (s.at(i) == t.at(j)) dp[i + 1][j + 1] = dp[i][j] + 1;
                else dp[i + 1][j + 1] = max(dp[i + 1][j], dp[i][j + 1]);
            }
        }
        
        cout << dp[s.size()][t.size()] << endl;
    }
    
    return 0;
}



Measured memory_bytes: 6816
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using P   = pair<ll, ll>;
using mat = vector<vector<ll>>;

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

const ll INF = 1e16;
const ll MOD = 1e9 + 7;
const ld EPS = 1e-12;

template <typename T> void dump(T x) { cout << x << endl; }
void dumpf(ld x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}

inline ll mod(ll a, ll b) {
	if (a > 0) return a % b;
	if (a % b == 0) return 0;
	ll x = -a / b + 1;
	a += x * b;
	return a % b;
}

// ll dx[4] = {1, 0, -1, 0};
// ll dy[4] = {0, 1, 0, -1};

int main() {
	IOS();
	ll n, m, c;
	cin >> n >> m >> c;
	vector<ll> b(m);
	for (int i = 0; i < m; i++) {
		cin >> b[i];
	}
	ll ans = 0;
	for (int i = 0; i < n; i++) {
		ll cnt = c;
		for (int j = 0; j < m; j++) {
			ll a;
			cin >> a;
			cnt += a * b[j];
		}
		if (cnt > 0) ans++;
	}
	dump(ans);
	return 0;
}

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


int main()
{
	ll X,Y;
	cin>>X>>Y;
	ll ans=0;
	while(X<=Y)
	{
		ans++;
		X*=2;	
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256