akhauriyash/Code-Regression huggingface dataset:
#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;   
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ld long double
#define dd double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) (ll)(a.size())
typedef long long ll;
typedef unsigned long long ull;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;
typedef vector<pll> vplll;
ll mod = 1e9+7;
const ld PI = 2 * acos(0.0);
const vector<ll> dx = {1, -1, 0, 0};
const vector<ll> dy = {0, 0, 1, -1};
#define round(x, y) ((x + y - 1) / y)
#define ce(x, y) ((x + y - 1) / y)
#define amax(x, y) \
    if (y > x)     \
        x = y;
#define amin(x, y) \
    if (y < x)     \
        x = y;
#define lcm(x, y) ((x) * (y) / __gcd(x, y))
#define len(x) (ll) x.length()
#define sq(x) ((x) * (x))
#define cb(x) ((x) * (x) * (x))
const int N = 1e5;
ll dp[N];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a,b,c,t,n,m,k,q; 
    t = 1;
    // cin>>t;
    while(t--)
    {
    	cin>>n;
    	ll ar[n];
    	for(int i = 0; i < n; i++)
    	{
    		cin>>ar[i];
    	}
    	dp[0] = 0;
    	dp[1] = abs(ar[1]-ar[0]);
    	for(int i=2;i<n;i++)
    	{
    		dp[i] = min(dp[i-1]+abs(ar[i]-ar[i-1]),dp[i-2]+abs(ar[i]-ar[i-2]));
    	}
    	cout<<dp[n-1]<<endl;
    }
    return 0;
}

Measured memory_bytes: 1792
N, M = [int(s) for s in input().split()]
b = [0]*N
for _ in range(M):
    b[int(input().strip())-1] = 1

a = [0]*N

if b[0] == 0:
    a[0] = 1
if N > 1 and b[1] == 0:
    a[1] = 1 + a[0]

for i in range(2, N):
    if b[i] == 0:
        a[i] = a[i-1] + a[i-2]
print(a[-1]%1000000007)

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

int main(){
	int a,b;
	cin >> a >> b;
	int min_a=12.5 * a,max_a = 12.5 *(a+1),min_b=10*b,max_b = 10*(b+1);
	if(a%2 == 1)
		min_a++;
	if(min_a <= min_b){
		if(max_a <= min_b){
			cout << "-1" << endl;
		}else
			cout << min_b << endl;
	}else{
		if(max_b <= min_a)
			cout << "-1" << endl;
		else
			cout << min_a << endl;
	}
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main() 
{
      string s,t;
      cin>>s>>t;
      int n=s.length(), m=t.length();
      int dp[n+1][m+1];
      for(int i=0; i<=n;i++)
        dp[i][0]=0;
        for(int i=0; i<=m;i++)
        dp[0][i]=0;
      for(int i=1; i<=n; i++)
      {
        for(int j=1; j<=m; j++)
        {
            //dp[i][j]=0;
            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]);
        }
      }
      
      int i=n,j=m;
      string st="";
      
      while(j>0 && i>0)
      {
        if(s[i-1]==t[j-1])
        {
          st.push_back(s[i-1]);
          i--,j--;
        }
        else if(dp[i-1][j]>dp[i][j-1])
                 i--;
                 else
                 j--;
          
      }
      
      reverse(st.begin(),st.end());
      cout<<st<<endl;
        return 0;
}

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

typedef long long ll;

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

	ll N = S.size();
	ll sum=0;
	for (int i = 0; i < 1 << N -1; i++) {
		ll tmp = S[0] - '0';

		for (int j = 0; j < N - 1; j++) {

			if (i & 1 << j) {
				sum += tmp;
				tmp = S[j + 1] - '0';
			}
			else {
				tmp = tmp * 10 + S[j + 1] - '0';
			}
		}
		sum += tmp;
	}

	cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define mem(i,a) memset(i,a,sizeof(i))
#define PI acos(-1.0)
#define DMAX 100005
#define MOD 20190823
#define eps 1e-8
#define bl bool
#define INF 1e+9
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
template<class T> inline void read(T &f){
	f=0;
    T x=1;
    char ch=getchar();
    while(ch<48 || ch>57) {
        if(ch=='-') {
            x=-1;
        }
        ch=getchar();
    }
    while(ch<=57 && ch>=48) {
        f=f*10+ch-'0';
        ch=getchar();
    }
    f*=x;
}
ll n,k;
int main(){
	ll x;
	ll ans=0;
	read(n),read(k);
	for(ll i=1;i<=n;i++){
		read(x);
		if(x>=k){
			ans++;
		}
	}
	cout<<ans<<endl;
	return 0; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,m,i,j,a[300005],t[300005],ans,l[300005],r[300005],del[300005],c11;
int main(){
	cin>>n>>m;ans=n+1;
	for(i=1;i<=n;i++){
		cin>>a[i];
	}
	for(i=1;i<=n;i++){
		cin>>t[i];
		ans+=t[i]/(m*2);
		t[i]%=m*2;
	}
	for(i=1;i<=n;i++){
		if(!t[i]){
			ans--;
			del[i]=1;
			continue;
		}
		l[i]=(2*(m-a[i])>=t[i]);
		r[i]=(2*a[i]>=t[i]);
		del[i]=(!l[i])&&(!r[i]);
	}
	if(l[n]) ans--;
	for(i=1;i<n;i++)if(!del[i]){
		if(!l[i]) break;
		if(r[i]) c11++;
		else if(c11){
			ans--;
			c11--;
		}
	}
	int tmp=c11;c11=0;j=i;
	for(i=n-1;i>=j;i--)if(!del[i]){
		if(!r[i]) break;
		if(l[i]) c11++;
		else if(c11){
			ans--;
			c11--;
		}
	}
	c11+=tmp;
	ans-=c11/2;
	cout<<2ll*m*ans<<endl; 
	return 0;
}

Measured memory_bytes: 6144
if __name__ == '__main__':
    a = []
    anslst = []
    n = int(input())
    for i in range(n):
        l = list(map(int, input().split()))
        if l[0] == 0:
            a.append(l[1])
        elif l[0] == 1:
            anslst.append(a[l[1]])
        else:
            a.pop()
    for n in anslst:
        print(n)


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

int main(void) {
  int n;
  cin >> n;
  int a[3];
  a[0] = n % 10; 
  n /= 10;
  a[1] = n % 10;
  n /= 10;
  a[2] = n;
  for(int i = 0; i < 3; i++)
  { 
    a[i] = a[i] == 1 ? 9 :
           a[i] == 9 ? 1 : a[i];
  }

  cout << a[2] << a[1] << a[0] << endl;  

  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
using namespace std;
int main()
{
	int m,n,s,t=0;
	cin>>m>>n>>s;
	for(int i=m;i<=n;i++)
	{
		if(i%s==0)
		t++; 	
	}
	cout<<t;
	return 0;
} 

Measured memory_bytes: 3588
#include<iostream>
using namespace std;
int main(){
  int x,y;
  cin >> x >> y;
  if((x==1||x==3||x==5||x==7||x==8||x==10||x==12)&&(y==1||y==3||y==5||y==7||y==8||y==10||y==12))cout << "Yes" << endl;
  else if((x==4||x==6||x==9||x==11)&&(y==4||y==6||y==9||y==11))cout << "Yes" << endl;
  else if(x==y&&x==2)cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>

int main(void){
	char s[3];
	scanf("%s",s);
	char m=s[0];
	for(int n=0;n<3;n++){
		if(s[n]!=m){
			printf("Yes");
			return 0;
		}
		m=s[n];
	}
	printf("No");
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
using namespace std;
#define ll long long

int main(){
  ll n,k;
  cin>>n>>k;
  vector<ll> h(n,0);
  for(int i=0;i<n;i++){
    cin>>h[i];
  }
  sort(h.begin(),h.end());
  reverse(h.begin(),h.end());
  ll ans=1999999999;
  ll z=0;
  for(ll i=k-1;i<n;i++){
    z=h[i-k+1]-h[i];
    if(ans>z){
      ans=z;
    }
  }
  cout<<ans<<endl;
}


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

using namespace std;

int n,ans,d[51];

int main(){
    cin>>n;
    for(int i=1;i<=n;i++)cin>>d[i];
    for(int i=1;i<=n;i++){
        for(int j=1;j<i;j++){
            ans+=d[i]*d[j];
        }
    }
    cout<<ans;
}

Measured memory_bytes: 256
S = input()

op = ["YYMM","MMYY","AMBIGUOUS","NA"]
a = int(S[0] + S[1])
b = int(S[2] + S[3])

if 1 <= a <= 12 and 1 <= b <= 12:
    print(op[2])
elif 1 <= a <= 12:
    print(op[1])
elif 1 <= b <= 12:
    print(op[0])
else:
    print(op[3])


Measured memory_bytes: 3060
#include <vector>
#include <stack>

/*
 * @title ヒストグラム中の最大長方形
 * @docs docs/utility/histogram-largest-rectangle.md
 */

template<typename T> long long histogram_largest_rectangle(std::vector<T> h) {
    h.emplace_back(0);
    std::vector<int> left(h.size());
    std::stack<int> stk;
    T ret = 0;
    for (int i = 0; i < h.size(); i++) {
        while (!stk.empty() && h[stk.top()] >= h[i]) {
            ret = std::max(ret, (i - left[stk.top()] - 1) * h[stk.top()]);
            stk.pop();
        }
        left[i] = stk.empty() ? -1 : stk.top();
        stk.emplace(i);
    }
    return ret;
}

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

int main() {
    int N;
    cin >> N;
    vector<long long> h(N);
    for (int i = 0; i < N; i++) { cin >> h[i]; }
    cout << histogram_largest_rectangle(h) << endl;
}


Measured memory_bytes: 5300
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <set>
#include <utility>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <cstdio>
#include <map>

using namespace std;

typedef long long Int;
typedef pair<Int,Int> P;

#define rep(i,x) for(Int i = 0; i < (Int)(x); i++)
#define rrep(i,x) for(Int i = ((Int)(x) - 1); i >= 0; i--)
#define _upgrade ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define all(x) (x).begin(), (x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pb push_back


template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

//ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
//ll lcm(ll x, ll y) {return x / gcd(x, y) * y;}

Int dx[4] = {1,0,-1,0};
Int dy[4] = {0,1,0,-1};
const Int INF = 1001002003004005006ll;
const Int mod = 1e9 + 7;
const double PI = 3.14159265358979323846;


// ****************************************CODE***************************************//








Int a[100005];


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

        Int ret = INF;

        //はじめ正の数
        int f = 1;
        Int sum = 0, now = 0;
        for(int i = 0; i < n; i++)
        {
                sum += a[i];
                if(f == 1 && sum <= 0)
                {
                        now += -sum + 1LL;
                        sum = 1LL;
                }
                else if(f == 0 && sum >= 0)
                {
                        now += sum + 1LL;
                        sum = -1LL;
                }
                f = 1 - f;
        }

        ret = min(ret,now);

        //はじめ負の数
        f = 0;
        sum = 0, now = 0;
        for(int i = 0; i < n; i++)
        {
                sum += a[i];
                if(f == 1 && sum <= 0)
                {
                        now += -sum + 1LL;
                        sum = 1LL;
                }
                else if(f == 0 && sum >= 0)
                {
                        now += sum + 1LL;
                        sum = -1LL;
                }
                f = 1 - f;
        }

        ret = min(ret,now);

        cout << ret << endl;
        return 0;
}












Measured memory_bytes: 1024
n,m=map(int,input().split())
s=input()
t=input()

def gcd(a,b):
    if b==0: return a
    return gcd(b,a%b)

G=gcd(n,m)
a,b = n//G,m//G
s=s[0::a]
t=t[0::b]
if s==t: print(a*b*G)
else: print(-1)

Measured memory_bytes: 9380
import java.io.InputStream;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        solve(System.in, System.out);
    }

    static void solve(InputStream is, PrintStream os) {
        // Your code here!
        Scanner scan = new Scanner(is);
        int N = scan.nextInt();
        int M = scan.nextInt();
        Integer first = null;
        Integer second = null;
        Integer third = null;
        for (int i = 0; i < M; i++) {
            int tmp = scan.nextInt();
            int restriction = scan.nextInt();
            switch (tmp) {
                case 1:
                    if(first != null && first != restriction){
                        os.println("-1");
                        return;
                    }
                    first = restriction;
                    break;
                case 2:
                    if(second != null && second != restriction){
                        os.println("-1");
                        return;
                    }
                    second = restriction;
                    break;
                case 3:
                    if(third != null && third != restriction){
                        os.println("-1");
                        return;
                    }
                    third = restriction;
                    break;
            }
        }

        if(N == 1) {
            if(first != null) {
                os.println(first);
            } else {
                os.println(0);
            }
        } else if (N == 2) {
            if(first != null) {
                if(first == 0) {
                    os.println(-1);
                    return;
                }
            } else {
                first = 1;
            }
            if(second != null) {
                os.println(first*10 + second);
            } else {
                os.println(first*10);
            }
        } else if (N == 3) {
            if(first != null) {
                if(first == 0) {
                    os.println(-1);
                    return;
                }
            } else {
                first = 1;
            }
            if(second == null)
                second = 0;
            if(third != null) {
                os.println(first*100 + second*10 + third);
            } else {
                os.println(first*100 + second*10);
            }
        }
    }
}

Measured memory_bytes: 21460
using System;
using System.Linq;

class C
{
	static long[] Read() => Console.ReadLine().Split().Select(long.Parse).ToArray();
	static void Main()
	{
		var p = Read();
		var k = (int)p[1];
		Console.WriteLine(Read().OrderByDescending(x => x).Skip(k).Sum());
	}
}


Measured memory_bytes: 51180
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
 
 
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;cin>>n;
    vector<ll> s(n+1);
    ll sum=0;s[0]=0;
    rep(i,n){
        ll a;cin>>a;
        s[i+1]=s[i]+a;
    }
    sort(s.begin(),s.end());
    ll ans=0;
    ll c = 1;
    rep(i,n){
        if(s[i]==s[i+1])c++;
        else{ans+=c*(c-1)/2;c=1;}
    }
    cout<<ans+c*(c-1)/2<<endl;
    return 0;
}

Measured memory_bytes: 1792
//所要時間3～4時間 再帰に慣れてなかったので脳がバグった

#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0;i<(n);i++)
int n;
const double root3 = 1.73205080768877;

void koch(double x0, double y0, double x1, double y1, int n)
{
	if (n == 0) cout <<fixed << setprecision(8) << x0 << " " << y0 << endl;
	else
	{
		double c1[2], c2[2], c3[2];
		 c1[0] = 2 * x0 / 3 + x1 / 3;
		 c1[1] = 2 * y0 / 3 + y1 / 3;
		 c2[0] = (x0 + x1) / 2 - root3 * (y1 - y0) / 6;
		 c2[1] = (y0 + y1) / 2 + root3 * (x1 - x0) / 6;
		 c3[0] = x0 / 3 + 2 * x1 / 3;
		 c3[1] = y0 / 3 + 2 * y1 / 3;
		 koch(x0, y0, c1[0], c1[1], n - 1);
		 koch(c1[0], c1[1], c2[0], c2[1], n - 1);
		 koch(c2[0], c2[1], c3[0], c3[1], n - 1);
		 koch(c3[0], c3[1], x1, y1, n - 1);

	}
}
int main()
{	
	cin >> n;	
	koch(0, 0, 100, 0, n);
	cout << fixed << setprecision(8) <<100<<" "<<0 << endl;;
	return 0;
}


Measured memory_bytes: 3232
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                Solve.Answer();
            }
            catch (Exception ex)
            {
                WriteLine(ex.ToString());
            }
        }
    }

    public class Solve
    {
        public static void Answer()
        {
            var N = IO_ShortCut.ReadInt;
            WriteLine((N + 1) / 2);
        }
    }

    public class IO_ShortCut
    {
        #region Input
        public static string ReadString => ReadLine();
        public static int ReadInt => int.Parse(ReadLine());
        public static long ReadLong => long.Parse(ReadLine());
        public static double ReadDouble => double.Parse(ReadLine());

        public static List<string> ReadSplitString => ReadLine().Split().ToList();
        public static List<int> ReadSplitInt => ReadLine().Split().Select(s => int.Parse(s)).ToList();
        public static List<long> ReadSplitLong => ReadLine().Split().Select(s => long.Parse(s)).ToList();
        public static List<double> ReadSplitdouble => ReadLine().Split().Select(s => double.Parse(s)).ToList();
        #endregion

        #region Output
        public static void OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list));
        public static void WriteLineYes_or_No(bool flag) => WriteLine(flag ? "Yes" : "No");

        #endregion
    }

    /// <summary>
    /// 正の数の四則演算のみ対応
    /// </summary>
    public class Mod
    {
        // 割る数の定義
        private readonly static long M = 1000000007;

        // 足し算
        public static long Add(long a, long b) => (a * b) % M;
        // 引き算
        public static long Sub(long a, long b) => (a - b) % M >= 0 ? (a - b) % M : (a - b) % M + M;
        // 掛け算
        public static long Multi(long a, long b) => (a * b) % M;
    }

    public class MathLib
    {
    }
}

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

#define PrintLn(X) cout << X << endl
int main(void)
{
	string a, b;
	cin >> a >> b;
	reverse(a.begin(), a.end());
	if(a == b){
		PrintLn("YES");
	}else{
		PrintLn("NO");
	}
	return 0;
}


Measured memory_bytes: 256
/*
本宝的程序外人别想看！！

name: [夏宝宝]
run time：[] ms
compilation time: [] ms
output memory: [] MiB
where: []
state: []
*/
#include<bits/stdc++.h>
using namespace std;

int main()
{
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	
	cout.sync_with_stdio(false);
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	long long int a, b;
	
	cin>>a>>b;
	
	long long int sum=0, tmp;
	
	for(int i=1; i<=b; i++)
	{
		cin>>tmp;
		
		sum+=tmp;
	}
	
	if(a<=sum)
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    string S;
    cin>>S;
    for(int i=0;i<S.size();i++){
        if(S[i]=='?'){
            S[i]='D';
        }
    }
    cout<<S<<endl;
    return 0;
}


Measured memory_bytes: 3756
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>
#include <queue>


#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl
#define FOR(n) for(lli i = 0; i < n; i++)

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;
using tlll = tuple<lli, lli, lli>;

lli mod197 = 1000000007LL;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}
	return d;
}

pll rewrite[200000] = {};

int main(void) {

	lli N, M;
	cin >> N >> M;

	for (int i = 0; i < N; i++) {
		lli A;
		cin >> A;
		rewrite[i] = pll{ A,1 };
	}

	for (int i = 0; i < M; i++) {
		lli B, C;
		cin >> B >> C;

		rewrite[i + N] = pll{ C,B };
	}

	sort(rewrite,rewrite + N + M);

	lli ans = 0;
	lli total = 0;

	for (int i = N + M - 1; i >= 0 && total < N; i--) {
		ans += rewrite[i].first * min(N - total, rewrite[i].second);
		total += rewrite[i].second;
	}

	COUT(ans);

	return 0;
}

Measured memory_bytes: 3328
//Let's join Kaede Takagaki Fan Club !!
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target ("avx")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
#define all(x) x.begin(),x.end()
template<class T>
void dmp(T a){
	rep(i,a.size()) cout << a[i] << " ";
	cout << endl;
}
template<class T>
bool chmax(T&a, T b){
	if(a < b){
		a = b;
		return 1;
	}
	return 0;
}
template<class T>
bool chmin(T&a, T b){
	if(a > b){
		a = b;
		return 1;
	}
	return 0;
}
template<class T>
void g(T &a){
	cin >> a;
}
template<class T>
void o(const T &a,bool space=false){
	cout << a << (space?' ':'\n');
}
//ios::sync_with_stdio(false);
const ll mod = 998244353;//998244353
template<class T>
void add(T&a,T b){
	a+=b;
	if(a >= mod) a-=mod;
}


int main(){
	ll n; cin >> n;
	int len = 1;
	for(ll x=26;;x*=26,len++){
		if(n > x) n-=x;
		else{
			n--;
			string ret="";
			rep(x,len){
				ret.pb('a'+n%26);
				n /= 26;
			}
			reverse(all(ret));
			cout<<ret<<endl;
			return 0;
		}
	}
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define rep0(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define ll long long
#define coYes cout << "Yes" << endl
#define coYES cout << "YES" << endl
#define coyes cout << "yes" << endl
#define coNo cout << "No" << endl
#define coNO cout << "NO" << endl
#define cono cout << "no" << endl
#define BIT_FLAG_0 (1<<0) // 0000 0000 0000 0001
int gcd(int a, int 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);
  }

ll digit_sum(ll a){ //10進桁和
    ll ans=0;
    while(a>0){
      ans+=a%10;
      a/=10;
    }
    return ans;
  }

int main(){
  string s;
  cin >> s;
  string a = "abcdefghijklmnopqrstuvwxyz";
  for (int i = 0; i < 26; i++) {
      for (int j = 0, l = s.length(); j < l; j++) {
        if (s[j] == a[i]) {
            break;
        }
        if (j == l - 1 && s[j] != a[i]) {
            cout << a[i] << endl;
            return 0;
        }
      }
  }
    cout << "None" << endl;
    return 0;
}

Measured memory_bytes: 3692
N = int(input())
a = list(map(int, input().split()))
ans = 0

i = 0
while i < N:
  if a[i] % 2 == 0:
    if a[i] % 3 != 0 and a[i] % 5 != 0:
      ans = 1
  i += 1
      
if ans == 0:
  print("APPROVED")
else:
  print("DENIED")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
int main(){
	int n;
	cin>>n;
	vector<int>h(n);
	for(int i=0;i<n;i++){
		cin>>h[i];
	}
	int ans=0;
	int maxheight=-1;
	for(int i=0;i<n;i++){
		if(maxheight<=h[i]){
			ans++;
			maxheight=h[i];
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
typedef unsigned int uint;
using namespace std;

const ll mod = 1e9+7;

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

    ll n, m, x, y, w = 0LL, h = 0LL;
    cin >> n >> m;
    for (ll i = 0; i < n; i++) {
        cin >> x;
        w = (w + i*x - (n-i-1)*x) % mod;
    }
    for (ll i = 0; i < m; i++) {
        cin >> y;
        h = (h + i*y - (m-i-1)*y) % mod;
    }

    cout << w * h % mod << "\n";
    return 0;
}

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

using namespace std;

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

const int maxn=1e6+5;

const ll mod=1e9+7;

char s[maxn];

int main(){
	scanf("%s",s+300000);
	int beg=300000;
	int end=strlen(s+beg)+beg;
	int flg=1;
	int q;
	scanf("%d",&q);
	while(q--){
		int t;
		scanf("%d",&t);
		if(t==1){
			flg=(3-flg);
		}
		else{
			int k;char c;
			scanf("%d %c",&k,&c);
			if(flg==1){
				if(k==1){
					s[beg-1]=c;
					beg--;
				}
				else{
					s[end++]=c;
				}
			}
			else{
				if(k==2){
					s[beg-1]=c;
					beg--;
				}
				else{
					s[end++]=c;
				}
			}
		}
	}
	if(flg==1){
		for(int i=beg;i<end;i++){
			printf("%c",s[i]);
		}
	}
	else{
		for(int i=end-1;i>=beg;i--){
			printf("%c",s[i]);
		}
	}
	return 0;
}

Measured memory_bytes: 896
var
	s,t:String;
	c,d:array[0..25]of Longint;
	i,j,k:Longint;
begin
	readln(s);
	readln(t);
	for i:=0 to 25 do begin
		c[i]:=-1;
		d[i]:=-1;
	end;
	for i:=1 to length(s) do begin
		j:=ord(s[i])-97;
		k:=ord(t[i])-97;
		if c[j]=-1 then c[j]:=k;
		if d[k]=-1 then d[k]:=j;
		if(c[j]<>k)or(d[k]<>j)then begin
			writeln('No');
			exit;
		end;
	end;
	writeln('Yes');
end.


Measured memory_bytes: 640
import java.util.Scanner;
import java.util.regex.*;
import java.math.*;

public class Main {
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		//int a = sc.nextInt();
		// スペース区切りの整数の入力
		//int b = sc.nextInt();
		//int c = sc.nextInt();
		// 文字列の入力
		//String s = sc.next();
		//1文字ずつ
		//s.atChar(i);
		// 出力
		//System.out.println("");
		//double countx=0;
		
		int N=sc.nextInt();
		
		int[][] nums=new int[25][15];
		
		for(int i=0;i<25;i++){
			for(int j=0;j<15;j++){
				nums[i][j]=4*i + 7*j;
			}
		}
	
		boolean x=false;
		
		yy:for(int i=0;i<25;i++){
			for(int j=0;j<15;j++){
				if(N==nums[i][j]){
					x=true;
					break yy;
				}
			}
		}
		if(x){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
		
	}
}

Measured memory_bytes: 21844
s=input()
t=input()
sl=len(s)
tl=len(t)
kotae=tl
for i in range(0,sl-tl+1):
  x=s[i:i+tl]
  b=0
  for j in range(tl):
    if x[j]!=t[j]:
      b+=1
  if b<kotae:
    kotae=b
print(kotae)

Measured memory_bytes: 9044
#include <vector>
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <climits>
using namespace std;

int main(){
    int n,m,count,j,point;
    cin >> n >> m;
    vector<int>a(n);
    vector<int>b(n);
    vector<int>c(m);
    vector<int>d(m);
    for(int i=0;i<n;i++){
        cin >> a[i] >> b[i];
    }
    for(int i=0;i<m;i++){
        cin >> c[i] >> d[i];
    }
    for(int i=0;i<n;i++){
        count=INT_MAX;
        point=99;
        for(int j=0;j<m;j++){
            if(count>abs(a[i]-c[j])+abs(b[i]-d[j])){
                count=abs(a[i]-c[j])+abs(b[i]-d[j]);
                point = j;
            }
        }
        cout << point+1 << "\n";
    }
}

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

#define pb push_back
#define vi vector < int >
#define ii pair < int, int >
#define vii vector < pair < int, int > >
#define vvi vector < vector < int > >
#define ll long long
#define X first
#define Y second
#define mp make_pair
#define FOR( i, lo, hi ) for( int i = (lo);i < (hi);i++ )
#define DFOR( i, hi, lo ) for( int i = (hi);i >= (lo);i-- )
#define pqueue priority_queue

using namespace std;

ll a, b;

int main()
{
	cin >> a >> b;
	if ( a % 2 != b % 2 )
		cout << "IMPOSSIBLE\n";
	else
	{
		cout << ( a + b ) / 2 << "\n";
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b,c,x,y,ans,m,M;
  cin>>a>>b>>c>>x>>y;
  m=min(x,y);
  M=max(x,y);
  cin>>a>>b>>c>>x>>y;
  ans=a*x+b*y;
  ans=min(ans,2*c*m+(x-m)*a+(y-m)*b);
  ans=min(ans,2*c*M);
  cout<<ans;
}

Measured memory_bytes: 256
/**********************************************************************/
/********                                                      ********/
/********                     Writer:孙~~                      ********/
/********                       Lang:C++                       ********/
/********                     Status:Unknow                    ********/
/********                                                      ********/
/**********************************************************************/
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <queue>
#include <list>
#include <cstdlib>
#include <algorithm>
#include <set>
#include <map>
#include <deque>
#include <cstring>
#include <cmath>
//#include<bits/stdc++.h>
using namespace std;

const int INF=0x3f3f3f3f;
const int SIZE=100005;
const double EPS=1e-6;

int a[SIZE][3];
int dp[SIZE][3];

int main(){
	/*main function start*/
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d%d%d",a[i]+0,a[i]+1,a[i]+2); 
	}
	dp[0][0]=a[0][0];
	dp[0][1]=a[0][1];
	dp[0][2]=a[0][2];
	for(int i=1;i<n;i++){
		dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a[i][0];
		dp[i][1]=max(dp[i-1][0],dp[i-1][2])+a[i][1];
		dp[i][2]=max(dp[i-1][0],dp[i-1][1])+a[i][2];
	}
	printf("%d\n",max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2])));
	return 0;
}


Measured memory_bytes: 2560
h, w = gets.split.map(&:to_i)

strings = []
h.times do
  strings << gets.chomp
end

dx = [-1,0,1,-1,1,-1,0,1]
dy = [-1,-1,-1,0,0,1,1,1]

h.times do |i|
  w.times do |j|
    next if strings[i][j] == '#'
    counter = 0

    8.times do |k|
      x = i + dx[k]
      y = j + dy[k]
      counter += 1 if x >= 0 && x < h && y >= 0 && y < w && strings[x][y] == '#'
    end
    strings[i][j] = counter.to_s
  end
end

strings.each do |string|
  puts "#{string}\n"
end

Measured memory_bytes: 1916
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<random>
#include<set>
#include<map>
#include<functional>
using namespace std;
#define int long long
#define inf 1145141919
#define rep(i,n) for(int i=0;i<n;i++)
typedef pair<int, int>P;
typedef pair<int, P> PP;
struct edge { int to, cost; };
vector<int>G[5005];
vector<int>ans;
int n, m; 
int op;
int vout[5005];
void tsort() {
	stack<int>st;
	rep(i, n)if (vout[i]==0)st.push(i);

	while (st.size()) {
		if (st.size() > 1)op=1;
		int i = st.top(); st.pop();
		ans.push_back(i);
		rep(j, G[i].size()) {
			vout[G[i][j]]--;
			if (vout[G[i][j]] == 0) {
				st.push(G[i][j]);
			}
		}
	}
}
signed main() {
	cin >> n >> m;
	rep(i, m) {
		int a, b; cin >> a >> b;
		G[a - 1].push_back(b - 1);
		vout[b - 1]++;
	}
	tsort();
	rep(i, n)cout << ans[i]+1 << endl;
	cout << op << endl;
}


Measured memory_bytes: 4440
#include <iostream>
#include <vector>

template <class Cost = int, class Cap = int>
struct Edge {
    int from, to, rev;
    Cost cost;
    Cap cap;
    Edge(int from = -1, int to = -1, Cost cost = 1, Cap cap = 0, int rev = -1)
        : from(from), to(to), cost(cost), cap(cap), rev(rev){};

    bool operator<(const Edge<Cost>& e) const { return this->cost < e.cost; }
    bool operator>(const Edge<Cost>& e) const { return this->cost > e.cost; }
};

template <class Cost = int, class Cap = int>
class Graph {
public:
    int size;
    std::vector<std::vector<Edge<Cost, Cap>>> path;

    explicit Graph(int N = 0) : size(N), path(size) {}
    void span(int u, int v, Cost cost = 1, Cap cap = 0) {
        path[u].push_back(Edge<Cost, Cap>(u, v, cost, cap));
    }
    std::vector<Edge<Cost, Cap>> operator[](int v) const { return path[v]; }
};

template <class Cost = int, class Cap = int>
class Lowlink {
private:
    Graph<Cost, Cap> graph;
    int cur;
    std::vector<int> order, low;

    void dfs(int v, int r) {
        order[v] = low[v] = cur++;
        int deg = 0;
        bool is_artic = false;

        for (auto e : graph[v]) {
            if (order[e.to] < 0) {
                ++deg;
                dfs(e.to, e.from);
                low[e.from] = std::min(low[e.from], low[e.to]);

                if (order[e.from] <= low[e.to]) is_artic = true;
                if (order[e.from] < low[e.to]) bridges.push_back(e);
            } else if (e.to != r) {
                // eは後退辺 1回だけ遡る
                low[e.from] = std::min(low[e.from], order[e.to]);
            }
        }

        if (r < 0) is_artic = (deg > 1);
        if (is_artic) artics.push_back(v);
    }

public:
    std::vector<int> artics;
    std::vector<Edge<Cost, Cap>> bridges;

    explicit Lowlink(const Graph<Cost, Cap>& graph)
        : graph(graph), order(graph.size, -1), low(graph.size, graph.size) {
        cur = 0;
        for (int v = 0; v < graph.size; ++v) {
            if (order[v] < 0) dfs(v, -1);
        }
    }
};

void fail() {
    std::cout << "No" << std::endl;
    exit(0);
}

void ok() {
    std::cout << "Yes" << std::endl;
    exit(0);
}

int main() {
    int N, M;
    std::cin >> N >> M;

    Graph<> graph(N);
    for (int i = 0; i < M; ++i) {
        int u, v;
        std::cin >> u >> v;
        --u, --v;
        graph.span(u, v);
        graph.span(v, u);
    }

    for (int v = 0; v < N; ++v) {
        if (graph[v].size() % 2 != 0) fail();
    }

    for (int v = 0; v < N; ++v) {
        if (graph[v].size() >= 6) ok();
    }

    int cnt = 0;
    for (int v = 0; v < N; ++v) {
        if (graph[v].size() >= 4) ++cnt;
    }

    if (cnt <= 1) fail();
    if (cnt >= 3) ok();

    Lowlink<> lowlink(graph);
    std::cout << (lowlink.artics.empty() ? "No" : "Yes") << std::endl;
    return 0;
}


Measured memory_bytes: 24064
S = input()[::-1]
P = ["dream"[::-1], "dreamer"[::-1], "erase"[::-1], "eraser"[::-1]]
i = 0
while i < len(S):
    for p in P:
        if S[i: i + len(p)] == p:
            i += len(p)
            break
    else:
        break
    continue
else:
    print("YES")
    exit()
print("NO")

Measured memory_bytes: 40560
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.DataInputStream;
import java.io.IOException;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author iavanish
 */
public class Main {

    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ACirclePond solver = new ACirclePond();
        solver.solve(1, in, out);
        out.close();
    }

    static class ACirclePond {

        private static final double pie = 3.14159265358979323846;

        public void solve(int testNumber, FastReader in, PrintWriter out) {
            double r = in.nextInt();
            out.println(2.0 * pie * r);
        }

    }

    static class FastReader {

        private final int BUFFER_SIZE = 1 << 16;
        private final InputStream inputStream;
        private final byte[] buffer;
        private int bufferPointer;
        private int bytesRead;

        public FastReader() {
            this.inputStream = new DataInputStream(System.in);
            this.buffer = new byte[BUFFER_SIZE];
            this.bufferPointer = bytesRead = 0;
        }

        public FastReader(InputStream inputStream) {
            this.inputStream = inputStream;
            this.buffer = new byte[BUFFER_SIZE];
            this.bufferPointer = bytesRead = 0;
        }

        public FastReader(String fileName) {
            try {
                this.inputStream = new DataInputStream(new FileInputStream(fileName));
                this.buffer = new byte[BUFFER_SIZE];
                this.bufferPointer = bytesRead = 0;
            } catch (FileNotFoundException e) {
                throw new RuntimeException(e);
            }
        }

        public int nextInt() {
            int nextInt = 0;
            byte c = read();
            while (c <= ' ') {
                c = read();
            }
            boolean negative = (c == '-');
            if (negative) {
                c = read();
            }
            do {
                nextInt = nextInt * 10 + c - '0';
            } while ((c = read()) >= '0' && c <= '9');
            if (negative) {
                return -nextInt;
            }
            return nextInt;
        }

        private void fillBuffer() {
            try {
                bytesRead = inputStream.read(buffer, bufferPointer = 0, BUFFER_SIZE);
                if (bytesRead == -1) {
                    buffer[0] = -1;
                }
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

        private byte read() {
            if (bufferPointer == bytesRead) {
                fillBuffer();
            }
            return buffer[bufferPointer++];
        }

    }

}



Measured memory_bytes: 25720
#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.at(i);
    }

    int min = *min_element(A.begin(), A.end());
    int max = *max_element(A.begin(), A.end());
    int a = 0;
    while (min != max)
    {
        for (int i = 0; i < N; i++)
        {
            if (A.at(i) == min)
            {
                continue;
            }

            a = A.at(i) % min;
            A.at(i) = a;
            if (a != 0 && a < min)
            {
                min = a;
            }
        }
        max = *max_element(A.begin(), A.end());
    }

    cout << min << endl;

    return 0;
}

Measured memory_bytes: 3688
n,k=map(int,input().split())
s=input()

lis=[]
c=1
for i in range(n-1):
    if s[i+1]==s[i]:
        c+=1
    else:
        lis.append(c)
        c=1
    if i==n-2:
        lis.append(c)

n_faced=len(lis)//2
if s[0]=="L" and  s[-1]=="R":
    n_faced-=1

n_unhappy=2*n_faced
if s[0]=="L":    n_unhappy+=1
if s[-1]=="R":    n_unhappy+=1

print(n-max(n_unhappy-2*k,1))

Measured memory_bytes: 45168
#include <bits/stdc++.h>
#define rep(i,n) for (ll i=0; i<(n); i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    string A,B,C; cin >> A >> B >> C;
    if (A[A.size()-1]==B[0] && B[B.size()-1]==C[0]) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
//atcoder clange
#include <stdio.h>
#include <stdlib.h>



int main(void){
  int N;
  scanf("%d", &N);
  int i=0;
  int p[N];
  int s[N];
  for(i=0;i<N;i++){
	scanf("%d", &p[i]);
 	s[i] = p[i];
  }
  
  int j=0;
  int tmp = 0;
  int count = 0;
  for (i=0; i<N; ++i) {
    for (j=i+1; j<N; ++j) {
      if (p[i] > p[j]) {
        tmp =  p[i];
        p[i] = p[j];
        p[j] = tmp;
        count++;
      }
    }
  }
  int c = 0;
  for(i=0;i<N;i++){
	if(p[i] != s[i]){
      c++;
    }
  }

  
  
  if(c > 2){
	printf("NO");
  }else if(c <= 2){
	printf("YES");
  }
  
    return 0;
}

Measured memory_bytes: 128
fun main(args: Array<String>) {
    val N = nextInt()
    val D = listOfLong()
    val X = LongArray(N)
    X[0] = D.reduceIndexed { n, acc, v -> if (n % 2 == 0) acc + v else acc - v }
    for (n in 0 until N - 1) X[n + 1] = 2 * D[n] - X[n]
    println(X.joinToString(separator = " "))
}
fun next() = readLine()!!
fun nextInt() = Integer.parseInt(next())
fun listOfString() = next().split(" ")
fun listOfLong(delta: Long = 0) = listOfString().map { it.toLong() + delta }

Measured memory_bytes: 58108
#include <iostream>
#include <cstring>
#include <string>
#include <vector>
#include <iomanip>
#include <algorithm>
#include <stack>
#include <tuple>
#include <queue>
#include <set>
#include <math.h>
#include <array>
#include <list>
#include <set>
#define MOD 1000000007
#define INF 1000000000
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef tuple<ll,int,int> tup;
typedef vector<int> vi;
typedef vector<pii> vpii;
int n;
ll ans1=0;
ll ans2=0;
ll a[100005];
int x[100005];
int x2[100005];
int main(int argc,char const* argv[])
{
  cin >> n;
  memset(a,0,sizeof(a));
  memset(x,0,sizeof(x));
  memset(x2,0,sizeof(x2));
  for(int i=0;i<n;i++)
    {
      cin >> a[i];
    }
  sort(a,a+n,greater<int>());
  for(int i=0;i<n;i++)
    {
      if(i==0) x[i]=-1;
      else if(i%2!=0 && i!=n-1)
	{
	  x[i]=2;
	}
      else if(i%2!=0 && i==n-1)
	{
	  x[i]=1;
	}
      else if(i%2==0 && i!=n-1)
	{
	  x[i]=-2;
	}
      else if(i%2==0 && i==n-1)
	{
	  x[i]=-1;
	}
    }
  for(int i=0;i<n;i++)
    {
      if(i==0) x2[i]=1;
      else if(i%2!=0 && i!=n-1)
	{
	  x2[i]=-2;
	}
      else if(i%2!=0 && i==n-1)
	{
	  x2[i]=-1;
	}
      else if(i%2==0 && i!=n-1)
	{
	  x2[i]=2;
	}
      else if(i%2==0 && i==n-1)
	{
	  x2[i]=1;
	}
    }
  sort(x,x+n,greater<int>());
  sort(x2,x2+n,greater<int>());
  for(int i=0;i<n;i++)
    {
      ans1+=x[i]*a[i];
    }
  for(int i=0;i<n;i++)
    {
      ans2+=x2[i]*a[i];
    }
  cout << max(ans1,ans2) << endl;
  return 0;
}


Measured memory_bytes: 1792
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int age = sc.nextInt();
		
		switch (age){
			case 3:
				System.out.println("YES");
				break;
			case 5:
				System.out.println("YES");
				break;
			case 7:
				System.out.println("YES");
				break;
			default:
				System.out.println("NO");
				break;
		}
	}
}

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

import numpy as np
import collections

A = np.array(A)
I = np.array(list(range(1, N + 1)))

G = A - I

b = np.median(G)
G = np.absolute(G - np.full(N, b))
re = np.sum(G)

print(int(re))

Measured memory_bytes: 26708
//in the name of Allah
#include <bits/stdc++.h>
using namespace std ;
#define F first
#define S second
typedef long long ll ;
const ll INF = 1e9 ;
const ll N = 1000002 ;
ll n , a[N] , dp[N] , last[N] , ans = 0  ;
// you can prove that last[i]s are all increasing :)
// Lets go for LIS
int main()
{
std::ios::sync_with_stdio(0) ;
cin.tie(0) ;
cout.tie(0);
cin >> n  ;
for(int i = 0 ; i < n ; i ++ )cin >> a[n-1-i] ;
for(int i = 0 ; i < n ; i ++)last[i]=INF ;
last[0]=0;
for(int i = 0 ; i< n ; i ++){
 ll x =upper_bound(last , last+n , a[i]) -last ;
 dp[i] = x ;
 last[x] = min(last[x] , a[i]) ;
 ans = max(ans , dp[i]) ;
}
cout << ans ;
return 0 ;
}


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

int main() {
    string a,b;
    cin >> a >> b;
    string stra = "";
    string strb = "";
    for(int i = 0;i < stoi(b);i++){
        stra += a;
    }

    for(int i = 0;i < stoi(a);i++){
        strb += b;
    }

    cout << (stra < strb ? stra : strb) << endl;
    
}

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

#define BR "\n"
#define SP " "
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] SP; } cout BR;
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout BR;

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

  double ans = 0;
  for (int i = 0; i < N; i++) {
    double x;
    string u;
    cin >> x >> u;
    if ( u == "JPY" ) {
      ans += x;
    } else {
      ans += (x * 380000.0);;
    }
  }

  cout << fixed << setprecision(6) << ans << BR;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <list>
#include <cstdlib>
#include <climits>

const int MAX_N = 100;

struct Node {
  int v;
  int d;
  bool visited;
};

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

  int n = 0;
  std::cin >> n;

  std::vector<std::vector<int> *> *graph = new std::vector<std::vector<int> *>(n + 1);
  std::vector<struct Node *> *nodes = new std::vector<struct Node *>(n + 1);
  
  for (int i = 1; i <= n; i++) {
    int v = 0;
    std::cin >> v;

    int k = 0;
    std::cin >> k;

    std::vector<int> *neighbors = new std::vector<int>(k);

    for (int j = 0; j < k; j++) {
      int a = 0;
      std::cin >> a;

      neighbors->at(j) = a;
    }

    graph->at(i) = neighbors;

    struct Node *node = (struct Node *) std::malloc(sizeof(struct Node));

    node->v = i;
    node->d = INT_MAX;
    node->visited = false;
    
    nodes->at(v) = node;
  }

  int count = 0;
  int start = 1;

  std::list<int> *stack = new std::list<int>();

  stack->push_back(nodes->at(start)->v);

  while (!stack->empty()) {
    std::vector<int> *newNodes = new std::vector<int>();

    while (!stack->empty()) {    
      int v = stack->front();
      stack->pop_front();

      if (count < nodes->at(v)->d) {
	nodes->at(v)->d = count;
      }
      
      nodes->at(v)->visited = true;
      
      std::vector<int> *neighbors = graph->at(v);

      for (std::vector<int>::iterator iterator = neighbors->begin(); iterator != neighbors->end(); ++iterator) {
	struct Node *node = nodes->at(*iterator);

	if (!node->visited) {
	  newNodes->push_back(node->v);
	}
      }
    }

    for (std::vector<int>::iterator iterator = newNodes->begin(); iterator != newNodes->end(); ++iterator) {
      stack->push_front(*iterator);
    }

    count++;
  }

  for (std::vector<struct Node *>::iterator iterator = nodes->begin() + 1; iterator != nodes->end(); ++iterator) {
    struct Node *node = *iterator;

    if (node->d == INT_MAX) {
      node->d = -1;
    }
        
    std::cout << node->v << " " << node->d << std::endl;
  }
  
  return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#pragma GCC optimize ("-O3")
#pragma GCC target ("sse4")

using namespace std;
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//const long double PI = 3.14159265358979323846;

int32_t main()
{
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    int k;
    cin >> k;
    int n;
    n = 1 << k;
    multiset<int> ms;
    for (int i = 0; i < n; i ++)
    {
        int a;
        cin >> a;
        ms.insert(a*-1);
    }
    bool np = false;
    vector<int> res;
    res.push_back(*ms.begin());
    ms.erase(ms.begin());

    for (int xx = 0; xx < k; xx++)
    {
        vector<int> nv;
        for (int x: res)
        {
            auto it = ms.upper_bound(x);
            if (it == ms.end())
            {
                np = true;
                break;
            }
            else
            {
                nv.push_back(*it);
                ms.erase(it);
            }
        }
        for (int x: nv)
            res.push_back(x);
        sort(res.begin(), res.end());
    }
    if (np)
        cout << "No\n";
    else
        cout << "Yes\n";

    return 0;
}

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

//#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

#define LL long long
#define PB push_back


int main() {
	LL n;
	cin >> n;

	vector<int> ans;
	while(n > 26) {
		int r = n%26;
		if(r == 0) {
			ans.push_back(26);
			r = 26;
		} else {
			ans.push_back(r);
		}
		n = n - r;
		n = n/26;
	}
	ans.push_back(n);
	reverse(ans.begin(),ans.end());

	for(int i=0;i<ans.size();i++) {
		char c = (ans[i] - 1) + 'a';
		cout << c;
	}
	cout << endl;

	return 0;
}


Measured memory_bytes: 3612
#include <cstdio>
#include <algorithm>

int main()
{
	int n, m;
	scanf("%d%d", &n, &m);
	int s[5];
	int c[5];
	for (int i = 0; i < m; ++i)
	{
		scanf("%d%d", s + i, c + i);
	}
	int begin = 0;
	int end = 0;
	switch (n)
	{
		case 1:
		{
			begin = 0;
			end = 9;
			break;
		}
		case 2:
		{
			begin = 10;
			end = 99;
			break;
		}
		case 3:
		{
			begin = 100;
			end = 999;
			break;
		}
	}
	for (int i = begin; i <= end; ++i)
	{
		int j = i;
		int d[3];
		for (int k = 0; k < n; ++k)
		{
			d[k] = j % 10;
			j /= 10;
		}
		bool ok = true;
		for (int j = 0; j < m; ++j)
		{
			if (d[n - s[j]] != c[j])
			{
				ok = false;
				break;
			}
		}
		if (ok)
		{
			printf("%d\n", i);
			return 0;
		}
	}
	puts("-1");
	return 0;
}


Measured memory_bytes: 128