akhauriyash/Code-Regression huggingface dataset:
# https://atcoder.jp/contests/agc022/tasks/agc022_a

import sys
# sys.setrecursionlimit(100000)


def input():
    return sys.stdin.readline().strip()


def input_int():
    return int(input())


def input_int_list():
    return [int(i) for i in input().split()]


def main():
    S = input()
    if S == "zyxwvutsrqponmlkjihgfedcba":
        print(-1)
        return
    if len(S) < 26:
        for i in range(ord("a"), ord("z") + 1):
            if chr(i) not in S:
                print(S + chr(i))
                return
    elif len(S) == 26:
        for i in range(25)[::-1]:
            c = S[i]
            ss = S[:i]
            for j in range(ord(c) + 1, ord("z") + 1):
                cc = chr(j)
                if cc not in ss:
                    print(ss + cc)
                    return
        print(-1)

    return


if __name__ == "__main__":
    main()


Measured memory_bytes: 62012
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
using namespace std;

#define ll long long
#define pb push_back

ll MAX(ll a, ll b) {

	if (a > b)return a;
	else return b;

}
ll MIN(ll a, ll b) {

	if (a < b)return a;
	else return b;

}
ll powsur(ll a, ll b, ll p) {

	if (b == 0) {

		return 1;

	}
	else if (b % 2 == 0) {

		ll d = powsur(a, b / 2, p);
		return ((d%p)*(d%p)) % p;

	}
	else {

		return ((a%p)*powsur(a, b - 1, p) % p) % p;

	}

}//pは素数,aのb乗をpで割った余り
ll CMOD(ll n, ll r, ll p) {

	ll a = 1, b = 1, c = 1, re;
	for (int i = 1; i <= n; i++) {

		a *= i;
		a = a%p;

	}
	for (int i = 1; i <= r; i++) {

		b *= i;
		b = b%p;

	}
	for (int i = 1; i <= n - r; i++) {

		c *= i;
		c = c%p;

	}
	b = powsur(b, p - 2, p);
	c = powsur(c, p - 2, p);
	re = ((a%p)*(b%p)) % p;
	re = ((re%p)*c%p) % p;

	return re;

}//pは素数,(nCr)%p
ll gcd(ll a, ll b) {

	if (a < b) {

		ll tmp = a;
		a = b;
		b = tmp;

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

}//最大公約数
ll lcm(ll a, ll b) {

	return a / gcd(a, b)*b;

}//最小公倍数

bool check_continue(int P,vector<int> V){
	if(P!=0)return true;
	int cnt=0;
	for(int i=0;i<V.size();i++){
		if(V[i]>0)cnt++;
	}
	if(cnt==1)return false;
	return true;
}

int main() {
	
	while(1){
		int N,P;
		cin>>N>>P;
		if(N==0&&P==0)break;
		vector<int> V;
		for(int i=0;i<N;i++)V.pb(0);
		ll cnt=0;
		while(check_continue(P,V)){
			if(P==0){
				P=V[cnt%N];
				V[cnt%N]=0;
			}else{
				P--;
				V[cnt%N]++;
			}
			cnt++;
		}
		for(int i=0;i<N;i++){
			if(V[i]>0){
				cout<<i<<endl;
				break;
			}
		}
	}

	return 0;
}


Measured memory_bytes: 3052
k, a, b = map(int, input().split())
c = 1
if a + 2 >= b: print(c+k)
else:
    if k - (a+1) >= 0:
        k = k - (a+1)
        c = b
        c += (k//2)*(b-a) + k%2
        print(c)
    else:
        print(c+k)

Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}




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

  ll a,b; cin >> a >> b ;
  ll ans = 0;

  if(a == 0){
    if(b >=0 ) cout << abs(b) << endl;
    if(b < 0) cout << abs(b)+1 << endl;
    return 0;
  }
  if(b == 0){
    if(a > 0) cout << abs(a)+1 << endl;
    else cout << abs(a) << endl;
    return 0;
  }
  
  if((a >= 0 && b >= 0) || (a<=0 && b<=0)){
    if(a > b ) ans = abs(a-b)+2;
    else ans = abs(a-b);
  }
  else if((a<=0 && b>=0) || (a >= 0 && b<=0)){
    a = -a;
    ans = abs(a-b) +1;
  }
  cout << ans << endl;
  
  
  
  
  //cout << fixed << setprecision(16) << ans << endl;
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <iostream>
#include <map>
using namespace std;
int vis[100000 + 7];

int main()
{   
    
    memset(vis,0,sizeof(vis));
    int N,K,R,S,P;
    scanf("%d%d%d%d%d",&N,&K,&R,&S,&P);
    memset(vis,0,sizeof(vis));

    string t;
    cin >> t;
    int tot = 0;
   
    for(int i = 0;i < t.size();++i)
    {
        if(t[i] == 'r')
        {
            if(vis[i%K] != 1)
            {
                tot += P;vis[i%K] = 1;
            }
            else
            {
                vis[i%K] = 0;
            }
            
        }
        else if(t[i] == 's')
        {

            if (vis[i % K] != 2)
            {
                tot += R;
                vis[i % K] = 2;
            }
            else
            {
                vis[i%K] = 0;
            }
        }
        else
        {

            if (vis[i % K] != 3)
            {
                tot += S;
                vis[i % K] = 3;
            }
            else
            {
                vis[i%K] = 0;
            }

        }     
    }

    
    cout << tot << endl;
    return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) FOR(i,0,b)
#define INF mugen
#define dump(x) cerr<<#x<<"="<<x<<endl
#define all(a) (a).begin(),(a).end()
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<vii> viii;
typedef pair<int,int> P;
template <class T> void chmin(T & a, T const & b) { if (b < a) a = b; }
#define int long long
using ll = long long;
const ll mod = LLONG_MAX;

int N;
int A[11234];
int B[11234];
int ta,tb;
signed main(){
  cin>>N;
  rep(i,N){
    cin>>A[i];
    ta+=A[i];
  }
  rep(i,N){
    cin>>B[i];
    tb+=B[i];
  }



  int r=tb-ta;
  int u=(ll)0;
  int u2=(ll)0;
  int dow=(ll)0;
  rep(i,N){
    int c=(ll)(B[i]-A[i]);
    if(c<(ll)0){
      dow+=(-c);
    }else{
      u2+=c/(ll)2;
    }
  }

  u2-=(dow);
  if(u2<(ll)0){
    cout<<"No"<<endl;
  }else{
    cout<<"Yes"<<endl;
  }
}


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

#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,n) for (int i = 0; i < n; i++)
#define forr(i,a,b) for (int i = a; i <= b; i++)
#define all(v) v.begin(), v.end()
#define pb emplace_back

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<ii> vii;

const int MX = 200005;
int n;
ii a[MX];
ll res = 0;

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

	cin >> n;
	forn (i, n) cin >> a[i].fi >> a[i].se;
	sort(a, a+n, [&] (ii& i, ii& j) {
		return i.fi - i.se < j.fi - j.se;
	});

	if (a[0].fi == a[0].se) {
		cout << 0 << endl;
		return 0;
	}

	ll res = 0;
	int mn = 1e9;
	forn(i, n) {
		res += a[i].fi;
		if (a[i].fi > a[i].se)
			mn = min(mn, a[i].se);
	}
	cout << res - mn << endl;

	return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		sc.close();

		long cnt = 0;
		if (k % 2 == 0) {
			int k2 = k / 2;
			int b = n / k2;
			long a = b - n / k;
			cnt += a * a * a;

			a = n / k;
			cnt += a * a * a;

		} else {
			long a = n / k;
			cnt += a * a * a;
		}

		System.out.println(cnt);
	}
}


Measured memory_bytes: 25044
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

using namespace std;

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()
{
	long long n;
	cin >> n;

	long long power = 1;
	for (int i = 1; i <= n; i++)
	{
		power *= i;
		power %= 1000000007;
	}
	cout << power << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	string xx[]={"0","7","5","3"};
	cin >> n;
	int ans = 0;
	int i[10];
	for(i[0]=0;i[0]<4;i[0]++)
		for(i[1]=0;i[1]<4;i[1]++)
			for(i[2]=0;i[2]<4;i[2]++)
				for(i[3]=0;i[3]<4;i[3]++)
					for(i[4]=0;i[4]<4;i[4]++)
						for(i[5]=0;i[5]<4;i[5]++)
							for(i[6]=0;i[6]<4;i[6]++)
								for(i[7]=0;i[7]<4;i[7]++)
									for(i[8]=0;i[8]<4;i[8]++)
	{
		int x[4] = {};
		bool add = true;
		bool x3,x5,x7;
		x3 = x5 = x7 = false;
		string k;
		for(int j=0;j<9;j++){
			x[i[j]]++;
			k += xx[i[j]];
			if(i[j]==0&&(x[1]+x[2]+x[3])!=0)
				add = false;
			if(i[j]==1)x7=true,x[1]++;
			if(i[j]==2)x5=true,x[2]++;
			if(i[j]==3)x3=true,x[3]++;
		}
		if(add)if(x7&&x5&&x3)if(stoi(k)<=n)ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int n;
    cin>>n;
    int a[n];
    
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    
    int dp[n];
    dp[0]=0;
    dp[1]=abs(a[0]-a[1]);
    
    for(int i=2;i<n;i++)
    {
        dp[i]=min(dp[i-1]+abs(a[i-1]-a[i]),dp[i-2]+abs(a[i-2]-a[i]));
    }
    cout<<dp[n-1]<<endl;
    return 0;
}


Measured memory_bytes: 1024
while True:
    n=int(input())
    if n == 0:break
    ans = [0 for i in range(10)]
    for l in range(n):
        a = int(input())
        ans[a] += 1
    for i in range(10):
        if ans[i] == 0: print('-')
        else:
            for j in range(ans[i]):
                print('*',end='')
            print('')



Measured memory_bytes: 7584
#include <bits/stdc++.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define int long long
#define mod 1000000007
#define INF LLONG_MAX/5
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1)*x%mod;
}
int mypow(int x, int y, int mood) {
	int res = 1;
	while (y > 0) {
		if (y & 1)res = res * x%mood;
		x = x * x%mood;
		y >>= 1;
	}
	return res;
}
P x[100000];
signed main(){
	int a,b,ans=1;
	cin>>a>>b;
	int c=gcd(a,b);
	for(int i=2;i*i<=c;i++){
		bool bo=false;
		while(c%i==0){
			if(!bo)ans++;
			bo=true;
			c/=i;
		}
	}
	if(c!=1)ans++;
	cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args)
	{
		Scanner s=new Scanner(System.in);
		
		int n=s.nextInt();
		int w=s.nextInt();
		
		long[][] arr=new long[n][2];
		
		for(int i=0;i<n;i++)
		{
			arr[i][0]=s.nextInt();
			arr[i][1]=s.nextInt();
		}
		
		long[][] dp=new long[n+1][w+1];
		
		for(int i=1;i<=n;i++)
		{
			for(int j=1;j<=w;j++)
			{
				if(j<arr[i-1][0])
				{
					dp[i][j]=dp[i-1][j];
				}
				else
				{
					dp[i][j]=Math.max(dp[i-1][j],arr[i-1][1]+dp[i-1][(int)(j-arr[i-1][0])]);
				}
			}
		}
		
		System.out.println(dp[n][w]);
		
	}
	
}

Measured memory_bytes: 129620
S = input()

ans = 0
def dfs(num_string, p):

  global ans
  
  if len(S) == 1:
    ans = int(S)
    return
  
  if p > len(S) - 1:
    #終わり
    ans += eval(num_string)
    return 
  
  #先頭の数字だけ扱いが微妙
  if p == 0:
    num_string  = "" + S[0]
    p = 1
  
  tmp = 0
  
  dfs(num_string + "+" + S[p], p+1)
  dfs(num_string + S[p], p+1)
  
  return

dfs(0,0)
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include<string>
using namespace std;
int main(){
	long long  max=0;
	int n;
	cin>>n;
	long long  a[n];
	long long  s=0;
	for(int i=0;i<n;i++){
		cin>>a[i];
		if(a[i]>max)
		max =a[i];
		if(a[i]<max)
		s += max -a[i];
	}
	cout<<s;
}

Measured memory_bytes: 5084
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int

using namespace std;

int main(){
    int a,b;
    cin >> a >> b;
    
    int area = (a - (b*2));
    if(area > 0) {
        cout << area << endl;
    } else {
        cout << 0;
    }
    
    
}


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

int main()
{
    long long n;cin>>n;
    string arr;cin>>arr;
    long long count[3];
    for(long long i=0; i<3; i++)
        count[i] = 0;
    for(long long i=0; i<n; i++)
    {

        if( arr[i] == 'R')
            count[0]++;
        else if( arr[i] == 'G')
            count[1]++;
        else
            count[2]++;
    }

    long long ans = count[0]*count[1]*count[2];
    //remove count
    
        for(long long i=0; i<n; i++)
        {
            for(long long j=i+1; j<n; j++)
            {
                if( arr[i] != arr[j])
                {
                    long long k = 2*j -i;
                    if(k < n && k >=0)
                    {
                        if( arr[k] != arr[j] && arr[k] != arr[i])
                            ans = ans -1;
                    }
                }
            }
        }
    cout<<ans;
}

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

int main(void){

  int W,H,x,y,r;

  cin >> W >> H >> x >> y >> r;

  if((x - r < 0) || (x + r > W) || (y - r < 0) || (y + r) > H)
     cout << "No" << endl;
  else
     cout << "Yes" << endl;
  

  return 0;
}

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

using namespace std;
#define MOD 1000000007
#define LL long long

long long f(int t)
{
    long long ans=1;
    for(int i=1;i<=t;i++)
    {
        ans=ans*26;
    }
    return ans;
}
int main()
{
   //freopen("input.txt","r",stdin);
  // freopen("output.txt","w",stdout);
  int n,m,l,i,j,te=1;
  long long ans=0;
  string st,st1,st2;
 cin>>st>>st1>>st2;
 if(st[st.size()-1]==st1[0] and st1[st1.size()-1]==st2[0])
         cout<<"YES\n";
         else
         cout<<"NO\n";



// cout<<"NO\n";
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<iomanip>
using namespace std;

int main(void)
{
    int n,ans = 0;
    string s;
    cin >> n >> s;
    for(int i = 1;i < n;i++)
    {
        int count = 0;
        for(char tmp = 'a';tmp <= 'z';tmp++)
        {
            bool left = false,right = false;
            for(int j = 0;j < i;j++)
            {
                if(s[j] == tmp){left = true;}
            }

            for(int j = i;j < n;j++)
            {
                if(s[j] == tmp){right = true;}
            }

            if(left && right){count++;}
        }
        if(ans < count){ans = count;}
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import sys
from fractions import gcd
lcm = lambda x, y : x*y // gcd(x, y)
from functools import reduce
inputs = sys.stdin.readlines()

n = int(inputs[0])
A = list(map(int, inputs[1].split()))

m = reduce(lcm, A)-1
ans = 0
for a in A:
    ans += m % a
print(ans)

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

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> a(n,0);
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    int cnt=0;
    bool flag=true;
    for(int i=0;i<n;i++){
        int minj=i;
        for(int j=i;j<n;j++){
            if(a[j]<a[minj]){
                minj=j;
            }
        }
        if(minj!=i){
            int t=a[i];
            a[i]=a[minj];
            a[minj]=t;
            cnt++;
        }
    }
    for(int i=0;i<n;i++){
        cout << a[i];
        if(i!=n-1)cout << " ";
    }
    cout << endl;
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3100
n, k = map(int, input().split())
A = [*map(int, input().split())]
ng, ok = 0, 1<<32 # (ng,ok] = (l,r]
while ok - ng > 1:
    m = (ng + ok) // 2
    c = 0
    for a in A: c += (a-1) // m
    if c <= k: ok = m
    else: ng = m
print(ok)


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

using namespace std;

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

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

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

int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;  cin >> s;
    vector<int> a(26);
    rep(i, s.size()) {
      a[s[i] - 'a']++;
    }
    rep(i, 26) {
      if (a[i] > 1) {
        cout << "no" << '\n';
        return 0;
      }
    }
    cout << "yes" << '\n';

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>

#define rep(i,n) for(int i=0;i<n;i++)
#define dup(x,y) (((x)+(y)-1)/(y)) // dup * y >= x なる最小のdup.
using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;

long long factorial(long long i){ // 階乗
 if(i > 0)
   return i * factorial(i-1);
 else
   return 1;
}
//// a^n mod
long long modpow(long long a, long long n, long long mod) {
 long long res = 1;
 while (n>0) {
   if(n & 1) res = res * a % mod;
   a = a * a % mod;
   n >>= 1;
 }
 return res;
}

//// a^(-1) mod
long long modinv(long long a, long long mod) {
 return modpow(a, mod-2, mod);
}
int main() {
	ll N, K;
	cin >> N >> K;
	vector<ll> A(N);
	rep(i, N) cin >> A[i];
	
	const ll MOD = 1000000000 + 7;

	ll ans = 0;

	rep(i, N) {
		ll before = 0;
		ll after = 0;
		rep(j, i) {
			if(A[i]>A[j]) before++;
		} 
		for(int j=i+1; j<N; j++) {
			if(A[i]>A[j]) after++;
		}
		ans += after*K;
		ans %= MOD;
		ans += (after+before)%MOD * (K-1) %MOD * K %MOD * modinv(2, MOD);
		ans %= MOD;
	}

	cout << ans << endl;

	return 0;
}

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

using ll = unsigned long long;
const ll MOD = 1e9 + 7;

int cnt[60];

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

  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 60; j++) {
      if ((a[i] >> j) & 1) cnt[j]++;
    }
  }

  ll ans = 0;
  for (int i = 0; i < 60; i++) {
    if (cnt[i] == 0) continue;

    ll t = pow(2, i);
    ll tmp = (t % MOD) * cnt[i];
    ll tmp2 = N - cnt[i];
    ans += ((tmp % MOD) * tmp2) % MOD;
    ans %= MOD;
  }

  cout << ans % MOD << endl;
  return 0;
}


Measured memory_bytes: 2688
k,n=map(int,input().split())
a=list(map(int,input().split()))
t=0
ma=0
su=0
for i in range(n-1):
	t=a[i+1]-a[i]
	su+=t
	ma=max(t,ma)
t=a[0]+k-a[n-1]
su+=t
ma=max(t,ma)
print(su-ma)

Measured memory_bytes: 25840
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

const int INF = 1e9 + 5;

int main()
{
	int n, k;
	cin >> n >> k;

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

	vector<int> dp(n, INF);
	dp[0] = 0;

	for (int i = 0; i < n; i++)
	{
		for (int j = i + 1; j <= i + k; j++)
		{
			if (j < n)
			{
				dp[j] = min(dp[j], dp[i] + abs(arr[i] - arr[j]));
			}
		}
	}
	cout << dp[n - 1] << endl;
}

Measured memory_bytes: 1024
n = int(input())

xs = [int(input()) for i in range(n)]

s = 0
candidate = 101
for x in xs:
    if x % 10 != 0:
        candidate = min(x, candidate)
    s += x

if s % 10 != 0:
    print(s)
elif candidate != 101:
    print(s - candidate)
else:
    print(0)



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

#define endl "\n"
#define ends ' '
#define die(x) return cout << x << endl, 0
#define all(v) v.begin(), v.end()
#define sz(x) (int)(x.size())
#define debug(x) cerr << #x << ": " << x << endl
#define debugP(p) cerr << #p << ": {" << p.first << ", " << p.second << '}' << endl
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const ll INF = 1e9;
const int MOD = 1e9 + 7;

////////////////////////////////////////////////////////////////////

const int N = 1e5 + 5;

int main() {

	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	
	int m1, d1, m2, d2; cin >> m1 >> d1 >> m2 >> d2;
	cout << (m2 == m1 + 1) << endl;

	return 0;
}


Measured memory_bytes: 256
coin=[10, 50, 100, 500, 500000]
first = True
while True:
    
    bill = int(input())
    if bill == 0:
        break;
    if not first:
        print()
    else:
        first = False
    posses = list(map(int, input().split()))
    Sumcoin= sum(coin[i] * posses[i] for i in range(4))
    change = Sumcoin - bill
    ChangeCoin = [change % coin[i+1] // coin[i] for i in range(4)]
    hand = [posses[i] - ChangeCoin[i] for i in range(4)]
    for i in range(4):
        if posses[i] > ChangeCoin[i]:
            print(coin[i], hand[i])
    
    


Measured memory_bytes: 5616
n=int(input())
d=[0,0]
x=list(map(int,input().split()))
for i in range(n):
     a=x[i]
     if a%2==0:
          d[0]+=1
     else:
          d[1]+=1
if d[1]%2==1:
     print('NO')
else:
     print('YES')

Measured memory_bytes: 14108
A = [list(map(int,input().split())) for _ in range(3)]
C = [0,0,0]
for j in range(3):
    for i in range(3):
        C[j] += A[i][j]
R = [0,0,0]
for i in range(3):
    for j in range(3):
        R[i] += A[i][j]
if (C[0]-C[1])%3==0 and (C[1]-C[2])%3==0 and (R[0]-R[1])%3==0 and (R[1]-R[2])%3==0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 38452
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
const int MOD=1000000007;
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
const int MAX_N=2e5+5;

int main(void){
    lint N,M;
    cin >> N >> M;
    lint A[N];
    rep(i,N) cin >> A[i];
    sort(A,A+N);
    lint sum[N+1]={};
    rep(i,N) sum[i+1]=sum[i]+A[i];
    lint lo=-1,hi=3e5,ans=0;
    while(hi-lo>1){
        lint cnt=0,mid=(hi+lo)/2;
        ans=0;
        rep(i,N){
            lint need=mid-A[i];
            lint add=N-(lower_bound(A,A+N,need)-A);
            cnt+=add;
            ans+=add*A[i]+(sum[N]-sum[N-add]);
        }
        (cnt>=M?lo:hi)=mid;
        ans-=lo*(cnt-M);
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
import sys
sys.setrecursionlimit(300000)
from math import gcd
from collections import defaultdict

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LMI(): return list(map(int, sys.stdin.readline().split()))
MOD = 10 ** 9 + 7
INF = float('inf')


K = I()
memo = dict()

def g(a, b):
    if a > b:
        a, b = b, a
    if memo.get((a, b)) is not None:
        return memo[(a, b)]
    else:
        val = gcd(a, b)
        memo[(a, b)] = val
        return val

d = defaultdict(int)
for b in range(1, K + 1):
    for c in range(1, K + 1):
        d[g(b, c)] += 1

ans = 0
for a in range(1, K + 1):
    for val, cnt in d.items():
        ans += g(a, val) * cnt
print(ans)


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

int main()
{
#define int long long
    const int INF = 1e18 + 5;
    int n, w;
    cin >> n >> w;

    vector<int> weight(n + 1);
    vector<int> value(n + 1);

    for (int i = 1; i <= n; i++)
    {
        cin >> weight[i];
        cin >> value[i];
    }

    int val_sum = 0;
    for (int i = 1; i <= n; i++)
        val_sum += value[i];

    vector<int> dp(val_sum + 1, INF);
    vector<int> ndp(val_sum + 1, INF);
    dp[0] = 0;
    ndp[0] = 0;

    for (int item = 1; item <= n; item++) // update for every item
    {
        for (int j = 1; j <= val_sum; j++) // dp[i] - max cost to get value i exactly
        {
            ndp[j] = dp[j];
            if (j - value[item] >= 0)
                ndp[j] = min(ndp[j], weight[item] + dp[j - value[item]]);
        }

        // for (int j = 1; j <= val_sum; j++)
        // {
        //     if (ndp[j] == INF)
        //         cout << "X ";
        //     else
        //         cout << ndp[j] << " ";
        // }
        // cout << "\n";
        dp = ndp;
    }

    int best = 0;
    for (int i = 1; i <= val_sum; i++)
        if (dp[i] <= w)
            best = i;

    cout << best << "\n";
}

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

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

typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素


int main(){
    int N;
    string S;
    cin>>N>>S;
    vector<int> v(3);
    rep(i,N) v[S[i]%3]++;
    ll ans=(ll)v[0]*v[1]*v[2];
    ll sub=0;
    rep(i,N){
        for(int j=i+1;j<N;j++){
            if(S[i]==S[j]) continue;
            int k=2*j-i;
            if(k>=N) continue;
            if(S[i]==S[k] || S[j]==S[k]) continue;
            sub++;
        }
    }
    ans-=sub;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3608
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
int main()
{
	int act;
	int wat;
	int n,m;
	int sum;
	scanf("%d %d",&n,&m);
	wat=pow(2,m)*1900*m;
	act=pow(2,m)*100*(n-m);
	sum = wat+act;
	printf("%d",sum);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main() {
  int K;
  string S;
  cin >> K >> S;
  if(S.size() <= K) {
    cout << S << endl;
  }
  else {
    for(int i = 0; i < K; i++) {
      cout << S[i];
    }
    cout << "..." << endl;
  }
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; ++i)
#define INF 100100100
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main(){
  int n, m;
  cin >> n >> m;
  vector<int> p(m);
  vector<string> s(m);
  rep(i,m){
  	cin >> p[i] >> s[i];
  	--p[i];
  }

  int ac = 0, pena = 0;
  vector<int> wrong(n);
  vector<bool> seen(n);
  rep(i,m){
  	if(s[i] == "AC" && seen[p[i]] == false){
  		++ac;
  		pena += wrong[p[i]];
  		seen[p[i]] = true;
  	}
  	if(s[i] == "WA") ++wrong[p[i]];
  }
  cout << ac << " " << pena << endl;
  return 0;
}


Measured memory_bytes: 6528
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>

using namespace std;

namespace Solver {

    int N, A, B, C, X;
    vector<int> Y;
    inline bool Read() {
        cin >> N >> A >> B >> C >> X;
        Y.resize(N);
        for (int i = 0; i < N; i++) cin >> Y[i];
        return N != 0;
    }

    inline void Work() {
        int j = 0;
        for (int i = 0; i <= 10000; i++) {
            if (Y[j] == X) {
                Y[j] = -1;
                j++;
                if (j == N) {
                    cout << i << endl;
                    return;
                }
            }

            X = (A * X + B) % C;
        }

        cout << -1 << endl;
    }

    inline void Solve() {
        while (Read()) Work();
    }
}

int main() {
    Solver::Solve();
}

Measured memory_bytes: 1212
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <map>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;

int main(){
  int n,m;
  cin >> n >> m;
  int marker[n+1];
  fill(marker,marker+n+1,0);
  REP(i,m){
    int l,r; cin >> l >> r;
    marker[l-1]++;
    marker[r]--;
  }
  int ans = 0;
  int sum = 0;
  REP(i,n){
    sum += marker[i];
    if(sum==m) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
string s;
int a[1000010], ans;
int main(){
    cin.sync_with_stdio(0); cin.tie(0);
    cin >> s; reverse(s.begin(), s.end());
    for (int i = 0; i < s.size(); i++) a[i] = s[i] -'0';
    for (int i = 0; i < s.size(); i++){
        if (a[i] == 10){
            a[i + 1]++;
            continue;
        }
        if (a[i] == 5){
            ans += 5;
            if (a[i + 1] >= 5) a[i + 1]++;
        }
        else if (10 - a[i] + 1 > a[i]) ans += a[i];
        else {
            ans += 10 - a[i];
            a[i + 1]++;
        }
    }
    if (a[s.size()]) ans++;
    cout << ans;
}

Measured memory_bytes: 5276
#include<iostream>
#include<vector>
#include<algorithm>
auto main ( ) -> int
{
    std::vector < int > v ( 3 ) ;
    for ( auto & e : v )
    {
        std::cin >> e ;
    }
    std::sort ( v.begin ( ) , v.end ( ) ) ;
    std::cout << v [ 0 ] << ' ' << v [ 1 ] << ' ' << v [ 2 ] << std::endl ;
}

Measured memory_bytes: 1204
#include <stdio.h>

int main(void){
  char s[1000000];
  char t[1000000];
  scanf("%s", s);
  scanf("%s", t);
  int i;
  int ans=0;
  for(i=0; s[i]!=0; i++){
    if(s[i]!=t[i]){
      ans++;
    }
  }
  
  printf("%d\n", ans);
  
  return 0;
}

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



int main(){
    string s;
    cin >> s;
    ll n=s.size();
    for(ll i=1;i<n;i++){
        if(s[i-1]=='B'&&s[i]=='C'){
            s[i-1]='D';
            s[i]='d';
        }
    }
    ll res=0,counta=0;
    for(ll i=0;i<n;i++){
        if(s[i]=='B'||s[i]=='C') counta=0;
        else if(s[i]=='A') counta++;
        else if(s[i]=='D') res+=counta;
    }
    cout << res << endl;
    return 0;
}  


Measured memory_bytes: 3728
r, c = map(int, input().split())
tbl = [[] for _ in range(r)]
cSum = [0 for _ in range(c+1)]

for i in range(r):
    tblS = input()
    tbl[i] = list(map(int, tblS.split()))
    print(tblS, end="")
    print(" ", sum(tbl[i]), sep="")
    
    for j in range(c):
        cSum[j] += tbl[i][j]
    cSum[c] += sum(tbl[i])
    
print(" ".join(map(str, cSum)))


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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------

int n, m, x;
int a[111];

int main() {
   cin >> n >> m >> x;
   rep (i, m) {
      int t; cin >> t;
      a[t] = 1;
   }

   int s1 = 0;
   for (int i = x; i <= n; i++) {
      s1 += a[i];
   }
   int s2 = 0;
   for (int i = x; i >= 0; i--) {
      s2 += a[i];
   }
   cout << min(s1, s2) << endl;

   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll a;
  in(a);
  if(a < 1200)
    out("ABC");
  else if(a < 2800)
    out("ARC");
  else
    out("AGC");
  memi;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int n,q,h,s,d;
long long ans;
main(){
    cin>>q>>h>>s>>d>>n;
    int q4=q*4,h2=h*2,q8=q*8,h4=h*4,s2=s*2;
    int dd=min({q8,h4,s2});
    dd=min(dd,d);
    int ss=min({q4,h2,s});
    while(n>0){
        if(n>=2)n-=2,ans+=dd;
        else n--,ans+=ss;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cctype>

using namespace std;

typedef long long lint;

int main()
{
	lint n, T;
	char fn[128];
	
	scanf("%lld %lld", &n, &T);
	scanf("%s", fn);
	
	lint lim = 1000000000 / T;
	lint ans = 0;
	
	for (int i = 0; fn[i]; i++){
		if (isdigit(fn[i])){
			fn[i] -= '0';
			lint r = 1;
			for (int rep = 0; rep < fn[i]; rep++){
				r *= n;
				if (r > lim) return (!printf("TLE\n"));
			}
			ans += r;
			if (ans > lim) return (!printf("TLE\n"));
		}
	}
	
	printf("%lld\n", ans * T);
	
	return (0);
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
using ll = long long;
#define vl vector<long long>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

ll nCr(ll n, ll r) {
    ll ans = 1;
    for (ll i = n; i > n - r; --i) {
        ans = ans*i;
    }
    for (ll i = 1 ; i < r + 1; ++i) {
        ans = ans / i;
    }
    return ans;
}

ll p(ll a){
  ll count=1;
  if(a-1<0){
    return count;
  }else{
    rep(i,a-1){
      count+=nCr(a-1,i+1);
    }
    return count;
  }
}

ll la(ll a,ll b){
  ll c=1;
  rep(i,a-b){
    c*=10;
  }
  return c;
}

ll sum(ll s,ll k){
  if(k==0){
    return 0;
  }else if(k==1){
    return s;
  }else{
    ll Ans=0;
    rep(i,k){
      ll d=la(k-1,i);
      Ans+=s/d*p(k-1-i)+sum(s-s/d*d,k-i-1);
    }
    return Ans;
  }
}

int main() {
  ll bn;
  cin>>bn;
  string a=to_string(bn);
  ll h=a.size();
  ll u=sum(bn,h);
  cout<<u<<endl;
}


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

int a[3*100000];
int main()
{
   int k, n;
   cin >> k >> n;
   for(int i = 0; i < n; i++)
      cin >> a[i];
   sort(a, a+n);
   int maxi = k - a[n-1] + a[0];
   for(int i = 1; i < n; i++)
   {
      int tmp = a[i] - a[i-1];
      maxi = max(maxi, tmp);
   }
   cout << k - maxi;





   return 0;
}


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

#define fi first
#define se second
#define pb push_back
#define sz(a) (int)(a).size()
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;

const ll MOD = 1e9 + 7;
const ll INF = 1e18;
const ll IINF = INT_MAX;

ll h;
ll p[45];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> h;
    p[0] = 1;
    for (int i = 0; i <= 45; i++) {
        if (i) p[i] = (p[i - 1] * 2);
        if (p[i] > h) {
            cout << p[i] - 1 << '\n';
            exit(0);
        }
    }    
    return 0;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int a=0,b=0;
    a = (s[0]-'0')*10+(s[1]-'0');
    b =  (s[2]-'0')*10+(s[3]-'0');
    if(a>=1&&a<=12){
        if(b>=1&&b<=12){
            cout << "AMBIGUOUS\n";
        }else{
            cout << "MMYY\n";
        }
    }else{
        if(b>=1&&b<=12){
            cout << "YYMM\n";
        }else{
            cout << "NA\n";
        }
    }
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a,b = map(int,input().split())
p = list(map(int,input().split()))

cnt = [0] * 3
for pi in p:
    if(pi <= a):
        cnt[0] += 1
    elif(pi > b):
        cnt[2] += 1
    else:
        cnt[1] += 1

print(min(cnt))

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

ll digit_sum(ll b,ll n){
    if(n<b) return n;
    else if(n>=b) return digit_sum(b,n/b)+n%b;
}

int main(){
    ll n,s;
    cin >> n >> s;
    ll b=-1;
    if(n==s) {cout << n+1 << endl;return 0;}
    for(ll i = 2;i <= (ll)sqrt(n);i ++){
        if(s==digit_sum(i,n)) {b=i;break;}
    }
    if(b!=-1) {cout << b << endl;return 0;}
    for(ll i = 1;i < sqrt(n);i ++){
        if((n+i-s)/i<2) continue;
        if(s==digit_sum((n+i-s)/i,n)) b=b==-1?(n+i-s)/i:min(b,(n+i-s)/i);
    }
    cout << b << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;

#define INF 1e10
#define fi first
#define se second
#define mp make_pair
#define MAXN 100005

int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n,a;
    cin >> n >> a;
    cout << n*n-a;
    return 0;
}


Measured memory_bytes: 256
input = require('fs').readFileSync(process.stdin.fd, 'utf8')
lines = input.split('\n')
line = lines[0]
j = 1
for(i = 0; i < line.length; i++) {
    if ((i+1)%2) {
        if (line[i] == 'L') {
            j = 0
            break;
        } 
    } else {
        if (line[i] == 'R') {
            j = 0
            break;
        } 
    }
}

NY = ['No', 'Yes']
console.log(NY[j])


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

typedef long long int ll;
#define INF 1999999999
#define MODA 1000000007
#define PI 3.1415926535897932384626433

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b;
    cin >> a >> b;

    if(a < 6)
    {
        cout << 0 << endl;
    }
    else if(a < 13)
    {
        cout << b/2 << endl;
    }
    else
    {
        cout << b << endl;
    }
    return 0;
}



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

int main() {
    int N;
    cin >> N;
    vector<int> b(N);
    for(int i=0; i<N; i++){
        cin >> b[i];
    }

    int flag = 0;
    vector<int> ans(N);
    while(flag == 0){
        for(int i = b.size(); i>0; i--){
            if(b[i-1] == i){
                ans[b.size()-1] = i;
                b.erase(b.begin() + i-1);
                flag = 0;
                break;
            }
            flag = -1;
        }
        if(b.empty()){
            flag = 1;
        }
    }

    if(flag == 1){
        for(int i=0; i<N; i++){
            cout << ans[i] << endl;
        }
    }else{
        cout << flag;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<cstring>
#include<utility>
#include<set>
#include<stack>
#include<complex>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define CC puts("-------ok--------");
#define all(in) in.begin(), in.end()
#define bv vector<bool>
using namespace std;
typedef pair<int, int>PI;
using namespace std;
#define MAX  999999
int main(){
    int a,b,c; cin >> a>>b>>c;
    int sum = a+b; ll ans = 0;
    for(int i = 0;10000;i++){
        ans=i*60+c;
        if(ans % (a+b)<=a){cout << ans << endl; break;}
        if(((a+b == 60) && c > a )|| i>5000){cout << -1 << endl; break;}
    }
    
}

Measured memory_bytes: 3112
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*
cout<<setprecision(20)
cin.tie(0);
ios::sync_with_stdio(false);
*/
const llint mod=998244353;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int main(void){
	int a,b,c;cin>>a>>b>>c;
	cout<<max({a,b,c})-min({a,b,c})<<endl;
	return 0;
}

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

int main() {
  long n;
  cin >> n;
  
  map<long, long> mp;
  
  for(int i=0; i<n; i++){
    long junban;
    cin >> junban;
    mp[junban-1] = i;
  }
  for(int i=0; i<n; i++){
  	cout << mp[i]+1 <<endl;
  }
   
  return 0;
}


Measured memory_bytes: 7040
from bisect import bisect_left

s = input()
t = input()
idx = [[] for _ in range(26)]
for i in range(len(s)):
    c = ord(s[i]) - ord('a')
    idx[c].append(i)
count = 0
index = -1
for i in range(len(t)):
    c = ord(t[i]) - ord('a')
    if len(idx[c]) == 0:
        print(-1)
        exit()
    j = bisect_left(idx[c], index+1)
    if j == len(idx[c]):
        count += 1
        index = idx[c][0]
    else:
        index = idx[c][j]
print(count*len(s) + index + 1)



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

#define ll long long
#define endl "\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const int mod = 1e9 + 7;
const int MAX = 1e5 + 1;

int main()
{
	IOS
	int t = 1;
	//cin >> t;
	while(t--)
	{
		int n;
		cin >> n;
		int a[n + 1];
		for(int i = 1; i <= n; ++i)
		{
			cin >> a[i];
		}
		//sort(a + 1, a + n + 1);
		ll ans = 0;
		for(int i = 1; i <= n; ++i)
		{
			for(int j = i + 1; j <= n; ++j)
			{
				for(int k = j + 1; k <= n; ++k)
				{
					if(a[i] != a[j] && a[j] != a[k] && a[i] != a[k])
					{
						if(a[i] + a[j] > a[k] && a[k] + a[j] > a[i] && a[i] + a[k] > a[j]) ans += 1;
					}
				}
			}
		}
		cout << ans;
	}
	return 0;
}


Measured memory_bytes: 3636
#include<iostream>
using namespace std;
int gcd(int x,int y)
{
  int tmp;
  if(x<y){
    swap(x,y);
  }
  while(y>0){
    tmp=x%y;
    x=y;
    y=tmp;
  }
  return x;
}

int main()
{
  int x,y;
  cin>>x>>y;
  cout<<gcd(x,y)<<"\n";
}



Measured memory_bytes: 3088
#include <iostream>
#include <vector>
#include <algorithm>


using namespace std;

int  main(int argc, char const *argv[]) {
  int N,tmp;
  std::vector<int> v;
  std::cin >> N;
  for (size_t i = 0; i < N; i++) {
    std::cin >> tmp;
    v.push_back(tmp);
    }
    sort(v.begin(),v.end());

    int center = (v.size()-1)/2;
    cout<<v[center+1]-v[center];


  return 0;
}


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

// macros
#define pb emplace_back
#define mk make_pair
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for(int i=((int)(n)-1);i>=0;i--)
#define irep(itr, st) for(auto itr = (st).begin(); itr != (st).end(); ++itr)
#define irrep(itr, st) for(auto itr = (st).rbegin(); itr != (st).rend(); ++itr)
#define whole(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define bit(n) (1LL<<(n))
// functions
template <class T>bool chmax(T &a, const T &b){if(a < b){a = b; return 1;} return 0;}
template <class T>bool chmin(T &a, const T &b){if(a > b){a = b; return 1;} return 0;}
template <typename T> istream &operator>>(istream &is, vector<T> &vec){for(auto &v: vec)is >> v; return is;}
template <typename T> ostream &operator<<(ostream &os, const vector<T>& vec){for(int i = 0; i < vec.size(); i++){ os << vec[i]; if(i + 1 != vec.size())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const set<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const unordered_set<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const multiset<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const unordered_multiset<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p){os << p.first << " " << p.second; return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const map<T1, T2> &mp){for(auto itr = mp.begin(); itr != mp.end(); ++itr){ os << itr->first << ":" << itr->second; auto titr = itr; if(++titr != mp.end())os << " "; } return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const unordered_map<T1, T2> &mp){for(auto itr = mp.begin(); itr != mp.end(); ++itr){ os << itr->first << ":" << itr->second; auto titr = itr; if(++titr != mp.end())os << " "; } return os;}
//  types
using ll = long long int;
using P = pair<int, int>;
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;
const int mod = 1000000007;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};
// io
struct fast_io{
  fast_io(){ios_base::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(20);}
} fast_io_;

ll calc(ll x){
  if(x == 1)return 1;
  ll tmp = calc(x / 2);
  return 2LL * tmp + 1;
}

int main(int argc, char const* argv[])
{
  ll h; cin >> h;
  cout << calc(h) << endl;
  return 0;
}


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

cost_list = []

for i in range(len(list)):
    if list[i][1] <= T:
        cost_list.append(list[i][0])

if len(cost_list) >= 1:
    print(min(cost_list))
elif len(cost_list) == 0:
    print('TLE')

Measured memory_bytes: 3060