akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>

int main(){

	int i, m, f, r;
	char record;

	while (1) {
		scanf("%d %d %d", &m, &f, &r);
		if ( m + f + r == -3 ) {
			break;
		} else {
			if ( m == -1 || f == -1 ) {
				record = 'F';
			} else if ( m + f >= 80 ) {
				record = 'A';
			} else if ( m + f >= 65 ) {
				record = 'B';
			} else if ( m + f >= 50 ) {
				record = 'C';
			} else if ( m + f >= 30 ) {
				record = 'D';
				if  ( r >= 50 ) {
					record = 'C';
				}
			} else {
				record = 'F';
			}
			printf("%c\n", record);
		}
	}

    return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
typedef long long ll;
typedef pair<int, int> P; 
const int inf = 1<<21;
const ll INF = 1LL << 60;
const ll mod = 1e9+7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

// DAME:

ll dp[100005][13]; // dp[i][j] := 下からi番目までであまりがjになるものの個数
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int n = s.size();
    reverse(s.begin(), s.end());
    if (s[0]=='?') {
        rep(i, 10) dp[0][i] = 1;
    }else{
        int index = s[0]-'0';
        dp[0][index] = 1;
    }
    int mul = 1;
    for(int i=1; i<n; i++){
        mul *= 10;
        mul %= 13;

        if (s[i] == '?') {
            rep(k, 10) {
                rep(j, 13){
                    dp[i][(k*mul+j)%13] += dp[i-1][j];
                    dp[i][(k*mul+j)%13] %= mod;
                }
            }
        }else{
            int k = s[i] - '0';
            rep(j, 13){
                dp[i][(k*mul+j)%13] += dp[i-1][j];
                dp[i][(k*mul+j)%13] %= mod;
            }
        }
    }

    cout << dp[n-1][5] << endl;
    return 0;
}

Measured memory_bytes: 10704
#pragma warning(disable:4996)

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <float.h>

#pragma region 定義
typedef long long  ll;
typedef unsigned long long  ull;


#define _itoa(A,N) sprintf(A, "%d", N);

int i_dsort(const void* a, const void* b);
int i_asort(const void* a, const void* b);

int  _gcd(int a, int b);
int  _swp(int* a, int* b);
int _cknum(char* a, int n);
int _atoi(char* s, int len);

int s_asort(const void* a, const void* b);
int s_dsort(const void* a, const void* b);

//昇順
int s_asort(const void* a, const void* b) {
	return(strcmp((char*)a, (char*)b));
}
int s_dsort(const void* a, const void* b) {
	return(strcmp((char*)b, (char*)a));
}

int i_dsort(const void* a, const void* b) {
	return(*(int*)b - *(int*)a);
}
int i_asort(const void* a, const void* b) {
	return(*(int*)a - *(int*)b);
}


int i_gcd(int a, int b);
int i_gcd(int a, int b) {
	if (!b)return a;
	return i_gcd(b, a % b);
}
int i_lcm(int a, int b);
int i_lcm(int a, int b) {
	return (a * b) / i_gcd(a, b);
}
int ll_gcd(ll a, ll b);
int ll_gcd(ll a, ll b) {
	if (!b)return a;
	return ll_gcd(b, a % b);
}
int ll_lcm(ll a, ll b);
int ll_lcm(ll a, ll b) {
	return (a * b) / ll_gcd(a, b);
}

// puts("Yes\n") puts("No\n")
// scanf("%d.%d") 浮動小数点入力を整数２つで得る


//#define pai  3.1415926535 
//#define  _USE_MATH_DEFINES でM_PIが使える

#define deg_rad(X)  (X*(M_PI/180))


int _swp(int* a, int* b)
{
	int tmp;
	tmp = *b; *b = *a; *a = tmp;
	return 0;
}
#define _abs(x) ((x)>0?(x):-(x))
#define _min(x,y) ((x)<(y)?(x):(y))
#define _max(x,y) ((x)<(y)?(y):(x))

int _cknum(char* a, int n) {
	int i;
	char t = '0';

	for (i = 0; i < n; i++) {
		if (a[i] < '0' || a[i]>'9') return 1;
	}
	return 0;
}


int _atoi(char* s, int len) {
	char tmp[20];
	memcpy(tmp, s, len);
	tmp[len] = 0x00;
	return (atoi(tmp));
}

//素因数分解　pf素数が入る　pc 素数の数
//ll _pfact(ll a);
//static ll pf[100000000];
//static ll pc;
//
//ll _pfact(ll a) {
//	long i, r;
//	if (a % 2 == 0) {
//		pf[pc] = 2; pc++;
//		return(_pfact(a / 2));
//	}
//	r = sqrt(a);
//	for (i = 3; i <= r; i += 2) {
//		if (a % i == 0) {
//			pf[pc] = i; pc++;
//			return(_pfact(a / i));
//		}
//	}
//	if (a != 1) {
//		pf[pc] = a; pc++;
//	}
//	return 0;
//
//}

//同じものの最初の文字をNULLにして降順
int _sort(const void* a, const void* b);
int _sort(const void* a, const void* b) {
	char rc;

	rc = strcmp((char*)b, (char*)a);
	if (rc == 0) {
		*(char*)a = 0x00;
		return(1);
	}
	return(rc);
}
// 立っている ビットの数
int bitcount(unsigned int uc);
int bitcount(unsigned int uc)
{
	int bit;

	for (bit = 0; 0 != uc; uc = (unsigned int)(uc >> 1))
		if (0 != (uc & 1))++bit;

	return bit;
}//bitco

#define _rnd(a,b)    ((a+b-1)/b) //　A/Bの余りを繰り上げる

#pragma endregion

// ABC081 A- Placing Marbles
int main(void) {
	int  a,b,c;
	
	scanf("%1d%1d%1d",&a,&b,&c);
	printf("%d\n",a+b+c);

	return 0;
}

Measured memory_bytes: 1732
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int M = Integer.parseInt(sc.next());
		double divM = (double) 1 / (4 * M);
		boolean judge = true;
		int voteSum = 0;
		Integer[] arrayA = new Integer[N];

		for (int i = 0; i < N; i++) {
			arrayA[i] = Integer.parseInt(sc.next());
			voteSum += arrayA[i];
		}
		sc.close();
		//降順にソートする
		Arrays.sort(arrayA, Comparator.reverseOrder());

		for (int i = 0; i < M; i++) {
			//総投票数の1/4M未満であるか
			if ((double) arrayA[i] / voteSum < divM) {
				judge = false;
				break;
			}
		}
		System.out.println(judge ? "Yes" : "No");
	}
}

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

#define f first
#define s second
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define ll long long
#define ull unsigned long long
#define db double
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pli pair<ll, int>
#define px pair<db, db>
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define input(a) for (auto& el : a) cin >> el;
#define output(a) cout << '!'; for (auto& el : a) cout << el << ' '; cout << '\n'; cout.flush();
#define sz(el) int(el.size())
#define sq(a) ((a) * (a))
#define xll bitset<128>
#define xmin(a,b) a = min(a, b)
#define xmax(a,b) a = max(a, b)
#define sun(a) sort(all(a)); a.resize(unique(all(a)) - a.begin());
/**/  /// extra
//#define forn(i,n) for (int i = 0; i < n; ++i)
//#define rforn(i,n) for (int i = n - 1; i >= 0; --i)
#define bn '\n'
#define vi vector<int>
#define vii vector<vi>
#define vl vector<ll>
#define vll vector<vl>
//#define G vector<vector<pii>>
#define GVE vector<vector<edge>>
#define usi unordered_set<int>
#define usp set<pii>
/**/

using namespace std;

const int INF = 1'000'000'017;
const ll LLINF = 1'000'000'000'000'000'017LL;
const ld inf = 1.0 / 0.0;
const ld eps = 1e-9;
const int MOD = 998244353;

//mt19937_64 rng(chrono::high_resolution_clock::now().time_since_epoch().count());

//uniform_int_distribution<int> uid(l, r); [l, r]
//int x = uid(rng);

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

    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<vector<int>> pos(10);
    for (int i = 0; i < n; ++i) {
        pos[int(s[i] - '0')].eb(i);
    }
    int ans = 0;
    for (int i = 0; i < 10; ++i) {
        for (int j = 0; j < 10; ++j) {
            for (int k = 0; k < 10; ++k) {
                int last = -1;
                auto it = upper_bound(all(pos[i]), last);
                if (it == pos[i].end()) {
                    continue;
                }
                last = *it;
                auto jt = upper_bound(all(pos[j]), last);
                if (jt == pos[j].end()) {
                    continue;
                }
                last = *jt;
                auto kt = upper_bound(all(pos[k]), last);
                if (kt == pos[k].end()) {
                    continue;
                }
                ++ans;
            }
        }
    }
    cout << ans;
    return 0;
}


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

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

typedef pair<int, int> pii;

const int N_SIZE = 100;

int dp[N_SIZE + 1][N_SIZE + 1];

void solve(int n, pii rc[])
{
  REP(i, n)
    dp[i][i] = rc[i].first * rc[i].second;
  REP(i, n - 1)
    dp[i][i + 1] = dp[i][i] * rc[i + 1].second;
  for(int i = 2; i < n; i++){
    for(int j = 0, k = i + j, m = 100000000; k < n; j++, k++){
      for(int l = j, x; l < k; l++){
	x = ((j == l) ? dp[j][l] * rc[k].second : dp[j][l]) + ((l + 1 == k) ? dp[l + 1][k] * rc[j].first : dp[l + 1][k]);
	if(j != l && l + 1 != k)
	  x += rc[j].first * rc[l].second * rc[k].second;
	m = min(m, x);
      }
      dp[j][k] = m;
      m = 100000000;
    }
  }
}
 
int main()
{
  int n;
  cin >> n;
  pii rc[n];
  REP(i, n)
    cin >> rc[i].first >> rc[i].second;
  if(n == 1){
    cout << "0" << endl;
  }else{
    solve(n, rc);
    cout << dp[0][n - 1] << endl;
  } 
}

Measured memory_bytes: 1200
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

using ll = long long;
using P = pair<int, int>;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

template<class T>
inline bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

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

    int k;
    cin >> k;
    if(~k & 1){
        cout << -1 << endl;
        return 0;
    }
    int c = 0;
    int cur = 0;
    while(c < 10000000){
        ++c;
        cur = (cur * 10 + 7) % k;
        if(cur == 0){
            cout << c << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int h,w;
vs a;

int main(){
	cin>>h>>w;
	a=vs(h);
	for(int i=0;i<h;i++) cin>>a[i];
	vi b(h);
	for(int i=0;i<h;i++) b[i]=i/2;
	do{
		int tmp=0;
		bool B=1;
		for(int i=0;i<h;i++){
			if(tmp==b[i]) tmp++;
			else if(tmp<b[i]&&b[i]<h/2) B=0;
		}
		if(!B) continue;
		vi c(h);
		vs A(h);
		for(int i=0;i<h;i++){
			if(c[b[i]]) A[h-b[i]-1]=a[i];
			else c[b[i]]=1,A[b[i]]=a[i];
		}
		c=vi(w);
		for(int i=0;i<w;i++) if(!c[i]){
			string s;
			for(int j=0;j<h;j++) s+=A[j][i];
			for(int j=i+1;j<w;j++) if(!c[j]){
				string t;
				for(int k=0;k<h;k++) t+=A[k][j];
				reverse(t.begin(),t.end());
				if(s==t){
					c[i]=1;c[j]=1;
					break;
				}
			}
			if(!c[i]&&w%2==1&&B){
				string s_=s;
				reverse(s.begin(),s.end());
				if(s==s_) c[i]=1,B=0;
			}
		}
		B=1;
		for(int i=0;i<w;i++) if(!c[i]) B=0;
		if(B){
			cout<<"YES"<<endl;
			return 0;
		}
	}while(next_permutation(b.begin(),b.end()));
	cout<<"NO"<<endl;
}

Measured memory_bytes: 256
from sys import stdin

def main():
    n = int(stdin.readline().rstrip())
    xs = [int(stdin.readline().rstrip()) for _ in range(n)]

    max_1 = max(xs)
    key_max = xs.index(max_1)

    for i in range(n):
        if key_max == i:
            print(max(xs[0:i]+xs[i+1:]))
        else:
          	print(max_1)

if __name__ == '__main__':
    main()


Measured memory_bytes: 15604
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)
N = parse(readline())
p = parseMap(split(readline()))
sort_p = sort(p)
count = 0
for i in 1:N
    if p[i] != sort_p[i]
        count += 1
    end
end      

println(count > 2 ? "NO":"YES")

Measured memory_bytes: 114564
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
)

var N, A, B, C int
var ls []int

func main() {
	N, A, B, C = ReadInt(), ReadInt(), ReadInt(), ReadInt()
	ls = ReadInts(N)
	fmt.Println(dfs(0, make([]int, N)))
}

func dfs(depth int, choices []int) int {
	if depth == N {
		var aNum, bNum, cNum int
		var aSum, bSum, cSum int
		for i := 0; i < N; i++ {
			if choices[i] == 0 {
				aNum += 1
				aSum += ls[i]
			}
			if choices[i] == 2 {
				bNum += 1
				bSum += ls[i]
			}
			if choices[i] == 3 {
				cNum += 1
				cSum += ls[i]
			}
		}
		if aNum*bNum*cNum == 0 {
			return math.MaxInt32
		}
		ans := 0
		ans += (aNum - 1) * 10
		ans += (bNum - 1) * 10
		ans += (cNum - 1) * 10
		ans += Abs(A - aSum)
		ans += Abs(B - bSum)
		ans += Abs(C - cSum)
		return ans
	}
	ans := math.MaxInt32
	for i := 0; i < 4; i++ {
		choices[depth] = i
		ans = Min(ans, dfs(depth+1, choices))
	}
	return ans
}

func Abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func Min(xs ...int) int {
	min := xs[0]
	for _, x := range xs[1:] {
		if min > x {
			min = x
		}
	}
	return min
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int) { Scan(&i); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 1844
#Collecting Balls (Easy Version)
N = int(input())
K = int(input())
x = list(map(int,input().split()))
S = 0

for i in range(N):
    if x[i] <= K - x[i]:
        S += 2*x[i]
    else:
        S += 2*(K - x[i])

print(S)

Measured memory_bytes: 2940
import heapq
n=int(raw_input())
a=map(int,raw_input().split())
su=[0]*(3*n+1)
hp1=[]
hp2=[]
for i in xrange(3*n):
    su[i+1]+=su[i]+a[i]
for i in xrange(n):
    heapq.heappush(hp1,a[i])
    heapq.heappush(hp2,-a[i+2*n])
ans=-float("inf")
ta1=0
ta2=0
p=[]
b=[]
for i in xrange(n+1):
    p.append(su[n+i]-ta1)
    b.append(su[3*n]-su[2*n-i]-ta2)
    heapq.heappush(hp1,a[i+n])
    heapq.heappush(hp2,-a[2*n-i-1])
    ta1+=heapq.heappop(hp1)
    ta2+=-heapq.heappop(hp2)
    #print hp1,hp2
#print p,b
for i in xrange(n+1):
    ans=max(ans,p[i]-b[n-i])
print ans


Measured memory_bytes: 79128
#include<cstdio>
#include<queue>
#include<map>
#include<vector>
#include<algorithm>
#include<functional>
#include<climits>
using namespace std;
struct S{int m,a,b;S(){}}s;
bool c(S l,S r){return l.a>r.a;}
vector<S>v;
bool f()
{
	typedef pair<int,int>PII;
	priority_queue<PII,vector<PII>,greater<PII> >q;
	PII p;
	int t=0;
	sort(v.begin(),v.end(),c);
	q.push(PII(INT_MAX,INT_MAX));
	while(!v.empty())
	{
		if((s=v.back()).a < (p=q.top()).first)
		{
			v.pop_back();
			if((t+=s.m)>150)return false;
			q.push(PII(s.b,s.m));
		}
		else
		{
			q.pop();
			t-=p.second;
		}
	}
	return true;
}
int main()
{
	int n;
	while(scanf("%d",&n),n)
	{
		v.clear();
		while(n--) scanf("%d%d%d",&s.m,&s.a,&s.b),v.push_back(s);
		puts(f()?"OK":"NG");
	}
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include <vector>
#include<string.h>
#include<cmath>
using namespace std;


  

const int MAX_SIZE = 1e6; 
  

bool prime[MAX_SIZE + 1]; 
  
void sieve() 
{ 
  
  
    memset(prime, true, sizeof(prime)); 
  
    for (int p = 2; p * p <= MAX_SIZE; p++) { 
  
   
        if (prime[p] == true) { 
  
       
            for (int i = p * p; i <= MAX_SIZE; i += p) 
                prime[i] = false; 
        } 
    } 
} 

int kthPrimeGreaterThanN(int n) 
{ 
  
    int res = -1;  
    for (int i = n ; i < MAX_SIZE; i++) { 
  
    
        if (prime[i] == true) {
            res = i; 
            break; 
        } 
    } 
  
    return res; 
} 
  

int main() 
{ 
    int x;
    cin>>x;
    sieve(); 
    cout << kthPrimeGreaterThanN(x); 
    return 0; 
} 

Measured memory_bytes: 1280
#include "bits/stdc++.h"

using namespace std;
typedef long long ll;
ll N;

int main(){

    ll N;
    cin >> N;

    vector<ll > v(N, 0);

    ll ans = 0;
    for(ll i = 0; i < N; i++){
        cin >> v[i];
        if(i + 1 != v[i]){
            ans++;
        }

        if(ans > 2){
            cout << "NO" << endl;
            return 0;
        }

    }

    if(ans == 0 || ans == 2){
        cout << "YES" << endl;
    }

}

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

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

const ll MOD=1000000007LL;

ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }

//xのe丈の高速計算
ll POW(ll x, ll e) {
  //最初1
  ll v=1;
  //後処理は、xの二乗を取って、e/2する。
  //for (;something;)はwhile(something)に同じ
  for(; e; x=MUL(x,x), e>>=1) {
    //もしeが奇数なら、vにxをかける。
    if (e&1) v = MUL(v,x);
  }
  return v;
}


//
inline bool bad(int a,int b,int c,int d){
    if (        b==1 && c==2 && d==3) return true;
    if (a==1         && c==2 && d==3) return true;
    if (        b==2 && c==1 && d==3) return true;
    if (        b==1 && c==3 && d==2) return true;
    if (a==1 && b==2         && d==3) return true;
    return false;
}

ll solve(int N) {
    ll dp[101][625][2];
    memset(dp, 0, sizeof(dp));
    dp[0][0][0] = 1;
    for (int i=0;i<N;i++){
        for (int a=0;a<5;a++) for (int b=0;b<5;b++) for (int c=0;c<5;c++) for (int d=0;d<5;d++) {
            int abcd = ((a*5+b)*5+c)*5+d;
            for (int e=1; e<5; ++e) {
                int bcde = ((b*5+c)*5+d)*5+e;
                bool _bad = bad(b,c,d,e);
                for (int j=0;j<2;j++){
                    (dp[i+1][bcde][j || _bad] += dp[i][abcd][j]) %= MOD;
                }
            }
        }
    }
    ll ans = 0;
    for (int i=0;i<625;i++) {
        (ans += dp[N][i][1]) %= MOD;
    }
    return SUB(POW(4,N), ans);
}

int main() {
    int N; cin >> N;
    cout << solve(N) << endl;
    return 0;
}


Measured memory_bytes: 1280
s=input()
s=list(map(int,s))
a=[0]*len(s)
b=[0]*len(s)
for i in range(0,len(s),2):
    a[i]=1
for i in range(1,len(s),2):
    b[i]=1
cnt1=0
cnt2=0

for i,j in zip(a,s):
    if i!=j:
        cnt1+=1
for i,j in zip(b,s):
    if i!=j:
        cnt2+=1 
print(min([cnt1,cnt2]))

Measured memory_bytes: 5536
"""from collections import *
from itertools import *
from bisect import *
from heapq import *

import math
from fractions import gcd
import sys
#input = sys.stdin.readline


"""
import copy
from collections import *
from heapq import *
N,K=map(int,input().split())
VVV=list(map(int,input().split()))
value=0

VV=deque(VVV)
Llst=[[]]
V=copy.copy(VV)
for i in range(min(K,N)):
    Llst.append(copy.copy(Llst[-1]))
    a=V.popleft()
    Llst[-1].append(a)

Rlst=[[]]
V=copy.copy(VV)
for i in range(min(K,N)):
    Rlst.append(copy.copy(Rlst[-1]))
    a=V.pop()
    Rlst[-1].append(a)

#print(Llst,Rlst)
for l in range(min(K,N)+1):
    for r in range(min(K,N)+1-l):
        lst=Llst[l]+Rlst[r]
        lst.sort(reverse=True)
        for i in range(K-l-r):
            if lst:
                if lst[-1]<0:
                    lst.pop()
                else:
                    break
            else:
                break
        value=max(value,sum(lst))
print(value)


Measured memory_bytes: 41324
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
typedef long long ll;
const int INF = 100000000, mod = 1000000007;
const ll LLINF = 1LL << 50;
using namespace std;

int main() {
    int q, likenum[100002] = { 0 };
    bool check[100002] = { 0 };
    for (int i = 2; i <= 100000; i++) {
        if (!check[i]) {
            for (int j = i + i; j <= 100000; j += i) check[j] = true;
        }
    }
    for (int i = 3; i <= 100000; i += 2) {
        if (!check[i] && !check[(i + 1) / 2])likenum[i]++;
    }
    for (int i = 3; i <= 100000; i++) {
        likenum[i] += likenum[i - 1];
    }
    cin >> q;
    for (int i = 0; i < q; i++) {
        int l, r;
        cin >> l >> r;
        cout << likenum[r] - likenum[l - 1] << endl;
    }
    return 0;
}


Measured memory_bytes: 1152
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a: String = read();
    let b: String = read();
    let c: String = read();

    let mut vec: [String;3] = [a, b, c];
    vec.sort();

    println!("{}", vec.join(" "));
}


Measured memory_bytes: 5028
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i< (n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;

//priority_queue<int, vector<int>, greater<int>> min_heap;
//long long ccw(const Point& A, const Point& B, const Point& C) {
//	return 1LL * (B.x - A.x)*(C.y - A.y) - 1LL * (B.y - A.y)*(C.x - A.x);
//}
double a[51];

int main() { // E 
	ios_base::sync_with_stdio(false); cin.tie(NULL); /*cout.tie(NULL);*/
	int n; cin >> n;
	rep(i, n) {
		cin >> a[i];
	}
	sort(a, a + n);
	double ans = (a[0] + a[1]) / 2;
	for (int i = 2; i < n; i++) {
		ans = (ans + a[i]) / 2;
	}
	printf("%.10f", ans);

	

}


Measured memory_bytes: 256
#include <stdio.h>



int main (void){
    int i,j;
    int a,b; 
    char n[11] = {0};
   

    scanf("%s",n);
    if(n[0] == 'Y' && n[1] == 'A' && n[2] == 'K' && n[3] == 'I'){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    
    
    return 0;
}

Measured memory_bytes: 128
# -*- coding: utf-8 -*-
from collections import Counter


if __name__ == '__main__':
    n = int(input())
    s = [input() for _ in range(n)]
    m = int(input())
    t = [input() for _ in range(m)]
    s_set = set(s)
    print(max(0, max([s.count(i) - t.count(i) for i in s_set])))


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;

const int MOD = 998244353;

// Binary Indexed Tree (Fenwick Tree)
// https://youtu.be/lyHk98daDJo?t=7960
template<typename T>
struct BIT {
    int n;
    vector<T> d;
    BIT(int n=0):n(n),d(n+1) {}
    void add(int i, T x=1) {
        for (i++; i <= n; i += i&-i) {
            d[i] += x;
            d[i] %= MOD;
        }
    }
    T sum(int i) {
        T x = 0;
        for (i++; i; i -= i&-i) {
            x += d[i];
            x %= MOD;
        }
        return x;
    }
    T sum(int l, int r) {
        return (sum(r-1) + MOD - sum(l-1)) % MOD;
    }
};

void Main(){
    int n, k; cin >> n >> k;
    vi l(k), r(k);
    rep(i, k){
        cin >> l[i] >> r[i];
    }

    BIT<int> dp(n+5);
    dp.add(1, 1);
    
    rep3(i, 2, n){
        rep(j, k){
            if(i - l[j] <= 0) continue;
            int L = max(0, i-r[j]);
            int R = i-l[j];
            int tmp = dp.sum(L, R+1);
            // cout << i << " " << j << " " << tmp << endl;
            dp.add(i, tmp);
        }
    }
    cout << dp.sum(n, n+1) << endl;
    return;
}

int main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

Measured memory_bytes: 3976
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
#include <numeric>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
//#define MOD 998244353
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
typedef vector<tint> vtint;
typedef vector<vint> vvint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=200050;
//↑templete
signed main(){

    int N;
    cin>>N;
    
    ll cnt[SIZE]={};
    vint A;
    for(int i=0;i<N;i++){
        int a;
        cin>>a;
        A.pb(a);
        cnt[a]++;
    }

    ll sum=0;
    for(int i=0;i<SIZE;i++)
        sum+=cnt[i]*(cnt[i]-1)/2;

    for(int a:A){
        ll temp=sum;
        temp-=cnt[a]*(cnt[a]-1)/2;
        temp+=(cnt[a]-1)*(cnt[a]-2)/2;
        cout<<temp<<endl;
    }

    return 0;
}


Measured memory_bytes: 5108
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n,i,l,r,a,b, sum =0;
	cin >> n ;
	for (int i=1;i<=n;i ++){
		cin >> a >> b;
		sum = sum +b-a+1;
		
	}
	cout << sum << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  int a=0,c=0,i=0;
  do{
  scanf("%d",&a);
  }while(a<0||a>999);
  
  c=a%10;
  if(c==2||c==4||c==5||c==7||c==9){
    printf("hon\n");}
  else if(c==0||c==1||c==6||c==8){
    printf("pon\n");}
  else if(c==3){
    printf("bon\n");}
  return 0;}
  

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



int main(){
    bool v[200100] ;
    int n,z ;
    cin >> n ;
    for(int i=0 ; i<n ; i++){
        cin >> v[i] ;
    }
    for(int i=n-1 ; i>0 ; i--){
        if(v[i] == 1){
         // here
         z = i +1 ;
             for (int j=1; j<=sqrt(z); j++)
                {
                    if (z%j == 0)
                    {
                        // If divisors are equal, print only one
                        if (z/j == j)
                            //printf("%d ", i);
                            v[j-1] = -1*(v[j-1]) +1 ;

                        else {
                             v[j-1] = -1*(v[j-1]) +1 ;
                             v[(z/j)-1] = -1*(v[(z/j)-1]) +1 ;
                        }// Otherwise print both
                            //printf("%d %d ", i, n/i);
                    }
                }

          // end
          v[i] = 1 ;
        }



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

    return 0 ;
}


Measured memory_bytes: 1280
-- C - City Savers

main = do
  n_str <- getLine
  let n = read n_str :: Int
  town_str <- getLine
  let town = take (n + 1) (map read (words town_str) :: [Int])
  savers_str <- getLine
  let savers = take n (map read (words savers_str) :: [Int])
  let ans = solve town savers 0 0
  putStrLn(show ans)

solve :: [Int] -> [Int] -> Int -> Int -> Int
solve (t0:ts) (s0:ss) sc count =
  if rest_t < s0
  then
    solve ts ss (s0 - rest_t) (t0 + count)
  else
    solve ts ss 0 (s0 + sc + count)
  where
    rest_t = max (t0 - sc) 0

solve (t0:_) [] sc count =
  if t0 < sc
  then
    count + t0
  else
    count + sc
  



Measured memory_bytes: 91644
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int a[100005];
int main()
{
	ios::sync_with_stdio(0);
	int n,m,sum=0;
	cin>>n>>m;
	for(int i=1;i<=n;i++) cin>>a[i];
	sort(a+1,a+1+n);
	for(int i=1;i<=m;i++) sum+=a[i];
	cout<<sum;
}

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

using ll = long long;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int n;
	cin >> n;
	int l = n%10;
	if (l == 3) return cout << "bon", 0;
	if (l == 0 || l == 1 || l == 6 || l == 8) return cout << "pon", 0;
	cout << "hon";
	return 0;
}


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

unsigned long max(unsigned long x, unsigned long y) {
    if(x > y) return x;
    return y;
}
unsigned long min(unsigned long x, unsigned long y) {
    if(x < y) return x;
    return y;
}


unsigned long pau(unsigned long a, unsigned long b) {
    int i;
    unsigned long ans = 1;
    for(i=0; i<b; i++) {
        ans *= a;
    }
    return ans;
}

void hoge(unsigned long a, unsigned long b) {
    unsigned long *A = (unsigned long*)malloc((a+1) * sizeof(unsigned long));
    unsigned long *B = (unsigned long*)malloc((a+1) * sizeof(unsigned long));
    unsigned long *C = (unsigned long*)malloc((a+1) * sizeof(unsigned long));
    unsigned long i;
    for(i=0; i<a+1; i++) {
        A[i] = 0;
        B[i] = 0;
    }
    unsigned long x = a;
    unsigned long y = b;
    i = 2;
    while(x != 1 && x >= i) {
        if(x % i == 0) {
            A[i]++;
            x = x / i;
        }
        else {
            i++;
        }
    }
    i = 2;
    while(y != 1 && y >= i) {
        if(y % i == 0) {
            B[i]++;
            y = y / i;
        }
        else {
            i++;
        }
    }
    unsigned long ans = 1;
    for(i=2; i<=a; i++) {
        C[i] = max(A[i], B[i]);
        // printf("%lu = %lu\n", i, C[i]);
        if(C[i] != 0) {
            ans *= pau(i, C[i]);
        }
    }
    printf("%lu\n", ans);
    free(A);
    free(B);
    free(C);
}

int main() {
    unsigned long A, B;
    scanf("%lu %lu", &A, &B);
    // printf("%lu\n", lcm(A, B));
    hoge(max(A, B), min(A, B));
    return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define pb push_back
#define S second
#define F first

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
int seq[1000];
int main(){

    int n;
    cin >> n;
    for (int i = 0;i < n;i++){
        cin >> seq[i];
    }
    sort(seq,seq + n);
    int sum = 0;
    for (int i = 1;i< n;i++){
        sum += (seq[i] - seq[i - 1]);
    }
    cout << sum << endl;
    return 0;
}


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

#define LL long long

#define FOR(INDEX, START, END) for (LL INDEX = (START); INDEX < (END); ++INDEX)
#define REP(INDEX, COUNT) for (LL INDEX = 0; INDEX < (COUNT); ++INDEX)

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

	double total = 0;
	REP(i, N) {
		double s1;
		string s2;
		cin >> s1 >> s2;

		if (s2 == "JPY") {
			total += s1;
		}
		else {
			total += s1 * 380000.0;
		}
	}

	cout << total << endl;

	return 0;
}


Measured memory_bytes: 256
/* Dsingh_24 */

#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define ios	    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

#define N  100005

int main()
{
	ios
	ll n,k,i,j;
	cin>>n>>k;
	ll a[n+1];
	for(i=0;i<n;i++)
		cin>>a[i];
	ll win[k+1]={0};
	for(i=1;i<=k;i++){
		for(j=0;j<n;j++){
			if(i>=a[j]&&win[i-a[j]]==0)
				win[i]=1;
		}
	}
	if(win[k]==1)cout<<"First";else cout<<"Second";
	return 0;
}

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

int main() {
  int x, a, b;
  cin >> x >> a >> b;

  if(max(a, x)-min(a, x)>max(b, x)-min(b, x)){
    cout << 'B' << endl;
  }
  else{
    cout << 'A' << endl;
  }

return 0;  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

#define ll long long
//#define bint int1024_t
#define ld long double
#define vect vector<ll>
#define unmap unordered_map
#define pb push_back
#define pi 3.1415926536
#define mod int(1e9+7)
#define mp make_pair
//ios_base::sync_with_stdio(false);cin.tie(NULL);
#define testcases ll t; cin>>t; while(t--)

using namespace std;
//using namespace boost::multiprecision;
//using namespace __gnu_pbds;

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

    // int k=0;
    // testcases
    // {
        

    //     cout<<"Case #"<<++k<<": "<<ans<<"\n";
    // }

    ll n,m,s=0;
    cin>>m>>n;
    vect v(n);
    for(ll& i:v) cin>>i,s+=i;

    cout<<(s>m?-1:m-s);


    return 0;
}

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

long long x, y, z, k, a[1009], b[1009], c[1009];
vector<long long>vec;

int main()
{
    cin >> x >> y >> z >> k;
    for(int i = 0; i < x; ++i) { cin >> a[i]; }
    sort(a, a+x, greater<long long>());
    for(int i = 0; i < y; ++i) { cin >> b[i]; }
    sort(b, b+y, greater<long long>());
    for(int i = 0; i < z; ++i) { cin >> c[i]; }
    sort(c, c+z, greater<long long>());

    for(int l = 0; l < x; ++l) {
        for(int m = 0; m < y; ++m) {
            for(int n = 0; n < z; ++n) {
                if((l+1)*(m+1)*(n+1) <= k) {
                    vec.push_back(a[l] + b[m] + c[n]);
                }
                else { break; }
            }
        }
    }

    sort(vec.begin(), vec.end(), greater<long long>());
    for(int i = 0; i < k; ++i) { cout << vec[i] << endl; }
    return 0;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(a,b) for(int a=0;a<(b);++a)
#define REP1(i,n) for(int i=1;i<=(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define INF (1<<29)
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define X first
#define Y second
#define pie 3.14159265358979323846
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;


template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}

const int MOD =(int)1e9+7;
const int mod =(int)1e9+7;
const int MAX =510000;
ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
ll COM(int n,int k){
    if(n<k) return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
ll gcd(ll a,ll b){
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
    ll g;g=gcd(a,b);
    return a*b/g;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

bool compare_by_a(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
    }else{
        return a.second < b.second;
    }
}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

ll RS(ll N,ll P,ll M){
    if(P==0){
        return 1;
    }else{
        if(P%2==0){
            ll t=RS(N,P/2,M);
            return t*t%M;
        }else{
            return N*RS(N,P-1,M)%M;
        }
    }
}
bool greater_pair(pair<ll,ll> a,pair<ll,ll> b){
    if(a.first!=b.first){
        return a.first>b.first;
    }else{
        return a.second>b.second;
    }
}
int main() {
    ios::sync_with_stdio(false);
    int A=in();
    int B=in();
    isYes(A*B%2==1);
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();
		int max = 0, sum = 0;
		for(int i = 0; i < num; i++){
			int len = sc.nextInt();
			if(len > max){
				sum += max;
				max = len;
			}else sum += len;
		}

		String ans = max < sum ? "Yes" : "No";
		System.out.println(ans);
	}
}




Measured memory_bytes: 23764
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cctype>
#include<vector>
#define rep(i,x,y) for(int i=x; i<=y; ++i)
#define repd(i,x,y) for(int i=x; i>=y; --i)
#define mid (l+r>>1)
#define lch (rt<<1)
#define rch (rt<<1|1)
#define pb push_back

using namespace std;
const int N=200005;
typedef long long LL;
int n;
LL a[N],f[N],g[N],D,ans;

int getint()
{
	char ch;
	while(!isdigit(ch=getchar()));
	int x=ch-48;
	while(isdigit(ch=getchar())) x=x*10+ch-48;
	return x;
}

signed main()
{
	n=getint(),D=getint();
	rep(i,1,n) a[i]=getint(),ans+=a[i];
	ans+=D*(n-1);
	f[1]=a[1];
	rep(i,2,n) f[i]=min(a[i],f[i-1]+D);
	g[n]=a[n];
	repd(i,n-1,1) g[i]=min(a[i],g[i+1]+D);
	rep(i,2,n-1) ans+=min(f[i],g[i]);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 4864
import qualified Data.IntMap as M

solve s t =
   if all (==True) $ M.elems xx then l else -1
  where
    n = length s
    m = length t
    l = lcm n m
    ss = M.fromList $ zip (ids n) s
    tt = M.fromList $ zip (ids m) t
    ids k = 1 : [ l `div` k * i  + 1 | i <- [1..] ]
    xx = M.intersectionWith (==) ss tt

main :: IO ()
main = do
    _ <- getLine
    [s,t] <- lines <$> getContents
    print $ solve s t

Measured memory_bytes: 29052
#include <iostream>

using namespace std;

int p[50];

int main(){
    int N;
    cin >> N;
    for(int i=0;i<N;i++){
        cin >> p[i];
    }
    int count = 0;
    for(int i=0;i<N;i++){
        if(p[i] != i+1) count++;
    }
    if(count < 3) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include <bits/stdc++.h>
#include <stdio.h>
#include <numeric>
#include<math.h>
#include <ctype.h>
#include <algorithm> // sort
#include <map> // pair
using namespace std;
int main() {
  int n;cin >> n;
  vector<int> vec(n-1);
  for(int i=0;i<n-1;i++){
    cin >> vec.at(i);
  }
 long long int sum=0;
  if(n==2){
    sum=2*vec.at(0);
  }
  else{
    sum=sum+vec.at(0)+vec.at(n-2);
      for(int i=0;i<n-2;i++){
      sum+=min(vec.at(i),vec.at(i+1));
      }
  }
  cout << sum << endl;
}

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

string to_string(string s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef LOCAL
#define db(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define db(...) 42
#endif

using ll = long long;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  ll ai = 0;
  for (int i = 0; i < 1000000; i++) {
    ai = (ai + a) % b;
    if (ai == c) {
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>//Carefully Crafted by hetp111
using namespace std;
#define int long long
#define double long double
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vii vector<pii>
#define MOD 1000000007
#define MOD2 998244353
#define MOD3 1000000009
#define PI acos(-1)
#define eps (1e-8)
#define INF (1e18)
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0)
template<class A,class B>ostream&operator<<(ostream&out,const pair<A,B>&a){return out<<"("<<a.first<<","<<a.second<<")";}
template<class A>ostream&operator<<(ostream&out,const vector<A>&a){for(const A &it:a)out<<it<<" ";return out;}
template<class A,class B>istream&operator>>(istream&in,pair<A,B>&a){return in>>a.first>>a.second;}
template<class A>istream&operator>>(istream&in,vector<A>&a){for(A &i:a)in>>i;return in;}
//ifstream cinn("in.in");ofstream coutt("out.out");
int poww(const int &a,int b,const int &m=MOD){if(b==0)return 1;int x=poww(a,b/2,m);x=x*x%m;if(b&1)x=x*a%m;return x;}
int ceil(const int &a,const int &b){return (a+b-1)/b;}
////Read:
//Check corner cases, n==1;
//
////Some function:
//__builtin_popcountll(), is_sorted(),

vi tree[4*500005];
int n,q;
int v[500005],b[500005],lst[500005];

void build(int s,int e,int idx,int S,int E){
    if(e<S || s>E)return;
    if(s==e){
        tree[idx].push_back(b[s]);
        return;
    }
    int mid=(s+e)/2;
    build(s,mid,idx*2+1,S,E);
    build(mid+1,e,idx*2+2,S,E);
    
    int i=0,j=0;
    const vi &a=tree[2*idx+1];
    const vi &b=tree[2*idx+2];
    vi &c=tree[idx];
    while(i<a.size() && j<b.size()){
        if(a[i]<b[j])c.push_back(a[i++]);
        else c.push_back(b[j++]);
    }
    while(i<a.size())c.push_back(a[i++]);
    while(j<b.size())c.push_back(b[j++]);
}

int get(int s,int e,int idx,int S,int E){
    if(e<S || s>E)return 0;
    if(s>=S && e<=E)return tree[idx].end()-upper_bound(all(tree[idx]),E);
    int mid=(s+e)/2;
    return get(s,mid,idx*2+1,S,E)+get(mid+1,e,idx*2+2,S,E);
}

signed main(){
    FASTER;
    cin>>n>>q;
    for(int i=0;i<n;i++){
        cin>>v[i];
        v[i]--;
        lst[i]=INF;
    }
    for(int i=n-1;i>=0;i--){
        b[i]=lst[v[i]];
        lst[v[i]]=i;
    }
    build(0,n-1,0,0,n-1);
    while(q--){
        int l,r;cin>>l>>r;
        cout<<get(0,n-1,0,l-1,r-1)<<"\n";
    }
}

Measured memory_bytes: 164656
fun main(args: Array<String>) {
    val (n, r) = readIntList()

    println(if (n <= 10) r + 100 * (10 - n) else r)
}

// Tools
fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)

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

#define pb push_back
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define REP(i,n) for(int _n=n, i=0;i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)
#define FORD(i,a,b) for(int i=(a),_b=(b);i>=_b;--i)
#define trav(a, x) for (auto& a : x)
using ull = uint64_t;
using ll = int64_t;
using PII = pair<int, int>;
using VI = vector<int>;
#define INF (1ll<<60)

string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string) s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B> string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename A> string to_string(A v) {
bool first = true; string res = "{";
for (const auto &x : v) { if (!first) { res += ", "; } first = false; res += to_string(x); }
res += "}"; return res; }
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H); debug_out(T...); }
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    ull K;
    cin >> K;
    if (K < 1000000000000000) {
        cout << 2 << "\n";
        if (K % 2ULL == 0ULL) {
            cout << K / 2ULL << " " << K / 2ULL + 1ULL << endl;
        } else {
            cout << (K - 1ULL) / 2ULL << " " << (K - 1ULL) / 2ULL + 2ULL << endl;
        }
    } else {
        vector<ull> V;
        REP(i, 50) V.pb((ull) i);
        ull m = K % 50ULL;
        REP(i, m) {
            ull mn = 1000;
            REP(j, 50) {
                if (V[j] < mn) mn = V[i];
            }
            REP(j, 50) {
                if (V[j] == mn) {
                    V[j] += 50ULL;
                } else {
                    V[j]--;
                }
            }
        }
        ull k = K / 50;
        REP(i, 50) {
            V[i] += k;
        }
        // ull sum = 0;
        // REP(i, 50) {
        //     sum += V[i];
        // }
        // ull s = 0;
        // REP(i, 50) s += i;
        // cout << sum << endl;
        // cout << s + K << endl;

        cout << "50\n";
        REP(i, 50) {
            cout << V[i] << " ";
        }
        cout << endl;
    }
}

Measured memory_bytes: 256
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()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main(){
    let p = read_vec::<i64>();
    let (x1,y1,x2,y2) = (p[0],p[1],p[2],p[3]);
    let xd = x2 -x1;
    let yd = y2-y1;
    let ax = xd.abs();
    let ay = yd.abs();
    let mut x3 = 0;
    let mut x4 = 0;
    let mut y3 = 0;
    let mut y4 = 0;
    if xd >= 0 && yd >= 0{
         x3 = x2 - ay;
         y3 = y2 + ax;
         x4 = x1 - ay;
         y4 = y1 + ax; 
    } else if xd <= 0 && yd >= 0 {
        x3 =x2 - ay;
        y3 = y2 - ax;
        x4 = x1 - ay;
        y4 = y1 -ax;
    } else if  xd >= 0 && yd <= 0 {
        x3 =x2 + ay;
        y3 = y2 + ax;
        x4 = x1  + ay;
        y4 = y1  +ax;
    } else if xd <= 0 && yd <= 0{
      x3 =x2 + ay;
        y3 = y2 - ax;
        x4 = x1  + ay;
        y4 = y1 -ax;
    }
    println!("{} {} {} {}",x3,y3,x4,y4 );
}

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

int main() {
  int s[10], i, result;
  for (i = 0; i < 10; i++) {
    cin >> s[i];
  }
  result = 0;
  for (i = 0; i < 10; i++) {
    result += s[i];
  }
  cout << result << endl;
  return 0;
}



Measured memory_bytes: 3084
import java.util.*; 
public class Main {

  public static void main(String[] args) {
  
  Scanner sc=new Scanner(System.in);
  int a[]=new int[3];
  a[0]=sc.nextInt();
  a[1]=sc.nextInt();
  a[2]=sc.nextInt();
  Arrays.sort(a);

  System.out.println(a[2]*10+a[0]+a[1]);
  }
  
}

Measured memory_bytes: 22996
#include <cmath>
#include<iostream>
#include <functional>
#include <string>
#include <sstream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <iomanip>
using namespace std;
 
int main(){    
  string S;
  cin >> S;
 
    if(S == "SUN"){
       cout << "7" << endl;
    }
    if(S == "MON"){
     cout << "6" << endl;
    }
    if(S == "TUE"){
     cout << "5" << endl;
    }
    if(S =="WED"){
     cout << "4" << endl;
    }
  if(S == "THU"){
     cout << "3" << endl;
  }
    if(S == "FRI"){
     cout << "2" << endl;
    }
    if(S == "SAT"){
     cout << "1" << endl;
    }
}

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


using namespace std;



int main() {
	int k, x;
	cin >> k >> x;
	cout << (k * 500 >= x ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256