akhauriyash/Code-Regression huggingface dataset:
S = list(input())

A = []
c = 0
pre = '<'
for s in S:
    if pre == s:
        c += 1
    else:
        A.append(c)
        c = 1
    pre = s
A.append(c)

ans = 0
if A[0] != 0:
    l = len(A)
    for i in range(l):
        if i%2 == 0:
            if i != l-1:
                ans += max(A[i], A[i+1])
            else:
                ans += A[i]
    for a in A:
        ans += a*(a-1)//2
else:
    l = len(A)
    for i in range(l):
        if i % 2 == 0:
            if i != l-1:
                ans += max(A[i], A[i+1])
            else:
                ans += A[i]
    for a in A:
        ans += a*(a-1)//2
print(ans)

Measured memory_bytes: 9648
import math
import queue

mod = 1e9+7

def swap(a,b):
    return (b,a)

def gcd(a,b):
    if (a<b):
        a,b = swap(a,b)
    if (b==0):
        return a
    else:
        return gcd(b,a%b)

def divisors(a):
    divisors = []
    for i in range(1,int(a**0.5)+1):
        if a%i==0:
            divisors.append(i)
            if i!=a//i:
                divisors.append(a//i)
    return divisors

def main():
    a,b = map(int,input().split())
    x = 1
    ans = 0
    while x<b:
        x += a-1
        ans += 1
    print(ans)
    return

if __name__ == '__main__':
    main()

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

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

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

constexpr ll INF = 1e18 + 10;

ll getS(const std::vector<ll> &v)
{
    ll res = 0;
    for (auto vl : v)
        res += vl;
    return res;
}

ll get(int m, const std::vector<ll> &v)
{
    if (m == 0)
        return 0;

    ll sum = getS(v);

    ll res = -INF, now = 0;

    rep(i, v.size())
    {
        now = v[i];
        for (int j = i + 1; j <= v.size(); ++j)
        {
            if (j - i <= m)
                res = std::max(res, now);
            if (v.size() - (j - i) <= m && (j - i) < v.size())
                res = std::max(res, sum - now);
            if (j != v.size())
                now += v[j];
        }
    }

    return res;

} //m個以下で最大

int main()
{
    int n;

    std::vector<std::vector<ll>> cyc; //n要素あり
    ll k;
    std::cin >> n >> k;

    std::vector<int> ne(n);

    rep(i, n)
    {
        std::cin >> ne[i];
        --ne[i];
    }

    std::vector<ll> cs(n);

    rep(i, n)
            std::cin >>
        cs[i];

    int ni = 0, x = 0;
    std::set<int> notused;
    rep(i, n)
        notused.insert(i);

    cyc.push_back(std::vector<ll>());

    while (!notused.empty())
    {
        if (!notused.count(x))
        {
            ++ni;
            cyc.push_back(std::vector<ll>());
            x = *notused.begin();
        }
        cyc[ni].push_back(cs[x]);
        notused.erase(x);
        x = ne[x];
    }

    /*rep(i, cyc.size())
    {
        rep(j, cyc[i].size())
                std::cerr
            << cyc[i][j] << ' ';
        std::cerr << std::endl;
    }*/

    ll ans = -INF;

    for (const auto &v : cyc)
    {

        ll sum = getS(v);

        //std::cerr << sum << std::endl;

        if (k >= v.size())
        {
            ans = std::max({ans, k / (ll)v.size() * sum + get(k % v.size(), v), ll(k / v.size() - 1) * sum + get(v.size(), v), get(v.size(), v)});
            //std::cerr << v.size() << ' ' << get(v.size(), v) << std::endl;
        }
        else
        {
            ans = std::max(ans, get(k, v));
        }
    }

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

    return 0;
}

Measured memory_bytes: 3972
#include <iostream>
#include <string>

using namespace std;


int main(void) {
    int A, B;
    char op;

    cin >> A >> op >> B;

    if (op == '+') {
        A += B;
    }
    else {
        A -= B;
    }

    cout << A << endl;

    return 0;
}


Measured memory_bytes: 256
S = input()
a = int(S[:2])
b = int(S[2:])
left = 1 <= a <= 12
right = 1 <= b <= 12
if left and right:
    print("AMBIGUOUS")
elif left:
    print("MMYY")
elif right:
    print("YYMM")
else:
    print("NA")


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

ll gcd(ll a, ll b){return b ? gcd(b, a%b):a;}

int main() {
  ll n, X;
  cin >> n >> X;
  vector<ll>sa(n);
  rep(i,n){
    ll x;
    cin >> x;
    sa[i] = abs(X-x);
  }
  int ans = sa[0];
  for (int i = 0; i < sa.size(); ++i){
    ans = gcd(ans, sa[i]);
  }
  cout << ans << endl;
}

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

int asso(int a,int b){
  int k = 1;
  while(k<=b)k*=10;
  return a*k+b;
}

int main(){
  int a[4];
  int n,tmp;
  int num = 0;

  cin >> n;
  for(int i=0;i<n;i++){
    cin >> tmp;
    for(int j=0;j<num;j++){
      if(a[j]>tmp)swap(a[j],tmp);
    }
    if(num<4)a[num++] = tmp;
  }

  vector<int> v;
  for(int i=0;i<num;i++){
    for(int j=0;j<num;j++){
      if(i!=j)v.push_back(asso(a[i],a[j]));
    }
  }
  
  sort(v.begin(),v.end());
  cout << v[2] << endl;
}

Measured memory_bytes: 1220
x = int(input())

def get_prime(n):
    p = [2]
    for i in range(3, n, 2):
        if all(i%j!=0 for j in p):
            p.append(i)
    return p

p = get_prime(x)

if x == 2:
    print(2)
else:
    if x%2 == 0:
        x += 1
    while True:
        for prime in p:
            if x%prime == 0:
                break
        else:
            print(x)
            break
        x += 2


Measured memory_bytes: 44668
//#include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <limits.h>
#include <string>
#include <deque>
#include <cmath>
#include <bitset>

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

#define rip(i, n, s) for (int i = (s);i < (int)( n ); i++)
#define mpa make_pair
#define all(a)

int main(){
	int n; cin >> n;
	vector<int> da(n);
	rip(i,n,0) cin >> da[i];
	int now = 1, ans = 0;
	rip(i,n,0){
		if(now == da[i]) now++; else ans ++;
	}
	if(now == 1){
		cout << -1 << endl;
	}
	else{
		cout << ans << endl;
	}
}

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

#define loop(n, i) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define HERE cout << "HERE: " << __LINE__ << endl;
#define INSP(v) cout << v << " at " << __LINE__ << endl;

using namespace std;
typedef long long ll;


int dfs(int i, int count, int sum, int n, int k, int s) {
     if (count == k) {
         if (sum == s) return 1;
         else return 0;
     } else if (count > k) {
        return 0;
     } else {
         int ans = 0;
         for (int j = i+1; j <= n; j++) {
             ans += dfs(j, count+1, j+sum, n, k, s);
         }
         return ans;
     }
}

int main()
{
    int n,k,s;
    while (cin >> n >> k >> s, n) {
        cout << dfs(0,0,0,n,k,s) << endl;
    }
}

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

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef pair<LL, LL> PLL;
typedef vector<PLL> VPLL;
typedef priority_queue<LL> PQ_DESC;
typedef priority_queue<LL, VL, greater<LL>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;
typedef priority_queue<VL> PQ_DESC_VL;
typedef priority_queue<VL, vector<VL>, greater<VL>> PQ_ASC_VL;
typedef priority_queue<PLL> PQ_DESC_PLL;
typedef priority_queue<PLL, vector<PLL>, greater<PLL>> PQ_ASC_PLL;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
//#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SORT_DESC(c) sort((c).rbegin(),(c).rend())
#define REV(c) reverse((c).begin(), (c).end())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF*(LL)INF;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

LL modpow(LL a, LL n) {
    LL res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

void Main()
{
    int n,k;cin>>n>>k;
    string s;cin>>s;

    LL result = 0;
    queue<int> q;

    if(s[0] == '0'){
        q.push(0);
    }

    LL sum = 0;
    LL num = 1;
    LL shiji = 0;
    REP(i,n-1){
        if(s[i] == s[i+1]){
            num++;
        }
        else{
            sum+=num;
            q.push(num);
            num=1;
            if(s[i]=='0'){
                shiji++;
            }
            if(shiji>k){
                shiji--;
                sum -= q.front();
                q.pop();
                sum -= q.front();
                q.pop();
            }
            result = max(result,sum);
        }
    }
    sum+=num;
    q.push(num);
    if(s[n-1]=='0'){
        shiji++;
    }
    if(shiji>k){
        shiji--;
        sum -= q.front();
        q.pop();
        sum -= q.front();
        q.pop();
    }
    result = max(result,sum);

    cout<<result<<endl;
    
	return;
}

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

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

using namespace std;
typedef long long ll;

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; }

int main()
{
  int P, Q, R;
  cin >> P >> Q >> R;
  vector<int> t(3);
  t[0]=P;
  t[1]=Q;
  t[2]=R;

  sort(t.begin(), t.end());
  cout << t[0]+t[1] << endl;
  
  
  
  
  

  return 0;
}


//cout << setprecision(13);
//next_permutation();
//__gcd();
//reverse();
//set ,tuple ,pair;
//bitset
//vector.find
//vector.count



Measured memory_bytes: 256
#![allow(unused)]

//入力マクロここから
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
//入力マクロここまで

//input
//use std::io::Read;

//collections
//use std::collections::BTreeMap;
//use std::collections::BTreeSet;
//use std::collections::HashMap;
//use std::collections::HashSet;
//use std::collections::VecDeque;

use std::cmp::*;

fn main() {
    input! {
        s: chars,
    }

    let mut z = 0;
    for i in 0..s.len() {
        if i % 2 == 0 && s[i] == '0' {
            z += 1;
        } else if i % 2 != 0 && s[i] == '1' {
            z += 1;
        }
    }

    let mut o = 0;
    for i in 0..s.len() {
        if i % 2 == 0 && s[i] == '1' {
            o += 1;
        } else if i % 2 != 0 && s[i] == '0' {
            o += 1;
        }
    }

    println!("{}", min(z, o))
}


Measured memory_bytes: 4352
<?php
// input
fscanf(STDIN,"%d",$n);
$C = explode(" ",trim(fgets(STDIN)));
// result
$C1 = BubbleSort($C,$n);
$C2 = SelectionSort($C,$n);
echo implode(" ",$C1)."\n";
echo "Stable"."\n";
echo implode(" ",$C2)."\n";
echo (isStable($C1,$C2,$n) ? "Stable\n" : "Not stable\n");

function BubbleSort($C,$n){
    for($i = 0; $i < $n - 1; ++$i){
        for($j = $n - 1; $j > $i; --$j){
            if($C[$j - 1][1] > $C[$j][1]){
                $tmp = $C[$j - 1];
                $C[$j - 1] = $C[$j];
                $C[$j] = $tmp;
            }
        }
    }
    return $C;
}
function SelectionSort($C,$n){
    for($i = 0; $i < $n - 1; ++$i){
        $minj = $i;
        for($j = $i + 1; $j < $n; ++$j){
            if($C[$minj][1] > $C[$j][1]){
                $minj = $j;
            }
        }
        if($i == $minj) continue;
        $tmp = $C[$i];
        $C[$i] = $C[$minj];
        $C[$minj] = $tmp;
    }
    return $C;
}
function isStable($C1,$C2,$n){
    for($i = 0; $i < $n; ++$i){
        if($C1[$i] != $C2[$i]){
            return false;
        }
    }
    return true;
}

Measured memory_bytes: 15488
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>
int p[200000], ans[200001];

int main(void){
  int n, i, max=0;
  scanf("%d",&n);
  for(i=0;i<=n;i++) ans[i]=0;
  for(i=0;i<n;i++){
    scanf("%d",&p[i]);
    ans[p[i]] = ans[p[i]-1]+1;
    if(max<ans[p[i]]) max = ans[p[i]];
  }
  printf("%d\n",n-max);
  return 0;
}

Measured memory_bytes: 1664
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define INF (1<<29)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;


Int all(Int n){//no bb
    Int rr = 1, bb = 1, rb = 0, br = 0;
    for(int i = 1;i < n;i++){
        Int nrr = (rr+rb) % MOD;
        Int nbb = br;
        Int nrb = rr;
        Int nbr = (bb + br) % MOD;
        rr = nrr;
        bb = nbb;
        rb = nrb;
        br = nbr;
    }
    return (rr + rb + br) % MOD;
}

Int tmp[216000];
Int rdp[216000];
Int dp[216000];
void calc(Int n, Int limit){
    dp[0] = 1;
    rdp[0] = 1;
    for(int i = 1;i <= n+1;i++){
        dp[i] = (rdp[i-1] - ((i-limit-1)>=0?rdp[i-limit-1]:0)) % MOD;
        if(dp[i] < 0)dp[i] += MOD;
        rdp[i] = (rdp[i-1] + dp[i]) % MOD;
    }
}

Int solve(Int n, Int limit){
    if(n % 2 == 1)return 0;
    limit = (limit+1) / 2;
    n /= 2;
    Int res = 0;
    calc(n+10, limit);
    for(Int i = 1;i <= limit;i++){
        if(n-i >= 0)res = (res + dp[n-i]*2*i) % MOD;
    }
    return res % MOD;
}

int main(){
    Int n, m;
    string str;
    vector<Int> vec;
    cin >> n >> m;
    cin >> str;
    bool allsame = true;
    for(int i = 0;i < m;i++)allsame &= (str[i] == str[0]);
    if(allsame){
        cout << all(n) << endl;
        return 0;
    }
    for(int i = 0;i < m;i++)vec.push_back(str[i] == str[0]);
    Int l = 0;
    while(vec[l] == 1)l++;
    if(l % 2 == 0)l++;
    Int limit = l;
    l = 0;
    for(int i = 0;i < vec.size();i++){
        if(vec[i] == 1)l++;
        else{
            if(l % 2 == 1)limit = min(limit, l);
            l = 0;
        }
    }
    cout << solve(n, limit) << endl;
    return 0;
}

Measured memory_bytes: 4904
def is_postal_code(a, b, s):
  if len(s.split('-')) != 2:
    return False
  
  x, y = s.split('-')
  return x.isdigit() and len(x) == a and y.isdigit() and len(y) == b
  

A, B = map(int, input().split())
S = input()

if is_postal_code(A, B, S):
  print('Yes')
else:
  print('No')

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define pb push_back
#define fi first
#define se second
const int maxn=1e5+10;
const int mod=1e9+7;
const int inf=0x3f3f3f3f;
int main()
{
	ios::sync_with_stdio(false);cin.tie(0);
	string a;
	int n,k;
	cin>>n>>k>>a;
	a[k-1]+='a'-'A';
	cout<<a<<'\n';
    return 0;
}



Measured memory_bytes: 256
import collections
n = int(input())
v = list(map(int, input().split()))

odd = collections.defaultdict(int)

even = collections.defaultdict(int)

for i in range(n):
    if i % 2 == 0:
        even[v[i]] += 1

    else:
        odd[v[i]] += 1

even = list(even.items())
odd = list(odd.items())

even.sort(key=lambda x: x[1], reverse=True)
odd.sort(key=lambda x: x[1], reverse=True)

if even[0][0] == odd[0][0]:
    if len(even) == 1 and len(odd) == 1:
        print(n // 2)
    elif len(even) == 1:
        print(n - (even[0][1] + odd[1][1]))
    elif len(odd) == 1:
        print(n - (even[1][1] + odd[0][1]))
    else:
        print(min(n - (even[1][1] + odd[0][1]),
              n - (even[0][1] + odd[1][1])))
else:
    print(n - (even[0][1] + odd[0][1]))


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


int main() {
    int l ,r , d;
    cin >> l >> r >> d;
    int sum = 0;
    for (int i = l; i < r+1; i++) {
        if (i % d == 0) {
            sum++;
        }
    }
    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;

signed main(void)
{
	int h, w;
	cin >> h >> w;
	string c[h];
	rep(i, h) cin >> c[i];
	rep(i, h) cout << c[i] << endl << c[i] << endl;
	return 0;
}


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

int main() {
  string s;
  cin >> s;
  if(s.size() == 3){
    if(s[0] == s[2]) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
  }
  if(((s.size()-1)/2)%2 == 0){
    for(int i = 0;i <= (s.size()-1)/4;i++){
      if(s[i] == s[s.size()-1-i] && (s[i] == s[(s.size()-1)/2-1-i] && s[i] == s[(s.size()+3)/2-1+i])) continue;
      cout << "No" << endl;
      return 0;
    }
  }
  else{
    for(int i = 0;i <= (s.size()-1)/4+1;i++){
      if(s[i] == s[s.size()-1-i] && (s[i] == s[(s.size()-1)/2-1-i] && s[i] == s[(s.size()+3)/2-1+i])) continue;
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}


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

int main(){
  int p, q, r;
  cin >> p >> q >> r;
  cout << p + q + r - max({p, q, r}) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>

int main()
{
	char* A = new char[11];
	char* B = new char[11];;
	char* C = new char[11];;

	std::cin >> A;
	std::cin >> B;
	std::cin >> C;

	if (A[strlen(A) - 1] == B[0] &&
		B[strlen(B) - 1] == C[0]) {
		std::cout << "YES" << std::endl;
	}
	else {
		std::cout << "NO" << std::endl;
	}

    return 0;
}



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

#define INF 1e9;

int main(){
  int n;
  while(true){
    cin >> n;
    if(n == 0)
      break;
    
    vector<int> a(n);
    for(int i=0; i<n; i++)
      cin >> a[i];

    int nmin = INF;
    for(int i=0; i<n-1; i++)
      for(int j=i+1; j<n; j++)
        nmin = min(nmin, (int)abs(a[i] - a[j]));

    cout << nmin << endl;
  }
             
  return 0;
}

Measured memory_bytes: 3088
S = input()

import sys

N = len(S)

be = S[:N//2]
af = S[N//2+1:]

if S == ''.join(list(reversed(S))):
    if be == ''.join(list(reversed(be))):
        if af == ''.join(list(reversed(af))):
            print("Yes")
            sys.exit()
            
print("No")

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

int main(void) {
	int h, n; cin >> h >> n;
	vector<int> A(n);
	bool ans = false;
	for (int i = 0; i < n; i++) {
		scanf("%d", &A[i]);	
	}

	sort(A.begin(), A.end(), greater<int>());
	
	for (int i = 0; i < n; i++) {
		h -= A[i];
		if (h <= 0) {
			ans = true;
			break;
		}
	}


	if (ans) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <string.h>

int main(void) {
  int n, i, j; scanf("%d", &n);
  int flag = 1;
  char str[n+1][13];
  for(i = 0; i < n; ++i) {
    scanf("%s", str[i]);
  }
  
  for(i = 1; i < n; ++i) {
    //printf("%c %c\n", str[i-1][strlen(str[i-1])-1], str[i][0]);
    if(str[i-1][strlen(str[i-1])-1] != str[i][0]) { flag = 0; break; }
    for(j = 0; j < i; ++j) {
      if(strcmp(str[j], str[i]) == 0) { flag = 0; break; }
    }
  }
  
  if(flag) { printf("Yes\n"); } else { printf("No\n"); }
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
int main()
{
    int N;
    while(cin>>N)
    {
        int vec[N + 5][3], dp[N + 5][3];

        vector< pair<int,int> > tr;

        tr.push_back(make_pair(1,2));
        tr.push_back(make_pair(0,2));
        tr.push_back(make_pair(0,1));

        for(int i = 0 ; i < N ; i++)
        {
            cin >> vec[i][0] >> vec[i][1] >> vec[i][2];
        }

        dp[0][0]=vec[0][0];
        dp[0][1]=vec[0][1];
        dp[0][2]=vec[0][2];

        for(int i = 1 ; i < N ; i++)
        {
            for(int x=0;x<3;x++)
            {
                pair<int,int> p = tr[x];
                dp[i][x] = vec[i][x] + max(dp[i-1][p.first] , dp[i-1][p.second]);
            }
        }
        int x=0;
        for(int y=0;y<3;y++)
        {
            x=max(x,dp[N-1][y]);
        }
        cout<<x<<'\n';
    }
    return 0;
}


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

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define SUM(x) accumulate(ALL(x), 0)
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MAXR 100000
#define PI acos(-1.0)

int main()
{
  string S; cin >> S;
  ll dx = 0, dy = 0;
  ll n = 0, s = 0, w = 0, e = 0;
  REP(i, SIZE(S)) {
    if (S[i] == 'N') n++;
    else if (S[i] == 'S') s++;
    else if (S[i] == 'W') w++;
    else if (S[i] =='E') e++;
  }

  string ans;
  if (n == 0 && 0 < s) ans = "No";
  else if (s == 0 && 0 < n) ans = "No";
  else if (w == 0 && 0 < e) ans = "No";
  else if (e == 0 && 0 < w) ans = "No";
  // else if ((n - s) % 2 == 0 && (w - e) % 2 == 0) ans = "Yes";
  // else ans = "No";
  else ans = "Yes";

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


Measured memory_bytes: 256
/*-----------------------------------------------,
|  __                                       __   |
| |  |--.-----.---.-.----.----.-----.-----.|  |_ |
| |  _  |  -__|  _  |  __|  __|  -__|  _  ||   _||
| |_____|_____|___._|____|____|_____|   __||____||
|                                   |__|         |
`-----------------------------------------------*/
#include<algorithm>
#include<array>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>
typedef long long ll; typedef long double ld ;using namespace std;
#define INF 1000000000000
#define MOD 10000007
#define ALL(name) (name).begin(),(name).end()
#define REP(counter, limit) for (long long counter = 0; counter < limit; counter++)
int gcd(int a, int b) { if (a % b == 0) { return(b); } else { return(gcd(b, a % b)); } }
int lcm(int a, int b) { return a * b / gcd(a, b); }
bool primenum(int a) { if (a == 1) { return false; }if (a == 2) { return true; }if (a % 2 == 0) { return false; }for (int i = 3; i < sqrt(a) + 1; i += 2) { if (a != i) { if (a % i == 0) { return false; } } }return true; }
struct setupios{setupios(){ios::sync_with_stdio(0);cin.tie(nullptr); /*cout<<fixed<<setprecision(20);*/};}setupios;
int main() {

  string s;
  cin>>s;
  for(int q=0;q<s.size()-1;q++){
    for(int i=q+1;i<s.size();i++){
      if(s[q]==s[i]){
        cout<<"no"<<endl;
        cerr<<"q:"<<q<<" i:"<<i<<endl;
        return 0;
      }
    }
  }
  cout<<"yes"<<endl;

}


Measured memory_bytes: 256
#include <stdio.h>
#include <assert.h>

#define MAX_NAME 10
#define MAX_N 100000
#define MOD 100000

typedef struct{
  char name[MAX_NAME+1];
  int _time;
} Data;

typedef struct{
  int head,tail;
  Data data[MAX_N];
} Queue;

void init(Queue*);
int isEmpty(Queue*);
void push(Queue*,Data);
Data pop(Queue*);

int main(){
  int N,Q,i,total = 0;
  Data data;
  Queue queue;
  scanf("%d %d",&N, &Q);
  for(i = 0 ; i < N ; i++){
    scanf("%s %d",data.name, &data._time);
    push(&queue,data);
  }
  while(!isEmpty(&queue)){
    data = pop(&queue);
    data._time -= Q;
    if(data._time > 0){
      total += Q;
      push(&queue,data);
    }else{
      total += data._time + Q;
      printf("%s %d\n", data.name, total);
    }
  }
  return 0;
}

void init(Queue *q){
  q->head = q->tail = 0;
}

int isEmpty(Queue *q){
  return (q->head == q->tail);
}

void push(Queue *q,Data d){
  q->data[(q->tail++)%MOD] = d;
}

Data pop(Queue *q){
  if(isEmpty(q)){
    assert(0);
  }
  return q->data[(q->head++)%MOD];
}

Measured memory_bytes: 2160
#ifndef VS
#include<bits/stdc++.h>
#endif

using namespace std;
typedef long long LL;

#ifdef BTK
#define DEBUG if(1)
#else
#define CIN_ONLY if(1)
struct cww {cww() {CIN_ONLY{ios::sync_with_stdio(false); cin.tie(0);}}
}star;
#define DEBUG if(0)
#endif

#define ALL(v) (v).begin(),(v).end()
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l, T r){bool a = l>r; if (a)l = r; return a;}
template <typename T>inline bool chmax(T &l, T r){bool a = l<r; if (a)l = r; return a;}
template <typename T>istream& operator>>(istream &is, vector<T> &v){for (auto &it : v)is >> it;return is;}

class range {private: struct I { int x; int operator*() { return x; }bool operator!=(I& lhs) { return x<lhs.x; }void operator++() { ++x; } }; I i, n;public:range(int n) :i({ 0 }), n({ n }) {}range(int i, int n) :i({ i }), n({ n }) {}I& begin() { return i; }I& end() { return n; }};

typedef vector<LL> V;
constexpr LL INF = 1e13;
int main() {
	int N;
	cin >> N;
	vector<LL> a(N);
	cin >> a;
	vector<LL> dp = a;
	vector<int> p(N, -1);
	for (int i : range(N)) {
		for (int j = 2; i - j >= 0; j += 2) {
			if (chmax(dp[i], dp[i - j] + a[i])) {
				p[i] = i - j;
			}
		}
	}
	int id = distance(dp.begin(), max_element(ALL(dp)));
	vector<int> cm;
	LL ret = dp[id];
	for (int i = N - 1; i > id; i--) {
		cm.push_back(i + 1);
	}
	while (p[id] >= 0) {
		int to = p[id];
		while (id - to > 2) {
			cm.push_back(id - 2 +1);
			id -= 2;
		}
		cm.push_back(id - 1 + 1);
		id -= 2;
	}
	for (int i : range(id)) {
		cm.push_back(1);
	}
	cout << ret << endl;
	cout << cm.size() << endl;
	for (int i : cm)cout << i << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int N;
    while(~scanf("%d",&N))
    {
        int i=0,ans=0;
        for(i=1; i<=N; i++)
        {
            if(i*i<=N)
            {
                ans=i*i;
                continue;
            }
            else
                break;
        }
        printf("%d\n",ans);
    }
    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

int main(void)
{

    int i, j, n, q, b, e, k, cnt;
    int A[1000];

    scanf("%d", &n);
    for (i = 0; i < n; i++)
        scanf("%d", A + i);

    scanf("%d", &q);
    for (i = 0; i < q; i++) {
        scanf("%d %d %d", &b, &e, &k);
        cnt = 0;
        for (j = b; j < e; j++)
            if (A[j] == k)
                cnt++;
        printf("%d\n", cnt);
    }

    return 0;
}


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

using namespace std;
int n ;
int tab[200];
int  E[1000001];
int main()
{
    cin >> n ;
    for(int i = 0 ; i<n ; i++)cin>>tab[i];
    E[0]=1;
    int s = 0 ;
    for(int i = 0 ; i<n ; i++){
        for(int j = s ; j>= 0 ; j-- ){
            if(E[j])E[j+tab[i]]=1;
        }
        s+=tab[i];
    }
    for(int j = s ; j>=0 ; j--){
        if(E[j] && j%10){
            cout << j;
            return 0 ;
        }
    }
    cout << 0 ;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
const int N=10005;
int n;
string s[N];
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>s[i];
	int ans=0;
	int A=0,B=0,BA=0;
	for(int i=1;i<=n;i++)
	{
		for(size_t j=1;j<s[i].size();j++)
			if(s[i][j-1]=='A'&&s[i][j]=='B') ans++;
		if(s[i].front()=='B'&&s[i].back()=='A') BA++;
		else if(s[i].front()=='B') B++;
		else if(s[i].back()=='A') A++;
	}
	if(BA>0)
	{
		if(A>0&&B>0) A--,B--,BA--,ans+=2;
		else if(A>0) A--,BA--,ans++;
		else if(B>0) B--,BA--,ans++;
		else BA--;
	}
	ans+=min(A,B)+BA;
	printf("%d",ans);
	return 0;
}

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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'
#define rep(i,n) for(int_fast32_t i = 0; i < ((int_fast32_t)(n)); i++)   // 0-indexed up
#define rep1(i,n) for(int_fast32_t i = 1; i <= ((int_fast32_t)(n)); i++) // 1-indexed up
#define rrep(i,n) for(int_fast32_t i = ((int_fast32_t)(n)-1); i >= 0; i--)  // 0-indexed down
#define rrep1(i,n) for(int_fast32_t i = ((int_fast32_t)(n)); i >= 1; i--)   // 1-indexed down
#define all(x) (x).begin(),(x).end()

using namespace std;

template<typename T>
using vec = vector<T>;
using i32 = int_fast32_t;
using i64 = int_fast64_t;
using u32 = uint_fast32_t;
using u64 = uint_fast64_t;
using ll = long long;
using ld = long double;
using vi = vec<int_fast32_t>;
using vl = vec<int_fast64_t>;
using vld = vec<ld>;
using vii = vec<vi>;
using PII = pair<int_fast32_t, int_fast32_t>;

template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}

const ld Pi = std::acos(-1.0L);
constexpr ll infll = (1LL<<62)-1;
constexpr int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    double START_TIME = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
//    cout << fixed << setprecision(15);

    i32 k, num = 0; cin >> k;
    rep1(i, k) {
        num = (num*10+7)%k;
        if(num == 0) {
            cout << i << '\n';
            return 0;
        }
    }

    cout << -1 << '\n';


//     printf("ElapsedTime: %5.3f ms\n",1000*((clock()-START_TIME)/CLOCKS_PER_SEC));
}


Measured memory_bytes: 3568
#include<bits/stdc++.h>
using namespace std;
int main() {
  int n,l;
  cin >> n >> l;
  int ans=0;
  int temp=l;
  for(int i=0;i<n;i++) {
    if(abs(temp)>abs(l+i)) {
      temp=l+i;
    }
    ans+=l+i;
  }
  cout << ans-temp << endl;
}

Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <queue>
# define MOD 1000000000+7
# define INF 1000000000
#define rep(i,rept)	for(ll i = 0; i<rept;i++)
typedef long long ll;
using namespace std;
unsigned long long int a = 0, b = 0, c = 0, d = 0, e = 0, ans = 0, x = 0, y = 0, z = 0, N = 0, m = 0, maxy = 0, mini = 9999, counter = 0, endp = 0, checker = 0;

std::vector <long long int> vec{}, vecsec{}, vecth{};
long long int iremono[100010], koware[100001];
long long  int iremono2[100001], check[100001], xpo[10000001], ypo[10000001], hei[1000001];
std::vector<std::string>kinds{}, kaku{};
char maze[1000][1000];
int sx, sy;
int gx, gy;
struct karu{
	string name;
	ll score;
	ll number;
};
pair<long long int, long long int> ann[103];
struct karu karuta[103];
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
bool okada = false, okada2 = false;
long long int dp[1000003];
std::string input[103],one,two,three;
char re;
unsigned long long int sa, sb, enda, endb, ab;
int H, W;//はんい
bool qw = false, er = false, ty = false, ui = false;
std::string code;
int main() {
	cin >> a>>b;
	rep(i, a) {
		cin >> iremono[i];
		dp[i] = INF;
	}
	dp[0] = 0;
	for(int i=0;i<a;i++){
		for (int j = 1; j <= b; j++) {
			if (i + j <= a) {
	
				dp[i + j] = min(dp[i + j], dp[i]+abs(iremono[i+j] - iremono[i]));
			
			}
		}
	}
	cout << dp[a-1] << endl;

}


Measured memory_bytes: 5888
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cout << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//#define int long long

void solve() {
	int n; cin >> n;
    string s; cin >> s;
    int m = (int)s.size();
    rep(i, m) {
        int k = s[i] - 'A';
        k += n;
        k %= 26;
        s[i] = ('A' + k);
    }
    cout << s << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}

Measured memory_bytes: 256
N, Q = map(int, input().split())
S = input()

t = [0] * (N+1)

for i in range(N):
    t[i+1] = t[i] + (1 if S[i:i+2] == 'AC' else 0)

for i in range(Q):
    l, r = map(int, input().split())
    print(t[r-1] - t[l-1])

Measured memory_bytes: 7748
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast", "unroll-loops")
#define ll long long 
#define pii pair<int, int>
#define ull unsigned ll
#define f first
#define s second
#define FOR(i,a,b) for (int i=(a); i<(b); i++)
#define REP(i,n) for (int i=0; i<(n); i++)
#define RREP(i,n) for (int i=(n-1); i>=0; i--)
#define ALL(x) x.begin(),x.end()
#define SZ(x) x.size()
#define MNTO(a,b) a = min(a,(__typeof__(a))(b))
#define MXTO(a,b) a = max(a,(__typeof__(a))(b))
#define pb push_back
#define debug(x) cerr<<#x<<" is "<<x<<endl
using namespace std;

// #define int ll

const int maxn = 3e3+5;
const int iinf = 1<<29;
const ll inf = 1ll<<60;
const ll mod = 1e9+7;


void GG(){cout<<"No\n"; exit(0);}

ll ways[maxn];

main(){
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    vector<int> a(3);
    int n; 
    REP(i,3) cin>>a[i]; cin>>n;
    ways[0]=1;
    for (int S : a){
    	REP(i,n+1) {
	    	if (i+S<=n) ways[i+S]+=ways[i];
	    }
    }
    cout<<ways[n]<<endl;


}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <climits>
#define INF INT_MAX;
using namespace std;

int main() {
  int A, B, C, D, E, F;
  cin >> A >> B >> C >> D >> E >> F;
  int m = 100 * A, n = 0;

  for (int a = 0; 100 * A * a <= F; a++) {
    for (int b = 0; 100 * B * b + 100 * A * a <= F; b++) {
      int water = 100 * a * A + 100 * b * B;
      for (int c = 0; water + C * c <= F; c++) {
        for (int d = 0; water + C * c + D * d <= F; d++) {
          int nn = C * c + D * d;
          if (E * (a * A + b * B) < nn)
            break;
          // cout << a << " " << b << " " << c << " " << d << endl;

          if (100 * n * (water + nn) < 100 * nn * m) {
            m = water + nn;
            n = nn;
          }
        }
      }
    }
  }
  cout << m << " " << n << endl;
}


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

#define REP(i,n) for(ll i=0; i<n; i++)
#define REPN(i,n) for(ll i=0; i<n; i++,cout<<"\n")
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod1 1000000007
#define ll long long
#define clr0(arr) memset(arr,0,sizeof(arr))
#define clrval(arr,val) memset(arr,val,sizeof(arr))
using namespace std;

ll dp[100100][3];

ll memo(ll arr[][3], ll n, ll prev){

	if(n<=0)
		return 0;

	if(prev!=-1 && dp[n-1][prev]!=-1)
		return dp[n-1][prev];

	ll tempAns=INT_MIN;

	REP(i,3){
		if(i==prev)
			continue;

		ll val = arr[n-1][i] + memo(arr,n-1,i);
		tempAns=max(tempAns,val);
	}

	if(prev!=-1)
		dp[n-1][prev] = tempAns;
	return tempAns;
}

void solve(){

	ll n;
	cin>>n;

	ll arr[n][3];
	REP(i,n) 
		cin>>arr[i][0]>>arr[i][1]>>arr[i][2];

	clrval(dp,-1);

	cout<<memo(arr,n,-1)<<"\n";
	// cout<<rec(arr,n,-1)<<"\n";

}

int main(){
	// int t;
	// cin>>t;

	// while(t--){
		solve();
	// }

	return 0;
}


Measured memory_bytes: 16100
<?php

class Dice
{
  public $top = 0;
  public $bottom = 0;
  public $north = 0;
  public $east = 0;
  public $south = 0;
  public $west = 0;

  public function toNorth()
  {
    $t = $this->top;
    $this->top = $this->south;
    $this->south = $this->bottom;
    $this->bottom = $this->north;
    $this->north = $t;
  }

  public function toEast()
  {
    $t = $this->top;
    $this->top = $this->west;
    $this->west = $this->bottom;
    $this->bottom = $this->east;
    $this->east = $t;
  }

  public function toSouth()
  {
    $t = $this->top;
    $this->top = $this->north;
    $this->north = $this->bottom;
    $this->bottom = $this->south;
    $this->south = $t;
  }

  public function toWest()
  {
    $t = $this->top;
    $this->top = $this->east;
    $this->east = $this->bottom;
    $this->bottom = $this->west;
    $this->west = $t;
  }

  public function spin()
  {
    $n = $this->north;
    $this->north = $this->west;
    $this->west = $this->south;
    $this->south = $this->east;
    $this->east = $n;
  }

  public function toBottom()
  {
    $this->toNorth();
    $this->toNorth();
  }

  public function toTop($x)
  {
    if ($x == $this->north) $this->toSouth();
    elseif ($x == $this->east) $this->toWest();
    elseif ($x == $this->south) $this->toNorth();
    elseif ($x == $this->west) $this->toEast();
    elseif ($x == $this->bottom) $this->toBottom();
  }

  public function equals($d)
  {
    $n1 = array($this->top, $this->bottom, $this->north, $this->east, $this->south, $this->west);
    $n2 = array($d->top, $d->bottom, $d->north, $d->east, $d->south, $d->west);
    sort($n1);
    sort($n2);
    if ($n1 != $n2) return false;

    $this->toTop($d->top);
    $count = 0;
    while ($this->south != $d->south && $count <= 3) {
      $this->spin();
      $count++;
    }

    if ($this->top == $d->top && $this->bottom == $d->bottom &&
      $this->north == $d->north && $this->east == $d->east &&
      $this->south == $d->south && $this->west == $d->west)
      return true;
    else
      return false;
  }
}

$n = trim(fgets(STDIN));
$dices = array();
for ($i = 0; $i < $n; $i++) {
  $num = explode(" ", trim(fgets(STDIN)));
  array_push($dices, getDice($num));
}

$notEqual = true;
for ($i = 0; $i < $n && $notEqual; $i++)
  for ($j = $i + 1; $j < $n && $notEqual; $j++)
    $notEqual = !$dices[$i]->equals($dices[$j]);

if ($notEqual) echo "Yes\n";
else echo "No\n";

function getDice($n)
{
  $dice = new Dice();
  $dice->top = $n[0];
  $dice->south = $n[1];
  $dice->east = $n[2];
  $dice->west = $n[3];
  $dice->north = $n[4];
  $dice->bottom = $n[5];
  return $dice;
}



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

using ll = long long;
using pii = pair<int, int>;
template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (int i = m; i < (n); i++)
#define ALL(c) (c).begin(), (c).end()

constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }

template <class T, class U>
void chmin(T &t, const U &u) {
    if (t > u) t = u;
}
template <class T, class U>
void chmax(T &t, const U &u) {
    if (t < u) t = u;
}

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "{";
    rep(i, v.size()) {
        if (i) os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

#ifdef LOCAL
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << H;
    debug_out(T...);
}
#define debug(...) \
    cerr << __LINE__ << " [" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif

int main() {
    int N, A, B;
    cin >> N >> A >> B;
    V<int> h(N);
    rep(i, N) cin >> h[i];

    auto ok = [&](ll x) {
        ll t = 0;
        rep(i, N) {
            ll r = max(0ll, h[i] - B * x);
            if (r) {
                t += (r + A - B - 1) / (A - B);
            }
        }
        return t <= x;
    };
    ll lo = 0, hi = TEN(9);

    while (hi - lo > 1) {
        ll m = (hi + lo) / 2;
        if (ok(m)) {
            hi = m;
        } else {
            lo = m;
        }
    }
    cout << hi << endl;

    return 0;
}

Measured memory_bytes: 640
#include <iostream>
using namespace std;
#define MAX 100000

int parent(int i){return i/2;}
int left(int i){return 2*i;}
int right(int i){return 2*i+1;}

int main()
{
    int H, i, A[MAX+1];
    cin >> H;
    for(i=1; i<=H; i++) cin >> A[i];
    for(i=1; i<=H; i++)
    {
        cout << "node " << i << ": key = " << A[i] << ", ";
        if(parent(i) >= 1) cout << "parent key = " << A[parent(i)] << ", ";
        if(left(i) <= H) cout << "left key = " << A[left(i)] << ", ";
        if(right(i) <= H) cout << "right key = " << A[right(i)] << ", ";
        cout << endl;
    }
    return 0;
}


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

typedef long long ll;
typedef long double ld;
#define size(a) int((a).size())
#define present(c, x) (c.find(x) != c.end()) 
#define printVerdict(verdict) cout << (verdict ? "YES": "NO") << '\n'
#define printDecimal(d) printf("%.9f\n", d)
#define inrange(val, start, end) (val >= start && val <= end)
#define var(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

const ll inf = 0x3f3f3f3f;

template <class T1, class T2, class T3> 
void printTuple(tuple<T1, T2, T3> t) { cout << get<0>(t) << " " << get<1>(t) << " " << get<2>(t) << '\n'; }
template <class T1, class T2>
void printPair(pair<T1, T2> p) { cout << p.first << " " << p.second << '\n'; }
template <class T>
void printArray(vector<T> arr) { for (int i = 0; i<size(arr); i++) {cout << arr[i] << " ";} cout << '\n'; } 

int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(0);
	string s; cin >> s;
	if (s[size(s)-1] == 's') s += "es";
	else s += "s";
	cout << s << '\n';
}



Measured memory_bytes: 3668
import java.util.Scanner;

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

	int[] x_ = new int[5];
	int[] y_ = new int[5];

	for(int i = 0; i < 5; i++){
	    x_[i] = scan.nextInt();
	}

	for(int i = 0; i < 5; i++){
	    y_[i] = x_[i] % 10;
	}

	int diff = 10;
	int diff_num = -1;
	for(int i = 0; i < 5; i++){
	    if(diff > y_[i] && y_[i] != 0){
		diff = y_[i];
		diff_num = i;
	    }
	}

	int sum = 0;
	for(int i = 0; i < 5; i++){
	    if(diff_num == i || y_[i] == 0){
		sum += x_[i];
	    }else{
		sum += x_[i]+(10-y_[i]);
	    }
	}

	System.out.println(sum);
    }
}
   


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

#define fi first
#define se second
#define be begin
#define en end
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ALL(a) (a).be() , (a).en()
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)        //repeat n times
#define REP2(i,s,n) for(int (i)=(s);(i)<(n);(i)++)   //repeat from s to n 
#define REPD(i,n) for(int (i)=(n);(i)>=0;(i)--)      //repeat from n to 0
#define REPD2(i,s,e) for(int (i)=(s);(i)>=(e);(i)--) //repeat from s to e
#define RANGE(i,v) for(auto &(i):v)                  //repeat range
#define ASIZE(a) (sizeof(a) / sizeof(a[0]))          //array size

using LL = long long;

template<typename T> using V = vector< T >;
using Vi = V<int>;
using Vs = V<string>;

const int MOD = 1000000007;
const int INF = 1999999999;

const int DX[4]= {-1,0,1,0};
const int DY[4]= {0,-1,0,1};

template<typename T>
T SUM(V<T> v, T init_val=0){return accumulate(ALL(v),T(init_val));}

//Bipartite method : x^n
LL BMPow(int x,int n,int m=0){
    LL ans=1;LL p=x;
    if(m==0){ while(n>0){if(n&1==1){ans*=p;} p*=p; n>>=1;}}
    else{ while(n>0){if(n&1==1){ans=(ans*p)%m;} p=(p*p)%m ;n>>=1;}}
    return ans;
}

//x^-1=x^(m-2) mod m
LL modInv(LL x,int m){return BMPow(x,m-2,m);}

//x! or x! mod m
LL factorial(int x,int m=0){
    LL a=1;
    if(m==0){REPD2(i,x,1){a*=i;}}else{REPD2(i,x,1){a=(a*i)%m;}}
    return a;
}

class Combination{
    V<LL> fact,fact_inv;
    LL mod;
    public:
        Combination(int n,int m): fact(n+1),fact_inv(n+1) {
            mod = m;
            fact[0] = 1;
            for(int i=1; i<=n; i++) fact[i] = (fact[i-1]*i)%mod;
            fact_inv[n] = modInv(fact[n],mod);
            for(int i=n; i>=1; i--) fact_inv[i-1] = (fact_inv[i]*i)%mod;
        }

        LL operator()(int n,int k){
            if(k<0 || k>n) return 0;
            return (((fact[n]*fact_inv[k])%mod)*fact_inv[n-k])%mod;
        }
};

int main(){
    int n,k;
    cin>>n>>k;
    Vi a(n);
    REP(i,n){
        cin>>a[i];
    }

    Combination C(n+1,MOD);

    sort(ALL(a));
    LL max_sum = 0;
    REP2(i,k-1,n){
        max_sum = (max_sum + (C(i,k-1)*a[i]) % MOD) % MOD;
    }

    sort(ALL(a),greater<int>());
    LL min_sum = 0;
    REP2(i,k-1,n){
        min_sum = (min_sum + (C(i,k-1)*a[i]) % MOD) % MOD;
    }

    int ans = (max_sum-min_sum)%MOD;
    if(ans<0){
        ans += MOD;
    }

    cout<<ans<<endl;

    return 0;
}

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

using namespace std;
const int MAXN = 100;
const int MAXK = 1e5 + 10;
int memo[MAXK][MAXN];
vector<int> A;

int minimax(int player, int a, int b){
    return player ? min(a,  b) : max(a, b);
}

int pd(int k, int player){
    if(k == 0) return player;

    if(memo[k][player] != -1)
        return memo[k][player];

    int ans = player;

    for(int a: A){
        if(a <= k)
            ans = minimax(player, ans, pd(k-a, !player));
    }

    return memo[k][player] = ans;
}
int main()
{
    int n, k;
    cin >> n >> k;
    for(int i = 0; i < n; i++){
        int ai;
        cin >> ai;
        A.push_back(ai);
    }
    memset(memo, -1, sizeof memo);
    cout << ( pd(k, 0) ? "First":"Second" ) << "\n";
    return 0;
}


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

int main()
{
    int N, count = 0;
    cin >> N;
    vector<int> A(N);

    for (int i = 0; i < N; i++)
        cin >> A.at(i);

    while (true) {
        int i;
        for (i = 0; i < N; i++) {
            if (A.at(i) % 2 == 0) {
                A.at(i) /= 2;
            } else {
                i = 0;
                break;
            }
        }

        if (i == N) {
            count++;
            continue;
        }

        break;
    }

    cout << count << endl;
}

Measured memory_bytes: 256