akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define int long long
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define repa(i, s, n) for(int i = s; i < (int)n; i++)
#define MOD 1000000007
using namespace std;
using ll = long long;
typedef vector<int> vi;

signed main() {
    int n;
    cin >> n;
    vi a(n);
    rep(i, n) cin >> a[i];

    sort(a.begin(), a.end(), greater<int>());

    int ans = 0;
    ans += a[0];
    // cout << "+ " << a[0] << " ";
    int pr = 1;
    rep(i, (n-1)/2){
        
        ans += a[pr];
        // cout << "+ " << a[pr] << " ";
        ans += a[pr];
        // cout << "+ " << a[pr] << " ";
        pr++;
    }
    if(n % 2){
        --pr;
        ans -= a[pr];
        // cout << "- " << a[pr] << endl;
    }

    cout << ans << endl;
}

Measured memory_bytes: 4836
#include <bits/stdc++.h>
using namespace std;
#define ll                  long long
#define ld                  long double
#define pb                  push_back
#define mkp                 make_pair
#define f(i,l,h)            for(ll i=l;i<h;i++)
#define fr(i,h,l)           for(ll i=h;i>=l;i--)
#define mem(a,val)          memset(a,val,sizeof(a))
#define all(v)              (v).begin(),(v).end()
#define ff                  first
#define ss                  second
#define spc(x)              cout<<fixed<<setprecision((x));
#define deb(x)              cout<<#x<<" "<<x<<endl;
#define deba(x)             cout<<#x<<": "; for(auto u:x) cout<<u<<" ";  cout<<endl;
#define check               cout<<"hello"<<endl;
#define fastio              ios_base::sync_with_stdio(false);cin.tie(NULL)
const ld pi=3.141592653589793;
const ll mod=998244353;
const ll INF=(ll)(1e9+7);
typedef pair<ll,ll> pll;
typedef vector<ll> vll;

ll power(ll a,ll b){
    ll res=1;
	while(b){
	    if(b&1) res=(res*a);
	    a=(a*a);
	    b>>=1;
	}
	return res;
}

int main()
{
    //cout << "Hello world!" << endl;
    ll n,k;
    cin>>n>>k;
    ll h[n+1];
    f(i,1,n+1) cin>>h[i];
    ll dp[n+1];
    dp[0]=0;
    dp[1]=0;
    f(i,2,n+1){
        dp[i]=LLONG_MAX;
        fr(j,i-1,i-k){
            if(j<1) break;
            dp[i]=min(dp[i],dp[j]+ abs(h[i]-h[j]));
        }
    }
    cout<<dp[n]<<endl;

    return 0;
}


Measured memory_bytes: 5168
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define endl "\n"
#define sz(x) (int)(x).size()
#define _USE_MATH_DEFINES
using namespace std;
typedef long long int lli;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    int n; 
    cin >> n;
    string s = "";
    while (n != 0) {
        int r = n % 2;
        if (r < 0)
            r += 2;
        n = (n - r) / (-2);
        s += (char)('0' + r); 
    }
    reverse(all(s));
    if (s == "")
        s = "0";
    cout << s << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

typedef pair<int, int> ii;
typedef pair<ll, ll> pll;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	string n;
	cin >> n;
	int sum = 0;
	for (auto l : n) {
		sum += l - '0';
	}
	if (sum % 9 == 0)
		cout << "Yes\n";
	else
		cout << "No\n";

	return 0;
}


Measured memory_bytes: 3740
package main

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

//Util
func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func maxInt(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func minInt(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}

func absInt(a int) int {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func absFloat64(a float64) float64 {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func maxFloat64(a, b float64) float64 {
	if a > b {
		return a
	} else {
		return b
	}
}

func minFloat64(a, b float64) float64 {
	if a > b {
		return b
	} else {
		return a
	}
}

func str2Int(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func isPrime(x int) bool {
	if x == 1 {
		return false
	}
	if x == 2 {
		return true
	}
	if x%2 == 0 {
		return false
	}

	b := true
	rootx := int(math.Sqrt(float64(x)))
	i := 3
	for i <= rootx {
		if x%i == 0 {
			b = false
			break
		}
		i += 2
	}
	return b
}

func PrimeFactors(n int) (pfs []int) {
	// Get the number of 2s that divide n
	for n%2 == 0 {
		pfs = append(pfs, 2)
		n = n / 2
	}

	// n must be odd at this point. so we can skip one element
	// (note i = i + 2)
	for i := 3; i*i <= n; i = i + 2 {
		// while i divides n, append i and divide n
		for n%i == 0 {
			pfs = append(pfs, i)
			n = n / i
		}
	}

	// This condition is to handle the case when n is a prime number
	// greater than 2
	if n > 2 {
		pfs = append(pfs, n)
	}

	return
}

//Main
const (
	initialBufSize = 10000
	maxBufSize     = 1000000
	mod            = 1e9 + 7
)

var (
	sc *bufio.Scanner = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, initialBufSize)
		sc.Buffer(buf, maxBufSize)
		return sc
	}()
)

var N int

func solution(j, k, i, N int) int {
	if i == N-1 {
		return j + k
	}
	return solution(k, j+k, i+1, N)
}

func main() {
	sc.Split(bufio.ScanWords)

	N = nextInt() - 1
	if N == 0 {
		fmt.Println(1)
		return
	}
	fmt.Println(solution(2, 1, 0, N))

}


Measured memory_bytes: 640
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi acos(-1.0)

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

const int MAX_N = 100010;
const ll mod = 1000000007;
ll fact[MAX_N] = {};
ll rfact[MAX_N] = {};


ll quick_power(ll x, ll p){
    if(p == 0) return 1;
    if(p % 2 == 0){
        ll buf = quick_power(x, p / 2);
        return buf * buf % mod;
    }else{
        return x * quick_power(x, p - 1) % mod;
    }
}

ll factrial(ll x){
    if(x == 0) return 1;
    if(fact[x] != 0) return fact[x];
    else return fact[x] = x * factrial(x - 1) % mod;
}

ll rfactrial(ll x){
    if(rfact[x] != 0) return rfact[x];
    return rfact[x] = quick_power(factrial(x), mod - 2);
}

ll combi(ll n, ll k){
    // n >= 0，k >= 0，n - k >= 0を保証する必要がある．
    // 逆に，上記を満たさない場合の処理をifで定める．
    if(n < k) return 0;
    if(k == 0) return 1;
    return (factrial(n) * rfactrial(n - k) % mod) * rfactrial(k) % mod;
}


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, l1, l2;
    int hash[MAX_N] = {};
    fill(hash, hash + MAX_N, -1);
    cin >> n;
    REP(i, n + 1){
        int a;
        cin >> a;
        if(hash[a] != -1){
            l1 = hash[a];
            l2 = i;
        }
        hash[a] = i;
    }

    FOR(k, 1, n + 1){
        ll ans = combi(n + 1, k) - combi(n + l1 - l2, k - 1) + mod;
        cout << ans % mod << "\n";
    }

    return 0;
}


Measured memory_bytes: 4736
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.*;

public class Main {
    // static int INF = (1 << 30) - 1;
    // static long L_INF = (1L << 62) - 1;
    // static long MOD = (long) 1e9 + 7;

    static class Solver {
        int N;
        // int[] A;

        // write your code
        void solve(InputReader in, PrintWriter out) {
            N = in.nextInt();
            int ans = 0;
            for (int i = 1; i <= N; i += 2) {
                int cnt = 0;
                for (int j = 1; j <= i; j++) {
                    if (i % j == 0) {
                        cnt++;
                    }
                }
                if (cnt == 8) {
                    ans++;
                }
            }
            out.println(ans);
        }

        void debug(Object... os) {
            System.err.println(Arrays.deepToString(os));
        }
    }

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

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }
    }
}


Measured memory_bytes: 21972
#include<bits/stdc++.h>
using namespace std;
int n;
int a[30];
int main() {
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  int max=-1,sum=0;
  for(int i=0;i<n;i++){
  	if(a[i]>=max) {
      sum++;
      max=a[i];
    }
  }
  cout<<sum<<endl;
  return 0;
}

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

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

int main() {
	// your code goes here
	int k;
	cin>>k; 
    set<int> st;
    int i=10%k;
    int j=7%k;
    int s=7%k;
    st.insert(j);//cout<<i<<" "<<s<<endl;
    if(k==1 || k==7) cout<<1<<endl;
    else{
    int d=1;
    while(1)
    {
    	 s=((i*s)%k+j)%k;
    	//cout<<s<<endl;
    	if(st.find(s)!=st.end())
    	{
    		cout<<-1<<endl;
    		break;
    	}
    	st.insert(s);
    	if(s==0)
    	{
    		cout<<d+1<<endl;
    		break;
    	}
    	d++;
    }
    }
	return 0;
}

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

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

	string S, T; cin >> S >> T;
	vector<int8_t> X(S.size()+1);
	vector<int8_t> Y(T.size()+1);
	for (int i = 0; i < int(S.size()); i++) X[i+1] = (X[i] + (S[i] == 'A' ? 1 : 2)) % 3;
	for (int i = 0; i < int(T.size()); i++) Y[i+1] = (Y[i] + (T[i] == 'A' ? 1 : 2)) % 3;

	int Q; cin >> Q;
	while (Q--) {
		int s1, s2, t1, t2; cin >> s1 >> s2 >> t1 >> t2; s1--, t1--;
		cout << ((X[s2] - X[s1] - Y[t2] + Y[t1]) % 3 == 0 ? "YES" : "NO") << '\n';
	}

	return 0;
}


Measured memory_bytes: 976
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
#define rall(a) (a).rbegin(),(a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

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

    int ans = 1;

    rep(i,n){
        ans += min(ans,k);
    }

    cout << ans << endl;

}

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

int main() {
  int N;
  cin >> N;
  int a[N];
  char c;
  cin >> c;
  if(c=='.')a[0]=1;
  else a[0]=0;
  for(int i=1;i<N;i++){
    cin >> c;
    if(c=='.')a[i]=a[i-1]+1;
    else a[i]=a[i-1];
  }
  int mini=a[N-1];
  for(int i=0;i<N;i++){
    int x=i+1-a[i]+a[N-1]-a[i];
    mini=min(x,mini);
  }
  cout << mini;
}






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

int main(){
  int N;
  long long temp=0;
  long long a[200100];
  cin>>N;
  for(int i=0;i<N;i++){
    cin>>a[i];
  }
  temp=a[0];
  long long ans=0;
  for(int i=1;i<N;i++){
    if(a[i]<temp){
      ans+=temp-a[i];
    }
    else{
      temp=max(temp,a[i]);
    }
  }
  cout<<ans<<endl;
  return 0;
}

 

Measured memory_bytes: 5112
/*
 * Author: .-O_O-.
 */
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include<bits/stdc++.h>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define rep0(a,b) for(int a=0;a<b;a++)
#define rep1(a,b) for(int a=1;a<=b;a++)
#define repp(a,b,c) for(int a=b;a<c;a++)
#define in insert
#define len length()
#define si size()
#define lb lower_bound
#define ub upper_bound
#define beg begin()
#define en end()
#define f first
#define s second
#define pr(a) cout<<a
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define nx cout<<"\n"
#define int long long
// void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
                                                     
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]"<<endl;}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif
const ll mod = 1000000007;
const ll N = 105;
const ll mm = 1e+18;
void solve()
{
    int a,b;
    cin>>a>>b;
    cout<<(a+b)%24;
}
signed main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
    //cin>>t;
    rep1(_i,t){
        //cout<<"Case #"<<_i<<": ";
        solve();
        //nx;
    }
    return 0;
}

Measured memory_bytes: 3612
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	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;
	}
}

// 二項係数計算
long long 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;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
int main() {
	int n;
	string s;
	cin >> n;
	cin >> s;
	string str = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	string ans = "";
	for (int i = 0; i < s.size(); i++) {
		char k = s[i];
		for (int j = 0; j < 26; j++) {
			if (k == str[j]) {
				int  sum = n + j;
				if (sum >= 26) {
					sum = sum - 26;
					ans = ans + str[sum];
				}
				else {
					ans = ans + str[sum];
				}
				break;
			}
		}
	}
	cout << ans;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void) {
	int n, k,c = 0;
	int h[100000];
	scanf("%d %d", &n, &k);
	for (int i = 0; i < n; i++) {
		scanf("%d", &h[i]);
		if (h[i] >= k) {
			c++;
		}
	}
	printf("%d", c);
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)

lli gcd(lli x, lli y){
	if (y == 0) {
		return x;
	} else {
		return gcd(y, x % y);
	}
}

lli lcm(lli x,lli y){
	return ((x/gcd(x,y))*y);
}

/*aまでの数でcで割り切れない数*/
lli func(lli a,lli c){
	return a-a/c;
}

/*a以上bまでの数でcで割り切れない数*/
lli calc(lli a,lli b,lli c){
	return func(b,c)-func(a-1,c);
}

signed main(){
 
 	lli a,b,c,d;
 	cin>>a>>b>>c>>d;

 	lli e=lcm(max(c,d),min(c,d));

 	cout<<calc(a,b,c)+calc(a,b,d)-calc(a,b,e)<<endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
  int a[50], i, j, s;
  double w, h, bmi;

  for (j = 0; j < 50; j++)
      a[j] = 0;
  i = 0;

  while (scanf("%d,%lf,%lf", &s, &w, &h) != EOF) {

    bmi = w / (h * h);
    if (bmi >= 25.0) {
      a[i] = s;
      i++;
    }
  }
  for (j = 0; j < i; j++)
    printf("%d\n", a[j]);

  return 0;
}

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

int main(){
    int R, C;
    while(1){
        cin >> R >> C;
        if(R == 0 && C == 0) break;

        vector<vector<bool>> senbei(R, vector<bool>(C));
        for(int i = 0, x; i < R; ++i){
            for(int j = 0; j < C; ++j){
                cin >> x;
                senbei[i][j] = x&1 ? true : false;
            }
        }

        int ans = 0;
        int m;
        for(int b = 0; b < 1<<R; ++b){ 
            vector<vector<bool>> senbei_tmp = senbei;
            for(int i = 0; i < R; ++i){
                if(b & (1<<i)){
                    for(auto&& s : senbei_tmp[i]) s = !s;
                }
            }

            m = 0;
            for(int i = 0; i < C; ++i){
                int sum = 0;
                for(int j = 0; j < R; ++j) if(senbei_tmp[j][i]) ++sum;
                m += max(sum, R-sum);
            }

            ans = max(ans, m);
        }

        cout << ans << endl;
    }
}


Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define lint long long
#define ll long long
#define pq priority_queue
#define mp make_pair
#define pb push_back
#define vl vector<long long>
#define pii pair<long long,long long>
#define all(x) (x).begin(),(x).end()
#define rep(x) for(int i = 0;i < (x);i++)
#define repj(x) for(int j = 0;j < (x);j++)
#define REP(i,x) for(int (i) = 0;(i) < (x);(i)++)
#define rrep(x) for(int i = (x);i >= 0;i--)
#define mod 1000000007
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
int qp(int a, ll b) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; }
int qp(int a, ll b, int mo) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a%mo; a = 1ll * a*a%mo; } while (b >>= 1); return ans; }
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };
long long INF = 1e10;
const int MAX_N = 200001;

int main() {
	int n; cin >> n;
	string s; cin >> s;
	vector<int> r(n), l(n);
	if (s[0] == 'E')r[0] = 1; else r[0] = 0;
	if (s[n - 1] == 'W')l[0] = 1; else l[0] = 0;
	for (int i = 1; i < n; i++) {
		if (s[i] == 'E')r[i] = r[i - 1] + 1; else r[i] = r[i - 1];
		if (s[n - 1 - i] == 'W')l[i] = l[i - 1] + 1; else l[i] = l[i - 1];
	}
	int ans = max(r[n - 2], l[n - 2]);
	for (int i = 1; i < n - 1; i++) {
		ans = max(ans, r[i - 1] + l[n - 2 - i]);
	}
	cout << n - 1 - ans << endl;
}

Measured memory_bytes: 3076
import std.stdio;
import std.array;
import std.conv;
void main() {
  string[] input=split(readln());
  int N=to!int(input[0]);
  int A=to!int(input[1]);
  int B=to!int(input[2]);
  int ans=0;
  for(int i=1;i<=N;i++) {
    int sum=0;
    int j=i;
    while(j>0) sum+=j%10,j/=10;
    if(A<=sum&&sum<=B) ans+=i;
  }
  writeln(ans);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0; i < (ll)(n); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1LL << 60;
int main(){
    ll n; cin >> n;
    ll rn = sqrt(n)+2;
    ll ab = INF;
    for(ll i=1; i<=rn; i++){
        if(n%i!=0) continue;
        ll now = i+n/i;
        if(now<ab) ab=now;
    }
    cout << ab - 2 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>


using namespace std;
string yn(bool a)
{
  if (a){return "Yes";}
  else{return "No";}
}

int main()
{
  ios::sync_with_stdio(false);
  string s;
  int x,y;
  cin>>s>>x>>y;
  vector<int> a,b;
  bool f=1;
  int tmp=0;
  int suma=0,sumb=0;
  for(auto itr=s.begin();itr !=s.end();itr++)
  {
    if(*itr=='F'){tmp++;}
    else {
      if(f){a.push_back(tmp);suma+=tmp;}
      else{b.push_back(tmp);sumb+=tmp;}
      f=!f;
    tmp=0;
  }

  }
  if(f){a.push_back(tmp);suma+=tmp;}
  else{b.push_back(tmp);sumb+=tmp;}
  x-=a[0];
  suma-=a[0];
  x=abs(x);
  y=abs(y);
  a.erase(a.begin());
  int flag=0;
  if((suma-x)%2 or (sumb-y)%2 or suma<x or sumb<y){flag=0;}
  else
  {
    x=(suma-x)/2;
    y=(sumb-y)/2;
    vector<int> dpx(max(x+1,y+1));
    dpx[0]=1;
    for(auto itr1=a.begin();itr1 !=a.end();itr1++)
    {
      for(int i=x-*itr1;i>-1;i--)
      {
        if(dpx[i]==1){dpx[i+*itr1]=1;}
      }
      if(dpx[x]!=0){flag+=1;break;}

    }
    if(a.size()==0 and x==0){flag+=1;}
    dpx.clear();
    dpx[0]=1;
    for(auto itr2=b.begin();itr2 !=b.end();itr2++)
    {
      for(int i=y-*itr2;i>-1;i--)
      {
        if(dpx[i]==1){dpx[i+*itr2]=1;}
      }
      if(dpx[y]!=0){flag+=1;break;}
    }
    if(b.size()==0 and y==0){flag+=1;}
  }
  cout<<yn(flag>=2)<<endl;
  return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ll long long int
using namespace std;

const int mod=1e9+7;

int main()
{
	//#ifndef ONLINE_JUDGE
		//freopen("input.txt","r",stdin);
		//freopen("output.txt","w",stdout);
	//#endif
	int n;
	cin>>n;
	if(n%10== 2||n%10==4||n%10==5||n%10==7||n%10== 9)
		cout<<"hon\n";
	if(n%10==0||n%10==1||n%10==6 ||n%10== 8)
		cout<<"pon\n";
	if(n%10==3)
		cout<<"bon\n";
	return 0;
}


Measured memory_bytes: 3584
namespace Coder {
  class Scanner {
    private buffer: string = '';
    private stdinQueue: any = [];

    constructor() {
      process.stdin.resume();
      process.stdin.setEncoding('utf8');
      process.stdin.on(
        'data',
        (chunk): void => {
          this.buffer += chunk;
          while (this.stdinQueue.length > 0) {
            const i = this.buffer.indexOf('\n');
            if (i < 0) {
              break;
            }
            let line = this.buffer.substr(0, i);
            if (line.endsWith('\r')) {
              line = line.slice(0, -1);
            }
            this.buffer = this.buffer.substr(i + 1);
            this.stdinQueue.shift()(line);
          }
        },
      );
    }
    public getLine(): Promise<string> {
      return new Promise((resolve, reject) => {
        const i = this.buffer.indexOf('\n');
        if (i >= 0 && this.stdinQueue.length === 0) {
          let line = this.buffer.substr(0, i);
          if (line.endsWith('\r')) {
            line = line.slice(0, -1);
          }
          this.buffer = this.buffer.substr(i + 1);
          resolve(line);
        } else {
          this.stdinQueue.push(resolve);
        }
      });
    }

    public async getNumbers(): Promise<number[]> {
      return (await this.getLine()).split(' ').map((x) => +x);
    }

    public async getStrings(): Promise<string[]> {
      return (await this.getLine()).split(' ');
    }

    public close(): void {
      process.stdin.pause();
    }
  }

  async function solve() {
    const sc = new Scanner();
    const [A, B, C] = await sc.getNumbers();
    if ((A <= C && C <= B) || (B <= C && C <= A)) {
      console.log('Yes');
    } else {
      console.log('No');
    }
    sc.close();
  }

  solve();
}


Measured memory_bytes: 7500
#include <bits/stdc++.h>
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<sstream>
#include<queue>
#include<set>
#include<map>
#include<bitset>
#include<stack>
#include<assert.h>
#define i64  long long
#define vi32 vector<int>
#define vi64 vector< long long>
#define  ii pair<int,int>
const  long long mod = 1e9 + 7, inf = 1e9, linf = 1 << 30;//linf = 9223372036854775807;
const long long hashmod[4] = { (int)1e9 + 2277, (int)1e9 + 5277, (int)1e9 + 8277, (int)1e9 + 9277 };
const long double EPS = 0.000000001L, pi = acos(-1);
using namespace std;
#define pb push_back
#define mp make_pair
#define N 100006
//i64 base = 311;
int dx[] = { 0,-1,-1,-1,0,1,1,1 };
int dy[] = { -1,-1,0,1,1,1,0,-1 };
// God of debug OPP
#define debugg assert
using namespace std;

int main()
{
	int n;
	cin >> n;
	vi32 mons(n + 1), hero(n);
	for (auto& z : mons)cin >> z;
	for (auto& z : hero)cin >> z;
	i64 cnt = 0;
	for (int i = 0; i < n; i++)
	{
		int l = mons[i];
		int r = mons[i + 1];
		cnt += min(l, hero[i]);
		hero[i] -= min(l, hero[i]);
		cnt += min(r, hero[i]);
		mons[i + 1] -= min(r, hero[i]);
	}
	cout << cnt;
}


Measured memory_bytes: 1024
#include <iostream>
using namespace std;
 
int main(){
 
  int N;
  int K;
  int S;
  string b;
   cin >>S;
   N=S/100;
 	K=S-N*100;
  if(N==0){
  if ((0<K) && (K<13)) { 
  b="YYMM"; 
  }else b="NA"; }
      
    if(K==0){
  if ((0<N) && (N<13)) { 
  b="MMYY"; 
  }else b="NA" ;}
      
       if ((0<K) && (K<13))
       { 
     if ((0<N) && (N<13)){ 
       
  b="AMBIGUOUS"; 
  }
         else {b="YYMM";}
         
       } else if((0<N) && (N<13)){b="MMYY";}else{ b="NA";}
         
        
             
   cout << b << endl;
     
    }

Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
#define MOD 1000000007
using namespace std;


int main(int argc, char* argv[])
{
    long a,b,c,d,e,k;
    scanf("%ld%ld%ld%ld%ld%ld", &a, &b, &c, &d, &e, &k);

    if(e-a>k) {
        printf(":(\n");
    }
    else {
        printf("Yay!\n");
    }

    return 0;
}


Measured memory_bytes: 128
n = input()
(a, b) = map(int, raw_input().split())
(c, d) = map(int, raw_input().split())

ans = 10 ** 10
for i in range(1, n + 1):
  def f(x):
    return ((x - 1) % i, (x - 1) / i)
  [aa, bb, cc, dd] = map(f, [a, b, c, d])
  ans = min(ans, abs(aa[0] - bb[0]) + abs(aa[1] - bb[1]) + abs(cc[0] - dd[0]) + abs(cc[1] - dd[1]))
print ans

Measured memory_bytes: 4256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main(void){
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin >> A[i];
  }
  sort(A.begin(),A.end());
  cout << A.back() - A[0] << endl;
  return 0;
}


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

not_fixed = [True] * N

# 矛盾のチェック
MAX = 0
for i in range(N):
    if T[i] > MAX:
        MAX = T[i]
        not_fixed[i] = False
        if T[i] > A[i]:
            print(0)
            exit()

MAX = 0
for i in reversed(range(N)):
    if A[i] > MAX:
        MAX = A[i]
        not_fixed[i] = False
        if A[i] > T[i]:
            print(0)
            exit()


MIN = [min(t, a) for t, a in zip(T, A)]
ans = 1
mod = 10 ** 9 + 7

for i in range(N):
    if not_fixed[i]:
        ans *= MIN[i]
        ans %= mod

print(ans)


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



int main(){
    ll n;
    cin >> n;
    cout << 0 << endl;
    vector<string> s(n);
    string s0;
    cin >> s0;
    s[0]=s0;
    if(s0=="Vacant"){
        cout << 0 << endl;
        return 0;
    }
    cout << n-1 << endl;
    string sn1;
    cin >> sn1;
    s[n-1]=sn1;
    if(sn1=="Vacant"){
        cout << n-1 << endl;
        return 0;
    }
    ll l=0;
    ll r=n-1;
    while(1){
        ll mid=(l+r)/2;
        cout << mid << endl;
        string smid;
        cin >> smid;
        s[mid]=smid;
        if(smid=="Vacant"){
            cout << mid << endl;
            return 0;
        }
        if((mid-l)%2==0&&s[mid]!=s[l]) r=mid;
        else if((mid-l)%2==1&&s[mid]==s[l]) r=mid;
        else if((r-mid)%2==0&&s[mid]!=s[r]) l=mid;
        else if((r-mid)%2==1&&s[mid]==s[r]) l=mid;
    }
}  


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

sa = [A[i]-B[i] for i in range(N)]
sa = sorted(sa)
ans=0
minus = 0
for i in sa:
  if i < 0:
    minus += i
    ans+=1
  if i >= 0:
    break

for i in sa[::-1]:
  if minus >= 0:
    break
  if i > 0:
    minus += i
    ans += 1
  if i <= 0:
    break
    
if minus < 0:
  print(-1)
else:
  print(ans)

Measured memory_bytes: 18356
n = int(input()) + 1
d = [0] + list(map(int, input().split()))
ans = 0
def dfs(time_set,index):
    # print("{} {}".format(time_set, index))
    if len(time_set) >= n:
        time_list = list(time_set)
        time_list.sort()
        cand = min(time_list[-1] - time_list[0], 24 + time_list[0] - time_list[-1])
        global ans
        for i in range(1,n):
            cand = min(cand, time_list[i] - time_list[i-1])
        ans = max(ans, cand)
    elif index < n:
        time1, time2 = d[index], 24 - d[index]
        if time1 not in time_set:
            dfs(time_set | {time1}, index+1)
        if time2 not in time_set:
            dfs(time_set | {time2}, index+1)
dfs(set(),0)
print(ans)

Measured memory_bytes: 9088
a, b, c = map(int, input().split())
if a == 5 and b == 5 and c == 7:
    print("YES")
elif a == 5 and b == 7 and c == 5:
    print("YES")
elif a == 7 and b == 5 and c == 5:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define iii tuple<int, int, int>
#define ii pair<int, int>
#define fi first
#define se second

using namespace std;
using namespace __gnu_pbds;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int main() {
    ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
    // freopen("in", "r", stdin);

    int n, k, M = 1e9 + 7;
    cin >> n >> k;

    vector<int> h(n), dp(n);
    for (auto& i : h) cin >> i;
    for (int i = 1; i < n; ++i) {
        dp[i] = dp[i - 1] + abs(h[i] - h[i - 1]);
        for (int j = 1; j <= i && j <= k; ++j) dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
    }

    cout << dp.back() << '\n';

    return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) 
	{
		Scanner sc = new Scanner(System.in);
		
		long x = sc.nextLong();
		
		for(long i = -1000; i <= 1000; i++)
			for(long j = -1000; j <= 1000; j++)
			{
				long a = i*i*i*i*i;
				long b = j*j*j*j*j;
				
				if(a-b == x)
				{
					System.out.println(i + " " + j);
					return;
				}
			}
	}

}


Measured memory_bytes: 27248
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define PI 				acos(-1)
#define mp				make_pair
#define pb				push_back
#define all(a)			(a).begin(), (a).end()
#define sz(a)			a.size()
#define srt(a)			sort(all(a))
#define mem(a, h)		memset(a, (h), sizeof(a))
#define f 				first
#define s 				second
#define MOD1			998244353
#define fore(i, b, e)	for(int i = b; i < e; i++)
#define forg(i, b, e, m)	for(int i = b; i < e; i+=m)
int in(){int r=0,c;for(c=getchar();c<=32;c=getchar());if(c=='-') return -in();for(;c>32;r=(r<<1)+(r<<3)+c-'0',c=getchar());return r;}

using namespace std;
using namespace __gnu_pbds;

typedef long long 		ll;
typedef unsigned long long 		ull;
typedef pair<int, int>  ii;
typedef vector<int>     vi;
typedef vector<ii>      vii;
typedef vector<ll>      vll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
const int tam = 100010;
const int MOD = 1e9+7;
const double EPS = 1e-9;
int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	//freopen("qwe.txt", "r", stdin);
	//freopen("asd.txt", "w", stdout);
	int n, tre[15], potre[16];
	potre[0] = 1;
	fore(i, 1, 16) potre[i] = potre[i-1] * 3;
	fore(i, 1, 15) tre[i] = potre[i] - 1;
	cin>>n;
	n--;
	int in = 1;
	int mul = 1;
	vector<pair<pair<int,int>, int>> ar;
	while(n >= potre[in]-1)
	{
		//cout<<potre[in]<<'\n';
		ar.pb(mp(mp(in-1, in), 0));
		ar.pb(mp(mp(in-1, in), mul));
		ar.pb(mp(mp(in-1, in), mul * 2));
		mul *= 3;
		in++;
	}
	/*fore(i, 0, ar.size())
		cout<<ar[i].f.f<<' '<<ar[i].f.s<<' '<<ar[i].s<<'\n';*/
	in--;
	n -= potre[in] - 1;
	int sus = potre[in] - 1;
	int ini;
	int an = in+1;
	ar.pb(mp(mp(in, an), 0));
	while(n > 0)
	{
		//cout<<n<<'\n';
		ini = 1;
		while(n > potre[ini] - 1)
			ini++;
		ini--;

		ar.pb(mp(mp(ini, an), sus + 1));
		n -= potre[ini];
		sus += potre[ini];
		if(n > potre[ini])
		{
			ar.pb(mp(mp(ini, an), sus + 1));
			sus += potre[ini];
			n -= potre[ini];
		}
	}
	cout<<an+1<<' '<<ar.size()<<'\n';;
	fore(i, 0, ar.size())
		cout<<ar[i].f.f+1<<' '<<ar[i].f.s+1<<' '<<ar[i].s<<'\n';
	return 0;
}

Measured memory_bytes: 256
//AUTHOR: *Akash Shrivastva*
//Birla Institute of Technology,Mesra,India
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define M 1000000007
#define mp make_pair
#define pb push_back
#define vll vector<ll>
#define pll vector< pair <ll,ll> >
#define F first
#define S second
#define PII pair <ll,ll>

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
   
    string s;cin>>s;
    ll l=s.length();
    ll n=l+1,i,pre[n],suf[n];
    pre[0]=0;
    for (i=0;i<l;i++)
    {
    	if (s[i]=='<')	pre[i+1]=pre[i]+1;
    	else	pre[i+1]=0;
    }
    suf[n-1]=0;
    for (i=l-1;i>=0;i--)
    {
    	if (s[i]=='>')	suf[i]=suf[i+1]+1;
    	else	suf[i]=0;
    }
    ll sm=0;
    for (i=0;i<n;i++)	sm+=max(pre[i],suf[i]);
    cout<<sm<<endl;
}

Measured memory_bytes: 8732
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;
#define int long long int
const int INF = 1001001001001001LL;

int di[] = {-1, 0, 1, 0, -1, 1, 1, -1};
int dj[] = {0, 1, 0, -1, 1, 1, -1, -1};

signed main(){
    
    int n; cin >> n;
    vector<pair<int, int> > v(n);
    for(int i = 0; i < n; i++){
        int a, b; cin >> a >> b;
        v[i].first = a;
        v[i].second = b;
    }
    
    int ans = n;
    for(int i = 0; i < n; i++){
        for(int j = i + 1; j < n; j++){
            int p = v[i].first - v[j].first;
            int q = v[i].second - v[j].second;

            vector<pair<int, int> > w(n);
            for(int k = 0; k < n; k++){
                w[k].first = v[k].first - p;
                w[k].second = v[k].second - q;
            }

            int tmp = n;

            for(int k = 0; k < n; k++){
                for(int l = 0; l < n; l++){
                    if(v[k] == w[l]) tmp--;
                }
            }

            ans = min(ans, tmp);
        }
    }

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


Measured memory_bytes: 256
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**9)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

s = ns()
ss = list(s)
a = 'No' if ss[0] == ss[1] and ss[1] == ss[2] else 'Yes'
print(a)

Measured memory_bytes: 3060
import java.util.Scanner;

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

        int[] a = new int[n];
        int[] b = new int[n];
        int[] c = new int[n];
        c[n - 1] = 0;
        for (int i = 0; i < n; i++) {
            a[i] = in.nextInt();
        }

        for (int i = 0; i < n; i++) {
            b[i] = in.nextInt();
        }

        for (int i = 0; i < n - 1; i++) {
            c[i] = in.nextInt();
        }

        int total = 0;
        int prevDinner = -1;
        for (int i = 0; i < n; i++) {
            int dinner = a[i];
            total += b[dinner - 1];

            if (prevDinner != -1 &&
                prevDinner + 1 == dinner) {
                total += c[prevDinner - 1];
            }

            prevDinner = dinner;
        }

        System.out.println(total);
    }
}


Measured memory_bytes: 22996
#include <cstdio>
#include <map>
#include <cstdlib>
#include <algorithm>
#define N 200005
using namespace std;

struct node {
    int t;
    node(){t = 0;}
}a[N];
int n, k;

bool cmp(node x, node y) {
    return x.t > y.t;
}

int main() {
    int num, cnt = 0, loc, ans = 0;
    scanf("%d %d", &n, &k);
    for(int i = 1; i <= n; i++) {
        scanf("%d", &num);
        a[num].t ++;
    }    
    sort(a+1, a+1+n, cmp);
    for(int i = 1; i <= n; i++) {
        if(a[i].t) cnt++;
        if(cnt == k) {
            loc = i;
            break;
        }
    }
    if(cnt < k) printf("0\n");
    else {
        for(int i = loc+1; i <= n; i++) 
            ans += a[i].t;
        printf("%d\n", ans);
    }

    return 0;
}

Measured memory_bytes: 896
#include<stdio.h>
#include<string.h>
int main(void){
	int lens,lenp,i,j,hante=0;
	char s[101]={'\0'},p[101]={'\0'},sg[201]={'\0'};

	scanf("%s",s);
	scanf("%s",p);
	lens=strlen(s);
	lenp=strlen(p);
	strcat(sg,s);
	strcat(sg,s);
	for(i=0;i<lens;i++){
		for(j=0;j<lenp;j++){
			if(sg[i+j]!=p[j]) break;
		}
		if(lenp==(j)) hante=1;
	}
	if(hante) printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 524
#include <bits/stdc++.h>
using namespace std;
int main()
{
    char str[] = {'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'};
    char C;
    cin >> C;
    cout << str[C + 1 - 'a'] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

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

    vvll a(3, vll(3));
    REP(i, 3) {
        REP(j, 3) {
            cin >> a[i][j];
        }
    }
    vvll c(3, vll(3));
    ll n;
    cin >> n;
    ll b;
    REP(xxx, n) {
        cin >> b;
        REP(i, 3) {
            REP(j, 3) {
                if (a[i][j] == b) c[i][j] = 1;
            }
        }
    }
    ll ng = 1;
    REP(i, 3) {
        ll tate = 1, yoko = 1;
        REP(j, 3) {
            if (c[i][j] == 0) yoko = 0;
            if (c[j][i] == 0) tate = 0;
        }
        if (tate || yoko) ng = 0;
    }
    ll l = 1, r = 1;
    REP(i, 3) {
        if (c[i][i] == 0) l = 0;
        if (c[i][2 - i] == 0) r = 0;
    }
    if (l || r) ng = 0;
    if (ng == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int N,M;
    cin>>N>>M;
    const int nmmax=50;
    char A[nmmax][nmmax],B[nmmax][nmmax];
    for (int y=0;y<N;y++){
        for(int x=0;x<N;x++)
            cin>>A[y][x];
    }
    for(int y=0;y<M;y++){
        for(int x=0;x<M;x++)
            cin>>B[y][x];
    }
    bool exist=false;
    for(int ly=0;ly<N;ly++){
        for(int lx=0;lx<N;lx++){
            if(ly+M-1>=N or lx+M-1>=N)
                continue;
            bool match=true;
            for(int y=0;y<M;y++){
                for(int x=0;x<M;x++){
                    if(A[ly+y][lx+x]!=B[y][x])
                        match=false;
                }
            }
            if(match)
                exist=true;
        }
    }
    if(exist)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

int main(void)
{
    IOS
    string s; cin >> s >> s;
    printf("A%cC\n",s[0]);
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		 Scanner sc = new Scanner(System.in);
	        int N = sc.nextInt();
	        double ans = 0;
	        double A = 0;
	        double A1 = 0;
			
			for (int i=0; i<N; i++){
				A1 = sc.nextDouble();
				A += (1 / A1);
			}
			
			ans = 1/A;
			
			System.out.println(ans);
	}
}

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

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  int n;cin>>n;
  int res=0;
  for(int i=1;i<=n;i++){
    res += i;
  }
  cout<<res<<endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
inline ll read() {ll x = 0;char ch = getchar(), w = 1;while(ch < '0' || ch > '9') {
if(ch == '-') w = -1;ch = getchar();}while(ch >= '0' && ch <= '9') {x = x * 10 + ch - '0';ch = getchar();
}return x * w;}
void write(ll x) {if(x < 0) putchar('-'), x = -x;if(x > 9) write(x / 10);putchar(x % 10 + '0');}
inline void writeln(ll x) {write(x);puts("");}
using namespace std;



const int N = 310;
int n;
int g[N][N];
char s[N];
int d[N], ans;
void check(int s) {
	queue<int> q;
	q.push(s);
	memset(d, -1, sizeof d);
	d[s] = 1;
	int res=0;
	while(!q.empty()) {
		int x = q.front(); q.pop();
		res = d[x];
		for(int i = 1; i <= n; ++i)
			if(g[x][i] && d[i] == -1) {
				d[i] = d[x] + 1;
				q.push(i);
			}
	}
	for(int i = 1; i<=n;++i)
		for(int j = i+1;j<=n;++j)
			if(g[i][j] && abs(d[i] - d[j]) < 1) return;
//	printf("res=%d\n", res);
	ans = max(ans, res);
}
int main() {
	n = read();
	for(int i = 1; i <= n; ++i) {
		scanf("%s", s + 1);
		for(int j = 1; j <= n; ++j)
			g[i][j] = s[j] - '0';
	}
	ans = -1;
	for(int i = 1; i <= n; ++i) check(i);
	writeln(ans);
	return 0;
}

Measured memory_bytes: 512
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = (ll)1e9;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

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

	int n = s.length() + 1;
	vector<ll> l(n), r(n);
	for (int i = 0; i < n; i++)
	{
		if (s[i] == '<')
		{
			l[i + 1] = l[i] + 1;
		}
	}

	for (int i = n - 1; i >= 0; i--)
	{
		if (s[i] == '>')
		{
			r[i] =r[i + 1] + 1;
		}
	}

	vector<ll> a;
	for (int i = 0; i < n; i++)
	{
		a.push_back(max(l[i], r[i]));
	}

	cout << accumulate(all(a), 0ll) << endl;
}

Measured memory_bytes: 14840
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using P = pair<int,int>;
constexpr int INF = 1e9+7;
int h, w, k, x1, yy1, x2, y2, dx[] = {0,0,1,-1}, dy[] = {1,-1,0,0};
vector<vector<int>> mp;
queue<P> qu;
char c[1000005];
int main(){
	scanf("%d%d%d", &h, &w, &k);
	scanf("%d%d%d%d", &x1, &yy1, &x2, &y2);
	mp.resize(h);
	x1--; yy1--; x2--; y2--;
	rep(i,h){
		mp[i].resize(w);
		scanf("\n%s", c);
		rep(j,w) mp[i][j] = c[j] == '@' ? -1 : INF;
	}
	qu.emplace(x1,yy1);
	mp[x1][yy1] = 0;
	while(!qu.empty()){
		auto [x, y] = qu.front(); qu.pop();
		rep(i,4) for(int nx = x + dx[i], ny = y + dy[i], u = 0; u < k; u++, nx += dx[i], ny += dy[i]){
			if(nx < 0 || h <= nx || ny < 0 || w <= ny || mp[nx][ny] <= mp[x][y]) break;
			if(mp[nx][ny] == INF) qu.emplace(nx, ny);
			mp[nx][ny] = mp[x][y] + 1;
		}
	}
	printf("%d\n", mp[x2][y2] == INF ? -1 : mp[x2][y2]);
}

Measured memory_bytes: 8296