akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
template<typename T>inline T read(){
	T f=0,x=0;char c=getchar();
	while(!isdigit(c)) f=c=='-',c=getchar();
	while(isdigit(c)) x=x*10+c-48,c=getchar();
	return f?-x:x;
}
namespace run{
	const int N=5e5+9,mod=998244353;
	inline int add(int x,int y){return x+y>=mod?x-mod+y:x+y;}
	inline int sub(int x,int y){return x>=y?x-y:x+mod-y;}
	inline int qpow(int x,int y){
		int ret=1;
		while(y){
			if(y&1) ret=1LL*x*ret%mod;
			x=1LL*x*x%mod,y>>=1;
		}
		return ret;
	}
	int fac[N],ifac[N],pwn[N],pwm[N];
	inline int C(int n,int m){
		if(n<0 || m<0 || n<m) return 0;
		return 1LL*fac[n]*ifac[m]%mod*ifac[n-m]%mod;
	}

	int n,m;
	int main(){
		n=read<int>(),m=read<int>();
		if(n<m) swap(n,m);

		fac[0]=ifac[0]=pwn[0]=pwm[0]=1;
		for(int i=1;i<=n;i++) fac[i]=1LL*fac[i-1]*i%mod;
		ifac[n]=qpow(fac[n],mod-2);
		for(int i=n-1;i>=1;i--) ifac[i]=1LL*ifac[i+1]*(i+1)%mod;
		for(int i=1;i<=n;i++) pwm[i]=1LL*pwm[i-1]*(m+1)%mod;
		for(int i=1;i<=m;i++) pwn[i]=1LL*pwn[i-1]*(n+1)%mod;

		int ans=0;
		for(int i=0;i<=m;i++){
			int tmp=1LL*fac[i]*C(n,i)%mod*C(m,i)%mod*pwn[m-i]%mod*pwm[n-i]%mod;
			if(i&1) ans=sub(ans,tmp);
			else ans=add(ans,tmp);
		}
		printf("%d\n",ans);
		return 0;
	}
}
int main(){
#ifdef my
	freopen(".in","r",stdin);
	freopen(".out","w",stdout);
#endif
	return run::main();
}

Measured memory_bytes: 11432
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
using namespace std;

int main(){
    int r, g, b;
    cin >> r >> g >> b;
    if((100*r+10*g+b) % 4 == 0)cout << "YES";
    else cout << "NO";
}  

Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int main(){
    string c;
    cin >> c;
    if(c == "a") cout << "vowel";
    else if(c == "i") cout << "vowel";
    else if(c == "u") cout << "vowel";
    else if(c == "e") cout << "vowel";
    else if(c == "o") cout << "vowel";
    else cout << "consonant";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define endl "\n"

ll power(ll a, ll b){
  ll res = 1;

  while (b > 0){
    if (b%2) res *= a;
    a *= a;
    b /= 2;
  } 

  return res;
}

 
int main ()
{
  
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  #define int ll
  
  int x;
  cin >> x;

  map <int, int> hello;
  
  for (int i=0; true; i++){
    int now = power(i, 5);
    if (now > 2e18) break;
    hello[now] = i;
    hello[-now] = -i;
  }
  // int num1, num2;
  int ans1, ans2;

  for (auto it = hello.begin(); it != hello.end(); it++){
    int now = it->first;
    int need = x + now;
    if (hello.count(need)){
      ans1 = hello[need];
      ans2 = it->second;
      break;
    }
  }

  cout << ans1 << " " << ans2 << endl;
  
  
  return 0;
  
}


Measured memory_bytes: 4204
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>  
#include <stdbool.h>   
#define inf (INT_MAX-1)
#define INF 9223372036854775807
#define PI 3.14159265358979323846;
#define EPS 1e-10
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
/*
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r)
*/
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r)
#define TYPE long long
#define ll long long
#define MEMSET(a) memset(a,0,sizeof(a))
#define MEMSET_U(a) memset(a,-1,sizeof(a))
#define bool    _Bool
const int mod = (int)1e09 + 7;

//#define DEBUG1
//#define DEBUG2
//#define DEBUGF
#define DUMMY

int in(void) { int i; scanf("%d", &i); return i; }
long long llin(void) { long long i; scanf("%lld", &i); return i; }
double din(void) { double i; scanf("%lf", &i); return i; }
void chin(char s[]) { scanf("%s", s); }

void print(int a) { printf("%d\n", a); }
void llprint(long long a) { printf("%lld\n", a); }
void dprint(double a) { printf("%.10f\n", a); }
void print2(int a, int b) { printf("%d %d\n", a, b); }
int Max(int a, int b) { if (a > b) { return a; }return b; }
int Min(int a, int b) { if (a < b) { return a; }return b; }
long long llmax(long long a, long long b) { return a > b ? a : b; }
long long llmin(long long a, long long b) { return a < b ? a : b; }
double dmax(double a, double b) { return a > b ? a : b; }
double dmin(double a, double b) { return a < b ? a : b; }
//long long llmax(long long a, long long b) { return a > b ? a : b; }
//long long llmin(long long a, long long b) { return a < b ? a : b; }
//double dmax(double a, double b) { return a > b ? a : b; }
int cmp(const void *a, const void *b) { return *(TYPE *)a - *(TYPE *)b; }
int cmp_r(const void *a, const void *b) { return *(TYPE *)b - *(TYPE *)a; }
int char_cmp(const void *a, const void *b) { return strcmp((char *)a, (char *)b); }
int char_cmp_r(const void *a, const void *b) { return strcmp((char *)b, (char *)a); }
void swap(int *a, int *b) { int t = *a; *a = *b; *b = t; }



int main() {
	char W[101];
	int f[26] = { 0 };
	int ng = 0;
	scanf("%s", W);

	for (int i = 0; i < strlen(W); i++) {
		f[W[i] - 'a']++;
	}
	for (int i = 0; i < 26; i++) {
		if (f[i]%2 != 0) {
			ng++;
			break;
		}
	}

	if (ng) {
		puts("No");
	}
	else {
		puts("Yes");
	}






#ifdef DEBUGF
	getch();
#endif
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define DBG_N(hoge) cerr<<" "<<(hoge)<<endl;
#define DBG cerr<<"!"<<endl;
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll a,b,c,d,e;
  string s,ss,sss;
  cin>>a>>b;
  a*=3;
  a+=b;
  cout<<a/2<<endl;
  return 0;
}


Measured memory_bytes: 256
n, h = map(int, input().split())
k = [None] * (n*2)

from math import ceil

for i in range(0, n*2, 2):
    a, b = map(int, input().split())
    k[i] = (a, True)
    k[i+1] = (b, False)

k.sort(reverse=True)
cnt = 0

for i in range(n*2):
    if k[i][1]:
        print(i + ceil((h - cnt) / k[i][0]))
        break
    cnt += k[i][0]
    if cnt >= h: 
        print(i+1)
        break


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

using namespace std;
const int MAX  =  1e5+7;
int a[MAX];

int main(){
    int n, k, q;

    cin>>n>>k>>q;
    int cnt = 0;

    for(int i = 1; i <= n; i++)
        a[i] = k;

    for(int i = 1; i <= q; i++) {
        cin>>k;
        a[k]++;
    }

    for(int i = 1; i <= n; i++) {
        if(a[i] <= q)
            puts("No");
        else
            puts("Yes");
    }

    return 0;
}


Measured memory_bytes: 1024
import java.util.*;

public class Main {
  public static void main (String[] args) {
    Scanner sc = new Scanner(System.in);
    
    int n = sc.nextInt();
    int a = sc.nextInt();
    int b = sc.nextInt();
    
    int c = a * n;
    
    System.out.println(Math.min(b, c));
  }
}

Measured memory_bytes: 21716
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <algorithm>

using namespace std;

int main(void)
{
    int p,q,r;

    cin >>p >>q >>r;

    printf("%d\n", min(min(p+q, p+r),q+r));

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cassert>
#include <iomanip>
#include <utility>
#include <cmath>
#include <numeric>
#include <vector>
#include <set>
#include <algorithm>
#include <queue>
#include <string>

using namespace std;

typedef long long ll;
typedef pair<int, int> p_i;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repext(i, a, b) for (int i = a; i < b; i++)
#define reprev(i, n) for (int i = n - 1; i >= 0; i--)
#define repextrev(i, a, b) for (int i = b - 1; i >= a; i--)
#define vec_all(vec) vec.begin(), vec.end()

// vectorデバッグ
template<typename T>
void dump_vec(vector<T> vec) {
    rep(i, vec.size()) {
        cout << vec[i] << endl;
    }
}

// --- notice ---
// intの和はllにしろ

int main() {
    int a, b, c, d, e, f;
    cin >> a >> b >> c >> d >> e >> f;

    vector<int> able_water;
    int w;
    // 水の検証
    rep(i, f / (100 * a) + 1) {
        rep(j, f / (100 * b) + 1) {
            w = 100 * a * i + 100 * b * j;
            if (w <= f) {
                able_water.push_back(w);
            }
        }
    }

    vector<int> able_sugar;
    rep(i, f / c + 1) {
        rep(j, f / d + 1) {
            w = c * i + d * j;
            if (w <= f) {
                able_sugar.push_back(w);
            }
        }
    }

    int water;
    int sugar;
    int ans_water = 100 * a;
    int ans_sugar = 0;
    rep(i, able_water.size()) {
        water = able_water[i];
        rep(j, able_sugar.size()) {
            sugar = able_sugar[j];
            if (water + sugar <= f && sugar * 100 <= water * e && sugar * ans_water > ans_sugar * water) {
                ans_water = water;
                ans_sugar = sugar;
            }
        }
    }

    cout << ans_water + ans_sugar << " " << ans_sugar << endl;

    return 0;
}

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

int main() {
  int N, A;
  cin >> N;
  cin >> A;
//  cout << N << A << N % 500 << endl;
//  cout << A << endl;
  if (N % 500 <= A) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define dcm(a) setprecision(a)<<fixed
#define MOD 1000000007
#define clr(memo, a) memset(memo,a,sizeof(memo))
int const N=1e5+5;
int a[N];
int n;
int memo[N];
int dp(int i){
    if(i>n)
        return +N;
    if(i==n-1)
        return 0;
    int &ret=memo[i];
    if(ret!=-1)
        return ret;
    return ret=min(dp(i+1)+abs(a[i+1]-a[i]),dp(i+2)+abs(a[i+2]-a[i]));
}
int main()
{cin>>n;
for(int i=0;i<n;i++)
    cin>>a[i];
clr(memo,-1);
cout<<dp(0)<<endl;


}


Measured memory_bytes: 2560
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include <sstream>
#include<iomanip>
#include <ctype.h>

//#include<bits/stdc++.h>




using namespace std;
int main() {
	int x;
	cin >> x;
	if (x < 1000)cout << "ABC" << endl;
	else cout << "ABD" << endl;

	return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

n = int(input())
a = list( map(int, input().split()))
q = int(input())

from collections import Counter
cnt = Counter(a)

ans = [sum(a)]

for i in range(q):
    b, c = map(int, input().split())
    cb = cnt[b]
    if cb:
        cnt[b]=0
        cnt[c]+=cb
        ans.append(ans[-1]-cb*b+cb*c)
    else:
        ans.append(ans[-1])

for i in range(1,q+1):
    print(ans[i])

Measured memory_bytes: 85932
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n; cin >> n;
  	int cur = 0;
  	for (int i = 0; i < n; i++) {
    	int x; cin >> x;
      	if (x - 1 == cur) cur++;
    }
  	if (cur == 0) cout << -1 << endl;
  else
  	cout << n - cur << endl;
}


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

#define F first
#define S second
#define P push
#define pb push_back
#define MEM(dp,i) memset(dp,i,sizeof(dp))
#define W while
#define R return
#define C continue
#define SI size()
#define ll long long
#define ld long double
#define pll pair<ll,ll>
#define pii pair<int,int>
#define SF(x) scanf("%Id",&x)
#define SF2(x,y) scanf("%Id%Id",&x,&y)
#define SF3(x,y,z) scanf("%I64d%I64d%I64d",&x,&y,&z)
#define SF4(x,y,z,o) scanf("%I64d%I64d%I64d%I64d",&x,&y,&z,&o)
#define all(v) v.begin(),v.end()

using namespace std;
const long long INF = 1e9;
const long long MOD = 1e9+7;
const int MX=100015;

int n,m;
int num[100005];
vector<pii> adj[100005];
bool vis[100005];
void DFS(int ver,int ind){
    if(vis[ver]){
        if(ind==num[ver])R;
        cout<<"No";
        exit(0);
    }
    vis[ver]=1;
    num[ver]=ind;
    for(auto i : adj[ver]){
        DFS(i.F,ind+i.S);
    }
}
int main()
{
    cin>>n>>m;
    int a,b,c;
    for(int i=0;i<m;i++){
        cin>>a>>b>>c;
        adj[a].pb({b,c});
        adj[b].pb({a,-c});
    }
    for(int i=1;i<=n;i++){
        if(!vis[i]){
            DFS(i,0);
        }
    }
    cout<<"Yes";
}


Measured memory_bytes: 11136
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 1000000002486618624LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);

  int N, a, x = 0, y = 0, z = 0;

  std::cin >> N;

  for (int i = 0; i < N; i ++) {
    std::cin >> a;

    if (a % 4 == 0) {
      y ++;
    }
    else if (a % 2 == 0) {
      x ++;
    }
    else {
      z ++;
    }
  }

  if (x) {
    std::cout << (y >= z ? "Yes" : "No") << std::endl;
  }
  else {
    std::cout << (y >= z - 1 ? "Yes" : "No") << std::endl;
  }

  return 0;
}


Measured memory_bytes: 256
a_num_str, operator, b_num_str = map(str, input().split())

a_num_int = int(a_num_str)
b_num_int = int(b_num_str)

if operator == "+" :
    sum_a_b = a_num_int + b_num_int
    print(sum_a_b)
elif operator == "-" :
    sum_a_b = a_num_int - b_num_int
    print(sum_a_b)

Measured memory_bytes: 9120
A, B, C, X, Y = map(int, input().split())

answer = 10 ** 18
for c in range(10 ** 5 + 1):
    a = X - c
    b = Y - c
    cost = C * c * 2
    cost += max(a, 0) * A
    cost += max(b, 0) * B
    if answer > cost:
        answer = cost
print(answer)

Measured memory_bytes: 9172
N = int(input())
D1 = [0]*N
D2 = [0]*N
for i in range(N):
    D1[i], D2[i] = map(int, input().split())

cnt = 0
is_zorome = False
for i in range(N):
    if D1[i] == D2[i]:
        cnt+=1
    else:
        cnt=0
    if cnt == 3:
        is_zorome = True

if is_zorome:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 9196
s = gets.chomp
ret1 = 0
ret2 = 0
s.each_char.with_index do |c, i|
    if i % 2 == 0
        ret1 += 1 if c == '0'
    else
        ret1 += 1 if c == '1'
    end
end
s.each_char.with_index do |c, i|
    if i % 2 == 0
        ret2 += 1 if c == '1'
    else
        ret2 += 1 if c == '0'
    end
end
puts [ret1, ret2].min

Measured memory_bytes: 1916
import sys
sys.setrecursionlimit(10**7)

readline = sys.stdin.buffer.readline
def readstr():return readline().rstrip().decode()
def readstrs():return list(readline().decode().split())
def readint():return int(readline())
def readints():return list(map(int,readline().split()))
def printrows(x):print('\n'.join(map(str,x)))
def printline(x):print(' '.join(map(str,x)))

import heapq


w,h =readints()
p = [readint() for i in range(w)]
q = [readint() for i in range(h)]

heapq.heapify(p)
heapq.heapify(q)

edge = 0
cost = 0
used = [0,0]

while edge < (h+1)*(w+1)-1:
    if p and q:
        if p[0]<q[0]:
            flag = 1
        else:
            flag = 0
    elif p:
        flag = 1
    else:
        flag = 0
    if flag:
        x = heapq.heappop(p)
        edge += h+1-used[1]
        cost += x * (h+1-used[1])
        used[0] += 1
    else:
        x = heapq.heappop(q)
        edge += w+1-used[0]
        cost += x * (w+1-used[0])
        used[1] += 1

print(cost)










Measured memory_bytes: 81748
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c;
  	cin>>a>>b>>c;
  	if(a!=b&&b!=c&&a!=c){
    	cout<<"No"<<endl;
    }
  	else if(a==b&&b==c&&a==c){
    	cout<<"No"<<endl;
    }
  	else{
    	cout<<"Yes"<<endl;
    }
  	
  	

}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices.ComTypes;

namespace ABC156D
{
    class Program
    {
        static void Main(string[] args)
        {
            long[] nav = ReadLong();
            long n = nav[0];
            long a = nav[1];
            long b = nav[2];

            long mod = 1000000000 + 7;

            //long[] pow = new long[64];
            //pow[0] = 1;
            //pow[1] = 2;
            //for (int i = 2; i < pow.Length; i++)
            //{
            //    pow[i] = (pow[i - 1] * pow[i - 1]) % mod;
            //}

            //long all = 0;
            //for (int i = 0; i < pow.Length; i++)
            //{
            //    var shift = n >> i;
            //    if (shift % 2 == 1) all = (all + pow[i + 1]) % mod;
            //}
            long all = Calc.ModPow(2, n, mod);

            long nCa = Calc.nCk(n, a, mod);
            long nCb = Calc.nCk(n, b, mod);

            long ans = (all - 1 - nCa - nCb) % mod;
            if (ans < 0) ans += mod;

            Console.WriteLine(ans);
            Console.ReadKey();
        }


        static int[] ReadInt()
        {
            int[] ret = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return ret;
        }
        static long[] ReadLong()
        {
            long[] ret = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return ret;
        }
    }

    static class Calc
    {

        /// <summary>
        /// a^n (mod p)
        /// nが非常に大きい時に有効
        /// </summary>
        /// <param name="a"></param>
        /// <param name="n"></param>
        /// <param name="mod"></param>
        /// <returns></returns>
        public static long ModPow(long a, long n, long p)
        {
            if (n == 1) return a % p;
            if (n % 2 == 1) return (a * ModPow(a, n - 1, p)) % p;

            long t = ModPow(a, n / 2, p);
            return (t * t) % p;
        }

        /// <summary>
        /// 組み合わせ個数
        /// </summary>
        /// <param name="n"></param>
        /// <param name="k"></param>
        /// <param name="p"></param>
        /// <returns></returns>
        public static long nCk(long n, long k, long p)
        {
            long ans = 1;
            for (long i = n; i > n - k; i--)
            {
                ans = (ans * i) % p;
            }

            for (long i = 1; i <= k; i++)
            {
                ans = (ans * ModPow(i, p - 2, p)) % p;
            }

            return ans;
        }
    }
}


Measured memory_bytes: 13396
#include <iostream>
#include <vector>
#include <functional>
#include <algorithm>
#include <numeric>
#include <string>
#include <map>
#include <queue>
using namespace std;

typedef long long ll;

int main(){
        ll N, M, a, b;
        cin >> N >> M;
        vector<pair<ll, ll>> A(N);
        priority_queue<ll> que;

        for(ll i=0; i<N; i++){
                cin >> A[i].first >> A[i].second;
        }
        sort(A.begin(), A.end());
        ll point = 0, count = 0,m = 1;
        while(M>=m){
                for(int i=point; A[i].first<=m && i < N;i++){
                        que.push(A[i].second);
                        point++;
                }
                if(!que.empty()){
                        count += que.top();
                        que.pop();

                }
                m++;
        }
        cout << count;
}

Measured memory_bytes: 2936
hlist = []
wlist = []

while(1):
    h, w = map(int, input().split())
    if h == 0 and w == 0:
        break

    hlist.append(h)
    wlist.append(w)

for h, w in zip(hlist, wlist):
    for i in range(h):
        for j in range(w):
            print("#", end="")
        print()
    print()



Measured memory_bytes: 7012
import sys
sys.setrecursionlimit(10**4)
N = int(input())
I = [[] for _ in range(N)]

i = 1
for a in list(map(int, input().split())):
  I[a-1].append(i)
  i += 1
X = list(map(int, input().split()))

def dfs(v,I,X):
  INF = 10**20
  DP = [INF for _ in range(X[v]+1)]
  DP[0] = 0
  for i in I[v]:
    x = X[i]
    y = dfs(i,I,X)
    if x < y:
      x,y = y,x  # x >= y
    for a in range(X[v],-1,-1):
      if a-y >= 0:
        DP[a] = DP[a-y] + x
        if a-x >= 0:
          DP[a] = min(DP[a], DP[a-x] + y)
      else:
        DP[a] = INF
        
  ans = min(DP)
  #print(DP, v)
  if ans >= INF:
    print("IMPOSSIBLE")
    sys.exit()                        
    
  del DP, INF
  return ans

dfs(0,I,X)
print("POSSIBLE")
  
                                                      

Measured memory_bytes: 33924
function Main(input) {
  const line = input.split('\n');
  var tmp = line[0].split(' ');
  const N = tmp[0];
  const X = parseInt(tmp[1], 10);;
  var ans = 1;
  var inc = 0;
  tmp = line[1].split(' ');
  var Ls = [];
  for (var v of tmp) {
    Ls.push(parseInt(v,10));
  }
  for (var v of Ls) {
    inc += v;
    if (inc<=X){
      ans++;
    }else{
      break;
    }
  }
  console.log('%d',ans);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 11468
#include<bits/stdc++.h>
using namespace std;
#define FILEIN freopen("input.txt", "r", stdin)

#define ll long long
#define endl "\n"

int main(){
	// FILEIN;
	map<string, int> m;
	string s, t, b;
	cin>>s>>t;
	int a; cin>>a;
	m[s] = a;
	cin>>a;
	m[t] = a;
	cin>>b;
	m[b]--;
	cout<<m[s]<<" "<<m[t]<<endl;

}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define dump(x) cout << (x) << endl;
typedef int64_t Int;
Int mod = 1e9+7;
Int INF = 114514810893364364;

int main() {
  string s, t;
  cin >> s >> t;
  for (Int i = 0; i < (Int)t.size(); i++) {
    cout << s[i] << t[i];
  }
  if (s.size() > t.size()) cout << s[(Int)s.size() - 1];
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K, x;		//N:個数　K:ロボbのx座標 x:各ボールのx座標
  int sum = 0;	//sum:移動距離合計
  
  cin >> N >> K ;	//個数・ロボ座標の入力
  for(int i=0; i<N ; i++){
    cin >> x;	// ボール座標の入力
    if( K - x <= x ){	// K>x なので K-x は正数
      sum += (K - x) * 2;
    }else{
      sum += x * 2;
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
 
public class Main {
    private static boolean debug = false;
    private static boolean elapsed = false;
 
    private static PrintWriter _out = new PrintWriter(System.out);
    private static PrintWriter _err = new PrintWriter(System.err);
 
    private int N;
    private int M;
 
    private void solve(Scanner sc) {
        N = sc.nextInt();
        M = sc.nextInt();
        int[] a = new int[M];
        int[] b = new int[M];
        int[] c = new int[M];
        for (int i = 0; i < M; ++i) {
            a[i] = sc.nextInt() - 1;
            b[i] = sc.nextInt() - 1;
            c[i] = sc.nextInt();
        }
 
        long[][] dist = new long[N][N];
 
        // 初期化
        for (int i = 0; i < N; ++i) {
            for (int j = 0; j < N; ++j) {
                if (i == j) {
                    dist[i][j] = 0;
                } else {
                    dist[i][j] = Integer.MAX_VALUE;
                }
            }
        }
        for (int i = 0; i < M; ++i) {
            dist[a[i]][b[i]] = Math.min(dist[a[i]][b[i]], c[i]);
            dist[b[i]][a[i]] = Math.min(dist[b[i]][a[i]], c[i]);
        }
 
        // 本計算
        for (int k = 0; k < N; ++k) {
            for (int i = 0; i < N; ++i) {
                for (int j = 0; j < N; ++j) {
                    dist[i][j] = Math.min(dist[i][k] + dist[k][j], dist[i][j]);
                }
            }
        }
 
        int ans = M;
        for (int i = 0; i < M; ++i) {
            boolean shortest = false;
            for (int j = 0; j < N; ++j) {
                if (dist[j][a[i]] + c[i] == dist[j][b[i]]) {
                    shortest = true;
                    break;
                }
            }
            if (shortest) {
                --ans;
            }
        }
 
        _out.println(ans);
    }
    private long C(long n, long r) {
        long res = 1;
        for (long i = n; i > n - r; --i) {
            res *= i;
        }
        for (long i = r; i > 1; --i) {
            res /= i;
        }
        return res;
    }
    private long P(long n, long r) {
        long res = 1;
        for (long i = n; i > n - r; --i) {
            res *= i;
        }
        return res;
    }
    /*
     * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9
     * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18
     */
    public static void main(String[] args) {
        long S = System.currentTimeMillis();
 
        Scanner sc = new Scanner(System.in);
        new Main().solve(sc);
        _out.flush();
 
        long G = System.currentTimeMillis();
        if (elapsed) {
            _err.println((G - S) + "ms");
        }
        _err.flush();
    }
}

Measured memory_bytes: 27436
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        new Main().run();
    }

    private void run() {
        Scanner scanner = new Scanner(System.in);

        int N = scanner.nextInt();
        int M = scanner.nextInt();
        int[] A = new int[N];
        int sum = 0;

        for(int i = 0; i < N; i++) {
            A[i] = scanner.nextInt();
            sum += A[i];
        }
        int cnt = 0;
        double threshold = (double)sum / (4 * M);
        for(int i = 0; i < N; i++) {
            if(threshold <= (double)A[i]) cnt++;
        }

        if(cnt >= M) {
            System.out.println("Yes");
            return;
        }
        System.out.print("No");
    }
}

Measured memory_bytes: 21716
#include <stdio.h>

int main(){
  int N;
  int i=0;
  int flag = 0;
  scanf("%d",&N);
  
  int D1[N+1],D2[N+1];
  
  while(i<N){
    scanf("%d %d",&D1[i],&D2[i]);
    if(D1[i] == D2[i]) flag++;
    else flag = 0;
    if(flag >= 3){
      printf("Yes\n");
      break;
    }
    i++;
  }
  
  if(flag < 3 ) printf("No\n");
  
  return 0;
}

Measured memory_bytes: 1656
import sys,math
kk = []
tmp = []
s = []
ans = 0
N,M = map(int,input().split())
for i in range(M):
    k,*t = list(map(int,input().split()))
    s.append(t)
    kk.append(k)
p = [int(i) for i in input().split()]
for i in range(2**N):
    flag = 0
    si = [0] * N
    for j in range(N):
        if (i>>j) & 1:
            si[j] += 1
    for x in range(M):
        tt = 0
        for y in range(kk[x]):
            tt += si[s[x][y]-1] 
        if tt % 2 == p[x]:
            flag += 1
    if flag == M:
        ans += 1
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 3e5 + 10;

ll f(ll now, vector<ll>& va, vector<ll>& vb) {
    ll res = 1e18;
    auto it_a = lower_bound(va.begin(), va.end(), now), it_b=vb.begin();
    if(it_a != va.end()) {
        ll pos_a = *it_a, pos_b;
        // right
        it_b = lower_bound(vb.begin(), vb.end(), pos_a);
        if(it_b != vb.end()) {
            pos_b = *it_b;
            res = min(res, pos_b - now);
        }
        // left
        if(it_b != vb.begin()) {
            it_b--;
            pos_b = *it_b;
            res = min(res, pos_a-now+pos_a-pos_b);
        }
    }
    if(it_a != va.begin()) {
        it_a--;
        ll pos_a = *it_a, pos_b;
        // right
        it_b = lower_bound(vb.begin(), vb.end(), pos_a);
        if(it_b != vb.end()) {
            pos_b = *it_b;
            res = min(res, now-pos_a+pos_b-pos_a);
        }
        // left
        if(it_b != vb.begin()) {
            it_b--;
            pos_b = *it_b;
            res = min(res, now-pos_b);
        }
    }
    return res;
}

int main() {
    int a, b, q;
    cin >> a >> b >> q;
    vector<ll> va, vb;
    for(int i = 0; i < a; i++) {
        ll x;
        cin >> x;
        va.push_back(x);
    }
    sort(va.begin(), va.end());
    for(int i = 0; i < b; i++) {
        ll x;
        cin >> x;
        vb.push_back(x);
    }
    sort(vb.begin(), vb.end());
    while(q--) {
        ll x;
        cin >> x;
        cout << min(f(x, va, vb), f(x, vb, va)) << '\n';
    }
    return 0;
}

Measured memory_bytes: 3060
import sys
from collections import deque
from collections import  Counter
import statistics
import math
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

a, b = na()
if a <= 8 and b <=8:
    print("Yay!")
else:
    print(':(')

Measured memory_bytes: 5132
# Begin Header {{{
from math import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations, combinations_with_replacement
# }}} End Header
# _________コーディングはここから！！___________
# ... 最小側の制約も確認した？
# ... オーバーフローしない？
s = input()
ans = ""
for x in s:
    if x=='0': ans+='0'
    elif x == '1': ans+='1'
    else:
        if len(ans) == 0: pass
        else: ans = ans[:-1]
    #print(ans)
print(ans)



Measured memory_bytes: 9372
#include <iostream>
#include <string>

using namespace std;

string s;

int main()
{
	cin >> s;

	if (s.length() == 2)
	{
		cout << s;
	}
	else if (s.length() == 3)
	{
		cout << s[2] << s[1] << s[0];
	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do { cout << "\033[32;1m " << #x << " -> "; err(x); } while (0)
void err() { cout << "\033[39;0m" << endl; }
template<template<typename...> class T, typename t, typename... A>
void err(T<t> a, A... x) { for (auto v: a) cout << v << ' '; err(x...); }
template<typename T, typename... A>
void err(T a, A... x) { cout << a << ' '; err(x...); }
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
    print(v[i],i==(int)(v.size())-1?suc:2);
}
int main()
{
    int k,n;
    cin>>k>>n;
    if(k*500>=n) cout<<"Yes\n";
    else cout<<"No\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
string match(const vector<string> v){
	const string PTN[7][4]{
		{"11","11"},
		{"1","1","1","1"},
		{"1111"},
		{"01","11","10"},
		{"110","011"},
		{"10","11","01"},
		{"011","110"}
	};
	const int PTN_H[7]{2,4,1,3,2,3,2};
	const string PTN_NAME[7]={"A","B","C","D","E","F","G"};
	int ans=-1;
	for(int k=0;k<7;++k){
		int pw=PTN[k][0].size(),ph=PTN_H[k];
		for(int i=0;i<8;++i){
			for(int j=0;j<8;++j){
				if(i+ph<=8&&j+pw<=8){
					bool f=true;
					for(int l=0;l<ph;++l){
						if(PTN[k][l]!=v[i+l].substr(j,pw))f=false;
					}
					if(f){ans=k;break;break;break;}
				}else{
					break;
				}
			}
		}
	}
	return PTN_NAME[ans];
}
int main(){
	for(;;){
		vector<string> surface;
		for(int i=0;i<8;++i){
			string s;
			cin>>s;
			if(s.empty())return 0;
			surface.push_back(s);
		}
		string ans = match(surface);
		cout<<ans<<endl;
		if(cin.eof())break;
	}
	return 0;
}

Measured memory_bytes: 1196
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(int i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
using namespace std;
using ll=long long;
using ld=long double;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
struct edge{ll to,cost;};
struct edge2{ll from,to,cost;};

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

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    vP X(N);
    vP F(N);
    rep(i,N){
        cin >> X[i].first;
        X[i].second=i;
    }
    sort(X.begin(),X.end());
    F=X;
    reverse(F.begin(),F.end());
    int sum=0;
    rep(i,N){
        sum+=(N-1-F[i].second);
        int yutori=(N*N-F[i].first)-sum;
        //cout << yutori << endl;
        if(yutori<0){
            cout << "No" << endl;
            return 0;
        }
        sum++;
    }
    ll sum0=0;
    rep(i,N){
        sum0+=X[i].second+1;
        int yutori=X[i].first-sum0;
        if(yutori<0){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    queue<int> que;
    vector<int> cnt(N,N);
    vector<int> need(N,0);
    rep(i,N){
        need[i]=i+1;
    }
    ll now_x=0,now_n=0;
    rep(i,N*N){
        if(now_x<N&&X[now_x].first==i+1){
            cout << X[now_x].second+1 << ' ';
            cnt[X[now_x].second]--;need[X[now_x].second]--;
            rep(i,cnt[X[now_x].second]){
                que.push(X[now_x].second+1);
            }
            cnt[X[now_x].second]=0;
            need[X[now_x].second]=0;
            now_x++;
        }//queに挿入するやつ
        else{
            while(now_n<N&&need[X[now_n].second]<=1){
                now_n++;
            }
            if(now_n==N){
                int x=que.front();
                que.pop();
                cout << x << ' ';                
            }//queから取ってくるやつ
            else{
                cout << X[now_n].second+1 << ' ';
                cnt[X[now_n].second]--;
                need[X[now_n].second]--;
            }//needを減らすやつ
        }
    }
}
/*
overflow checked?
corner case checked?
boundary checked?
not TLE in worst case checked?
*/

Measured memory_bytes: 4072
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
	ll ans = 0;
	int tmp;
	int n;
	cin >> n;
	vector<ll> a(n+1);
	a[0] = -1;
	REP1(i, n) cin >> a[i];
	ll r[n+2] = {};
	bool ch = true;
	for(int i = n; i >= 1; i--){
		if(a[i] - a[i-1] > 1) ch = false;
		r[i] = max((ll)0,r[i+1]-1);
		if(a[i] > r[i]){
			ans += a[i];
			r[i] = a[i];
		}
	}
	if (ch) cout << ans << endl;
	else cout << "-1" << endl;
	//cout << ans << endl;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define _CRT_SECURE_NO_WARNINGS
#define ll long long
#define BUF 1e5
#define INF 1<<30
constexpr ll mod = 1e9 + 7;
using namespace std;
ll A, B, C, D, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

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


Measured memory_bytes: 256
// Problem : B - Mix Juice
// Contest : AtCoder - AtCoder Beginner Contest 171
// URL : https://atcoder.jp/contests/abc171/tasks/abc171_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define eb emplace_back
#define pb push_back
#define size(s) (int)s.size()
#define int long long
#define vi vector<int>
#define vs vector<string>
#define vv vector<vector<int>>
#define pii pair<int,int>
#define m_p(x,y) make_pair(x,y)
#define vp vector<pair<int,int>>
#define setbits(x) __builtin_popcountll(x)
#define f first
#define se second
#define inc(v,n,x) v.assign(n,x)
#define incd(v,n) v.resize(n)
#define iniz(n) memset(n,0,sizeof(n))
#define inin(n) memset(n,-1,sizeof(n))
#define inimi(n) memset(n,0xc0,sizeof(n))
#define inima(n) memset(n,0x3f,sizeof(n))
#define all(v) (v).begin(),(v).end()

using namespace std;

template<typename T1,typename T2>istream &operator>>(istream &is, vector<pair<T1,T2>> &v) { for (pair<T1,T2> &t : v) is >> t.f>>t.se; return is; }
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }

const int N=200001;
double pi=acos(-1.0);
int md=1e9+7;
const int INF=1e15;
int dx1[]={0,0,-1,1};
int dy1[]={1,-1,0,0};

template<class T>
T abst(T a)
{return a<0?-a:a;}

template<class T>
T max2(T a,T b){return a>b?a:b;}
template<class T>
T min2(T a,T b){return a<b?a:b;}

void solve()
{
int n,k;cin>>n>>k;
vi v(n);cin>>v;
int sum=0;
sort(all(v));
for(int i=0;i<k;i++)
sum+=v[i];
cout<<sum;
}

int32_t main(){
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int t=1;
//cin>>t;
for(int i=1;i<=t;i++)
{
    solve();
}
return 0;
}


Measured memory_bytes: 3652
#define _USE_MATH_DEFINES
#include  <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include <stdlib.h>
#include<stdio.h>
#include <queue>
#include<map>
#include <sstream>
#include<set>
#include<stack>

//#include<bits/stdc++.h>


using namespace std;



int main() {

	int n;
	cin >> n;
	vector<int>p(n);
	for (int i = 0; i < n; i++)cin >> p[i];
	vector<int>a(n), b(n);
	int t = p[0];
	a[0] = t;
	for (int j = 1; j < n; j++) {
		int r = p[j];
		if (t > r)swap(r, t);
		while (r%t != 0) {
			int x = t;
			t = r%t;
			r = x;
		}
		a[j] = t;

	}
	b[n - 1] = p[n - 1];
	t = b[n - 1];
	for (int i = n - 1; i >= 0; i--) {
		int r = p[i];
		if (t > r)swap(r, t);
		while (r%t != 0) {
			int x = t;
			t = r%t;
			r = x;
		}
		b[i] = t;
	//	cout << b[i] << " ";
	}
//	cout << endl;
	int ans = max(b[1], a[n - 2]);
//	cout << ans << endl;
	for (int i = 1; i < n - 1; i++) {
		
		int x = a[i - 1], y = b[i + 1];
		if (x > y)swap(x, y);
		while (y%x) {
			int m = x;
			x = y%x;
			y = m;
		}

		ans = max(ans, x);
	}
	cout << ans << endl;
	return 0;

}

Measured memory_bytes: 1408
#include "bits/stdc++.h"
#ifndef err
#define err(...)(void)0
#endif
using namespace std;
using ll = long long;
using ull = decltype(1ull);
template<class T>int size(T&&a) { return a.size(); }
#define REP(t,a)for(typename make_signed<decltype(a.second)>::type t=a.first,_l##t=a.second;t<_l##t;t++)
#define RREP(t,a)for(typename make_signed<decltype(a.second)>::type t=a.second-1,_l##t=a.first;t>=_l##t;t--)
template<class B>pair<int, B>make_pair(B b) { return{ 0,b }; }
#define rep(t,...)REP(t,make_pair(__VA_ARGS__))
#define rrep(t,...)RREP(t,make_pair(__VA_ARGS__))
#define all(a)begin(a),end(a)
#define rall(a)a.rbegin(),a.rend()

void Calc();
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr); cin.exceptions(istream::failbit | istream::badbit);
  cout << fixed << setprecision(15); Calc(); cout.flush(); return 0;
}
template<class A>void amax(A&a, A b) { a = max(a, b); }
template<class A>void amin(A&a, A b) { a = min(a, b); }
struct Scanner {
  template<class A = string>A Next() { A a; cin >> a; return a; }
  template<class A = int>vector<A>Array(int n) { vector<A>a(n); for (A&i : a) cin >> i; return a; }
  string Line() const { string s; getline(cin, s); return s; }
  template<class A>Scanner&operator,(A&a) { a = Next<A>(); return *this; }
  template<class A>operator A() { return Next<A>(); }
}in;

/*---------------------------------------------------------------------*/
vector<string> split(const string &str, char delim) {
  vector<string> res;
  size_t current = 0, found;
  while ((found = str.find_first_of(delim, current)) != string::npos) {
    res.push_back(string(str, current, found - current));
    current = found + 1;
  }
  res.push_back(string(str, current, str.size() - current));
  return res;
}
vector<string> split(const string &str, const string &delim) {
  vector<string> res;
  size_t current = 0, found, delimlen = delim.size();
  while ((found = str.find(delim, current)) != string::npos) {
    res.push_back(string(str, current, found - current));
    current = found + delimlen;
  }
  res.push_back(string(str, current, str.size() - current));
  return res;
}

void Calc() {

  string s = in;
  auto a = split(s,',');
  cout << a[0] << ' ' << a[1] << ' ' << a[2] << endl;

}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    static final int MOD = 2019;

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

        int min = l % MOD;
        int max = Math.min((r - l), MOD);
        int ans = MOD;
        for (int i = min; i <= min + max; i++) {
            for (int j = i + 1; j <= min + max; j++) {
                int tmp = (i * j) % MOD;
                if (tmp < ans) {
                    ans = tmp;
                }
            }
        }
        System.out.println(ans);
    }

}


Measured memory_bytes: 21844
#include <stdlib.h>
#include <stdio.h>
int compare(const void *a,const void *b){
    return *(int*)a-*(int*)b;
}
int main()
{   int n;
    scanf("%d",&n);
    int a[n],b[n];
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
        b[i]=a[i]-i;
    }
    qsort(b,n,sizeof(int),compare);
    int k=b[n/2];
    long ans=0;
    for(int i=0;i<n;i++){
        ans+=abs(b[i]-k);
    }
    printf("%ld",ans);
    return 0;
}


Measured memory_bytes: 2556
import java.util.*;

public class Main {
	  public static void main(String args[]){
      	Scanner scan = new Scanner(System.in);
          
        int n = scan.nextInt();
        String st[] = new String[3];
        
        st[0] = scan.next();
        st[1] = scan.next();
        st[2] = scan.next();
        
        int cnt = 0;
        
        for(int i = 0 ; i < n ; i++){
          
          if(st[0].substring(i,i+1).charAt(0) == st[1].substring(i,i+1).charAt(0) &&
             st[1].substring(i,i+1).charAt(0) == st[2].substring(i,i+1).charAt(0) ){
          }
          else if(st[0].substring(i,i+1).charAt(0) == st[1].substring(i,i+1).charAt(0) ||
             st[1].substring(i,i+1).charAt(0) == st[2].substring(i,i+1).charAt(0) ||
             st[0].substring(i,i+1).charAt(0) == st[2].substring(i,i+1).charAt(0) ){
            cnt++;
          }
          else
            cnt += 2;
        }
            
        System.out.println(cnt);
	  }
}

Measured memory_bytes: 22608
#include<bits/stdc++.h>
    #define int ll
    #define M 1000000007
    #define hell 998244353
    #define big 1e18
    #define pb push_back
    #define pi 3.1415926536
    #define mp make_pair
    #define ub upper_bound
    #define lb lower_bound
    #define mem0(a) memset(a,0,sizeof(a))
    #define memf(a) memset(a,false,sizeof(a))
    #define mem1(a) memset(a,1,sizeof(a))
    #define all(a) a.begin(),a.end()
    #define ll long long
    #define vec vector <int>
    #define pii pair<int,int>
    #define endl "\n"
    using namespace std;
    int power(int x, unsigned int y, unsigned int m) 
	{ 
    	if (y == 0) 
        	return 1; 
    	int p = power(x, y/2, m) % m; 
    	p = (p * p) % m; 
  
 	   return (y%2 == 0)? p : (x * p) % m; 
	} 
	int modInverse(int a, int m) 
	{   
    	return power(a, m-2, m);
	}
    signed main()
    {
    	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    	ll t=1;
    	// cin >> t;
    	/*SAARE INPUTS LENA*/
    	/*VARIABLES KI RANGE DEKHLENA*/
    	while(t-->0)
    	{
    		ll n=0;
    		cin>>n;
    		cout<<2*pi*n;
    	}
    	return 0;
    }

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

int main(){
    int n,m;
    cin>>n>>m;
    vector<int> s(m);
    vector<char> c(m);
    rep(i,m) cin>>s[i]>>c[i];

    for(int i=0;i<=999;i++){
        string x=to_string(i);
        if(x.size()!=n) continue;
        bool ok=true;
        rep(i,m){
            if(x[s[i]-1]!=c[i]) ok=false;
        }
        if(ok){
            cout<<i<<endl;
            return 0;
        }
    }

    cout<<-1<<endl;
}


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

#define ed cout << "\n";
#define speed                         \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define ll long long
#define ffor(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(i, n) ffor(i, 0, n)
#define All(obj) (obj).begin(), (obj).end()
#define INF ((ll)1e9 + 7)
#define c(a) cout << a << "\n";
using namespace std;
const int N = 100005;
ll gcd(ll a, ll b)
{
    if (a % b == 0)
        return (b);
    else
    {
        return gcd(b, a % b);
    }
}
ll lcm(ll a, ll b)
{
    return a * b / gcd(a, b);
}

int main()
{
    speed;
    cout << fixed << setprecision(6);
    /*start*/
    int a, b;
    cin >> a >> b;
    ll ans = lcm((ll)a, (ll)b);
    c(ans);
    return 0;
}

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

int main() {
  int n, k;
  cin >> n >> k;
  
  int count=0;
  while(n>=1){
    n/=k;
    count++;
  }
  
  cout << count << endl;
  
}

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

#define N_MAX 100

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

    long a = s;
    long i = 1;
    while (a != 1 && a != 2 && a != 4) {
        if (a % 2 == 0) {
            a /= 2;
        }
        else {
            a = 3 * a + 1;
        }
        i++;
    }

    cout << i + 3 << endl;

    return 0;
}


Measured memory_bytes: 256
d, n = map(int, input().split())

cnt = 0
for i in range(1, 10**7+1):
    if i%(100**d) == 0:
        cnt += 1
    if n == 100:
        if cnt == n+1:
            print(i)
            exit()
    else:
        if cnt == n:
            print(i)
            exit()
        

Measured memory_bytes: 64288
#include <iostream>
using namespace std;
int isValid(int nr) {
	if (nr >= 1 && nr <= 9)
		return 1;
		return 0;
}
int main()
{
	long long int N;
	cin >> N;
	long long int f1, f2;
	f1 = -1;
	f2 = -1;

	for (long long int i = 2; i*i <= N; i+=1)
	{
		if (N%i == 0)
		{
			f1 = i;
			f2 = N / i;
		}
	}
	if (f1 == -1)
	{
		cout << N - 1;
	}
	else cout << f1 + f2 - 2;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
constexpr long long MOD = 1000000007;
using ll = long long;
int main() {
ll n;
cin>>n;
ll a[n];
ll b[n];
for (ll i = 0; i < n; i++) {
    cin >> a[i];
    b[i] = a[i];
}
sort(b, b + n);
bool flag = false;
if (b[n - 1] == b[n - 2]) flag = true;
ll maxi = 0;
for (ll i = 0; i < n;i++) {
    maxi = max(maxi, a[i]);
}
for (ll i = 0; i < n;i++){
    if(a[i]==maxi){
        if (flag) cout << b[n-1] << endl;
        else cout << b[n-2] << endl;
    }
    else cout << b[n-1] << endl;
}
}


Measured memory_bytes: 4736