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

using namespace std;
using ll = long long;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int a, b, n;
  cin >> a >> b >> n;
  int mx = max(a, b);
  cout << (n + mx - 1) / mx << '\n';
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MAXN 110
#define pii  pair<int, int>
#define pll  pair<long long, long long>
#define ss second
#define ff first
 
using ll = long long;
using namespace std;
const int mod = 1e9 + 7;


int main(){
    ll n, a , b, ans = 0;

    cin >> n >> a >> b;
    vector<ll> v(n);

    for (ll& x: v) cin >> x;

    for (ll i=0; i<n-1; i++){
        ans+= min((v[i+1] - v[i])*a, b);
    }

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

Measured memory_bytes: 1024
#include<stdio.h>
int main(void)
{
	int a[6],i,w,x,j;
	for(i=0;i<6;i++){
		scanf("%d",&a[i]);
	}
	for(i=0;i<3;i++){
		for(j=i+1;j<4;j++){
			if(a[i]<a[j]){
				w=a[i];
				a[i]=a[j];
				a[j]=w;
			}
		}
	}
	if(a[4]>a[5]){
		x=a[0]+a[1]+a[2]+a[4];
	}
	else{
		x=a[0]+a[1]+a[2]+a[5];
	}
	printf("%d\n",x);
	return 0;
}

Measured memory_bytes: 2688
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			String str = sc.nextLine();
			String[] t = str.split("[,. ]"); //区切った単語をすべて配列に入れなおす
			ArrayList<String> l = new ArrayList<>();
			for(String s: t) {              //区切ったできた単語を順にsに入れて扱う
				if(3<=s.length() && s.length()<=6) {
					l.add(s);
				}
			}
			String[] tt = l.toArray(new String[0]);
			System.out.println(String.join(" ", tt));
		}
	}

}




Measured memory_bytes: 26292
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define GET_ARRAY_SIZE(a)   (sizeof(a)/sizeof(a[0]))
#define LL long long
#define VI vector<int>
#define VL vector<LL>
#define VII vector< vector<int> >
#define VLL vector< vector<LL> >
#define VS  vector<string>
#define VSS vector< vector<string> >
#define PII pair<int,int>
#define PIS pair<int,string>
#define PSI pair<string,int>
#define PLL pair<LL,LL>
const LL MOD = 1000000007;
const LL INF = 1e16;
LL facctorialMethod(int k);
int main(){
    string s;
    cin >> s;
    LL count = 0;
    LL count_max = 0;
    LL s_len = s.length();
//    cout << "s_len :" << s_len << endl;
    for(int i = 0; i < 3; i++) {
//        cout << "i1 :" <<  i << endl;
//        cout << "s.substr(i,1) :" << s.substr(i,1) << endl;
        if(s.substr(i,1) == "R"){
            count++;
        }else if(i != s_len-1 && s.substr(i,1) == "S"){
            count_max = max(count,count_max);
//            cout << "count_max :" << count_max << endl;
            count = 0;
        }
        count_max = max(count,count_max);
//        cout << "i2 :" <<  i << endl;
    }
    cout << count_max << endl;


    return 0;
}

LL facctorialMethod(int k){
    int sum = 1;
    for (int i = 1; i <= k; ++i){
        sum *= i;
    }
    return sum;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define MAX_N 100000 + 5
using namespace std;

bool cmp(long long &a, long long &b){
	return a > b;
}

int main(){
	int N;
	long long n[MAX_N];
	cin >> N;
	for(int i = 0; i < N; i++)
		cin >> n[i];
	sort(n, n + N, cmp);
	
	long long ans = 0, res = 0;
	for(int i = 0; i < N; i++){
		if(n[i] != res){
			int cnt = 1;
			for(int j = i + 1; j < N; j++){
				if(n[i] == n[j]) cnt++;
				else break;
			}
			
			if(cnt >= 2){
				if(cnt >= 4)
					ans = max(ans, n[i] * n[i]);
				ans = max(ans, res * n[i]);
				
				res = n[i];
			}
		}
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr double INFD = 1e100;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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; }
// ios::sync_with_stdio(false);
// cin.tie(nullptr);
// ---------------------------------------------------------------------------


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    for(int i=0; i<=100; i++){
        if(N < i*4) break;
        if((N-i*4)%7 == 0){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <functional>
#include <utility>

template <typename T, typename Compare = std::less<T>>
class binaryheap {
public:
    binaryheap() {};

    binaryheap(std::vector<T> vec):data(vec) { build_heap(); }

    void insert(T val) {
        data.push_back(val);
        std::size_t pos = data.size() - 1;
        while(pos > root && Compare()(data[parent(pos)], data[pos])) {
            std::swap(data[parent(pos)], data[pos]);
            pos = parent(pos);
        }
    }

    T maximum() {
        return data.at(root);
    }

    T extract_max() {
        T max_elem = data.at(root);
        data[root] = data.back();
        data.pop_back();
        heapify(root);
        return max_elem;
    }

    std::size_t size() { return data.size(); }

private:
    std::vector<T> data;
    const std::size_t root = 0;
    std::size_t parent(std::size_t node) { return (node - 1) / 2; }
    std::size_t left_child(std::size_t node) { return (node << 1) + 1; }
    std::size_t right_child(std::size_t node) { return (node << 1) + 2; }

    void heapify(std::size_t pos) {
        while (pos < (data.size() >> 1)) {
            std::size_t l = left_child(pos);
            std::size_t r = right_child(pos);
            
            std::size_t largest = pos;
            if (l < data.size() && Compare()(data[largest], data[l])) largest = l;
            if (r < data.size() && Compare()(data[largest], data[r])) largest = r;

            if (largest == pos) break;
            std::swap(data[pos], data[largest]);
            pos = largest;
        }
    }

    void build_heap() {
        for (int pos = (data.size() >> 1) - 1; pos >= 0; --pos) {
            heapify(pos);
        }
    }
};

#include <iostream>
#include <vector>
using namespace std;

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

    vector<binaryheap<int>> que(n, binaryheap<int>());
    while(q--) {
        int k, t; std::cin >> k >> t;
        if(k == 0) {
            int x; cin >> x;
            que[t].insert(x);
        } else if(k == 1) {
            if(que[t].size() > 0) cout << que[t].maximum() << endl;
        } else {
            if(que[t].size() > 0) que[t].extract_max();
        }
    }
}


Measured memory_bytes: 4072
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <utility>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) int((x).size())
#define OUT(x) cout << (x) << endl;
typedef long long ll;
typedef vector<int> V;
typedef vector<vector<int>> VV;
typedef pair<int, int> P;
typedef map<string, int> M;
typedef unordered_map<int, int> HM;
typedef set<int> S;
typedef queue<int> Q;

int main(){
    int n;
    cin >> n;
    V v(n);
    for (int i = 0; i < n; i++)
    {
        cin >> v[i];
    }
    for (int i = 0; i < n; i++)
    {
        int c;
        cin >> c;
        v[i] -= c;
    }
    sort(ALL(v), greater<int>());
    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        if (v[i] > 0)
        {
            ans += v[i];
        }
        else
        {
            break;
        }
    }
    OUT(ans);
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int main(){
  string s;
  cin>>s;
  bool a,b,c,d;
  a=b=c=d=false;
  REP(i,s.size()){
    if(s[i]=='N')a=true;
    if(s[i]=='S')b=true;
    if(s[i]=='E')c=true;
    if(s[i]=='W')d=true;
  }
  if(a^b==1 || c^d==1){
    puts("No");
  }else{
    puts("Yes");
  }
  return 0;
}


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

using namespace std;

int main(int argc, const char *argv[]) {
  int a[32] = {1, 1, 1, 2, 1, 2, 1, 5,  2, 2, 1, 5, 1, 2, 1, 14,
               1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int K;

  cin >> K;
  cout << a[K - 1] << endl;

  return 0;
}


Measured memory_bytes: 888
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>
#include <iomanip>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n;
    while(cin >> n, n){
        cin.ignore();
        vector<map<string, int>> v(26);
        for (int i = 0; i < n; ++i) {
            string A; getline(cin, A);
            stringstream ss; ss << A;
            string s;
            while(ss >> s){
                v[s.front()-'a'][s]++;
            }
        }
        char c;
        cin >> c;
        if(v[c-'a'].empty()) puts("NA");
        else {
            vector<pair<int, string>> ans;
            for (auto &&i : v[c-'a']) {
                ans.emplace_back(-i.second, i.first);
            }
            sort(ans.begin(),ans.end());
            for (int i = 0; i < min<int>(ans.size(), 5); ++i) {
                if(i) putchar(' ');
                cout << ans[i].second;
            }
            puts("");
        }
    }
    return 0;
}


Measured memory_bytes: 3176
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <iomanip>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
typedef long long ll;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};

int main(){
    int n;cin >> n;
    string s;cin >> s;
    string res;
    int k;cin >> k;
    rep(i,n){
        if(s[i]!=s[k-1])res.push_back('*');
        else res.push_back(s[i]);
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
from math import floor,ceil,sqrt
import fractions
from collections import deque
import itertools
import collections
from heapq import *
N,M=map(int,input().split())
flship=[]
for i in range(M):
    s,e=map(int,input().split())
    if s<e:
        flship.append([s-1,e-1])
    else:
        flship.append([e-1,s-1])
flship=list(map(list, set(map(tuple, flship))))
#print(flship)
tree=[[] for _ in range(N)]
for l in flship:
    tree[l[0]].append(l[1])
    tree[l[1]].append(l[0])
#print(tree)
group=[-1]*N
l=[]
for i in range(N):
    d=deque()
    v=i
    if group[v]==-1:
        d.append(v)
        group[v]=i
    while len(d)>0:
        v=d.popleft()
        for j in tree[v]:
            if group[j]==-1:
                group[j]=i
                d.append(j)
    #print(group)
c=collections.Counter(group)
values=list(c.values())	#aのCollectionのvalue値のリスト(n_1こ、n_2こ…)
key=list(c.keys())	#先のvalue値に相当する要素のリスト(要素1,要素2,…)
ans=0
for i in range(len(key)):
    ans=max(ans,values[i])
print(ans)

Measured memory_bytes: 182188
#include<bits/stdc++.h>
using namespace std;
template<class S, class T> inline S max_L(S a,T b){
  return a>=b?a:b;
}
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    putchar_unlocked(c[i]);
  }
}
int N;
int L[10];
int main(){
  int m, s;
  rd(N);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=0;Lj4PdHRW<N;Lj4PdHRW++){
      rd(L[Lj4PdHRW]);
    }
  }
  {
    int KL2GvlyY, Q5VJL1cS;
    if(N==0){
      Q5VJL1cS = 0;
    }
    else{
      Q5VJL1cS = L[0];
      for(KL2GvlyY=1;KL2GvlyY<N;KL2GvlyY++){
        Q5VJL1cS = max_L(Q5VJL1cS, L[KL2GvlyY]);
      }
    }
    m =Q5VJL1cS;
  }
  {
    int cTE1_r3A, e98WHCEY;
    if(N==0){
      cTE1_r3A = 0;
    }
    else{
      cTE1_r3A = L[0];
      for(e98WHCEY=1;e98WHCEY<N;e98WHCEY++){
        cTE1_r3A += L[e98WHCEY];
      }
    }
    s =cTE1_r3A- m;
  }
  if(s > m){
    wt_L("Yes");
    wt_L('\n');
  }
  else{
    wt_L("No");
    wt_L('\n');
  }
  return 0;
}
// cLay varsion 20190715-1

// --- original code ---
// int N, L[10];
// {
//   int m, s;
//   rd(N,L(N));
// 
//   m = max(L(N));
//   s = sum(L(N)) - m;
//   wt( if[s > m, "Yes", "No"] );
// }


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

using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

inline int toInt(string s) {int v; istringstream sin(s);sin>>v; return v;}

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector< vector<int> > Mat;
typedef tuple<int, int, int, int> T;

const int MOD = (int)1e9+7;
const int INF = (int)1e9;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

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

    if(K % 2 == 0){
        cout << (K / 2) * (K / 2) << endl;
    }else{
        cout << (K / 2) * ((K + 1) / 2) << endl;
    }

    return 0;
}

Measured memory_bytes: 256
a=[]
for i in range(5):
  a.append(int(input()))
b=[]
for j in range(5):
  if a[j]%10==0:
    b.append(10)
  else:
    b.append(a[j]%10)
idx=b.index(min(b))
cnt=a[idx]
del a[idx]
for k in range(4):
  if a[k]%10==0:
    cnt+=a[k]
  else:
    cnt+=a[k]+10-(a[k]%10)
print(cnt)
  




Measured memory_bytes: 3064
#!/usr/bin/env python3
import sys


def f(H, W):
    mh = H // 2
    if mh != 0:
        yield mh*W, (H-mh)*W
    mw = W // 2
    if mw != 0:
        yield H*mw, H*(W-mw)

def solve_iter(H: int, W: int):
    for h in range(1, H):
        for s in (tuple([h*W])+s for s in f(H-h, W)):
            yield max(s) - min(s)
    for w in range(1, W):
        for s in (tuple([H*w])+s for s in f(H, W-w)):
            yield max(s) - min(s)

def solve(H: int, W: int):
    return min(solve_iter(H, W))


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    print(solve(H, W))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    #test()
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using ll = long long;
const int INF = 2147483647;
const ll MOD = 998244353;
// const ll INF = 1000000000000000000LL;

int main(){
 int x;
 cin >> x;
 if(x>=30)   cout << "Yes" << endl;
 else cout << "No" << endl;
 return 0;
}

Measured memory_bytes: 3628
//quming
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
const int N=1e5+5;
int n,res;char s[N];
int main(){
	scanf("%d%s",&n,s+1);
	fp(i,1,n)res+=s[i]!=s[i-1];
	printf("%d\n",res);
	return 0;
}

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

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	long long n;
	double m;
	cin >> n >> m;
	int z = (m + 1e-5)*100;
	long long ans = (n*z)/100;
	cout << ans;
}


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

vector<string> v;

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

    for(int i = 0; i < (int)s.size(); i++){
        for(int j = 0; j <= k; j++){
            v.push_back(s.substr(i, j));
        }
    }

    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());
    //for(int i = 0; i < (int)v.size(); i++) cout << v[i] << endl;

    cout << v[k] << endl;
    return 0;
}


Measured memory_bytes: 1660
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define mkp make_pair
#define pr(num) cout << num << "\n"
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define INF 1000000000000000000
#define MOD 1000000007LL
#define MAX 100010
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;


int main(void) {
    ll N;
    cin >> N;
    ll dp[MAX];
    ll i, j;
    for(i=0; i<=N; i++) {
        dp[i]=INF;
    }
    
    dp[0]=0;
    
    for(i=0; i<=N; i++) {
        for(j=1; i+j<=N; j*=6) {
            dp[i+j]=min(dp[i+j], dp[i]+1);
        }
        
        for(j=1; i+j<=N; j*=9) {
            dp[j+i]=min(dp[i+j], dp[i]+1);
        }
        
    }
    
    pr(dp[N]);
    
}

























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

int main() {
    int N;
    cin>>N;
    vector<int> A(N),B(N);
    for (int i = 0; i < N; i++){
        cin>>A[i]>>B[i];
    }
    sort(A.begin(),A.end());
    sort(B.begin(),B.end());
    if(N%2==1){
        int m=(N+1)/2-1;
        cout<<B[m]-A[m]+1<<endl;
    }else{
        int m=N/2-1;
        cout<<B[m]+B[m+1]-A[m]-A[m+1]+1<<endl;
    }

}

Measured memory_bytes: 4816
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
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;
}
bool is_prime(ll n) {
  for (ll i = 2; i*i <= n; i++) {
    if (n%i == 0) return false;
  }
  return n != 1;
}
ll mod_pow(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll res = mod_pow(x*x%mod, n/2, mod);
  if (n & 1) res = res * x % mod;
  return res;
}

int main() {
    ll res, tmp = 0;
    rep(i, 3) {
        ll a;
        cin >> a;
        if (a > tmp) {
            tmp = a;
            res = i;
        }
    }
    char ans = 'A' + res;
    cout << ans << endl;
}


Measured memory_bytes: 3104
#include <iostream>
#include <vector>
using namespace std;
typedef vector<int> vi;
#define rep(i,n) for(int i=0; i<n; i++)
#define reprev(i,n) for(int i=N-1; i>=0; i--)

int main() {
  int N;
  cin >> N;
  vi H(N);
  rep(i,N) {
    cin >> H[i];
  }

  rep(i,N) {
    if(i==0 || H[i-1] < H[i]) {
      H[i]--;
    }
    if(i != 0) {
      if(H[i-1] > H[i]) {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
  
  return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<vector>
#include<unordered_map>
using namespace std;

int parse(string a) {
	int b = 0;
	for (char c : a) {
		b = b * 10 + c - 48;
	}
	return b;
}
int main() {
	int a, b;
	while (cin >> a >> b,a|b) {
		string c = to_string(a);
		vector<int>V;
		unordered_map<int, int>M;
		M[a] = 0;
		V.push_back(a);
		for (int d = 0;; d++) {
			while (c.length() < b)c = "0" + c;
			sort(c.begin(), c.end());
			int k = parse(c);
			reverse(c.begin(), c.end());
			k = parse(c) - k;
			auto p = find(V.begin(), V.end(), k);
			if (p != V.end()) {
				cout << M[*p] << " " << *p << " " << d + 1 - M[*p] << endl;
				break;
			}
			M[k] = d + 1;
			V.push_back(k);
			c = to_string(k);
		}
	}
}

Measured memory_bytes: 3212
#ITP2_1_A Vector

lists = []
n = int(input())

for i in range(n):
    query = list(map(int, input().split()))
    if(query[0] == 0):
        lists.append(query[1])
    elif(query[0] == 1):
        print(lists[query[1]])
    elif(query[0] == 2):
        lists.pop()



Measured memory_bytes: 13360
def check(p,arr,k,n)
    i = 0
    j = 0
    while j < k
        s = 0
        while s +arr[i] <= p
            s +=arr[i]
            i += 1
            if i == n
                return n
            end
        end
        j +=1
    end
    return i
end

def solve(arr,k,n)
    left = 0
    right = 100000 * 100000
    while (right - left > 1)
        mid = (right+left)/2
        v =check(mid,arr,k,n)
        if v >= n
            right = mid 
        else
            left =mid
        end
    end
    return right
end

n, k = gets.split.map(&:to_i)
arr=[]
n.times do 
    obj = gets.to_i
    arr << obj
end

ans = solve(arr,k,n)

puts ans


Measured memory_bytes: 9820
#include <cstdio>

int main() {
  int H, W, K;
  scanf("%d%d%d", &H, &W, &K);
  for(int i = 0; i <= H; i++) {
    auto r0 = i, r1 = H - i;
    for(int j = 0; j <= W; j++) {
      auto c0 = j, c1 = W - j;
      if(r0 * c1 + r1 * c0 == K) {
        puts("Yes");
        return 0;
      }
    }
  }
  puts("No");
  return 0;
}

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

int main() {
  int A;
  cin>>A;
  if(A/100==7||A%100/10==7||A%10==7){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
}


Measured memory_bytes: 3568
#include<bits/stdc++.h>
#define Tp template<typename Ty>
#define Ts template<typename Ty,typename... Ar>
#define Reg register
#define RI Reg int
#define Con const
#define CI Con int&
#define I inline
#define W while
#define N 300
#define X 998244353
#define Inc(x,y) ((x+=(y))>=X&&(x-=X))
using namespace std;
int n,f[N+5][N+5][N+5],g[N+5][N+5][N+5];char s[N+5];
int main()
{
	RI i,j,k;scanf("%s",s+1),n=strlen(s+1);
	for(f[n][0][0]=1,i=n;i;--i) for(j=n-i;~j;--j) for(k=n-i-j;~k;--k)
		Inc(f[i-1][j][k],f[i][j][k]),Inc(f[i-1][j+(s[i+j+k]^48)][k+(s[i+j+k]^49)],f[i][j][k]);
	for(g[1][0][0]=1,i=1;i<=n;++i) for(j=i;~j;--j) for(k=i-j;~k;--k) g[i][j][k]&&
	(
		g[i+1][j][k]=1,i^n&&(g[i+2][j+(s[i]^49)][k+(s[i]^48)]=g[i+2][j+(s[i+1]^49)][k+(s[i+1]^48)]=1),
		j&&(g[i+1][j-1+(s[i]^49)][k+(s[i]^48)]=1),k&&(g[i+1][j+(s[i]^49)][k-1+(s[i]^48)]=1)
	);
	RI t=0;for(i=0;i^n;++i) for(j=n-i;~j;--j) for(k=n-i-j;~k;--k) g[i+j+k+1][j][k]&&Inc(t,f[i][j][k]);
	return printf("%d\n",t),0;
}

Measured memory_bytes: 86780
#include<bits/stdc++.h>
using namespace std;
int bucket[200005];
int main()
{
int n,k,counta=0;
scanf("%d%d",&n,&k);
for(int i=1;i<=n;i++)
{
int input;
scanf("%d",&input);
if(bucket[input]==0)
counta++;
bucket[input]++;
}
long long ans=0;
if(counta>k)
{
vector<int> v;
for(int i=1;i<=n;i++)
if(bucket[i]>0)
v.push_back(bucket[i]);
sort(v.begin(),v.end());
for(int i=0;i<counta-k;i++)
ans+=v[i];
}
printf("%lld\n",ans);
}

Measured memory_bytes: 2168
def sum_start(k):
    return (k-1) * k / 2

def sum_end(n,k):
    return sum_start(n+1) - sum_start(n-k+1)


N,K = map(int, input().split())

total = 0
while((N + 1) >= K):
    start = sum_start(K)
    end = sum_end(N,K)
    total += end - start + 1
    K += 1

print(int(total % (10 ** 9 + 7)))

Measured memory_bytes: 9100
#include <bits/stdc++.h>
using namespace std;
#define rep(i,s,t) for(int i=s;i<t;i++)
#define pii pair<int,int>
#define MAXNUM 1111
char mat[MAXNUM][MAXNUM];
int isused[MAXNUM][MAXNUM];pii q[MAXNUM*MAXNUM];
int dir[4][2]={1,0,0,1,-1,0,0,-1};
int main()
{
    int n,m;scanf("%d%d",&n,&m);
    rep(i,1,n+1)scanf("%s",mat[i]+1);
    int top=0,front=0;
    rep(i,1,n+1)rep(j,1,m+1)if(mat[i][j]=='#')
    {
        isused[i][j]=1;
        q[top++]={i,j};
    }
    while(top!=front)
    {
        pii p=q[front++];
        rep(j,0,4)
        {
            int newi=p.first+dir[j][0],newj=p.second+dir[j][1];
            if(newi<=0||newi>n||newj<=0||newj>m)continue;
            if(isused[newi][newj])continue;
            isused[newi][newj]=isused[p.first][p.second]+1;
            q[top++]={newi,newj};
        }
    }
    int res=0;
    rep(i,1,n+1)rep(j,1,m+1)res=max(res,isused[i][j]);
    printf("%d\n",res-1);
}

Measured memory_bytes: 15616
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#define ll long long
using namespace std;
int N;
vector<ll> A;

ll loop_gcd(int num){
     if(num == N-1){
          return A[num];
     }
     return __gcd(A[num],loop_gcd(num+1));
}
int main(){
     cin >> N;
     A.resize(N);
     for(int i = 0; i < N; i++){
          cin >> A[i];
     } 
     cout << loop_gcd(0) << endl;
     return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define INF 1000000000000
int m, n;
long long dp[505][10005] = { 0 };
int main() {
	cin >> m >> n;
	vector<long long>p(m);
	for (int i = 0; i < m; i++) {
		cin >> p[i];
	}
	sort(p.begin(), p.end());
	reverse(p.begin(), p.end());
	for (int i = 1; i < m; i++) {
		p[i] += p[i - 1];
	}
	long long c[10005] = { 0 }, e[10005] = { 0 };
	for (int i = 1; i <= n; i++) {
		cin >> c[i] >> e[i];
	}
	for (int i = 0; i < 505; i++) {
		for (int j = 0; j < 10005; j++) {
			dp[i][j] = INF;
		}
	}
	dp[0][0] = 0;
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j <= 10000; j++) {
			if (j < c[i]) {
				dp[i][j] = dp[i - 1][j];
			}
			else {
				dp[i][j] = min(dp[i - 1][j], dp[i - 1][j - c[i]] + e[i]);
			}
			//if(dp[i][j]!=INF) cout << dp[i][j] << " ";
		}
		for (int j = m; j >= 0; j--) {
			dp[i][j] = min(dp[i][j], dp[i][j + 1]);
		}
		//cout << "\n";
	}
	long long res = 0;
	for (int i = 1; i <= m; i++) {
		for (int j = i; j <= 10000; j++) {
			res = max(res, p[i - 1] - dp[n][j]);
		}
	}
	cout << res << endl;
	return 0;
}



Measured memory_bytes: 42852
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

template <typename T>
struct Dijkstra {
    using P = pair<T, int>;
    int n;
    T inf;
    vector<T> dist;
    vector<int> rev;
    vector<vector<pair<int, T>>> G;

    Dijkstra(vector<vector<pair<int, T>>> &G_) : G(G_) {
        n   = G.size();
        inf = numeric_limits<T>::max();
    }

    void build(int s) {
        dist.clear();
        dist.resize(n, inf);
        rev.clear();
        rev.resize(n, -1);
        priority_queue<P, vector<P>, greater<P>> q;
        dist[s] = 0;
        q.emplace(dist[s], s);
        while (!q.empty()) {
            P p = q.top();
            q.pop();
            int v = p.second;
            if (dist[v] < p.first)
                continue;
            for (auto &e : G[v]) {
                int u = e.first;
                T c   = e.second;
                if (dist[u] > dist[v] + c) {
                    dist[u] = dist[v] + c;
                    rev[u]  = v;
                    q.emplace(dist[u], u);
                }
            }
        }
    }
    vector<int> get_path(int t) {
        vector<int> path;
        for (; t != -1; t = rev[t])
            path.push_back(t);
        reverse(path.begin(), path.end());
        return path;
    }
};

int main() {
    int n;
    cin >> n;
    vector<vector<pii>> edges(n);
    map<pii, int> idx;
    for (int i = 0; i < n - 1; ++i) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        if (a > b)
            swap(a, b);
        edges[a].emplace_back(b, 1);
        edges[b].emplace_back(a, 1);
        idx[{a, b}] = i;
    }
    int m;
    cin >> m;
    vi u(m), v(m);
    for (int i = 0; i < m; ++i) {
        cin >> u[i] >> v[i];
        u[i]--, v[i]--;
    }
    Dijkstra<int> t(edges);
    vector<bitset<20>> usededges(m, 0);

    for (int i = 0; i < m; ++i) {
        t.build(u[i]);
        vi path = t.get_path(v[i]);
        for (int j = 1; j < (int)path.size(); ++j) {
            int l = path[j - 1];
            int r = path[j];
            if (l > r)
                swap(l, r);
            usededges[i][idx[{l, r}]] = 1;
        }
    }
    ll ret = 0;
    for (int i = 0; i < (1 << m); ++i) {
        int bits        = __builtin_popcount(i);
        bitset<20> used = 0;
        for (int j = 0; j < m; ++j) {
            if (i & (1 << j)) {
                used |= usededges[j];
            }
        }
        int k = used.count();
        ret += (1LL << (n - 1 - k)) * (bits % 2 == 1 ? -1 : 1);
    }
    cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 256
fun main(array: Array<String>) {
    val n = readLine()!!.toInt()
    var a = readLine()!!.split(" ").map { it.toInt() }.toMutableList()
    var ans = 0
    while (true){
        repeat(n) {
            if(a[it] % 2 == 0) {
                a[it] /= 2
            }
            else {
                print(ans)
                return
            }
        }
        ans++
    }
}

Measured memory_bytes: 37816
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <unordered_set>
#include <unordered_map>
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
static const int INF = 1000010000;
static const int MOD = 1000000007;
 
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define SORT(v) sort(v.begin(), v.end());
#define pb push_back
#define mp make_pair
#define np next_permutation
#define pq priority_queue

//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};

int main(){
	int n;
	cin >> n;
	vector<ll> v;
	REP(i, n){
		ll tmp;
		cin >> tmp;
		v.pb(tmp);
	}
	SORT(v);
	ll af = v[n - 1];
	ll ans = 0;
	ll as = 0;
	REP(i, n){
		if(v[i] >= af / 2){
			ll tmp = af - v[i];
			if(as < tmp){
				ans = v[i];
				as = tmp;
			}
		}else{
			if(as < v[i]){
				ans = as = v[i];
			}
		}
	}
	cout << af << " " << ans << endl;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, start, n) for (int i = (int)(start); i < (int)(n); ++i)
static const int INFTY = (1 << 30);
int N, M;
void func()
{
    cin >> N;
    vector<vector<pair<int, int>>> A(N + 1);
    int v[N + 1] = {}; //0が不親切、1が親切
    int ans = 0;       //正直者の数
    int tmp, tmpx, tmpy;
    rep(i, 1, N + 1)
    {
        cin >> tmp;
        rep(j, 0, tmp)
        {
            cin >> tmpx >> tmpy;
            A[i].push_back(make_pair(tmpx, tmpy));
        }
    }
    rep(i, 0, N + 1) //親切な人の数
    {
        rep(j, 1, N - i + 1)
        {
            v[j] = 0;
        }
        rep(j, N - i + 1, N + 1)
        {
            v[j] = 1;
        }
        do
        {
            // rep(j, 1, N + 1)
            // {
            //     cout << v[j] << ' ';
            // }
            // cout << endl;
            bool check = true;
            rep(k, 1, N + 1)
            {
                if (!v[k])
                    continue;
                rep(l, 0, A[k].size())
                {
                    if (v[A[k][l].first] != A[k][l].second)
                    {
                        check = false;
                        break;
                    }
                }
                if (!check)
                    break;
            }
            if (check)
            {
                ans = (i > ans) ? i : ans;
            }
        } while (next_permutation(&v[1], &v[N + 1]));
    }
    cout << ans << endl;
}
int main()
{
    func();
}

Measured memory_bytes: 256
#include <iostream>
#include<stdio.h>
#include<stack>
#include<vector>

using namespace std;
int n,m,f[100003],avail[100003],topo[100003];
vector<int>g[100003];
stack<int>st;

void DFS(int u)
{
    avail[u]=1;
    for(int i=0;i<g[u].size();++i)
    {
        int v=g[u][i];
        if(avail[v]==0)
        {
            DFS(v);
        }
    }
    st.push(u);
}

void DP()
{
    for(int i=1;i<=n;++i)
    {
        f[i]=0;
    }
    for(int i=1;i<=n;++i)
    {
        int u=topo[i];
        for(int j=0;j<g[u].size();++j)
        {
            int v=g[u][j];
            f[v]=max(f[v],f[u]+1);
        }
    }
    int maxx=0;
    for(int i=1;i<=n;++i)
    {
        maxx=max(maxx,f[i]);
    }
    printf("%d",maxx);
}

int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;++i)
    {
        int u,v;
        scanf("%d%d",&u,&v);
        g[u].push_back(v);
    }
    for(int i=1;i<=n;++i)
    {
        if(avail[i]==0)
        {
            DFS(i);
        }
    }
    n=1;
    while(!st.empty())
    {
        topo[n]=st.top();
        st.pop();
        ++n;
    }
    --n;
    DP();
    return 0;
}


Measured memory_bytes: 9296
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
template<class T> void chmin(T &a,const T &b){if(a>b) a=b;}
template<class T> void chmax(T &a,const T &b){if(a<b) a=b;}

ll A,B,N;

ll f(ll x){
  return (A*(x%B))/B-(A-1)*(x/B);
}

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

  cin>>A>>B>>N;

  ll ans=f(min(B-1,N));
  cout<<ans<<endl;

  return 0;
}


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

int main(){
  int N;
  cin >> N;
  int X = N/1.08;
  for(int i=X; i<=X+1; i++){
    int A = i*1.08;
    if(A==N){
      cout << i << endl;
      return 0;
    }
  }
  cout << ":(" << endl;
  return 0;
}

Measured memory_bytes: 256
n = int(input())
abc = 'abcdefghijklmnopqrstuvwxyz'
def sub(l, i):
    if len(l) >= n:
        print(l)
        return
    for k in range(i):
        sub(l + abc[k], i)
    sub(l + abc[i], i + 1)

sub('', 0)
    
    




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

int main() {
  char b;
  cin >> b;
  
  if(b == 'A') cout << "T" << endl;
  else if(b == 'T') cout << "A" << endl;
  else if(b == 'C') cout << "G" << endl;
  else if(b == 'G') cout << "C" << endl;
  
  return 0;
}

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

using namespace std;
typedef unsigned long long ull;


int main(int argc, char const *argv[]) {
    ull H, W, N;
    cin >> H >> W >> N;


    vector<int> a_all(N), b_all(N);
    for (int i = 0; i < N; i++) {
        cin >> a_all[i] >> b_all[i];
    }

    map<pair<int, int>, int> pool;
    for (int i = 0; i < N; i++) {
        int a = a_all[i];
        int b = b_all[i];

        for (int y = a - 1; y <= a + 1; y++) {
            if (y <= 1 || y >= H) continue;
            for (int x = b - 1; x <= b + 1; x++) {
                if (x <= 1 || x >= W) continue;

                auto key = make_pair(y, x);
                auto iter = pool.find(key);
                if (iter != pool.end()) {
                    pool[key] += 1;
                } else {
                    pool[key] = 1;
                }
            }
        }
    }

    vector<ull> count(10, 0);
    for (const auto& item : pool) {
        count[item.second] += 1;
    }
    ull sum = 0;
    for (int i = 0; i < 10; i++) {
        sum += count[i];
    }
    count[0] = (H - 2) * (W - 2) - sum;
    for (int i = 0; i < 10; i++) {
        cout << count[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 57216
n = int(input())
s = input()
ans = 0
i = 0
j = n-1
while i < j:
    if s[i] == 'W' and s[j] == 'R':
        ans += 1
        i += 1
        j -= 1
        continue
    if s[i] == 'R':
        i += 1
    if s[j] == 'W':
        j -= 1
print(ans)

Measured memory_bytes: 9476
#include<bits/stdc++.h>
using namespace std;
string s;
int main() {
  cin >> s;
  int l = s.size();
  if(s[0] == s[l-1]) {
    if((l - 2) % 2)printf("Second\n");
    else printf("First\n");
  }
  else {
    if((l - 2) % 2) printf("First\n");
    else printf("Second\n");
  }
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <list>
#include <iomanip>
#include <queue>
#include <numeric>
#define repl(i, l, r) for (ll i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)

using namespace std;
using ll = long long;
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() {

    ll N, M;
    cin >> N >> M;
    vector<ll> B(N + 1, 1);
    vector<bool> b(N + 1, false);
    
    b[1] = true;

    ll x, y;

    rep(i, M) {
        cin >> x >> y;
        B[x]--;
        B[y]++;
        if (b[x]) {
            b[y] = true;
        }
        if (B[x] == 0) {
            b[x] = false;
        }
    }

    ll ans = 0;

    rep(i, N + 1) {
        if (b[i]) {
            ans++;
        }
    }

    cout << ans;


    return 0;
}


Measured memory_bytes: 3988
// Colored Cubes 
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1259

#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<numeric>
#include<functional>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;

using namespace std;

enum AXIS {X, Y, Z};
const int INF = INT_MAX / 3;
const vector<vector<int>> pattern = {
    {3, 1, 0, 5, 4, 2}, // x????????¢
    {4, 0, 2, 3, 5, 1}, // y????????¢
    {0, 3, 1, 4, 2, 5}  // z????????¢
};

int N;
int ans, max_color;
vector<vector<int>> cubes;

void roll(int n, int axis) {
    vector<int> result;
    vector<int> cube = cubes[n];
    for (int p : pattern[axis]) {
        result.push_back(cube[p]);
    }
    cubes[n] = result;
}

int repaint() {
    int res = 0;
    for (int j = 0; j < 6; ++j) {
        vector<int> counter(max_color);
        for (int i = 0; i < N; ++i) {
            ++counter[cubes[i][j]];
        }
        int most = *max_element(ALL(counter));
        res += N - most;
    }
    return res;
}

void dfs(int n) {
    if (n == N) {
        ans = min(ans, repaint());
        return;
    }
    for (int i = 0; i < 6; ++i) {
        for (int x = 0; x < 4; ++x) {
            dfs(n + 1);
            roll(n, X);
        }
        if (i % 2 == 0) {
            roll(n, Y);
        } else {
            roll(n, Z);
        }
    }
    return;
}

int main() { 
    while (cin >> N) {
        if (N == 0) break;

        map<string, int> converter;
        const function<int(string)> encode = [&](const string &color) -> int {
            if (!converter.count(color)) converter.emplace(color, converter.size());
            return converter[color];
        };

        cubes.assign(4, vector<int>(6, 0));
        for (int i = 0; i < N; ++i) {
            for (int j = 0; j < 6; ++j) {
                string color;
                cin >> color;
                cubes[i][j] = encode(color);
            }
        }

        ans = INF, max_color = converter.size();
        dfs(0);
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3164
$%=<>;
@c=(0,2,5,5,4,5,6,3,7,6)[@a=sort{$a-$b}glob<>];
$M=-//,map($M+=$-=($'<$_?-9:$p[$'-$_]+1)-$M,@c),$p[$']=$M for 1..$%;
$i=(grep$p[$%<$c[$_]?$%:$%-$c[$_]]+1==$p[$%],0..$#a)[-1],$%-=$c[$i],print$a[$i]while$%

Measured memory_bytes: 1152
#include <iostream>
#include <cstdlib>
#include <fstream>
#include <set>
#include <unordered_set>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <map>
#include <unordered_map>
#include <iomanip>
#include <numeric>

using namespace std;

typedef long long ll;

#define forn(i, n) for(int i = 0; i < (int)(n);++i)
#define fore(i, a, b) for(int i = (int)(a); i <= (int)(b); ++i)
#define fi first
#define se second
#define pb push_back
#define pll pair<ll,ll>
#define vi vector<int>
#define vb vector<bool>
#define vvi vector<vi>
#define vpll vector<pll>
#define vll vector<ll>
#define vvll vector<vll>
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()


void fastik() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
}

//ifstream &cin
void solve(){

}

int main() {
    fastik();
    ll n; cin >> n;
    vll d(n);
    forn(i,n) cin >> d[i];
    sort(all(d));
    ll ans = 0 ;
    ll pos = n/2;
    ll prev = pos-1;
    ll cnt = 0;
    if(d[pos] > d[prev]){
        ans += d[pos] - d[prev];
    }
    cout << ans;
}


Measured memory_bytes: 1024
<?php
const BIG_COIN = 500;
const SMALL_COIN = 5;

$amount = (int)trim(fgets(STDIN));

$big_count = floor($amount / BIG_COIN);
$big_amount = BIG_COIN * $big_count;
$amount -= $big_amount;

$small_count = floor($amount / SMALL_COIN);


echo $big_count * 1000 + SMALL_COIN * $small_count;



Measured memory_bytes: 3828
memo=[[-1]*51 for i in range(5)]
def rec(i,n):
    if memo[i][n]!=-1:
        return memo[i][n]
    r=0
    if i==4:
        return 1 if n==0 else 0
    for m in range(10):
        r+=rec(i+1,n-m)
    memo[i][n]=r
    return r
     
while True:
    try:
        n=int(input())
        print(rec(0,n))
    except:
        break

Measured memory_bytes: 7532
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
#include <stack>
#include <iomanip>
#include <limits>
using namespace std;
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;

#define INF 1e+9
#define MAX_V 300

struct edge {
    int to;
    int cost;
};
using P = pair<ll, ll>;

int main(){
  ll d;cin>>d;
  vector<ll> c(26);
  vector<ll> t(d);
  vector<vector<ll>> s(d,vector<ll>(26));
  REP(i,26){cin>>c[i];}
  REP(i,d){
    REP(j,26){
      cin>>s[i][j];
    }
  }
  REP(i,d){cin>>t[i];t[i]--;}
  vector<ll> last(26,-1);
  ll score=0;
  for(int day=0;day<d;day++){
    int contest_type=t[day];
    last[contest_type]=day;
    score+=s[day][contest_type];
    for(int i=0;i<26;i++){
      score=score-c[i]*(day-last[i]);
    }
    cout<<score<<endl;
  }
  return 0;
}

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

int main(){
  string S;
  cin >> S;
  string t="";
  for(int i=0;i<S.size();i++){
    if(S[i]!='x'){
      t+=S[i];
    }
  }
  string r=t;
  reverse(r.begin(),r.end());
  if(r!=t){
    cout << -1 << endl;
    return 0;
  }
  int count =0;
  string R=S;
  reverse(R.begin(),R.end());
  for(int i=0;i<R.size();i++){
    if(R[i]!=S[i]){
      count++;
      if(S[i]=='x'){
        S.insert(S.size()-i,"x");
        R.insert(i,"x");
      }else{
        R.insert(R.size()-i,"x");
        S.insert(i,"x");
      }
    }
  }
    cout << count << endl;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define MP make_pair
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define PLI pair<ll, int>
#define PIL pair<int, ll>
#define STR string
#define Fst first
#define Snd second
#define SHN 1e9
#define LSHN 1e18
using namespace std;
ll n,m;
ll x,y;
ll res=0;
int main()
{
	cin >>n>>m;
	for (ll i=m;i<=n+1;i++)
	{
		ll x=i*(i-1)/2,y=i*(n+n-i+1)/2;
		//cout <<y<<" "<<x<<" ##\n";
		res+=y-x+1;
		res%=(ll)1e9+7;
	}
	cout <<res;
	return 0;
}

Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong();
		long b = sc.nextLong();
		long x = sc.nextLong();
		long sum1 = b / x + 1;
		if(a == 0) {
			System.out.println(sum1);
		} else {
			long sum2 = (a - 1) / x + 1;
			System.out.println(sum1 - sum2);
		}
	}
}


Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a) for(int i=0;i<(a);i++)
const ll MOD=1000000007;

int sum1[303030], sum2[303030];
const int INF=INT_MAX/2;

int main(){
  int N; cin>>N;
  string S; cin>>S;
  rep(i,N){
    if(S[i]=='E') sum1[i+1]=sum1[i]+1;
    else sum1[i+1]=sum1[i];
    if(S[N-1-i]=='W') sum2[N-i]=sum2[N+1-i]+1;
    else sum2[N-i]=sum2[N+1-i];
  }
  int ans=INF;
  rep(i,N){
    ans=min(ans,i-sum1[i]+(N-1-i)-sum2[i+2]);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3076
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> initVec2(size_t n0, size_t n1, T e = T()){
    return vector2<T>(n0, vector<T>(n1, e));
}

template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> initVec3(size_t n0, size_t n1, size_t n2, T e = T()){
    return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}

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

    int ans = 0;
    vector<int> a;
    rep(i, 5){
        int x;
        cin >> x;
        ans += x / 10 * 10;
        if(x % 10 != 0){
            a.push_back(x % 10);
        }
    }
    sort(ALL(a), greater<int>());

    rep(i, SZ(a) - 1){
        ans += 10;
    }
    if(SZ(a) > 0){
        ans += a.back();
    }
    cout << ans << endl;

    return 0;
}


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

mod=10**9+7

B=[0]
for i in range(1,N+1):
    B.append(A[i-1]+B[i-1])

ans=0
for i in range(N-1):
    ans+=A[i]*(B[N]-B[i+1])
    ans%=mod

print(int(ans))

Measured memory_bytes: 31440
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;cin>>N;
  int A=0,B=0;
  vector<int> n(N);
  for(int i=0; i<N; i++){
    cin>>n[i];
  }
  sort(n.begin(),n.end());
  for(int i=1; i<=N; i++){
    if(i%2==0)A+=n[i-1];
    if(i%2==1)B+=n[i-1];
  }
  cout<<abs(A-B)<<endl;
}

Measured memory_bytes: 256