akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define endl "\n"
#define ar array
#define pb push_back
#define sz(X) ((int)(X).size())
#define ordered_set tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>
#define sort_unique(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define get_pos(c, x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define all(X) (X).begin(), (X).end()
#define  No cout<<"NO"<<endl;
#define  Yes cout<<"YES"<<endl;
#define  nl cout<<endl;

template<typename T>
ostream &operator+(ostream &out, const vector<T> &vec) {
    for (const auto &x : vec) {
        out << x << " ";
    }
    out << "\n";
    return out;
}

template<typename T>
ostream &operator*(ostream &out, const vector<T> &vec) {
    for (const auto &x : vec) {
        out + x;
    }
    return out;
}

template<typename T>
istream &operator>>(istream &in, vector<T> &vec) {
    for (auto &x : vec) {
        in >> x;
    }
    return in;
}
// DEBUG
void DBG() { cerr << "]" << endl; }
template<class H, class... T> void DBG(H h, T... t) {
    cerr << ts(h); if (sizeof...(t)) cerr << ", ";
    DBG(t...); }

#ifdef _DEBUG // compile with -DLOCAL
#define dbg(...) cerr << "LINE(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "]: [", DBG(__VA_ARGS__)
#else
#define dbg(...) 0
#endif

template<class T>
bool ckmin(T &a, const T &b) { return b < a ? a = b, 1 : 0; }

template<class T>
bool ckmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }


const int mod = 1e9 + 7;
const int mod2 = 998244353;
const ll INF = 1e9 + 6;

ll add(ll a, ll b) {
    a += b;
    return a % mod;
}

ll mul(ll a, ll b) {
    a *= b;
    return a % mod;
}

inline ll power(ll x, ll y, ll p) {
    ll res = 1;
    x = x % p;
    while (y > 0) {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
inline ll modInverse(ll x,ll p){
    return power(x,p-2,p);
}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

const int MXN = 2e5+5;
int n,k;
int h[MXN];
ll cache[MXN];

ll dp(int idx){
    if(idx<1){
        return 1e9;
    }
    if(idx==1){
        return 0;
    }
    if(cache[idx]!=-1){
        return cache[idx];
    }
    ll &ans=cache[idx];
    ans=1e18;
    for(int i=1;i<=k;i++){
        ans=min(ans,dp(idx-i)+abs(h[idx]-h[idx-i]));
    }
    return ans;
}
void solve() {
    cin>>n>>k;
    for(int i=1;i<=n;i++){
        cin>>h[i];
    }
    memset(cache,-1,sizeof cache);
    cout<<dp(n);
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
//#ifndef ONLINE_JUDGE
//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);
//#endif
    int t = 1;
     //cin>>t;
    while (t--)solve();
    // cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
    return 0;
}
//look if it requires ll


Measured memory_bytes: 11856
// https://beta.atcoder.jp/contests/abc103/tasks/abc103_c

#include<iostream>
#include<vector>
#include<string>
using namespace std;
long long lcm(long long a, long long b){
	if (a<b){
		long long temp = a;
		a = b;
		b = temp;
	}
	long long x = a*b;
	long long r = a % b;
	while(r != 0){
		a = b;
		b = r;
		r = a%b;
	}
	return x/b;
}
int main()
{
	int N;
	cin >> N;
	vector<int> A(N);
	for(int i=0;i<N;i++) cin >> A[i];

	int ans = 0;
	for(int i=0;i<A.size();i++){
		ans += A[i] - 1;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <algorithm>
#define EPS 1e-10
using namespace std;
const double g = 9.8;
int n, v, x, y;
int L[55], B[55], R[55], T[55];
double calc(double vy, double t) {
    return vy * t - g * t * t / 2;
}
int cmp(double lb, double ub, double a) {
    return a < lb + EPS ? -1 : a > ub - EPS ? 1 : 0;
}
bool check(double qx, double qy) {
    double a = g * g / 4, b = g * qy - v * v, c = qx * qx + qy * qy;
    double D = b * b - 4 * a * c;
    if(D < 0 && D > -EPS) D = 0;
    if (D < 0) return false;
    for (int d = -1; d <= 1; d += 2) {
        double t2 = (-b + d * sqrt(D)) / (2 * a);
        if (t2 <= 0) continue;
        double t = sqrt(t2);
        double vx = qx / t, vy = (qy + g * t * t / 2) / t;
        double yt=calc(vy, x / vx);
        if (yt < y - EPS) continue;
        bool ok = true;
        for (int i = 0; i < n; ++i) {
            if (L[i] >= x) continue;
            if (R[i] == x && y <= T[i] && B[i] <= yt) ok = false;
            int yL = cmp(B[i], T[i], calc(vy, L[i] / vx));
            int yR = cmp(B[i], T[i], calc(vy, R[i] / vx));
            int xH = cmp(L[i], R[i], vx * (vy / g));
            int yH = cmp(B[i], T[i], calc(vy, vy / g));
            if (xH == 0 && yH >= 0 && yL < 0) ok = false;
            if (yL * yR <= 0) ok = false;
        }
        if (ok) return true;
    }
    return false;
}
int main() {
    scanf("%d %d %d %d", &n, &v, &x, &y);
    for (int i = 0; i < n; ++i) {
        scanf("%d %d %d %d", L + i, B + i, R + i, T + i);
        R[i] = min(R[i], x);
    }
    bool ok = check(x, y);
    for (int i = 0; i < n; ++i) {
        ok |= check(L[i], T[i]);
        ok |= check(R[i], T[i]);
    }
    puts(ok ? "Yes" : "No");
    return 0;
}



Measured memory_bytes: 2696
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.util.Arrays;

/**
 * Knapsack problem 1 - N items each having weight w(i). 
 * Find the maximum amount of items that Taro can take. 
 */

public class Main {  
 
    static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() 
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
  
    public static void main(String[] args) { 
        
        FastReader s=new FastReader(); 

        int N = s.nextInt(); // can be upto 100
        int W = s.nextInt(); // limit - 10^5

        int[] w = new int[N]; // has W elements
        long[] v = new long[N]; // limit - 10^9 
        
        long[][] dp = new long[N+1][W+1];
        

        for (int i = 0; i < N; i++) {
            w[i] = s.nextInt();
            v[i] = s.nextLong();
        }

        // System.out.println("Weights: " + Arrays.toString(w));
        // System.out.println("Values: " + Arrays.toString(v));

        // for (int i = 0; i < 1; i++) {
        //     for (int j = 0; j < 1; j++) {
        //         dp[i][j] = 0;
        //     }
        // }

        for (int i = 1; i <= N; i++) {
            for (int j = 0; j <= W; j++) {
                // if (i-1 >= 0 && j-w[i-1] >= 0) {
                    /*
                    if (w[i-1] <= W) {
                        dp[i][j] = Math.max(v[i-1] + dp[i-1][j-w[i-1]], dp[i-1][j]);
                    } else {
                        dp[i][j] = dp[i-1][j];
                    }
                    */
                    if (j < w[i-1]) {
                        dp[i][j] = dp[i-1][j];
                    } else {
                        dp[i][j] = Math.max(v[i-1] + dp[i-1][j-w[i-1]], dp[i-1][j]);
                    }
                // }
            }
        }
        
        // System.out.println(Arrays.deepToString(dp));
        System.out.println(dp[N][W]);
    }
        

}


Measured memory_bytes: 127828
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using P   = pair<ll, ll>;
using mat = vector<vector<ll>>;
typedef string::const_iterator State;
class ParseError {};

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

const ll INF = 1e16;
const ll INM = 114514;
const ll MOD = 1e9 + 7;
const ld EPS = 1e-12;

template <typename T>
void dump(T x) { cout << x << endl; }
void dumpf(ld x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
inline ll mod(ll a, ll b) {
	if (a > 0) return a % b;
	if (a % b == 0) return 0;
	ll x = -a / b + 1;
	a += x * b;
	return a % b;
}
ll powm(ll a, ll b, ll c) {
	if (b == 0)
		return 1;
	else if (b % 2 == 0) {
		ll d = powm(a, b / 2, c);
		return (d * d) % c;
	} else
		return (a * powm(a, b - 1, c)) % c;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll dx[4] = {1, 0, -1, 0};
ll dy[4] = {0, 1, 0, -1};

int main() {
	IOS();
	ll a;
	string s;
	cin >> a >> s;
	dump(a >= 3200 ? s : "red");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1e9 + 7/*998244353*/;
const ll INF = 1LL << 60;
ll mod_pow(ll, ll, ll); ll mod_fact(ll, ll); ll mod_inv(ll, ll); ll gcd(ll, ll); ll lcm(ll, ll);
//
int main(){
    int n;
    cin >> n;
    vector<ll> nums(n);
    set<ll> appeared, reappeared;
    ll mx = 0;
    for(int i = 0; i < n; i++) {cin >> nums[i]; mx = max(mx, nums[i]);}
    vector<bool> available(mx + 1, true);
    for(int i = 0; i < n; i++){
        if(appeared.count(nums[i])) {reappeared.insert(nums[i]); continue;}
        appeared.insert(nums[i]);
        for(int j = 2; j <= mx / nums[i]; j++){
            //cout << nums[i] * j;
            available[nums[i] * j] = false;
        }
    }
    ll ans = 0;
    for(int i = 0; i < n; i++){
        if(reappeared.count(nums[i])) continue;
        if(available[nums[i]]) ans++;
    }
    //for(int i = 0; i <= mx; i++) cout << available[i] << " ";
    cout << ans;
}

Measured memory_bytes: 14356
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n) ; ++i)
#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define emb emplace_back
#define fcout cout << fixed << setprecision(15)

using namespace std;
using ll = long long;
using P = pair<int,int>;

template<typename T> void pv(vector<T> vec) {
  cout << "[";
  for(auto& v : vec) { cout << v << ","; }
  cout << "]" << endl;
}

template<>
void pv(vector<P> vec) {
  cout << "[";
  for(auto& v : vec) {
    cout << "<" << v.fi << ","<< v.se << ">" << ",";
  }
  cout << "]" << endl;
}

int dp[100005];
int INF = 1001001001;
int main() {
  int n;
  cin >> n;
  vector<int> h(n,0);
  rep(i,n) cin >> h.at(i);
  h.emb(INF);
  h.emb(INF);


  rep(i,n) dp[i] = INF;
  dp[0] = 0;

  rep(i,n) {
    dp[i+1] = min(dp[i+1],dp[i]+abs(h.at(i+1)-h.at(i)));
    dp[i+2] = min(dp[i+2],dp[i]+abs(h.at(i+2)-h.at(i)));
  }
  cout << dp[n-1] << endl;
  return 0;
}


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

int main(void) {
  string s;
  cin >> s;
  if (s[5] == '1' or s[6] >= '5') {
    cout << "TBD" << endl;
  }
  else {
    cout << "Heisei" << endl;
  }
}

Measured memory_bytes: 256
H, W = map(int, input().split())
A = [list(input()) for _ in range(H)]
counts = {}
for a_ in A:
  for a in a_:
    if not a in counts:
      counts[a] = 1
    else:
      counts[a] += 1
ans = "Yes"
oe = H%2+W%2
if oe == 0:
  for n in counts.values():
    if n % 4 != 0:
      ans = "No"
      break
elif oe == 1:
  even = H if H % 2 == 0 else W
  modis2 = 0
  for n in counts.values():
    if n % 4 == 2:
      modis2 += 1
      if modis2 > even / 2:
        ans = "No"
        break
    elif n % 4 != 0:
      ans = "No"
      break
else:
  if H == 1 or W == 1:
    oddcount = 0
    for n in counts.values():
      if n % 2 == 1:
        oddcount += 1
        if oddcount > 2:
          ans = "No"
          break
  else:
    modcount = [0] * 4
    for n in counts.values():
      modcount[n%4] += 1
    if modcount[1]+modcount[3] == 1 and modcount[2] + modcount[3] == (H//2)+(W//2):
      ans = "Yes"
    else:
      ans = "No"
print(ans)


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

typedef long long ll;
// #define int ll
#define pb push_back
const int INF = 1e9;

signed main(){

	ios_base::sync_with_stdio(false);
	cin.tie(0);




	set<string> s;
	int n; cin>>n;
	for(int i=0;i<n;i++){
		string x;
		cin>>x;
		s.insert(x);
	}
	
	cout<<s.size();
	return 0;
}

Measured memory_bytes: 19196
#include <bits/stdc++.h>
typedef long long ll;
#define INF 1000000000
using namespace std;
int s(int n){
    int sum=0;
    while(n){
        sum+=n%10;
        n/=10;
    }
    return sum;
}
int main(void){
    int n;
    cin>>n;
    if(n%s(n)==0){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}

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

#define REP(i, n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
#define square(x) (x) * (x)

const int INF = 1e9;

using namespace std;

int main() {
    string s, p;
    cin >> s >> p;
    s.append(s);
    if(s.find(p) != string::npos)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
using namespace std;
int a,b,i,k;
int main()
{
   //  ifstream cin ("a.in");
   //   ofstream cout ("a.out");
    cin>>a>>b>>k;
    for(i=100; i>=1; --i)
    {
        if(a%i==0&&b%i==0)--k;
        if(k==0)
        {
            cout<<i;
            return 0;
        }
    }
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>

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

  std::string S;
  std::cin >> S;

  std::vector<int> acc(N);

  for (int i=1; i<N; i++) {
    acc[i] = acc[i-1];
    if (S[i-1] == 'A' && S[i] == 'C') acc[i]+=1;
  }

  for (int i=0; i<Q; i++) {
    int l, r;
    std::cin >> l >> r;
    std::cout << acc[r-1] - acc[l-1] << '\n';
  }

  return 0;
}


Measured memory_bytes: 1408
#pragma target("avx")
#pragma optimize("O3")
#include<bits/stdc++.h>
using ll = int_fast64_t;
using P = std::pair<ll,ll>;
using PP = std::pair<ll,P>;
using V = std::vector<ll>;
template<typename T> using pq = std::priority_queue<T>;
template<typename T> using rpq = std::priority_queue<T, std::vector<T>, std::greater<T>>;

#define REP(i,b,e) for(ll i=b; i<e; i++)
#define ALL(vec) vec.begin(),vec.end()
#define PRINT(vec) printf("[ ");for(auto &i:vec)printf("%ld ",i);puts("]");
#define SCAN(vec) for(auto &i:vec)scanf("%ld",&i)
#define fi first
#define se second

const int MOD = 1e9+7;
const ll INF = 1e18;
int dx[] = {0, 1, 0, -1, 1, 1, -1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

int main(){
	ll a, b;
	scanf("%ld %ld", &a, &b);
	printf("%ld\n", a * b / std::gcd(a, b));
	return 0;
}



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

int main()
{
    deque<int> b;
    int n; cin>>n;
    for(int i=0; i<n; ++i) {
        int a; cin>>a;
        i%2 ? b.push_front(a) : b.push_back(a);
    }
    if (n%2) reverse(begin(b), end(b));
    for(auto& e: b) cout<<e<<' ';
    cout<<endl;
}

Measured memory_bytes: 2944
import math

S = input()
pad = []

if S[0] == "<":
    left_flag = True
    count = 0
    for k in S:
        if left_flag and k == "<":
            count += 1
        elif left_flag and k == ">":
            pad.append(count)
            left_flag ^= 1
            count = 1
        elif (not left_flag) and k == ">":
            count += 1
        else:
            pad.append(-count)
            left_flag ^= 1
            count = 1
    if left_flag:
        pad.append(count)
    else:
        pad.append(-count)


    result = 0
    for i, j in zip(pad[0::2], pad[1::2]):
        if i > abs(j):
            result += sum(range(i + 1)) + sum(range(abs(j)))
        else:
            result += sum(range(i)) + sum(range(abs(j) + 1))
    if len(pad) % 2 == 1:
        result += sum(range(abs(pad[-1] + 1)))
    print(result)

else:
    left_flag = False
    count = 0
    for k in S:
        if left_flag and k == "<":
            count += 1
        elif left_flag and k == ">":
            pad.append(count)
            left_flag ^= 1
            count = 1
        elif (not left_flag) and k == ">":
            count += 1
        else:
            pad.append(-count)
            left_flag ^= 1
            count = 1
    if left_flag:
        pad.append(count)
    else:
        pad.append(-count)

    result = sum(range(abs(pad[0]) + 1))
    for i, j in zip(pad[1::2], pad[2::2]):
        if i > abs(j):
            result += sum(range(i + 1)) + sum(range(abs(j)))
        else:
            result += sum(range(i)) + sum(range(abs(j) + 1))
    if len(pad) % 2 == 0:
        result += sum(range(abs(pad[-1] + 1)))
    print(result)


Measured memory_bytes: 8348
using System;

public class Test
{
	static public void Main( )
	{
		var x = int.Parse( Console.ReadLine() );
		var h = x/3600;
		var m = ( x%3600 )/60;
		var s = ( x%3600 )%60;
		Console.WriteLine( "{0}:{1}:{2}", h, m, s );
	}
}

Measured memory_bytes: 19964
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
using namespace __gnu_pbds;
using namespace std;
/*
int dx[]={-1,1,0,0};
int dy[]={0,0,-1,1};
*/
#define ull unsigned long long int
#define ll long long int
#define MAX 1000000007
//1e9+7
#define pll pair<ll,ll>
#define pii pair<int,int>
#define piiii pair<pii,pii>
#define IO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FO ifstream fin("a.in");ofstream fout("a.out");
#define TEST int testcase;cin>>testcase;while(testcase--)
#define all(x) (x).begin(),(x).end()
#define mset0(x) memset((x), 0, sizeof((x)));
#define mset1(x) memset((x), -1, sizeof((x)));
#define endl "\n"
#define plll pair<ll,pll>
#define logg2 0.30102999566398119521373889472449L
typedef tree<ll,null_type,less<ll>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
const int maxn=2e5;

vector<int> adj[maxn+1];
vector<int> ans;

int state[maxn+1]={0};//  0:not visit    1:processing     -1:processed
bool ok=true;
void dfs(int node){
    if(!ok) return;
    state[node]=1;
    for(auto nex:adj[node]){
        if(state[nex]==0) dfs(nex);
        else if(state[nex]==1) {ok=false;return;}
    }
    state[node]=-1;
    //cout<<node<<" ";
    ans.push_back(node);
}
void solve(){

    int n,m;
    cin>>n>>m;
    int a;
    priority_queue<int> pq;
    while(n--){
        cin>>a;
        pq.push(a);
    }
    while(m--){
        int p=pq.top();
        pq.pop();
        pq.push(p/2);
    }
    ll ans=0;
    while(!pq.empty()){
        ans+=pq.top();
        pq.pop();
    }
    cout<<ans;
    return;
}
int main(){
    IO

    //TEST
    solve();
    return(0);
}


Measured memory_bytes: 8584
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define call(var) cout<<#var<<"="<<var<<endl;
#define dup(x,y) (((x)+(y)-1)/(y))
using ll=long long;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;
template<class t,class u> inline bool chmax(t&a,u b){if(a<b){a=b;return true;}return false;}
template<class t,class u> inline bool chmin(t&a,u b){if(b<a){a=b;return true;}return false;}

int main(){
    string s,t;cin >> s >> t;
    rep(i,26){
        string ss = s + (char)('a' + i);
        if(ss == t){
            cout << "Yes\n";
            return 0;
        }
    }
    cout << "No\n";
}

Measured memory_bytes: 3632
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        String t = sc.nextLine();
        for(int i = 0; i < s.length(); i++) {
            if(s.indexOf(s.charAt(i), i+1) != t.indexOf(t.charAt(i), i+1)) {
                System.out.println("No");
                return;
            }
        }
        System.out.println("Yes");
    }
}

Measured memory_bytes: 29712
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

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

typedef int long long ll;
using namespace std;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);
int main() {
    int n, k;
    cin >> n >> k;
    vector<int> v(n);
    for (int i = 0; i < n; i++) {
        cin >> v[i];
    }

    int mx = 0;
    int limit = min(n, k);
    for (int i = 0; i <= limit; i++) {
        for (int j = 0; j <= limit - i; j++) {
            int t = 0;
            vector<int> m;
            for (int l = 0; l < i; l++) {
                t += v[l];
                if (v[l] < 0) {
                    m.push_back(v[l]);
                }
            }
            for (int r = 0; r < j; r++) {
                t += v[n - 1 - r];
                if (v[n - 1 - r] < 0) {
                    m.push_back(v[n - 1 - r]);
                }
            }
            sort(m.begin(),m.end());
            for (int d = 0; d < min(k - (i + j), (int)m.size()); d++) {
                t -= m[d];
            }

            mx = max(mx, t);
        }
    }

    cout << mx << endl;
}

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

#define rep(i, n) for(int i=0; i<n; i++)
using namespace std;
vector<int> dy = {1, 0, -1, 0};
vector<int> dx = {0, 1, 0, -1};
typedef pair<int, int> PII;

int main() {
    int n;
    cin >> n;
    vector<int> vec(n);
    long long ans = 0;
    cin >> vec.at(0);
    int comp = vec.at(0);
    for(int i = 1; i < n; i++){
        cin >> vec.at(i);
        if(comp > vec.at(i)){
            ans += (comp - vec.at(i));
        }else{
            comp = vec.at(i);
        }
    }
    cout << ans << endl;

    return 0;

}

Measured memory_bytes: 4016
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>

using namespace std;

typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;

const int INF = INT_MAX / 4;

#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); i++ )
#define UREP( i, m, n ) for ( ui i = (ui)( m ); i < (ui)( n ); i++ )
#define EACH( v, c ) for ( __typeof( c.front() ) &v : c )

#define ITER( c ) __typeof( (c).begin() )
#define IREP( c, it ) for ( ITER(c) it = c.begin(); it != c.end(); ++it )
#define ALL( c ) (c).begin(), (c).end()
#define RALL( c ) (c).rbegin(), (c).rend()

#define PB( n ) push_back( n )
#define MP( a, b ) make_pair( ( a ), ( b ) )
#define EXIST( c, e ) ( (c).find( e ) != (c).end() )

#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define DEBUG( x ) cerr << __FILE__ << ":" << __LINE__ << ": " << #x << " = " << ( x ) << endl

double powdist( double x1, double y1, double x2, double y2 )
{
	return pow( x1 - x2, 2 ) + pow( y1 - y2, 2 );
}

double dist( double x1, double y1, double x2, double y2 )
{
	return sqrt( pow( x1 - x2, 2 ) + pow( y1 - y2, 2 ) );
}

int main()
{
	while ( true )
	{
		int n;
		cin >> n;

		if ( !n )
		{
			break;
		}

		vector<double> x( n ), y( n );
		char dummy;

		REP( i, 0, n )
		{
			cin >> x[i] >> dummy >> y[i];
		}

		int res = 1;

		REP( i, 0, n )
		{
			REP( j, i + 1, n )
			{
				if ( powdist( x[i], y[i], x[j], y[j] ) <= 4 )
				{
					double mx = ( x[i] + x[j] ) / 2, my = ( y[i] + y[j] ) / 2;
					double xl = sqrt( 1 - pow( dist( x[i], y[i], x[j], y[j] ) / 2, 2 ) );
					
					double ox1 = mx, oy1 = my, ox2 = mx, oy2 = my;

					if ( x[i] - x[j] == 0 )
					{
						oy1 += xl;
						oy2 -= xl;
					}
					else if ( y[i] - y[j] == 0 )
					{
						ox1 += xl;
						oy2 -= xl;
					}
					else
					{
						double s = -( ( x[j] - x[i] ) / ( y[j] - y[i] ) );
						double th = atan( s );
						
						ox1 = mx + xl * cos( th );
						oy1 = my + xl * sin( th );

						ox2 = mx - xl * cos( th );
						oy2 = my - xl * sin( th );
					}

					int tmp1 = 2, tmp2 = 2;

					REP( k, 0, n )
					{
						if ( i == k || j == k )
						{	
							continue;
						}

						if ( powdist( x[k], y[k], ox1, oy1 ) <= 1 )
						{
							tmp1++;
						}

						if ( powdist( x[k], y[k], ox2, oy2 ) <= 1 )
						{
							tmp2++;
						}
					}

					res = max( res, max( tmp1, tmp2 ) );
				}
			}
		}

		cout << res << endl;
	}

	return 0;
}

Measured memory_bytes: 1312
N, M, Q = map(int, input().split())
reqs = [list(map(int, input().split())) for _ in range(Q)]

max_ans = 0


def dfs(s):
    global max_ans
    if len(s) < N:
        for i in range(s[-1], M + 1):
            dfs(s + [i])
    else:
        ans = 0
        for a, b, c, d in reqs:
            a -= 1
            b -= 1
            if s[b] - s[a] == c:
                ans += d
        max_ans = max(max_ans, ans)


for j in range(M):
    dfs([j + 1])
print(max_ans)

Measured memory_bytes: 9156
#include <iostream>//bit DP
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <string>
#include <cmath>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef pair<ll,ll>PP;
int main(){
  int n;
  int ans=0;
  cin>>n;
  for(int i=1;i<=n;i++){
    int a;cin>>a;
    if(a%2==1&&i%2==1)ans++;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3616
/*
    Author: Nguyen Tan Bao
    Status:
    Idea:
*/

#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

const ll MODBASE = 1000000007LL;
const int MAXN = 110;
const int MAXM = 1000;
const int MAXK = 16;
const int MAXQ = 200010;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    int n;
    cin >> n;
    cout << n / 2 + n % 2;
    return 0;
}


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

using namespace std;

typedef long long   ll;
const ll mod = ll(1e9) + 7LL;
const int N = 2010;
ll c[N][N];

void pascal(){
    for(int i = 0 ; i < N ; i++){
        c[i][i] = c[i][0] = 1LL;

        for(int j = 1 ; j < i ; j++){
            c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % mod;
        }
    }
}

ll calc(int n, int k){
    if(k < 0){
        return 0;
    }

    return c[n][k];
}

int main(){
    pascal();

    int n, k;

    scanf("%d %d", &n, &k);

    for(int i = 1 ; i <= k ; i++){
        if(n == k){
            if(i == 1){
                printf("1\n");
            }else{
                printf("0\n");
            }

            continue;
        }

        ll rig = (calc(n - k - 1, i - 2) + 2LL * c[n - k - 1][i - 1] + c[n - k - 1][i]) % mod;
        //printf("%lld\n", rig);

        printf("%lld\n", (c[k - 1][i - 1] * rig) % mod);
    }

    return 0;
}

Measured memory_bytes: 30336
fun main (args:Array<String>){
    val N = readLine()!!.toInt()
    var S = readLine()!!

    fun changeChar(changePoint: Int): (s: Char)-> Char {
        val changePoint = changePoint
        return {
            if (it.toInt() + changePoint > 'Z'.toInt()) {
                ('A'.toInt() + (it.toInt() + changePoint - 'Z'.toInt() - 1)).toChar()
            } else {
                (it.toInt() + changePoint).toChar()
            }
        }
    }

    val changeChar = changeChar(N)

    for (s in S) {
        print(changeChar(s))
    }
}


Measured memory_bytes: 37376
#include<iostream>

using namespace std;

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

	int ans=0;
	int tmp;
	int prev = 1;
	while(n >= 1){
		tmp = n%10;
		if(tmp == 1 && n < 10 && prev == 0) ans += 10;
		else if(tmp == 1)		  ans += 1;
		else		ans += tmp;

		n /= 10;
		prev = tmp;
	}
	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
int main() {
	int n, m;
	std::cin >> n >> m;
	while (n != 0 && m != 0) {
		std::vector<std::vector<int>> on_land(n, std::vector<int>(n, 1000000));
		std::vector<std::vector<int>> on_ship(n, std::vector<int>(n, 1000000));
		{
			int x, y, t;
			char s;
			for (auto i = 0; i < n; ++i) {
				on_land[i][i] = on_ship[i][i] = 0;
			}
			for (auto i = 0; i < m; ++i) {
				std::cin >> x >> y >> t >> s;
				switch (s) {
				case 'L': 
					if (on_land[x - 1][y - 1] > t) {
						on_land[x - 1][y - 1] = on_land[y - 1][x - 1] = t;
					}
						  break;
				default:
					if (on_ship[x - 1][y - 1] > t) {
						on_ship[x - 1][y - 1] = on_ship[y - 1][x - 1] = t;
					}
				}
			}
			for (auto mid = 0; mid < n; ++mid) for (auto from = 0; from < n; ++from) for (auto to = from + 1; to < n; ++to) {
				if (on_land[from][mid] + on_land[mid][to] < on_land[from][to])
					on_land[from][to] = on_land[to][from] = on_land[from][mid] + on_land[mid][to];
				if (on_ship[from][mid] + on_ship[mid][to] < on_ship[from][to])
					on_ship[from][to] = on_ship[to][from] = on_ship[from][mid] + on_ship[mid][to];
			}
		}
		std::vector<int> vec_a(n, 1000000);
		std::vector<int> vec_b(n, 1000000);
		int r, from, to;
		std::cin >> r;
		auto *from_vec = &vec_a;
		auto *to_vec = &vec_b;
		std::cin >> from;
		vec_a[from - 1] = 0;
		for (auto i = 1; i < r; ++i) {
			std::cin >> to;
			for (auto ship_from = 0; ship_from < n; ++ship_from) {
				if ((*to_vec)[ship_from] > (*from_vec)[ship_from] + on_land[from - 1][to - 1])
					(*to_vec)[ship_from] = (*from_vec)[ship_from] + on_land[from - 1][to - 1];
				for (auto ship_to = 0; ship_to < n; ++ship_to) {
					if ((*to_vec)[ship_to] > (*from_vec)[ship_from] + on_land[from - 1][ship_from] + on_ship[ship_from][ship_to] + on_land[ship_to][to - 1])
						(*to_vec)[ship_to] = (*from_vec)[ship_from] + on_land[from - 1][ship_from] + on_ship[ship_from][ship_to] + on_land[ship_to][to - 1];
				}
			}
			auto temp = to_vec;
			to_vec = from_vec; from_vec = temp;
			for (auto &vec : (*to_vec)) vec = 1000000;
			from = to;
		}
		int min = 1000000;
		for (const auto v : (*from_vec)) {
			if (min > v) min = v;
		}
		std::cout << min << std::endl;
		std::cin >> n >> m;
	}
}



Measured memory_bytes: 3252
n = int(input())
l = list(map(int, input().split()))
l.sort()
ans = 0

for i in range(n-2):
    for j in range(i+1, n-1):
        if l[i]==l[j]:
            continue
        for k in range(j+1, n):
            if l[i]==l[k] or l[j]==l[k]:
                continue
            if l[j]+l[i] > l[k]:
                ans += 1
print(ans)

Measured memory_bytes: 9196
cnt500 = int(input())
cnt100 = int(input())
cnt50 = int(input())
X = int(input())

result = 0
for a in range(cnt500+1):
    for b in range(cnt100+1):
        for c in range(cnt50+1):
           if (a*500 + b*100 + c*50) == X:
               result += 1
print(result)

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

int main() {
    int n;
    std::cin >> n;
    std::vector<int> a(n), b(n), c(n - 1);
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
    }
    for (int i = 0; i < n; i++) {
        std::cin >> b[i];
    }
    for (int i = 0; i < n - 1; i++) {
        std::cin >> c[i];
    }

    int ans = 0;
    for (int i = 0; i < n - 1; i++) {
        ans += b[i];
        if (a[i] + 1 == a[i + 1]) {
            ans += c[a[i] - 1];
        }
    }
    ans += b[n - 1];

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

int main() {
  ll h,w;
  cin >> h >> w;
  mat dp(h,vec(w,0));
  dp[0][0]=1;
  vector<string> a(h);
  for(ll i=0;i<h;i++) cin >> a[i];
  for(ll i=0;i<h;i++) {
    for(ll j=0;j<w;j++) {
      if(a[i][j]=='#') continue;
      if(i+1<h&&a[i+1][j]) (dp[i+1][j]+=dp[i][j])%=mod;
      if(j+1<w&&a[i][j+1]) (dp[i][j+1]+=dp[i][j])%=mod;
    }
  }
  cout << dp[h-1][w-1] << endl;
}

Measured memory_bytes: 9216
#include <stdio.h>

int main()
{
	int N, A, B, C, D;
	scanf("%d %d %d %d %d", &N, &A, &B, &C, &D);
	
	int i, j, k, l, r, m;
	long long L, R;
	l = 0;
	r = N - 1;
	while (l < r) {
		m = (l + r) / 2;
		L = A - (long long)D * m + (long long)C * (N - m - 1);
		R = A - (long long)C * m + (long long)D * (N - m - 1);
		if (B >= L && B <= R) break;
		else if (L > B) l = m + 1;
		else r = m;
	}
	
	if (l < r) printf("YES\n");
	else printf("NO\n");
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 1624
import sys
input = sys.stdin.readline

'''

'''

a, b, c = map(int, input().split())
k = int(input())

def solve(k, tup):
    a, b, c = tup
    while k > 0:
        if a >= b:
            b *= 2
            k -= 1
            continue
        if b >= c:
            c *= 2
            k -= 1
            continue

        return "Yes"
    
    if a < b < c:
        return "Yes"
    else:
        return "No"


print(solve(k, (a, b, c)))

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

using namespace std;

long long f(int n, long long m) {
    map<tuple<int, int, int>, long long> mem;
    function<long long (int, int, int)> calc = [&](int progress, int num, int jumps) {
        if (jumps > n) return 0LL;
        if (num == 3 * n) return 1LL;
        auto p = make_tuple(progress, num, jumps);
        if (mem.find(p) != mem.end()) return mem[p];
        long long answer = 0;
        if (progress > num) {
            answer += calc(progress, num + 1, jumps) * (progress - num);
        }
        for (int i = 1; i <= 3 && progress + i <= 3 * n; ++i) {
            answer += calc(progress + i, num + 1, jumps + (i > 1));
        }
        return mem[p] = answer % m;
    };
    return calc(0, 0, 0);
}

long long g(int n, long long m) {
    map<tuple<int, int>, long long> mem;
    function<long long (int, int)> h = [&](int s, int d) {
        // s is the sum
        // d is #1 - #2
        if (s < abs(d)) return 0LL;
        if (s == 0) return 1LL;
        auto t = make_tuple(s, d);
        if (mem.find(t) != mem.end()) return mem[t];
        long long answer = 0;
        answer += h(s - 1, d - 1);
        answer += h(s - 2, d + 1) * (s - 1) % m;
        answer += h(s - 3, d) * (s - 1) % m * (s - 2) % m;
        answer %= m;
        return mem[t] = answer;
    };
    long long total = 0;
    for (int i = 0; i <= 3*n; ++i) {
        total += h(3 * n, i);
    }
    total %= m;
    return total;
}

long long h(int n, long long m) {
    vector<vector<long long>> xs(3*n + 1, vector<long long>(6*n + 3, 0LL));
    xs[0][3 * n + 1] = 1LL;
    for (int s = 1; s <= 3 * n; ++s) {
        for (int d = 1; d <= 6 * n + 1; ++d) {
            long long answer = 0;
            answer += xs[s - 1][d - 1];
            if (s >= 2) {
                answer += xs[s - 2][d + 1] * (s - 1);
            }
            if (s >= 3) {
                answer += xs[s - 3][d] * (s - 1) % m * (s - 2);
            }
            answer %= m;
            xs[s][d] = answer;
        }
    }
    long long total = 0;
    for (int i = 0; i <= 3*n; ++i) {
        total += xs[3 * n][3 * n + 1 + i];
    }
    total %= m;
    return total;
}


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    long long m;
    cin >> n >> m;
    auto t0 = clock();
    // cout << f(n, m) << endl;
    // cout << g(n, m) << endl;
    cout << h(n, m) << endl;
    auto t1 = clock();
    cerr << "Time used: " << t1 - t0 << " ms" << endl;
    return 0;
}


Measured memory_bytes: 563328
list = input().split()
vote_list = input().split()
is_accepted = True

sum = 0
for i in range(int(list[0])):
  sum += int(vote_list[i])

counter = 0
ave = 1/(4*int(list[1]))
for i in range(int(list[0])):
  if( int(vote_list[i]) < sum * ave):
    continue
  else:
    counter +=1
    
if counter >= int(list[1]):
  print("Yes")
else:
  print("No")

Measured memory_bytes: 9172
#include <bits/stdc++.h>
#define all(a) (a).begin(),(a).end()
#define rep(i,n) for(ll i=0,i##_len=(n);i<i##_len;i++)
#define rep2(i,a,b) for(ll i=(a),i##_len=(b);i<=i##_len;i++)
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define pb push_back
using namespace std;
using ll = long long;

template<class T> bool chmax(T&a,const T&b){if(a<b){a=b;return true;}return false;}
template<class T> bool chmin(T&a,const T&b){if(a>b){a=b;return true;}return false;}
template<class T> void show(vector<T>v){rep(i,v.size()-1){cout<<v.at(i)<<" ";}cout<<v.at(v.size()-1)<<endl;}
template<class T> T abs(T x){return max(x,-x);}
template<class T> T gcd_vec(vector<T>v){T r=v.at(0);for(T i=1;i<v.size();i++)r=gcd(r,v.at(i));return r;}
template<class T> T lcm(T m,T n) {return m*n/gcd(m,n);}
template<class T> T lcm_vec(vector<T>v){T r=v.at(0);for(T i=1;i<v.size();i++)r=lcm<T>(r,v.at(i));return r;}
template<class T> T factorial(T n){if(n==0)return 1;T r=1;for(T i=2;i<=n;i++)r*=i;return r;}
template<class T> T nCr(T n,T k){return factorial<T>(n)/(factorial<T>(k)*factorial<T>(n-k));}
vector<string> split(const string&s,char d){vector<string>r;stringstream ss(s);string k;while(getline(ss,k,d))if(!k.empty())r.pb(k);return r;}

// Template ends here

int main() {
    int a, b, minimum, maximum;
    cin >> a >> b;
    minimum = max(ceil(a / 0.08), ceil(b / 0.10));
    maximum = min(floor((a + 0.99999) / 0.08), floor((b + 0.99999) / 0.10));

    if (minimum > maximum) {
        cout << -1 << endl;
    } else {
        cout << minimum << endl;
    }
    return 0;
}

Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#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;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;
 
int main() {
    int N; scanf("%d", &N);
    vector<int> A(N);
    for(int i=0; i<N; i++) scanf("%d", &A[i]);

    int max_val = -1;
    ll ans = 0;
    for(int i=0; i<N; i++) {
        int h = max(0, max_val - A[i]);
        A[i] += h;
        ans += h;
        chmax(max_val, A[i]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4016
#include <iostream>
#include <cstdio>
#include <cstdlib>

using namespace std;

int main() {
    long long g;
    scanf("%lld", &g);

    long long h, n, w;

    long long hmin = g / 4 + 1;
    int hmax = 3500;

    for(int i=hmin;i<=hmax;i++) {
        long long nmin = i * g / (4*i - g) + 1;
        for(int j=nmin;j<=hmax;j++) {
            if(4*i*j - g*i - g*j == 0) continue;

            w = g * i * j / (4 * i * j - g * i - g * j);

            if((i * j + i * w + j * w) * g == i * j * w * 4) {
                printf("%d %d %d\n", i, j, w);
                return 0;
            }
        }
    }
    return 0;
}

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

int main()
{
	vector<int>a(6);
	for (int b = 0; b < 6; b++) {
		int c;
		cin >> c;
		a[b] = c;
	}
	string d;
	cin >> d;
	for (int e = 0; e < d.length(); e++) {
		vector<int>f(6);
		for (int b = 0; b < 6; b++) {
			f[b] = a[b];
		}
		switch (d[e]) {
		case 'N':a[0] = f[1]; a[1] = f[5]; a[4] = f[0]; a[5] = f[4]; break;
		case 'S':a[1] = f[0]; a[5] = f[1]; a[0] = f[4]; a[4] = f[5]; break;
		case 'E':a[0] = f[3]; a[2] = f[0]; a[3] = f[5]; a[5] = f[2]; break;
		case 'W':a[3] = f[0]; a[0] = f[2]; a[5] = f[3]; a[2] = f[5]; break;
		}
	}
	cout << a[0] << endl;
}

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
#define DEBUG freopen("in.txt", "r", stdin);

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

const int N = 1e5 + 5;
ll n, x, ans;
ll a[N];

int main() {
    cin >> n >> x;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        if (i == 0 && a[i] > x) {
            ans += a[i] - x;
            a[i] = x;
        }
        if (i > 0) {
            if (a[i] + a[i - 1] > x) {
                ll d = a[i] + a[i - 1] - x;
                a[i] -= d;
                ans += d;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4436
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
const int N=1e5+5;
ll sum[N],a[N],m;
ll n;

int main()
{
    cin>>n>>m;
    for(ll i=1;i<=n;i++){
        cin>>a[i];
    }
    sort(a+1,a+n+1);
    for(ll i=1;i<=n;i++){
        sum[i]=sum[i-1]+a[i];
    }
    ll l=0,r=2e5+1;
    ll ans,res,cnt;
    while(l<=r){
        ll mid=(l+r)>>1;
        res=cnt=0;
        for(ll i=1;i<=n;i++){
            ll pos=lower_bound(a+1,a+n+1,mid-a[i])-a;
            cnt+=n-pos+1;
            res+=sum[n]-sum[pos-1]+a[i]*(n-pos+1);
        }
        if(cnt>=m){
            ans=mid;
            l=mid+1;
        }
        else r=mid-1;
    }
    printf("%lld\n",res-(cnt-m)*ans);
}


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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define ALPHABET    (26)
#define INF         INT_MAX
#define MOD         (1000000007LL)

using LL  = long long;
// }}}

int main() {
    std::ios::sync_with_stdio(false);
    string o, e;cin >> o >> e;
    int n = o.size()+e.size();
    for(int i=0;i<n;i++){
        if(i%2 == 0){
            cout << o[i/2];
        }else{
            cout << e[i/2];
        }
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
package main

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

// 表計算
func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Scan()
	ary := strings.Split(sc.Text(), " ")
	r, _ := strconv.Atoi(ary[0])
	c, _ := strconv.Atoi(ary[1])

	hsum := make([]int, c+1)
	s := ""
	for i := 0; i < r; i++ {
		sc.Scan()
		ary := strings.Split(sc.Text(), " ")
		rsum := 0
		for j := 0; j < c; j++ {
			v, _ := strconv.Atoi(ary[j])
			rsum += v
			s += ary[j] + " "
			hsum[j] += v
		}
		s += fmt.Sprintf("%v\n", rsum)
		hsum[c] += rsum
	}
	for _, v := range hsum {
		s += fmt.Sprintf("%v ", v)
	}
	fmt.Println(strings.TrimSpace(s))
}



Measured memory_bytes: 8288
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
cin>>n;
string s;
cin>>s;
long long ans=0;
for(int i=0;i<s.size()-2;i++){
    if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C'){
        ans++;
    }
}
cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define per(i, a, b) for(int i = (b) - 1; i >= (a); --i)
#define de(x) cout << #x << " = " << x << endl
#define dd(x) cout << #x << " = " << x << " "
#define pw(x) (1ll<<(x))
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef double db;
typedef vector<int> vi;

int a[111];

int main() {
	std::ios::sync_with_stdio(0);
	std::cin.tie(0);
	int n; cin >> n; n <<= 1;
	rep(i, 1, n + 1) cin >> a[i];
	sort(a + 1, a + 1 + n);
	ll ans = 0;
	for(int i = 1; i < n; i += 2) ans += a[i];
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FO(i,a,b) for (int i = (a); i < (b); i++)

int m4(int c) {
    return ((c%4)+4)%4;
}

int H, W, d;
char col[4] = {'R', 'Y', 'G', 'B'};
int main() {
    scanf ("%d %d %d", &H, &W, &d);
    if (d%2) {
        FO (i,0,H) {
            FO (j,0,W) {
                printf ("%c", col[(i+j)%2]);
            }
            printf ("\n");
        }
        return 0;
    }
    FO (i,0,H) {
        FO (j,0,W) {
            int c1 = i+j;
            int c2 = j-i+1000;
            int c = ((c1/d)+(c2/d)*2)%4;
            printf ("%c", col[c]);
        }
        printf ("\n");
    }
    return 0;
}


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

int main() {

	int money = 700;
	char topping[3];

	for (int i = 0; i < 3; i++) {
		cin >> topping[i];

		if (topping[i] == 'o')money += 100;
	}

	cout << money;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<iomanip>

using namespace std;

typedef struct Shiki{
  double a,b,c;//ax+by=c
  double x,y;
};

Shiki Equation (Shiki, Shiki);

Shiki clean={clean.a=0,clean.b=0,clean.c=0,clean.x=0,clean.y=0};

main(){
  Shiki shiki1,shiki2;
  vector<Shiki> ans;
  int i=0;
  
  while(cin){

    cin>>shiki1.a>>shiki1.b>>shiki1.c>>shiki2.a>>shiki2.b>>shiki2.c;
    ans.push_back(Equation(shiki1,shiki2));
    i++;
    shiki1 = clean;
    shiki2 = clean;
  }
 
  for(int j = 0; j < i-1 ;j++){
    cout<< fixed << setprecision(3) << ans[j].x << " " << ans[j].y << endl; 
  }
}

Shiki Equation (Shiki A, Shiki B){
  Shiki ans,preA;
  int x,y,aa,ba;
  
  preA = A;

  aa = A.a;
  ba = B.a;
  
  A.a *= ba;
  A.b *= ba;
  A.c *= ba;
  
  B.a *= aa;
  B.b *= aa;
  B.c *= aa;
  
  ans.a = 0;
  ans.b = A.b - B.b;
  ans.c = A.c - B.c;
  ans.y = ans.c / ans.b;
  ans.x = (preA.c - preA.b*ans.y)/preA.a;
  
  if((int)(ans.y*1000)%10 >= 5)ans.y += 0.0001;
  if((int)(ans.y*1000)%10 >= 5)ans.x += 0.0001;
  
  return ans;
}

Measured memory_bytes: 1300
n = int(input())
adm = []
for i in range(n):
    x = list(map(int,input().split()))
    tmp = [0]*n
    if x[1] == 0:
        adm.append(tmp)
    else:
        a = x[2:]
        for j in a:
            tmp[j-1] = 1
        adm.append(tmp)
for i in range(len(adm)):
    print(*adm[i])



Measured memory_bytes: 6376
def main():
    from math import gcd
    K = int(input())
    ans = 0
    for a in range(1, K+1):
        for b in range(1, K+1):
            g = gcd(a, b)
            for c in range(1, K+1):
                ans += gcd(g, c)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 70136