akhauriyash/Code-Regression huggingface dataset:
//Vivek
#pragma optimize("", off)
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma comment(linker, "/STACK:36777216")
#ifndef ONLINE_JUDGE
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long 
#define mod 1000000007
#define all(v) v.begin(),v.end()
#define pb push_back
#define sz(i) int(i.size())
#define setto(n) cout << fixed << setprecision(n)
#define fi first
#define se second
#define mem(a, b) memset(a, b, sizeof(a))
#define len(s) int(s.length())
#define INF LONG_MAX
#define UNIQUE(a) ((a).erase(unique((a).begin(), (a).end()), (a).end()))
#define random() ((ll)rand() << 32 | rand())
#define C(c) c-'a'

using namespace std;

#ifdef ONLINE_JUDGE
#define endl '\n'
#endif
#ifndef ONLINE_JUDGE
#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
template<class T> void smin(T& a, T val) {if (a > val) a = val;}
template<class T> void smax(T& a, T val) {if (a < val) a = val;}
template<typename T>inline std::ostream &operator << (std::ostream & os,const std::vector<T>& v){bool first = true;os << "[";for(auto i: v){if(!first)os << ", ";os << i;first = false;}return os << "]";}
//Check N size twiceeeeeeeeeeeeeeeeee, and verify it
const int N = 2*1e5 + 10;

int n, a[N];
int main(){
	boost;

	cin>>n;

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

	int ma = -INT_MAX;

	for (int i = 0; i < n; ++i)
	{
		for (int j = i+1; j < n; ++j)
		{	
			smax(ma, abs(a[i]-a[j]));
		}
	}

	cout<<ma;

	return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int n = sc.nextInt();
		int m = sc.nextInt();
		int x = sc.nextInt();
		int y = sc.nextInt();
		
		int[] xx = new int[n];
		for (int i = 0; i < n; i++) {
			xx[i] = sc.nextInt();
		}
		Arrays.sort(xx);

		int[] yy = new int[m];
		for (int i = 0; i < m; i++) {
			yy[i] = sc.nextInt();
		}
		Arrays.sort(yy);

		for (int i = x + 1; i <= y; i++) {
			if (i > xx[n - 1] && i <= yy[0]) {
				pr.println("No War");
				return;
			}
		}

		pr.println("War");
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(INPUT == null ? System.in : new ByteArrayInputStream(INPUT.getBytes()));
		pr = new Printer(System.out);

		solve();

//		pr.close();
		pr.flush();
//		sc.close();
	}

	static String INPUT = null;

	private static class Printer extends PrintWriter {
		Printer(OutputStream out) {
			super(out);
		}
	}
}


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

int N;
int L[110];

int main() {
    cin >> N;
    int M = 2*N;
    for (int i = 0; i < M; i++) cin >> L[i];

    sort(L, L+M);

    int ans = 0;
    for (int i = 0; i < M; i++) {
        ans += min(L[2*i], L[2*i+1]);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
using Yorukatsu045.Questions;
using Yorukatsu045.Extensions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace Yorukatsu045.Questions
{
    /// <summary>
    /// ARC047 C
    /// </summary>
    public class QuestionC : AtCoderQuestionBase
    {
        public override IEnumerable<object> Solve(TextReader inputStream)
        {
            var s = inputStream.ReadLine();
            var last = s[0];
            var count = 0;
            for (int i = 1; i < s.Length; i++)
            {
                if (s[i] != last)
                {
                    count++;
                }
                last = s[i];
            }

            yield return count;
        }
    }
}


namespace Yorukatsu045
{
    class Program
    {
        static void Main(string[] args)
        {
            IAtCoderQuestion question = new QuestionC();    // 問題に合わせて書き換え
            var answers = question.Solve(Console.In);
            foreach (var answer in answers)
            {
                Console.WriteLine(answer);
            }
        }
    }
}

#region Base Classes

namespace Yorukatsu045.Questions
{

    public interface IAtCoderQuestion
    {
        IEnumerable<object> Solve(string input);
        IEnumerable<object> Solve(TextReader inputStream);
    }

    public abstract class AtCoderQuestionBase : IAtCoderQuestion
    {
        public IEnumerable<object> Solve(string input)
        {
            var stream = new MemoryStream(Encoding.Unicode.GetBytes(input));
            var reader = new StreamReader(stream, Encoding.Unicode);

            return Solve(reader);
        }

        public abstract IEnumerable<object> Solve(TextReader inputStream);
    }

}

#endregion

#region Extensions

namespace Yorukatsu045.Extensions
{
    internal static class TextReaderExtensions
    {
        internal static int ReadInt(this TextReader reader) => int.Parse(ReadString(reader));
        internal static long ReadLong(this TextReader reader) => long.Parse(ReadString(reader));
        internal static double ReadDouble(this TextReader reader) => double.Parse(ReadString(reader));
        internal static string ReadString(this TextReader reader) => reader.ReadLine();

        internal static int[] ReadIntArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(int.Parse).ToArray();
        internal static long[] ReadLongArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(long.Parse).ToArray();
        internal static double[] ReadDoubleArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(double.Parse).ToArray();
        internal static string[] ReadStringArray(this TextReader reader, char separator = ' ') => reader.ReadLine().Split(separator);
    }
}

#endregion

Measured memory_bytes: 13280
#include <iostream>
#include <fstream>
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <sstream>
#include <string>
#include <vector>
using namespace std;

#pragma comment(linker, "/STACK:400000000")

#define EPS 1e-9
#define INF MOD
#define MOD 1000000007LL
#define fir first
#define foreach(it,X) for(it=X.begin();it!=X.end();it++)
#define iss istringstream
#define ite iterator
#define ll long long
#define mp make_pair
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<n;i++)
#define pi pair<int,int>
#define pb push_back
#define sec second
#define sh(i) (1LL<<i)
#define sst stringstream
#define sz size()
#define vi vector<int>
#define vc vector
#define vl vector<ll>
#define vs vector<string>

bool isp[1000011];
int last[1000011];
ll cur[1000011];
ll A,B,a,b;

int main(){
	cin>>A>>B;
	a=max(2LL,A-B);
	b=A+B;
	fill(isp,isp+1000011,1);
	fill(last,last+2*B+1,INF);
	for(ll i=a;i<=b;i++)cur[i-a]=i;
	for(ll i=2;i*i<=b;i++){
		if(isp[i]){
			for(ll j=2*i;j*j<=b;j+=i) isp[j]=0;
			for(ll j=max(2LL,(a+i-1)/i)*i;j<=b;j+=i){
				if(last[j-a]>-1){
					int y=0;
					while(cur[j-a]%i==0)cur[j-a]/=i,y++;
					if(last[j-a]<y)last[j-a]=-1;
					else last[j-a]=y;
				}
			}
		}
	}
	int ans=0;
	for(ll i=a;i<=b;i++)ans+=last[i-a]>-1;
	cout<<ans<<endl;
}

Measured memory_bytes: 13000
#include <iostream>
#include <vector>
using namespace std;
#define NUMSSIZE 6

int main()
{
    vector<int> nums;
    for(int i = 0; i < NUMSSIZE; i++)
    {
        int j = 0;
        cin >> j;
        nums.push_back(j);
    }
    
    if(nums[nums.size() - 2] - nums[0] <= nums[nums.size() - 1] )
    {
        cout << "Yay!";
    }
    else
    {
        cout << ":(";
    }
    
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <string>
#include <cmath>
#include <sstream>
#include <istream>
#include <iomanip>
#include <typeinfo>
#include <stack>
#include <map>
#include <queue>

using namespace std;
typedef long long int ll;

int main(){

    ll N, C , K;
    cin >> N >> C >> K;
    vector<ll > T(N, 0);
    for(ll i = 0; i < N; i++){
        cin >> T[i];  
    }
    sort(T.begin(), T.end());
    
    ll ans = 0;

    ll mn = T[0];
    ll mx = T[0] + K;
    ll cn = 0;
    bool flg = false;

    for(ll i = 0; i < N; i++){
        if(C == 1){
            ans++;
            continue;
        }
        if(flg == true){
            flg = false;
            cn = 0;
            ans++;
            mn = T[i];
            mx = T[i] + K;
        }

        if(T[i] >= mn && T[i] <= mx){
            cn++;
            if(cn == C) flg = true;
        }else{
            cn = 1;
            ans++;
            mn = T[i];
            mx = T[i] + K;
        }
    }

    if(C != 1 && cn < C){
        ans++;
    }

    cout << ans << endl;


} 

Measured memory_bytes: 1024
#include <iostream>
#include<vector>
#include<cmath>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define drep(i,n) for(int i = (n)-1; i >= 0; i--)
#define srep(i,s,t) for (int i = s; i < t; i++)
#define rng(a) a.begin(),a.end()
typedef long long ll;

using namespace std;


int main() {
    int n, d;
    cin>>n>>d;
    vector<vector<int>>x(n,vector<int>(d));
    rep(i,n){
        rep(j,d) cin>>x[i][j];
    }
    int ans = 0;
    
    rep(i,n-1){
        rrep(k,n-i-1){
            double dist = 0;
            rep(j,d){
                dist += (x[i][j]-x[i+k][j])*(x[i][j]-x[i+k][j]);    
            }
            if((int)sqrt(dist)*(int)sqrt(dist)==(int)dist){
                ans++;
            }
        }
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <string>
#include <cctype>
#include <cmath>
#include <cstring>
#include <climits>
#include <complex>
#include <set>
#include <deque>
#define DEBUG(x) cerr<<"line:"<<__LINE__<<", "<<#x" == "<<(x)<<endl;
#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define FOR(it,s) for(__typeof(s.begin()) it=s.begin();it!=s.end();it++)
#define fst first
#define snd second
#define ALL(a) a.begin(),a.end()
#define RI(x) scanf("%d",&(x))
#define RII(x,y) scanf("%d%d",&(x),&(y))
#define RIII(x,y,z) scanf("%d%d%d",&(x),&(y),&(z))
#define DRI(x) int (x);scanf("%d",&(x))
#define DRII(x,y) int (x),(y);scanf("%d%d",&(x),&(y))
#define DRIII(x,y,z) int (x),(y),(z);scanf("%d%d%d",&(x),&(y),&(z))
#define MS0(a) memset((a),0,sizeof((a)))
#define MS1(a) memset((a),-1,sizeof((a)))
#define MS(a,b) memset((a),(b),sizeof((a)))
using namespace std;

typedef long long LL;
typedef unsigned int uint;
typedef unsigned long long ULL;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<vi> vvi;

LL pow(LL a, LL b, LL MOD) {
    LL ans = 1;
    while (b) {
        if (b & 1) ans = ans * a % MOD;
        a = a * a % MOD;
        b >>= 1;
    }
    return ans;
}

#define INF (int)1e9
#define EPS (1.0e-8)
// ------------------


int main(void)
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
#ifdef LOCAL
    // freopen(".in", "r", stdin);
    // freopen(".out", "w", stdout);
#endif
    long long N, K;
    cin >> N >> K;
    cout << min(N % K, (K - N%K)) << endl;
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int N,M,masu[1000],dice[1000],now,i;
  while(1){
    cin >>N>>M;
    if( N == 0 && M == 0)break;
    now=1;
    for(i=1 ; i <= N ; i++)cin >>masu[i];
    for(i=1 ; i <= M ; i++)cin >>dice[i];
    for(i=1 ; i <= M ; i++){
      now+=dice[i];
      now+=masu[now];
      if(now >= N)break;
    }
    cout <<i<<endl;
  }
  return 0;
}

Measured memory_bytes: 2980
n, k = map(int, input().split())
a = [int(i) - 1 for i in input().split()]
ans = 0
while k:
    if k & 1:
        ans = a[ans]
    c = [a[a[i]] for i in range(n)]
    a = c[:]
    k >>= 1
print(ans + 1)

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

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

    int ans = N - accumulate(A.begin(), A.end(), 0);
    cout << (ans >= 0 ? ans : -1) << endl;

    return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define int long long
#define pb emplace_back
#define mp make_pair
#define mt make_tuple
#define all(v) v.begin(),v.end()
#define rep(i,start,lim) for(long long (i)=(start);i<(lim);i++)
#define revrep(i,n) for(long long i=n-1;i>=0;i--)
#define boost ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define osit ostream_iterator<int> output (cout," ")
#define endl '\n'
#define f first
#define s second
#define PI 3.141592653589793
#define MOD 1000000007
#define set0(x) memset(x,0,sizeof(x))
#define set1(x) memset(x,1,sizeof(x))
using namespace std;
typedef vector<int> vi;
typedef list<int> li;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef tuple<int, int, int> iii;
template<typename T> T gcd(T a,T b){if(a==0) return b; return gcd(b%a,a);}
template<typename P> P dectobin(P a){if(a==0)return 0; else return(a%2 + 10*dectobin(a/2));}
template<typename Y> Y bintodec(Y a){int ans=0,b=1,t=a; while (t){int ld=t%10; t/=10;ans+=ld* b;b=b*2;} return ans; }
template<typename H> H modExp(H x, H n){ int r=1; while(n>0){if(n%2==1){r=(r*x)%MOD;}x=(x*x)%MOD;n/=2;}return r;}
template<typename T> T isPowerOfTwo(T x){return x && (!(x & (x - 1)));}	
template<typename T> T lcm(T a,T b) {return a*b/gcd(a,b);}
//template<typename T> T extendedEuclid(T A,T B){if(B==0){d=A; x=1;y=0;}else{ extendedEuclid(B,A%B);int temp=x; x=y; y=temp-(A
//B)*y;}}

int32_t main(){
	boost;osit;
	int n;
    cin>>n;
    string s;
    cin>>s;
    if(n>=3200) cout<<s;
    else cout<<"red";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define sz(x) int(x.size())
using namespace std;

bool palindrome(string a) {
	string b = a;
	reverse(b.begin(), b.end());
	return a == b;
}

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

	if(sz(a) % 2 == 0) {
		cout<<"No\n";
		return 0;
	}

	if(palindrome(a) && palindrome(a.substr(0, sz(a)/2)) && palindrome(a.substr(sz(a)/2+1, sz(a)/2))) {
		cout<<"Yes\n";
	}
	else cout<<"No\n";
}

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

int main()
{
  int N, T, S;
  scanf("%d %d %d", &N, &T, &S);
  static int as[3001], bs[3001];
  for (int i = 1; i <= N; i++) {
    scanf("%d %d", &as[i], &bs[i]);
  }

  static int dp[3001][3001];
  int ans = 0;
  for (int i = 1; i <= N; i++) {
    for (int j = 1; j <= T; j++) {
      dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
      const int beg = j-bs[i];
      if (beg >= 0 && (S <= beg || j <= S)) {
        dp[i][j] = max(dp[i][j], dp[i-1][beg] + as[i]);
      }
      ans = max(ans, dp[i][j]);
    }
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<cstring> 
using namespace std;
int a[10];
bool vis[10];
int main(){
	int t;
	cin>>t;
	while(t--){
		memset(vis, 0, sizeof vis);
		for(int i = 0; i < 10; i++) cin>>a[i];
		int now = 0;
		for(int i = 1; i < 10; i++){
			if(a[i] > a[now]){
				now = i;
				vis[now] = 1;
			}
		}
		bool flag = true;
		now = -1;
		for(int i = 1; i < 10; i++){
			if(!vis[i]){
				if(now == -1) now = i;
				else{
					if(a[i] < a[now]){
						flag = false;
						break;
					}
					else now = i;
				}
			}
		}
		if(flag) cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}
}

Measured memory_bytes: 2904
s = str(input())
a = ['a', 'b', 'c', 'd', 'e','f','g','h','i','j','k','l','m','n',
     'o','p','q','r','s','t','u','v','w','x','y','z']
I = -2
J = -2
for letter in a:
  if s[-1] == letter and s[-2] == letter:
    I = len(s)-2
    J = len(s)-1
    break
  for i in range(0, len(s)-2):
    if s[i] == letter and s[i+1] == letter:
      I = i
      J = i + 1
      break
    elif s[i] == letter and s[i+2] == letter:
      I = i
      J = i + 2
      break
print(I + 1, J + 1)

Measured memory_bytes: 3188
import sys
from itertools import accumulate
import bisect
input = sys.stdin.readline


def readstr():
    return input().strip()


def readint():
    return int(input())


def readnums():
    return map(int, input().split())


def readstrs():
    return input().split()


def main():
    N, M, K = readnums()
    A = list(readnums())
    B = list(readnums())

    aa = list(accumulate(A))
    bb = list(accumulate(B))
    ans = bisect.bisect_right(bb, K)
    for i in range(len(aa)):
        if aa[i] <= K:
            tmp = bisect.bisect_right(bb, K - aa[i]) + i + 1
        else:
            continue
        ans = max(ans, tmp)

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 49320
from functools import lru_cache
import sys

sys.setrecursionlimit(100000)

s = int(input())
# for cnt_5 in range(s // 5):
#     for cnt_4 in range((s - (cnt_5 * 5)) // 4):
#         rest = s - (cnt_5 * 5 + cnt_4 * 4)
#         if rest % 3 != 0:
#             continue
#         cnt_3 = rest // 3
@lru_cache(maxsize=2000)
def f(n):
    if n < 3:
        return 0
    if n >= 3 and n <= 5:
        return 1

    ans = 0
    for i in range(3, (n-1) // 2 + 1):
        ans += f(i) + f(n - i)
    if n % 2 == 0:
        ans += f(n // 2)
    ans += 1
    return ans % 1000000007

print(f(s))





Measured memory_bytes: 10124
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)
#define RREP(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define ALL(v) (v).begin(), (v).end()
template<class T>
using reverse_priority_queue = priority_queue<T, vector<T>, greater<T>>;

double calc_dist(ll x1, ll y1, ll x2, ll y2){
    const double dx = x1 - x2;
    const double dy = y1 - y2;
    return sqrt(dx * dx + dy * dy);
}

int main(){
    ll xs, ys, xt, yt;
    cin >> xs >> ys >> xt >> yt;
    ll n;
    cin >> n;

    vector<pair<ll, ll>> xy(n + 2);
    vector<ll> r(n + 2);

    xy.at(0) = {xs, ys};
    xy.at(1) = {xt, yt};
    r.at(0) = 0;
    r.at(1) = 0;

    REP(i, n){
        ll xi, yi, ri;
        cin >> xi >> yi >> ri;
        xy.at(i + 2) = {xi, yi};
        r.at(i + 2) = ri;
    }

    vector<double> dist(n + 2, numeric_limits<double>::max());
    dist.at(0) = 0;
    reverse_priority_queue<pair<double, ll>> que;
    que.emplace(0, 0);
    while(!que.empty()){
        const auto p = que.top(); que.pop();
        const ll i = p.second;
        if(i == 1){ break; }
        if(p.first > dist.at(i)){ continue; }
        for(ll j = 1; j < n + 2; ++j){
            if(i == j){ continue; }
            double d = max(0.0, calc_dist(
                xy.at(i).first, xy.at(i).second, xy.at(j).first, xy.at(j).second
            ) - r.at(i) - r.at(j));
            if(dist.at(j) > dist.at(i) + d){
                dist.at(j) = dist.at(i) + d;
                que.emplace(dist.at(j), j);
            }
        }
    }
    printf("%.10f\n", dist.at(1));
    return 0;
}


Measured memory_bytes: 7332
import Data.List
import Data.Ord
import Data.Char
import Data.Ratio
import Data.Maybe

main = do
  [_,_,x,y] <- map (read::String->Int) . words <$> getLine
  xmax <- maximum . map (read::String->Int) . words <$> getLine
  ymin <- minimum . map (read::String->Int) . words <$> getLine
  putStrLn $ war [z|z<-[x+1..y], xmax<z, z<=ymin]
  
war l
  |length l/=0 = "No War"
  |otherwise   = "War"

Measured memory_bytes: 4800
# coding: utf-8
# Your code here!

N, M, X = map(int, input().split())
toll = [int(i) for i in input().split()]
counter1 = 0
counter2 = 0

for i in range(X - 1, 0, -1):
    for j in range(len(toll)):
        if toll[j] == i:
            counter1 += 1

for k in range(X, N):
    for l in range(len(toll)):
        if toll[l] == k:
            counter2 += 1

if counter1 <= counter2:
    print(counter1)
else:
    print(counter2)


Measured memory_bytes: 3064
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

#[derive(PartialEq, Debug)]
enum NumsState {
    Incr,
    Decr,
    Unknown,
}

fn main() {
    read::<String>();
    let nums: Vec<i32> = read_vec();
    let (_, _, count) = nums.iter().fold(
        (*nums.get(0).unwrap(), NumsState::Unknown, 1),
        |tuple: (i32, NumsState, i32), num| {
            let (before_num, state, count) = tuple;
            let (new_state, new_count) = match state {
                NumsState::Unknown => {
                    let state = if before_num < *num {
                        NumsState::Incr
                    } else if before_num > *num {
                        NumsState::Decr 
                    } else {
                        NumsState::Unknown
                    };
                    (state, count)
                },
                NumsState::Incr => {
                    if before_num > *num {
                        (NumsState::Unknown, count + 1)
                    } else {
                        (NumsState::Incr, count)
                    }
                },
                NumsState::Decr => {
                    if before_num < *num {
                        (NumsState::Unknown, count + 1)
                    } else {
                        (NumsState::Decr, count)
                    }
                },
            };
            (*num, new_state, new_count)
        }
    );
    println!("{}", count);
}

Measured memory_bytes: 6396
#include <iostream>
#include<string>
#include<vector>
#include<stdio.h>

using namespace std;


int main()
{

	int a, b, c, d;
	cin >> a >> b >> c >> d;

	if (a + b > c + d) {
		cout << "Left" << endl;
	}
	else if (a + b == c + d) {
		cout << "Balanced" << endl;
	}
	else {
		cout << "Right" << endl;
	}

	return 0;




}




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

int main(){
  int A, B, C, X, Y; cin >> A >> B >> C >> X >> Y;
  if(A > B) {swap(A, B); swap(X, Y);}
  int ans;
  if(2 * C <= A) ans = 2 * C * max(X, Y);
  else if(2 * C <= B) ans = 2 * C * Y + A * max(X - Y, 0);
  else if(2 * C <= A + B) {
    if(X < Y) ans = 2 * C * X + (Y - X) * B;
    else ans = 2 * C * Y + (X - Y) * A;
  }else ans = A * X + B * Y;
  
  cout << ans << endl;
}

Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, M, K = MAP()
A = [0]+LIST()
B = LIST()

A = list(accumulate(A))
B = list(accumulate(B))
ans = 0
for i in range(N+1):  # Aの上からi冊読む
    left = K-A[i]
    if left < 0:
        continue
    ans = max(ans, i+bisect(B, left))
print(ans)


Measured memory_bytes: 44024
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <limits.h>

int main(void) {
	int H, W, i, j;
	while (1){
		scanf("%d %d", &H, &W);
		if (H == 0 && W == 0) break;
		for (i = 0; i < H; ++i){
			for (j = 0; j < W; ++j){
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 572
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i< (n); i++)
int main(){
long long int a=0, b=0, c=0;
cin >> a >> b >> c;
if(c-a-b<=0) cout << "No" << endl;
else if (4*a*b<(c-a-b)*(c-a-b)) cout << "Yes" << endl;
else cout << "No" << endl;
}

Measured memory_bytes: 256
using System;

namespace atcoderA
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            int[] line = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            int X = line[0];
            int Y = line[1];
            Console.WriteLine(X + Y / 2);
        }
    }
}

Measured memory_bytes: 13140
s = input()
n = len(s)

ans = 0

for bit in range(2 ** (n - 1)):
    f = s[0]

    for i in range(n - 1):
        if bit & (1 << i):
            f += "+"
        f += s[i + 1]

    ans += sum(map(int, f.split("+")))

print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<functional>
#include<stack>
#include<queue>
#include <iomanip>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<deque>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

using namespace std;

#define DBG cerr << '!' << endl;
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(10)

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

int main()
{
	ll n,m;cin >> n >> m;
	
	ll ans = min(n,m/2);
	m -= 2*n;
	if(m > 0)
	{
		ans += m/4;
	}
	
	cout << ans << endl;
	
	
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
typedef long long LL;
const LL INF = 0x3f3f3f3f3f3f3f3f;

LL ec = 0,hed[10005] = {0},nxt[20005],to[20005];
void add_edge(LL f,LL t){
	++ ec; to[ec] = t; nxt[ec] = hed[f]; hed[f] = ec;
}

LL n,sum = 1LL;
LL an1 = INF,an2 = INF;
LL mxd[10005],dep[10005],deg[10005],ans[10005];
LL eu[10005],ev[10005];

void dfs(LL u,LL f){
	dep[u] = dep[f] + 1;
	for(LL i = hed[u];i;i = nxt[i]){
		LL v = to[i];
		if(v == f) continue;
		dfs(v,u);
		deg[u] ++;
	}
	ans[dep[u]] = max(ans[dep[u]],deg[u]);
}

int main(){
	LL u,v,tmp = INF;
	cin >> n;
	for(LL i = 1;i < n;i ++){
		cin >> eu[i] >> ev[i];
		add_edge(eu[i],ev[i]);
		add_edge(ev[i],eu[i]);
	}
	
	for(LL i = 1;i <= n;i ++){
		for(LL j = 0;j <= n;j ++) ans[j] = 0,deg[j] = 0;
		tmp = 0; sum = 1LL; dfs(i,0);
		for(LL j = 1;j <= n;j ++) tmp = max(tmp,dep[j]),sum *= (ans[j] ? ans[j] : 1LL);
		if(tmp == an1) an2 = min(an2,sum);
		if(tmp < an1){ an1 = tmp; an2 = sum; }
	}
	for(LL i = 1;i < n;i ++){
		u = eu[i],v = ev[i];
		for(LL j = 0;j <= n;j ++) ans[j] = 0,deg[j] = 0;
		tmp = 0; sum = 1LL; dep[u] = 0; dfs(v,u); dep[v] = 0; dfs(u,v);
		for(LL j = 1;j <= n;j ++) tmp = max(tmp,dep[j]),sum *= (ans[j] ? ans[j] : 1LL);
		sum <<= 1;
		if(tmp == an1) an2 = min(an2,sum);
		if(tmp < an1){ an1 = tmp; an2 = sum; }
	}
	
	cout << an1 << ' ' << an2 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    for(;;){
        vector<int> a(5);
        for(int i=0; i<5; ++i){
            int b;
            cin >> a[i] >> b;
            a[i] += b;
            if(a[i] == 0)
                return 0;
        }

        int i = max_element(a.begin(), a.end()) - a.begin();
        cout << (char)(i + 'A') << ' ' << a[i] << endl;
    }
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <map>
const int MOD = 1e9+7;
typedef long long ll;
using namespace std;


int main(){
	int num[33] = {0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
}; 
	int k;
	cin >> k;
	cout << num[k] << endl;
	return 0;
 }



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

int main(){
   int a,b,c,x,y;cin>>a>>b>>c>>x>>y;
   
   long int min=99999999999999;
   int m=max(x,y);
   for(int k=0;k<=2*m;k+=2){
        long int sum=0;
        int i=x-k/2;
        if(i<0) i=0;
        int j=y-k/2;
        if(j<0) j=0;
        sum+=a*i+b*j+c*k;
        if(min>sum){
            min=sum;
        }
   }
    cout <<min<<endl;
}


Measured memory_bytes: 256
import sys
H,W = map(int,input().split())
array_list = []
for I in range(H):
    array_list.append(list(map(str,input())))

if not ( 1 <= H <= 100 and 1 <= W <= 100 ):
    sys.exit()

Horizon_list = []
Vertical_list = []
# Horizon check
for J in range(len(array_list)):
    if array_list[J].count('.') == W:
        Horizon_list.append(J)
# Vertical check
list_check = [list(x) for x in zip(*array_list)]
for K in range(len(list_check)):
    if list_check[K].count('.') == H:
        Vertical_list.append(K)
# print result
for L in range(H):
    for M in range(W):
        if (L not in Horizon_list ) and (M not in Vertical_list):
            print(array_list[L][M],end='')
    print('\n')

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

#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define pb push_back
#define pf push_front
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T1,class T2,class T3>inline void          in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T>inline void                             out(T p){cout<<p<<endl;}
long N,K,len=1,i,M,ans=1,L,k;
string S;
deque<long>v,s;
inline void solve(void){
  in(N,K,S);
  up(i,1,N-1){
    if(S[i]==S[i-1])len++;
    else{
      v.pb(len);
      len=1;
    }
  }
  v.pb(len);
  if(S[0]=='0')v.pf(0);
  if(S[N-1]=='0')v.pb(0);
  M=v.size();
  s.resize(M+1);
  for(i=0;i<M;i++)s[i+1]=s[i]+v[i];
  for(i=0;i<M;i+=2){
    L=2*K+1+i;
    if(L>M)L=M;
    chmax(ans,s[L]-s[i]);
  }
  out(ans);
}

int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


Measured memory_bytes: 2000
#include<stdio.h>

#define MAX 100005
#define NIL -1

struct Node{int p,l,r,ls,rs;};
struct Node T[MAX];
int n,D[MAX],M=0;

int getDepth(int u){
  int d=0;
  while(T[u].p != -1){
    u = T[u].p;
    d++;
  }
  return d;
}


int getSibling(int s){
  int i; 
  for(i=0; i<n; i++){
    if(s == T[i].l)return T[i].ls;
    if(s == T[i].r)return T[i].rs;
  }
  return -1;
}

int height(struct Node p,int h){
  
  int l=0,r=0;
  if(p.r==-1 && p.l==-1){ return 0; }
  if(p.r!=-1)r = height(T[p.r],r);
  if(p.l!=-1)l = height(T[p.l],l); 
  
  if(l<r) M = r+1;
  
  else M =l+1;
  
  return M;
  
  
}


int getDegree(int d){
  if(T[d].l != -1  && T[d].r != -1) return 2;
  else if(T[d].l == -1 && T[d].r != -1)return 1;
  else if(T[d].l != -1 && T[d].r == -1)return 1;
  else return 0;
}

void print(int u){
  int i=0,count=0;
  printf("node %d: parent = %d, sibling = %d, degree = %d, ",u,  T[u].p,  getSibling(u), getDegree(u));
  printf("depth = %d, height = %d, ", D[u], height(T[u], 0));
  if(D[u] == 0)printf("root\n");
  else if(T[u].l != -1 || T[u].r != -1)printf("internal node\n");
  else printf("leaf\n");
  M = 0;
}



main(){
  int i,j,d,v,c,l;
  
  scanf("%d",&n);

  for (i=0; i<n; i++){
    T[i].p = T[i].l = T[i].r = T[i].ls = T[i].rs = NIL;
  }
  
  for (i=0; i<n; i++){
    scanf("%d",&v);
    for (j=0; j<2; j++){
      scanf("%d",&c);
      

      if(j == 0){
	T[v].l = c;
	T[c].p = v;
	T[v].rs = c; 
      }
      else if(j == 1){
	T[v].r = c;
	T[c].p = v;
	T[v].ls = c;
      }
    }
  }
  for (i=0; i<n; i++){
    D[i] = getDepth(i);
  }



   for (i=0; i<n; i++) print(i);
  return 0;
}

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

#define MAXINF 1000000005
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define repc(it, x) for(auto it = (x).begin(); it != (x).end(); ++it)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rrepc(it, x) for(auto it = (x).rbegin(); it != (x).rend(); ++it)
#define all(x) (x).begin(), (x).end()
#define P pair<int, int>

const int MX = 2005;
bool d[3][3][MX];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    vector<string> s(3);
    rep(i, 3) cin >> s[i];
    sort(all(s));
    int ans = MX*3;
    do {
        rep(i,3) rep(j,3) rep(k,s[i].size()) {
            if(i > j) continue;
            bool ok = true;
            for(int ni = k; ni < s[i].size(); ni++) {
                int nj = ni-k;
                if(nj >= s[j].size()) break;
                if(s[i][ni]=='?' || s[j][nj]=='?') continue;
                if(s[i][ni]!=s[j][nj]) ok = false;
            }
            d[i][j][k] = ok;
        }

        auto f = [&](int i, int j, int k) {
            if( k >= s[i].size()) return true;
            return d[i][j][k];
        };
        rep(x,MX)rep(y,MX) {
            if(!f(0,1,x)) continue;
            if(!f(1,2,y)) continue;
            if(!f(0,2,x+y)) continue;
            int now = 0;
            now = max<int>(now, s[0].size());
            now = max<int>(now, x+s[1].size());
            now = max<int>(now, x+y+s[2].size());
            ans = min(ans, now);
        }
    } while(next_permutation(all(s)));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdio>
#include <cmath>
#include <algorithm>

using namespace std;
int main() {
    int a[6];
    for (int i=0; i<6; i++) {
        cin >> a[i];
    }
    
    string str;
    cin >> str;
    int b,c,d,e;
    b=c=d=e=0;
    for (int i=0; i<str.size(); i++) {
        if(str[i]=='W'){
            
            b=a[0];c=a[2];d=a[3];e=a[5];
            a[3]=b;a[0]=c;a[5]=d;a[2]=e;
        }
        if(str[i]=='N'){
            
            b=a[0];c=a[1];d=a[4];e=a[5];
            a[4]=b;a[0]=c;a[5]=d;a[1]=e;
        }
        if(str[i]=='E'){
            
            b=a[0];c=a[2];d=a[3];e=a[5];
            a[2]=b;a[5]=c;a[0]=d;a[3]=e;
        }
        if(str[i]=='S'){
            b=a[0];c=a[1];d=a[4];e=a[5];
            a[1]=b;a[5]=c;a[0]=d;a[4]=e;
        }
        
    }
    cout << a[0] << endl;
}



Measured memory_bytes: 3184
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	//	"strings"
)

// numDivisor ...
func numDivisor(n int) []int {
	arr := make([]int, n+1)
	for i := 1; i < n+1; i++ {
		for j := i; j < n+1; j += i {
			arr[j] += 1
		}
	}
	return arr
}

func main() {
	sc := NewScanner()
	n := sc.NextInt()

	arr := numDivisor(n)
	ans := 0
	for i := 1; i <= n; i++ {
		if i%2 == 0 {
			continue
		}
		if arr[i] == 8 {
			ans++
		}
	}
	fmt.Printf("%+v\n", ans) // output for debug
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			result = append(result, v)
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	result = append(result, v)

	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
typedef long long int lld;
typedef unsigned long long int llu;
#define INF (lld)(9223372036854775807)
#define IINF (int)(2147483647)

using namespace std;

int main(void) {
  lld h1, m1, h2, m2, k;
  cin >> h1 >> m1 >> h2 >> m2 >> k;
  cout << (h2 * 60 + m2 - (h1 * 60 + m1) - k) << "\n";
}


Measured memory_bytes: 3636
// https://atcoder.jp/contests/abc163/tasks/abc163_e

#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define DEBUG 0
#if DEBUG
  #define DUMP(a) REP(_i, a.size()) cout << a[_i] << (_i + 1 == a.size() ? "\n" : " ")
  #define DUMPP(a) REP(_i, a.size()) cout << a[_i].first << "," << a[_i].second << (_i + 1 == a.size() ? "\n" : " ")
  #define DUMP2D(b) REP(_j, b.size()) DUMP(b[_j]); cout << endl
#else
  #define DUMP(a)
  #define DUMPP(a)
  #define DUMP2D(b)
#endif

const int N_MAX = 2000;
const int A_I_MAX = 1e9;

int N;
vector<pair<ll, int>> vs;
vector<vector<ll>> dp;

int main() {
  cin >> N;
  vs = vector<pair<ll, int>>(N);
  REP(i, N) {
    int A;
    cin >> A;
    vs[i] = { A, i };
  }
  sort(vs.begin(), vs.end(), greater<pair<int, int>>());

  DUMPP(vs);

  dp = vector<vector<ll>>(N + 1);
  dp[0] = vector<ll>(1, 0LL);
  REP(i, N) {
    dp[i + 1] = vector<ll>(i + 2, 0LL);
    ll A = vs[i].first;
    int k = vs[i].second;
    FOR(j, 0, i + 1) {
      if (j < i + 1) {
        int j2 = N - (i + 1) + j;
        dp[i + 1][j] = max(dp[i + 1][j], dp[i][j] + A * abs(k - j2));
      }
      if (j > 0) {
        int j2 = j - 1;
        dp[i + 1][j] = max(dp[i + 1][j], dp[i][j - 1] + A * abs(k - j2));
      }
    }
  }

  DUMP2D(dp);

  ll ans = 0;
  FOR (i, 0, N) ans = max(ans, dp[N][i]);
  cout << ans << endl;
}


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

int main() {
    int a,b;
    cin >> a >> b;
    int aa[13],bb[10];
    if(a%2==0){
        for(int i=0;i<13;i++){
            aa[i]=25*(a/2)+i;
        }
    }
    else if(a%2==1){
        for(int i=0;i<12;i++){
            aa[i]=25*(a/2)+13+i;
        }
        aa[12]=1e9;
    }
    for(int i=0;i<10;i++){
        bb[i]=10*b+i;
    }
    int ans=-1;
    for(int i=0;i<13;i++){
        for(int j=0;j<10;j++){
            if(aa[i]==bb[j]){
                ans=aa[i];
                break;
            }
        }
        if(ans!=-1) break;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
def f():
 for c in range(n):
  for d in a[c+1:]:
   for p in([0,1,2,3,4,5],[1,5,2,0,4,3],[2,1,5,3,0,4],[3,0,2,5,4,1],[4,1,0,3,5,2],[5,1,4,3,2,0]):
    f=[d[i]for i in p]
    if f[::5]==a[c][::5]:
     f=f[1:5]*2
     for k in range(4):
      if f[k:k+4]==a[c][1:5]:return"No"
 return"Yes"
b=0
n=int(input())
a=[input().split()for _ in[0]*n]
for b in a:b[3:5]=b[4],b[3]
print(f())


Measured memory_bytes: 5604
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}

public class Main {
    static int MOD = 1000000007;

    public static class Mas {
        int x;
        int y;
        int step;

        Mas(int x, int y, int step) {
            this.x = x;
            this.y = y;
            this.step = step;
        }
    }

    private static final int[] vX = { 1, 0, 0, -1 };
    private static final int[] vY = { 0, 1, -1, 0 };

    public static void main(String[] args) {

        FastScanner fs = new FastScanner();
        int n = fs.nextInt();
        int b = fs.nextInt();
        // int[] a = new int[n];
        // for (int i = 0; i < n; i++) {
        //     a[i] = fs.nextInt();
        // }
        System.out.println(b>=n?"unsafe":"safe");

    }

}


Measured memory_bytes: 25356
#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;
#define sz 52
#define mod 998244353
ll n,q,i,k,t,arr[sz],brr[sz],crr[sz],a,b,c,d,m,x,y,l,r,z,dp[sz][sz][sz],drr[sz];
int main()
{
    scanf("%lld %lld %lld",&n,&m,&q);
    if(q<m)
        i=q;
    else
    {
        i=q/m;
        i*=m;
        i--;
    }
    t=i*n;
    t/=m;
    a=i/m;
    a*=n;
   printf("%lld\n",t-a);
    return 0;
}


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

#define ll long long

using namespace std;

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

    vector<int> h(n);
    vector<int> bad(n);
    for (int i = 0; i < n; i++) cin >> h[i];

    int tmp1, tmp2;
    for (int i = 0; i < m; i++) {
        cin >> tmp1 >> tmp2;
        tmp1--; tmp2--;

        if (h[tmp1] <= h[tmp2]) bad[tmp1] = 1;
        if (h[tmp2] <= h[tmp1]) bad[tmp2] = 1;
    }

    cout << count(bad.begin(), bad.end(), 0) << endl;

    return 0;
}


Measured memory_bytes: 4048
//Utkarsh.25dec
#include <bits/stdc++.h>
#include <chrono>
#include <random>
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define loop(i,a,b) for(ll i=a;i<=b;i++)
#define vi vector <int>
#define vs vector <string>
#define vc vector <char>
#define vl vector <ll>
#define all(c) (c).begin(),(c).end()
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
using namespace std;
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll modInverse(ll a){return power(a,mod-2);}
const int N=500023;
bool vis[N];
vector <int> adj[N];
void solve()
{
    ll k,x;
    cin>>k>>x;
    if(k*500>=x)
        cout<<"Yes";
    else
        cout<<"No";
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int T=1;
    //cin>>T;
    int t=0;
    while(t++<T)
    {
        //cout<<"Case #"<<t<<":"<<' ';
        solve();
        //cout<<'\n';
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 12032
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <iomanip>
using namespace std;

void solve(){
  string s; cin >> s;
  if(s == "ABC") cout << "ARC\n";
  else cout << "ABC\n";
  return;
}

int main(){
  solve();
  return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define PI  3.14159265358979323846
#define lp(i,n) for(int i = 0; i <n;i++)
#define rlp(i,n) for(int i = int(n);i >= 0;i--)
#define range1(i,a,b,c) for(int i = int(a);i <= int(b);i+=int(c))
#define range(i,a,b) for(int i = int(a);i <= int(b);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define MP make_pair
#define fr first
#define sc second
#define sz(v) ((int)((v).size()))
#define sfi1(v) scanf("%d",&v)
#define sfi2(v1, v2) scanf("%d %d",&v1,&v2)
#define sfi3(v1, v2, v3) scanf("%d %d %d",&v1,&v2,&v3)
#define sfll1(v) scanf("%I64d",&v);
#define sfll2(v1, v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1, v2, v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
typedef pair<int, int> pii;
template<class T> using ordered_set=tree<T,
null_type,
less<T>,
rb_tree_tag,
tree_order_statistics_node_update>;
const ll MOD = 1e9 + 7;
const int OO = (int)1e6;
const int N = (int)1e7;
int dx[] = {0,0,-1,1};
int dy[] = {1,-1,0,0};
void init(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
void _run(){
    string s;
    cin>>s;
    ll sum =0;
    lp(i,sz(s)){
        sum+=(ll)s[i]-'0';
    }
    if(sum%9==0)puts("Yes");
    else puts("No");
}
int main() {
	#   ifdef LOCAL_PROJECT
        freopen("in.txt", "r", stdin);
    #   endif
    int t=1;
    // scanf("%d",&t);
    while(t--)_run();
    
    return 0;
}

Measured memory_bytes: 3748
k=int(input().split(" ")[0])
a = sorted(map(lambda x: int(x), input().split("\n")[0].split(" ")))
dfs=[k-a[len(a)-1]+a[0]]
for i in range(len(a) - 1):
    dfs.append(a[i+1]-a[i])
print(sum(dfs)-max(dfs))

Measured memory_bytes: 25840