akhauriyash/Code-Regression huggingface dataset:
#include<string>
#include<iostream>
using namespace std;
int main(){
	string card, tmp1, tmp2;
	int sh_place, sh_cnt;
	while(true){
		cin >> card;
		if(card == "-") break;
		cin >> sh_cnt;
		while(0 < sh_cnt--){
			cin >> sh_place;
			tmp1 = card.substr(0,sh_place);
			tmp2 = card.substr(sh_place);
			card = tmp2 + tmp1;
		}
		cout << card << endl;
	}
	return 0;
}

Measured memory_bytes: 1216
#include <algorithm>
#include <array>
#include <bitset>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using namespace std;

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15);
  }
} initializer;

template<typename T> istream& operator>>(istream &s, vector<T> &v) {
  for (T &t : v) s >> t;
  return s;
}

template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
  for (const T &t : v) s << t << endl;
  return s;
}

int main() {
  int n, r = 0;
  cin >> n;
  vector<int> a(n);
  cin >> a;
  for (int i = 1; i < n; ++i) {
    if (a[i - 1] == a[i]) {
      a[i] = -1;
      ++r;
    }
  }
  cout << r << endl;
}



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

using namespace std;

int main()
{
	string s;
	cin >> s;
	string ans = "";
	for (int i = 0; i < s.length(); i++) {
		switch (s[i]) {
		case '0':
			ans += '0';
			break;
		case '1':
			ans += '1';
			break;
		default:
			if (!ans.empty()) {
				ans.pop_back();
			}
			break;
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
using namespace std;
double in, ans;
int sz;
int main(){
  cin>>sz;
  for(int i = 1; i<=sz;i++){
    cin>>in;
    in=1.0/in;
    ans+=in;
  }
  cout<<fixed<<setprecision(8)<<1.0/ans;
  }

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

using namespace std;

#define all(v)				((v).begin()), ((v).end())
#define allr(v)				((v).rbegin()), ((v).rend())
#define sz(v)				((int)((v).size()))
#define ll long long
#define pb					push_back
#define fIO ios_base::sync_with_stdio(0);cin.tie(0);

const ll oo = 1e8;
const double pi = 3.1415926535897;


const double EPS = (1e-7);
int dcmp(double x, double y) {	return fabs(x-y) <= EPS ? 0 : x < y ? -1 : 1;	}


typedef vector<int>                vi;
typedef vector<pair<int,int>>      vii;
typedef vector<ll>                 vll;
typedef vector<double>             vd;
typedef vector< vi >               vvi;
typedef vector< vd >               vvd;
typedef vector<string>             vs;
typedef pair<int, int>             pii;

/**
    * PLEASEEE READDD PROBLEEEM CARFULLY ****
    * Always check for OVERFLOW ll vs int
    * Always check for array bounds
    * Check for function return
    * READ OUTPUT SECTION AGAIN!!!
**/

struct edge{
    int from, to, w;

    edge(){}
    edge(int x, int y, int we): from(x), to(y), w(we){}

    bool operator < (const edge &rhs) const{
        return w > rhs.w;
    }

};

int main(){
    fIO
//    freopen("", "r", stdin);
//    freopen("", "w", stdout);

    for(int i = 1; i <= 5; i++) {
        int a;
        cin >> a;
        if(a == 0) return cout << i, 0;
    }

}








Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pi 3.141592653589793238
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MOD 1000000007


void solve()
{
		ll n,l,cnt=0;
		cin>>n>>l;
        // ll cnt=0;
        for(ll i=1;i<=n;i++){
                cnt+=l+i-1;
        }
        if(n==1){
                cout<<0<<endl;
                return;
        }
        ll ans=-100000;
        for(ll i=1;i<=n;i++)
        {
                ll c=cnt-l+1-i;
                if(abs(c-cnt)<abs(cnt-ans)){
                        ans=c;
                }
        }
        cout<<ans<<endl;
    return;
}

int main()
{
        fast;
        ll q;
        q=1;
        // cin>>q;
        while(q--)
        	solve();
        
        return 0;
}

Measured memory_bytes: 3592
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int dx[] = { -1, 0, 1, 0 }; const int dy[] = { 0, 1, 0, -1 };

struct UnionFind {
	vector<int> v;
	UnionFind(int n) : v(n)  { for (int i = 0; i < n; i++) v[i] = i; }
	int  find(int x)         { return v[x] == x ? x : v[x] = find(v[x]); }
	void unite(int x, int y) { v[find(x)] = find(y); }
};

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a + b == c || a + c == b || c + b == a)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

Measured memory_bytes: 256
import java.io.PrintWriter

fun main(args: Array<String>) {
    val (n, k, c) = readLine()!!.split(' ').map { it.toInt() }
    val s = readLine()!!

    fun f(s: String): IntArray {
        val list = mutableListOf<Int>()
        var i = 0
        while (i < n && list.size < k) {
            if (s[i] == 'o') {
                list.add(i)
                i += c + 1
            } else {
                i++
            }
        }
        return list.toIntArray()
    }

    val l = f(s)
    val r = f(s.reversed())
    for (i in r.indices) r[i] = n - r[i] - 1

    val lastL = IntArray(n + 1) { -1 }
    for (i in 0 until k) lastL[l[i] + 1] = i
    for (i in 0 until n) if (lastL[i + 1] == -1) lastL[i + 1] = lastL[i]

    val lastR = IntArray(n + 1) { -1 }
    for (i in 0 until k) lastR[r[i]] = i
    for (i in n - 1 downTo 0) if (lastR[i] == -1) lastR[i] = lastR[i + 1]

    val pw = PrintWriter(System.out)

    for (i in 0 until n) {
        if (s[i] == 'x') continue

        val li = lastL[i]
        val ri = lastR[i + 1]

        var cnt = 0
        cnt += li + 1
        cnt += ri + 1
        if (li != -1 && ri != -1 && r[ri] - l[li] <= c) cnt--

        if (cnt == k - 1) println(i + 1)
    }

    pw.flush()
}


Measured memory_bytes: 58300
#include<bits/stdc++.h>
using namespace std;
 
ostream& operator<<(ostream &out, string str) {
	for(char c : str) out << c;
	return out;
}
 
template<class L, class R> ostream& operator<<(ostream &out, pair<L, R> p) {
	return out << "(" << p.first << ", " << p.second << ")";
}
 
template<class T> auto operator<<(ostream &out, T a) -> decltype(a.begin(), out) {
	out << "{";
	for(auto it = a.begin(); it != a.end(); it = next(it))
		out << (it != a.begin() ? ", " : "") << *it;
	return out << "}";
}
 
void dump() { cerr << "\n"; }
template<class T, class... Ts> void dump(T a, Ts... x) {
	cerr << a << ", ";
	dump(x...);
}

#ifdef DEBUG
#  define debug(...) cerr << "[" #__VA_ARGS__ "]: ", dump(__VA_ARGS__)
#else
#  define debug(...) false
#endif
 
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define ST first
#define ND second
 
template<class T> int size(T && a) { return a.size(); }
 
using LL = long long;
using PII = pair<int, int>;

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

	int n, m;
	cin >> n >> m;

	vector<vector<char>> plane(n, vector<char>(m));
	REP(i, n) REP(j, m) {
		cin >> plane[i][j];
	}

	int inf = 1e9;
	vector<vector<int>> dst(n, vector<int>(m, inf));
	dst[0][0] = (plane[0][0] == '#');
	deque<PII> Q = {{0, 0}};

	vector<int> dx = {0, +1};
	vector<int> dy = {+1, 0};

	while(!Q.empty()) {
		PII v = Q.front();
		Q.pop_front();

		REP(dir, 2) {
			int x = dx[dir] + v.ST;
			int y = dy[dir] + v.ND;
			if(x < n && y < m) {
				int cost = (plane[x][y] == '#' && plane[v.ST][v.ND] == '.');
				if(dst[x][y] > dst[v.ST][v.ND] + cost) {
					dst[x][y] =  dst[v.ST][v.ND] + cost;
					if(cost) Q.emplace_back(x, y);
					else Q.emplace_front(x, y);
				}
			}
		}
	}

	REP(i, n) debug(i, dst[i]);

	cout << dst[n - 1][m - 1] << "\n";
}


Measured memory_bytes: 384
///////////////////////////////////////////
//root@NULLCT$(☝ ՞ਊ ՞)☝  << "Be accept!!"//
///////////////////////////////////////////
//#define BOOST
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <cctype>    // isupper, islower, isdigit, toupper, tolower
#include <cstdint>   // int66_t, int*_t
#include <cstdio>    // printf
#include <deque>     // deque
#include <iomanip>   //setfill(char)
#include <ios>       //left,right
#include <iostream>  // cout, endl, cin
#include <map>       // map
#include <queue>     // queue, priority_queue
#include <set>       // set
#include <stack>     // stack
#include <string>    // string, to_string, stoi
#include <tuple>     // tuple, make_tuple
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <utility>       // pair, make_pair
#include <vector>        // vector
#ifdef BOOST
#include <boost/multiprecision/cpp_int.hpp> // cpp_int
using namespace boost::multiprecision;
#endif
#define rep(i, n) for (int i = 0; i < n; i++)
using ll = long long;
using namespace std;
int setup(void) { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); return 0; }
int lenght(char* str) { int i = 0; while (str[i])i++; return i; }
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); }
int iinput(void) { int a = 0; cin >> a; return a; }
int dinput(void) { double a = 0; cin >> a; return a; }
string sinput(void) { string a = ""; cin >> a; return a; }
int kuriup(double a) { int b = int(a); if (a != b) { return b + 1; } else { return b; } }
int kuridown(double a) { int b = int(a); return b; }
int run(void);
int main() { setup(); run(); return 0; }
/////////////////////////////////////////////////////////////////////////////////////////
int run(void) {

  int a,b,m;
  cin>>a>>b>>m;
  vector<int> arei(a);
  vector<int> bden(b);
  int nowaribikirei=200000;
  int nowaribikiden=200000;
  for(int i=0;i < a;i++){
    cin>>arei[i];
    nowaribikirei=min(nowaribikirei,arei[i]);
  }
  for(int i=0;i < b;i++){
    cin>>bden[i];
    nowaribikiden=min(nowaribikiden,bden[i]);
  }
  int ans=nowaribikirei+nowaribikiden;
  int xyc[100000][3];
  for(int i=0;i < m;i++){
    cin>>xyc[i][0]>>xyc[i][1]>>xyc[i][2];
    ans=min(ans,(arei[xyc[i][0]-1]+bden[xyc[i][1]-1])-xyc[i][2]);
  }
  cout<<ans<<endl;



  return 0;
}


Measured memory_bytes: 2176
#include <iostream>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <queue>
#include <memory>
#include <algorithm>
#include <map>
#include <stack>
#include <vector>
#include <string>
#include <cstring>
#include <functional>
#include <cassert>
using namespace std;

#define MOD 1000000007

int n;
string s;
long long dp[13][100100];

int main() {
	cin >> s;
	n = s.length();
	if (s[0] == '?') {
		for (int i = 0; i <= 9; ++i) dp[i][0] = 1;
	} else {
		dp[s[0]-'0'][0] = 1;
	}
	for (int i = 1; i < n; ++i) {
		if (s[i] == '?') {
			for (int r = 0; r <= 12; ++r) {
				for (int d = 0; d <= 9; ++d) {
					int rr = (r*10 + d) % 13;
					dp[rr][i] = (dp[rr][i] + dp[r][i-1]) % MOD;

				}
			}
		} else {
			int d = s[i] - '0';
			for (int r = 0; r <= 12; ++r) {
				int rr = (r*10 + d) % 13;
				dp[rr][i] = (dp[rr][i] + dp[r][i-1]) % MOD;
			}
		}
	}
	cout << dp[5][n-1] << endl;

    return 0;
}

Measured memory_bytes: 10624
h, w = map(int, input().split())
grid = [[1 if i == "#" else 0 for i in input()] for _ in range(h)]
seen = [[0] * w for _ in range(h)]
DX = (0, 1, 0, -1)
DY = (1, 0, -1, 0)
ans = 0


def dfs(X, Y, cnt):
    todo = [(X, Y)]
    seen[X][Y] = cnt
    black = 0
    white = 1
    while todo:
        x, y = todo.pop()
        now = grid[x][y]
        for dx, dy in zip(DX, DY):
            nx = x + dx
            ny = y + dy
            if nx < 0 or ny < 0 or nx >= h or ny >= w:  # インデックスが範囲外ならだめ
                continue
            if seen[nx][ny] == cnt or now == grid[nx][ny]:  # 既に見ていたり、白-白、黒-黒ならばだめ
                continue
            if 1-now:  # 現在位置が白色の場合
                black += 1
            else:
                white += 1
            seen[nx][ny] = cnt
            todo.append((nx, ny))
    return black*white


cnt = 1
for i in range(h):
    for j in range(w):
        if grid[i][j] or seen[i][j]:
            continue
        ans += dfs(i, j, cnt)
        cnt += 1

print(ans)


Measured memory_bytes: 13248
N = int(input())
s = [input() for _ in range(N)]

Mx,Ax,Rx,Cx,Hx=0,0,0,0,0

for n in range(N):
  if   s[n][0] =="M":
    Mx += 1
  elif s[n][0] =="A":
    Ax += 1
  elif s[n][0] =="R":
    Rx += 1
  elif s[n][0] =="C":
    Cx += 1
  elif s[n][0] =="H":
    Hx += 1

MAR = Mx * Ax * Rx
MAC = Mx * Ax * Cx
MAH = Mx * Ax * Hx
MRC = Mx * Rx * Cx
MRH = Mx * Rx * Hx
MCH = Mx * Cx * Hx

ARC = Ax * Rx * Cx
ARH = Ax * Rx * Hx
ACH = Ax * Cx * Hx

RCH = Rx * Cx * Hx

print(MAR+MAC+MAH+MRC+MRH+MCH+ARC+ARH+ACH+RCH)

Measured memory_bytes: 9776
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdlib.h>

using namespace std;

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

  vector<int> t;

  for(int i=0;i<2*n;i++){
    int temp;
    cin >> temp;
    t.push_back(temp);
  }
  
  sort(t.begin(),t.end());
  
  int ans = 0;

  for(int i=0;i<n;i++){
    int a = t[2*i];
    int b = t[2*i+1];
    if(a<b){
      ans+=a;
    }else{
      ans+=b;
    }
  }
  cout << ans << endl;
        return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python

def main():
    s = int(input())
    if s <= 10 ** 9:
        x1 = s
        y2 = 1
        y1 = 0
        x2 = 0
    elif s < 10 ** 18:
        u, d = divmod(s, 10**9)
        x1 = u + 1
        y2 = 10 ** 9
        y1 = 10 ** 9 - d
        x2 = 1
    else:
        x1 = 10 ** 9
        y2 = 10 ** 9
        y1 = 0
        x2 = 0

    print(0, 0, x1, y1, x2, y2)

if __name__ == '__main__':
    main()


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

int main() {
  string s;
  int n,f=0,r[2];
  
  cin >> n;
  for(int i=1;i<=n;i++){
    cin >> s[i];
  }
  
  for(int t=1;t<=n;t++){
    r[1]=0;
    r[2]=0;
    for(int u=0;u<=t-1;u++){
      if(s[t]==s[u]){
        r[1]=1;
      }
      else{
        r[2]=1;
      }
    }
    
    if(r[1]==0&&r[2]==1){
      f++;
    }
    else{
      f=f;
    }
  }
    
    if(f==3){
      cout << "Three" << endl;
    }
    else if(f==4){
      cout << "Four" << endl;
    }
  else if(f==2){
    cout << "Two" << endl;
  }
  else{
    cout << "One" << endl;
  }
  
}

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

int main(){
  int A,B ;
  cin >> A >> B ;
  if(A == 1)
    A =14 ;
  if(B == 1)
    B = 14;
  if(A > B)
    cout <<"Alice" << endl;
  else if (A < B)
    cout <<"Bob" <<endl;
  else
    cout <<"Draw" <<endl;
}


Measured memory_bytes: 256
// Problem : B - Crane and Turtle
// Contest : AtCoder - AtCoder Beginner Contest 170
// URL : https://atcoder.jp/contests/abc170/tasks/abc170_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//mst,pq,mp,st,q
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define all(x) begin(x),end(x)

int mod = 1e9+7;
int inf = 4e18;
const int N = 5e5+5;
		
signed main()
{
    io
    int tt = 1;
    //cin>>tt;
    while(tt--)
    {
		int x,y;
		cin>>x>>y;
		if(y>4*x or y<2*x)
		{
			cout<<"No";
			return 0;
		}
		if((-y+4*x)>=0 and (-y+4*x)%2==0)
		cout<<"Yes";
		else
		cout<<"No";		
    }
    return 0;
}


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

int main() {
    int a,b,c;cin>>a>>b>>c;
    if(b/a>c)cout<<c<<endl;
    else cout<<b/a<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int next[200001];
int prev[200001]; 
int main(){
	int N, M, Q; int a, q; int i, j, p = 0, r = 0;
	scanf("%d %d %d", &N, &M, &Q);
	for (i = 0; i < N; i++){
		next[i] = (i + 1) % N;
		prev[i] = (i + N - 1) % N;
	}
	for (i = 0; i < M; i++){
		scanf("%d", &a);
		for (j = 0; j < a; j++) p = a % 2 == 1 ? prev[p] : next[p];
		next[prev[p]] = next[p];
		prev[next[p]] = prev[p];
		r = next[p];
		next[p] = -1;
		prev[p] = -1;
		p = r;
	}
	for (i = 0; i < Q; i++){
		scanf("%d", &q);
		if (next[q] != -1) printf("1\n");
		else printf("0\n");
	}

	return 0;
}

Measured memory_bytes: 2572
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  // AGC002B - Box and Ball
  // 1からNまでの番号が振られたN個の箱
  // 1番目の箱には赤いボール、2からN番目の箱には白いボールが1個ずつ入っている
  // M回操作、x番目の箱からボールを1個選びy番目の箱に移動
  // 赤いボールが入っている可能性のある箱の数を求める
  // 基本はbool型の配列を準備して、論理和を求める
  // ただし、箱が空っぽになった場合は元の箱をfalseにしなければならない
  // 個数管理の配列も準備する
  int N, M;
  cin >> N >> M;
  vector<int> x(M);
  vector<int> y(M);
  REP(i, M){
    cin >> x.at(i) >> y.at(i);
  }
  // bool型の配列（赤いボールが入っている可能性があればtrue
  vector<bool> red(N+1, false);
  red[1] = true;
  // 個数管理の配列
  vector<int> cnt(N+1, 1);
  REP(i, M){
    red[y.at(i)] = red[x.at(i)] || red[y.at(i)];
    cnt[y.at(i)]++;
    cnt[x.at(i)]--;
    if(cnt[x.at(i)] == 0) red[x.at(i)] = false;
  }
  int ans = 0;
  REP(i, N+1){
    ans += red.at(i);
  }
  cout << ans << endl;
}


Measured memory_bytes: 1408
/* BISMILLAHIR RAHMANIR RAHIM */
#include<bits/stdc++.h>
using namespace std;
#define ll        long long
#define ull       unsigned long long
#define sd(x)     scanf("%lf", &x)
#define l0(i,n)   for(ll i=0; i<n; i++)
#define MAX       100005
#define maxn 	  200005
#define pb 		  push_back
#define mk 		  make_pair
#define endl	  "\n"
#define INF 	  1000000000
#define MOD		  1000000007
#define imie(...) "[" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "


int main()
{
	int n;
	cin >> n;
	vector<int> hap[n+5];
	vector<int> dp[n+5];
	for (int i=0 ; i<n ; i++) 
	{
		int a,b,c;
		cin >> a >> b >> c;
		hap[i].pb(a);
		hap[i].pb(b);
		hap[i].pb(c);
		dp[i].pb(0);
		dp[i].pb(0);
		dp[i].pb(0);
	}
	//memset(dp,0,sizeof(dp));
	dp[0][0] = hap[0][0];
	dp[0][1] = hap[0][1];
	dp[0][2] = hap[0][2];
	for(int i = 1; i < n; i++){
			dp[i][0] = hap[i][0]+max(dp[i-1][1], dp[i-1][2]);
			dp[i][1] = hap[i][1]+max(dp[i-1][0], dp[i-1][2]);
			dp[i][2] = hap[i][2]+max(dp[i-1][0], dp[i-1][1]);
	}
	int ans = *max_element(dp[n-1].begin(),dp[n-1].end());
//	for (int i=0 ; i<n ; i++)
//	{
//		ans = max(ans,dp[n-1][i]);
//	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 14504
while True:
    try:
        Clst = list(map(int, input().split()))
        mynum = 21 - (Clst[0] + Clst[1])
        a = list(range(1, min(11, mynum)))

        for i in Clst:
            if i in a:
                a.remove(i)
        
        if len(a)/7 >= 0.5 :
            print('YES')
        else:
            print('NO')


    except EOFError:
        break


Measured memory_bytes: 5608
n,m = map(int,input().split())
h = list(map(int,input().split()))
h_c = [0 for i in range(n)]
a=[]
b=[]
for i in range(m):
    a_1,b_1 = list(map(int,input().split()))
    a.append(a_1)
    b.append(b_1)

for i in range(m):
    if h[a[i]-1] <= h[b[i]-1]:
        h_c[a[i]-1]+=1
    if h[b[i]-1] <= h[a[i]-1]:
        h_c[b[i]-1]+=1


print(h_c.count(0))


    



Measured memory_bytes: 90616
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main()
{
    int n;
    cin >>n;
    vector<int> a;
    for(int i=0;i<n;i++){
        int hoge;
        cin>>hoge;
        a.push_back(hoge);
    }
    int default_=abs(a[0])+abs(a[n-1]);
    for(int i=0;i<n-1;i++){
        default_+=abs(a[i]-a[i+1]);
    }
    cout<<default_-abs(a[0])-abs(a[0]-a[1])+abs(a[1])<<endl;
    for(int i=0;i<n-2;i++){
        cout<<default_-abs(a[i+1]-a[i])-abs(a[i+2]-a[i+1])+abs(a[i+2]-a[i])<<endl;
    }
    cout<<default_-abs(a[n-1])-abs(a[n-1]-a[n-2])+abs(a[n-2])<<endl;
    return 0;
}

Measured memory_bytes: 1784
import scala.io.StdIn.readLine

object Main extends App {

  val (n, y) = readLine().split(" ") match {
    case Array(n, y) => (n.toInt, y.toLong)
  }
  val p = for {
    a <- (0 to n).view
    na = n - a
    b <- (0 to na).view
    c = na - b
    if 10000 * a + 5000 * b + 1000 * c == y
  } yield (a, b, c)

  val (a, b, c) = p.headOption.getOrElse((-1, -1, -1))
  println(s"$a $b $c")
}


Measured memory_bytes: 51108
#include <stdio.h>
#include <stdlib.h>
#define VMAX 100000
#define MAX 200000001

int main (){
  unsigned short *A,*B;
  int C[VMAX+1]={0};
  int n,i,j;
  scanf("%d",&n);

  A=malloc(sizeof(short)*n+1);
  B=malloc(sizeof(short)*n+1);

  //for(i=0;i<=VMAX;i++) C[i]=0;
  for(i=1;i<=n;i++) {
    scanf("%hu", &A[i]);
    C[A[i]]++;
  }
  for(i=1;i<=VMAX;i++) C[i]=C[i]+C[i-1];  
  for(j=1;j<=n;j++) {
    B[C[A[j]]]=A[j];
    C[A[j]]--;
  }
  for(i=1;i<=n;i++) {
    if(i>1)  printf(" ");
    printf("%d", B[i]);
  }
  printf("\n");
  return 0;
}


Measured memory_bytes: 9940
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <functional>
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
class UF{
    public:
        int par[100000];
        int ran[100000];

        UF(int n){
            for(int i = 0;i < n;i++){
                par[i] = i;
                ran[i] = 0;
            }
        }

        int find(int x){
            if(par[x] == x)return x;

            else return par[x] = find(par[x]);
        }

        void unite(int x,int y){
            x = find(x);
            y = find(y);

            if(ran[x] < ran[y])par[x] = y;
            else{
                par[y] = x;
                if(ran[x] == ran[y])ran[x]++;
            }
        }

        bool same(int x,int y){
            return find(x) == find(y);
        }
};

int main(){
    int n,m;
    cin >> n >> m;
    
    UF uf(n);
    for(int i = 0;i < m;i++){
        int x,y,z;
        cin >> x >> y >> z;
        x--,y--;
        uf.unite(x,y);
    }

    map<int,bool> mp;
    for(int i = 0;i < n;i++){
        int root = uf.find(i);
        mp[root] = true;
    }

    cout << mp.size() << endl;
}


Measured memory_bytes: 5760
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
#define Mod 1000000007
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
#define INF 1234567890

int main(){
    ll i,j;
    string s;
    cin>>s;
    VVI z(26);
    for(i=0;i<s.size();i++){
        ll u=s[i]-'a';
        z[u].pb(i);
        z[u].pb(i+s.size());
    }

    for(i=0;i<26;i++){
        sort(z[i].begin(),z[i].end());
    }
    string t;
    cin>>t;
    ll n=s.size();
    ll tem=-1;
    ll rem=-1;
    for(i=0;i<t.size();i++){
        ll po=t[i]-'a';
        if(z[po].size()==0) {
            cout<<-1<<endl;
            return 0;
        }
        auto it=lower_bound(z[po].begin(),z[po].end(),rem+1);
        if(tem==-1&&rem==-1) {
            tem=0;
            rem=0;
        }
        tem+=*it-rem;
        rem=tem%n;
    }
    cout<<tem+1<<endl;
    
    return 0;
}

Measured memory_bytes: 2676
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <set>
#include <map>

#define N 0
#define INF 0x3f3f3f3f
#define LL long long
#define mz(x) ms(x,0)
#define ms(x,y) memset(x,y,sizeof(x))
#define mc(x,y) memcopy(x,y,sizeof(y))
#define MOD 1000000007

using namespace std ;

int main()
{
	int n, x, t ;
	scanf ("%d%d%d", &n, &x, &t) ;
	
	cout << (n + x - 1) / x * t << endl ;

	return 0 ;
}

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

using namespace std;


void solve() {
    int n; cin >> n;
    set<int> s;
    for (int _ = 0; _ < n; _++) {
        int x; cin >> x;
        s.insert(x);
    }
    cout << (s.size()==n?"YES":"NO");
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}


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

typedef long long ll;

const int mod = 998244353;

int main() {
    ll N, M;
    cin >> N >> M;
    vector<bool>check(N+1, false);
    vector<ll>box(N+1, 1);
    check[1] = true;

    for (int i = 0; i < M; i++) {
        ll x, y;
        cin >> x >> y;
        if (check[x]) {
            if (box[x]>=2) {
                check[y] = true;
            } else {
                check[x] = false;
                check[y] = true;
            }
        }
        box[x]--;
        box[y]++;
    }
    ll ans = 0;
    for (int i = 1; i <= N; i++) {
        if (check[i]) {
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<cstring>
#define inf 1000000001
using namespace std;
int n,k;
int dp[1000000];
int h[100000];
int min_cost(int i)
{
    if(i == n)
        return 0;

    if(dp[i] != -1)
        return dp[i];
    int j = 1;
    dp[i] = inf;
    while(j<=k && (i+j)<=n)
    {
        dp[i] = min(dp[i],min_cost(i+j)+abs(h[i]-h[i+j]));
        j++;
    }

    return dp[i];
}
int main()
{
    memset(dp,-1,sizeof(dp));
    cin>>n>>k;
    for(int i=1;i<=n;i++)
        cin>>h[i];
    cout<<min_cost(1);
    return 0;
}



Measured memory_bytes: 7680
DICT = {
  'C' => 0, 'C#' => 1, 'D' => 2, 'D#' => 3, 'E' => 4, 'F' => 5,
  'F#' => 6, 'G' => 7, 'G#' => 8, 'A' => 9, 'A#' => 10, 'B' => 11,
}

def check(stairs, music, i, k)
  loop do
    if i == 0
      return k == -1
    end

    tone = music[i - 1]
    stair = stairs[k]
    if k >= 1 && tone == (stair + 1) % 12
      i -= 1
      k -= 2
      next
    end
    if tone == stair
      i -= 1
      k -= 1
      next
    end
    if k < stairs.size - 1 && tone == (stair - 1) % 12
      i -= 1
      k += 1
      next
    end
    return false
  end
end

def work(stairs, music)
  (stairs.size >= 2 && check(stairs, music, music.size, stairs.size - 2)) ||
      check(stairs, music, music.size, stairs.size - 1)
end

s = STDIN.gets.to_i
s.times do
  STDIN.gets
  stairs = STDIN.gets.split.map{|x| DICT[x]}
  music = STDIN.gets.split.map{|x| DICT[x]}
  puts work(stairs, music) ? 'Yes' : 'No'
end

Measured memory_bytes: 18124
#include <iostream>

using namespace std;

int main()
{
    int N,d[101];
    int sum = 0;
    cin >> N;
    for(int k=0; k<N; k++){
        cin >> d[k];
    }

    for(int i=0; i<N-1; i++){
        for(int j=i+1; j<N; j++){
            sum += d[i]*d[j];
        }
    }

    cout << sum;
}

Measured memory_bytes: 256
function Main(input) {
    input = input.split("\n");
    const n = parseInt(input[0], 10);
    const l = input[1].split(" ").map(v => parseInt(v, 10));

    let count = 0;
    for(let i = 0; i < n; i++) {
        for(let j = i + 1; j < n; j++) {
            for(let k = j + 1; k < n; k++) {
                if(!allUnique(l[i], l[j], l[k])) {
                    continue;
                }
                if(isTriangle(l[i], l[j], l[k])) {
                    count++;
                }
            }
        }
    }

    console.log(count);
}

function allUnique(a, b, c) {
    if(a !== b && a !== c && b !== c) {
        return true;
    }
    return false;
}

function isTriangle(a, b, c) {
    if(a + b > c && b + c > a && c + a > b) {
        return true;
    }
    return false;
}
 
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 31788
#include <bits/stdc++.h>
using namespace std;
int d[10005][3][105],n,m;
char s[10005];

int main()
{
    scanf("%s %d", &s, &n);
    m = strlen(s);
	d[0][0][0] = 1;
	for(int i = 0;i < m;i++)
	{
		for(int j = 0;j < 2;j++)
		{
			int x = j ? 9 : s[i]-48;
			for(int l = 0;l <= x;l++)
			{
				for(int k = 0;k < n;k++)
					(d[i+1][j | l < x][(k+l) % n] += d[i][j][k]) %= 1000000007;
			}
		}
	}
	cout << (d[m][0][0]+d[m][1][0]-1+1000000007) % 1000000007;
}

Measured memory_bytes: 12544
# coding: utf-8
import sys

N = int(input())
A = [int(s) for s in input().split(' ')]
B = [int(s) for s in input().split(' ')]
D = []
cnt = 0
t_diff = 0

if sum(A) < sum(B):
    print(-1)
    sys.exit()
    
for i in range(len(A)):
    if A[i] < B[i]:
        cnt = cnt + 1
        t_diff = t_diff + (B[i] - A[i])
    if A[i] > B[i]:
        D.append(A[i] - B[i])

D.sort(reverse=True)

for i in range(len(D)):
    
    if t_diff <= 0:
        break
    t_diff = t_diff - D[i]
    cnt = cnt + 1
    
print(cnt)
    


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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;

int main()
{
    int N;
    string S, ACGT = "ACGT";
    cin >> S;
    N = S.size();

    int ans = 0;
    int cnt = 0;
    rep(i, N)
    {

        if (ACGT.find(S[i]) != -1)
        {
            cnt++;
            ans = max(ans, cnt);
        }
        else
        {
            cnt = 0;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define M 1000000007
#define ll long long
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define REPI(i,a,b) for(ll i=b-1;i>=a;i--)
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define G(a,b) get<a>(b)
#define VI vector<int>
#define VLL vector<long long>

#define o_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define o_setll tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
//member functions :
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set

ll modI(ll a, ll m);
ll gcd(ll a, ll b);
ll powM(ll x, unsigned ll y, unsigned ll m);
void pairsort(int a[], int b[], int n);
void pairsortll(ll a[],ll b[],ll n);
ll logint(ll x,ll y);


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

ll powM(ll x,ll y,ll m)
{
    if(y==0) return 1;
    ll p=powM(x,y/2,m)%m;
    p=(p*p)%m;
    return (y%2==0)?p:(x*p)%m;
}

ll modI(ll a, ll m)
{
    ll m0=m,y=0,x=1;
    if(m==1) return 0;
    while(a>1)
    {
        ll q=a/m;
        ll t=m;
        m=a%m;
        a=t;
        t=y;
        y=x-q*y;
        x=t;
    }
    if(x<0) x+=m0;
    return x;
}

void pairsort(int a[],int b[],int n)
{
    pair<int,int> v[n];
    REP(i,0,n)
    {
        v[i].F=a[i];
        v[i].S=b[i];
    }
    sort(v,v+n);
    REP(i,0,n)
    {
        a[i]=v[i].F;
        b[i]=v[i].S;
    }
}

void pairsortll(ll a[],ll b[],ll n)
{
    pair<ll,ll> v[n];
    REP(i,0,n)
    {
        v[i].F=a[i];
        v[i].S=b[i];
    }
    sort(v,v+n);
    REP(i,0,n)
    {
        a[i]=v[i].F;
        b[i]=v[i].S;
    }
}

ll logint(ll x,ll y)
{
    ll ans=0;
    ll a=1;
    for(ll i=0;i<=x;i++)
    {
        if(x<a)
        {
            return ans;
        }
        ans++;
        a*=y;
    }
    return -1;
}

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

    /*
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    */

    ll q=1;
    //cin>>q;
    while(q--)
    {
        ll n;
        cin>>n;
        double sum=0;
        REP(i,1,n+1) if(i%2) sum++;
        sum/=n;
        printf("%.12f",sum);
    }

    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    N,M=map(int,input().split())
    ans=0
    t=M*1900+(N-M)*100
    print(t*2**M)

if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
#include<stdio.h>

int main(){
	int n,i,j,k,b[100];
	scanf("%d",&n);
	for(i=0;i<n;i++)scanf("%d",&b[i]);
	int f=0;
	for(i=0;i<n;i++){
		f+=b[i];
		if(b[i]>i+1){
			puts("-1");
			return 0;
		}
	}
	if(f>n*(n+1)/2){
		puts("-1");
		return 0;
	}
	int ans[100],ansc=0;
	for(i=n-1;i>=0;i--){
		for(k=i;k>=0;k--){
		if(b[k]==k+1){
			ans[ansc++]=b[k];
			for(j=0;j+k+1<=i;j++){
				b[k+j]=b[k+j+1];
			}
			break;
		}
		}
	}
	for(i=n-1;i>=0;i--)printf("%d\n",ans[i]);
	return 0;
}

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

#define ff first
#define ss second
#define PI acos(-1)
#define pb push_back
#define int long long
#define ld long double
#define sp fixed<<setprecision
#define bp __builtin_popcountll
#define all(x) x.begin(),x.end()
#define pii pair<long long,long long>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

const int M = (1e9)+7;
const int N = 1e6+5;

signed main()
{
    FAST
    int tc=1;
    //cin>>tc;
    for(int ti=1;ti<=tc;ti++)
    {
        int x,y;
        cin>>x>>y;
        int ok = !(y%2);
        y/=2;
        int b = y-x,a = x-b;
        ok &= (b>=0);
        ok &= (a>=0);
        cout<<(ok?"Yes":"No")<<endl;
    }
    return 0;
}


Measured memory_bytes: 3648
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            // 解答はココに書く
            var N = cin.ReadInt;
            var A = cin.ReadInt;
            var B = cin.ReadInt;
            var ans = 0;
            for(var n = 1; n <= N; n++)
            {
              var sum = 0;
              foreach(var c in n.ToString())
                sum += (int)(c - '0');
              if (A <= sum && sum <= B)
                    ans += n;
            }
            WriteLine(ans);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }
}



Measured memory_bytes: 11220
#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b){
  if (b == 0){
    return a;
  } else {
    return gcd(b, a % b);
  }
}
int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++){
    cin >> A[i];
  }
  int ans = A[0];
  for (int i = 1; i < N; i++){
    ans = gcd(ans, A[i]);
  }
  cout << ans;
}

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

int main(){
  int n;
  cin >> n;
  vector<int> a(32);
  a={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};
  cout << a[n-1] << endl;
}

Measured memory_bytes: 3596
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>
#include<cmath>

using namespace std;

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

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    int ans = (a * b * c) / (2 * max(a, max(b, c)));
    cout << ans << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(25) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 1000000007
#define MAX 510000
#define ALL(a)  a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int main(){
  lli A,B,C,D,E,F,N,M,K,L,X,Y,Z,H,W,sum=0,num=0,flag=0;string S,T;
  cin >> S;
  if(S[0]==S[1]&&S[1]==S[2])Out("No");
  else Out("Yes");
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;int n,m,l,x,i,a[1<<18];main(){cin>>n>>m;n*=2;while(cin>>a[i])i++;sort(a,a+n);for(i--;i>l;i--){while(a[i]+a[l]<m&&l<i-1)l++;if(a[i]+a[l]>=m){a[i]-=m;l++;}}sort(a,a+n);for(i=0;i<n/2;i++)x=max(x,a[i]+a[n-i-1]);cout<<x;}

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
using ull = unsigned long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

template<class T>
bool ChangeMax(T&a,const T&b){
  if(a >= b) return false;
  a = b;    return true;
}

template<class T>
bool ChangeMin(T&a,const T&b){
  if(a <= b) return false;
  a = b;    return true;  
}

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int main(){
  int n; cin >> n;
  bool f = true;
  set<string> st;
  string pre;
  for(int i = 0; i < n; ++i){
    string s; cin >> s;
    f &= i == 0 || (s.front() == pre.back() && st.find(s) == st.end());
    st.emplace(s);
    pre = move(s);
  }
  cout << (f ? "Yes" : "No") << endl;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
	using namespace std;
	#define IOS ios::sync_with_stdio(false), cin.tie(0)
	#define REP(i, n) for (int i = 0; i < n; i++)
	#define FOR(i, a, b) for (int i = a; i < b; i++)
	#define ALL(x) (x).begin(), (x).end()
	#define dump(x) cout << (x) << endl
	#define LMAX 9223372036854775807LL
	#define LMIN -9223372036854775807LL

	using ll = long long;
	template<typename T>
	using vec = vector<T>;
	using P = pair<ll, ll>;

	template <typename A, size_t N, typename T>
	void Fill(A (&array)[N], const T &val){
		fill((T *)array, (T *)(array + N), val);
	}
	
	const ll INF = 1e18;
	const ll mod = 1e9 + 7;

	//int dx[4] = {1,0,-1,0};
	//int dy[4] = {0,1,0,-1};
	//ll pas[51][52];
	
	ll powm(ll a, ll b, ll c) {
		if (b == 0)return 1;
		else if (b % 2 == 0) {
			ll d = powm(a, b / 2, c);
			return (d * d) % c;
		}
		else return (a * powm(a, b - 1, c)) % c;
	}

	signed main(){
		IOS;
		ll h, w, a, b;
		cin >> h >> w >> a >> b;
		vec<ll> x(h + w + 1), y(h + w + 1);
		x[0] = y[0] = 1;
		for(ll i = 1;i <= h + w;i++){
			x[i] = (x[i - 1] * i) % mod;
			y[i] = (y[i - 1] * powm(i,mod - 2,mod)) % mod;
		}
		ll ans = (x[h + w - 2] * y[h - 1]) % mod;
		ans = (ans * y[w - 1]) % mod;
		ll sum = 0;	
		for(int i = 0;i <= b - 1;i++){
			ll tmp = (((x[h - a + i - 1] * y[h - a - 1]) % mod ) * y[i]) % mod;
			tmp = (((((tmp * x[w + a - i - 2]) % mod) * y[a - 1]) % mod) * y[w - i - 1]) % mod;
			sum = (sum + tmp) % mod;  
		}
		while(ans < sum){
			ans += mod;
		}
		dump(ans - sum);
	}

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

int main() {
  long n,ans=0;
  cin >> n;
  vector<long> a(n);
  map<long,long> aaa;
  for(long i=0;i<n;i++) cin >> a[i];
  
  for(long i=0;i<n;i++) {
    ans+=aaa[i-a[i]];
    aaa[i+a[i]]++;
  }
  cout << ans << endl;
}

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

using namespace std;

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

    string S;
    cin >> S;
    int flag = -2;
    //cout << S << endl;
    for(auto s:S){
        if(isupper(s))flag++;
    }

    if(
            S.at(0)=='A' &&
            count(S.begin()+2,S.end()-1,'C') ==1 &&
            flag==0
            ){
        cout << "AC" <<endl;
    }
    else{
        cout << "WA" << endl;
    }
}

Measured memory_bytes: 256
import Control.Applicative
import Control.Monad
import Data.List
import Data.Array

solve :: Int -> Int -> [(Int, Int)] -> Int
solve n ww wvs = iter n ww
  where
    wva = listArray (1, n) wvs
    memo = listArray ((0, 0), (n, ww)) [iter i j | i <- [0..n], j <- [0..ww]]
    iter i j
        | i == 0    = 0
        | j <  wi   = memo ! (i - 1, j)
        | otherwise = max (memo ! (i - 1, j - wi) + vi) (memo ! (i - 1, j))
      where
        (wi, vi) = wva ! i

main :: IO ()
main = do
    [n, w] <- fmap read . words <$> getLine :: IO [Int]
    wvs <- replicateM n $ do
        [v, w] <- fmap read . words <$> getLine :: IO [Int]
        return (w, v)
    print $ solve n w wvs


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

using namespace std;
char pic[55][55];
int con[55][55];
int H,W;

void fun(int x,int y,int& n)
{
    for(int p=-1;p<=1;++p)
        for(int q=-1;q<=1;++q)
    {
        if(x+p<0||x+p>=H||y+q<0||y+q>=W)continue;
        if(p==0&&q==0)continue;
        else if(pic[x+p][y+q]=='#')
        {
            ++n;
        }
    }
}
int main()
{
    cin>>H;cin>>W;
    int i,j;
    memset(con,0,sizeof(con));
    for(i=0;i<H;++i)
            for(j=0;j<W;++j)
    {
        cin>>pic[i][j];
    }
    for(i=0;i<H;++i)
        for(j=0;j<W;++j)
    {
        if(pic[i][j]!='#')
        {
            fun(i,j,con[i][j]);
        }
        else if(pic[i][j]=='#')con[i][j]=-1;
    }
    for(i=0;i<H;++i)
        for(j=0;j<W;++j)
    {
        if(con[i][j]>=0)
        pic[i][j]=(char)(48+con[i][j]);
        cout<<pic[i][j];
        if(j==W-1)cout<<endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define num 1000000007
//#define num 998244353
#define REP(i,a,n) for(ll i=a;i<n;i++)
#define inarr(i,a,n,A) for(ll i=a;i<n;i++) { cin>>A[i]; }
#define vll vector<long long>
#define pii pair <int,int>
#define pll pair<long long, long long>
#define vpii vector< pair <int,int>>
#define vpll vector< pair<long long, long long>>
//#define max(a,b) ((a>b)?a:b)
//#define min(a,b) ((a>b)?b:a)
#define max3(a,b,c) ((a>b)?(a>c)?a:c:(b>c)?b:c)
#define min3(a,b,c) ((a<b)?(a<c)?a:c:(b<c)?b:c)
#define avg(a,b) ((a)+(b))/2
#define pb push_back
#define pob pop_back
#define sf int flag=0     //Remember semicolon
// #define assmin(a,b) if(b<=a) { a=b; }
// #define assmax(a,b) if(b>=a) { a=b; }
#define f first
#define s second
#define fix(f,n) std::fixed<<std::setprecision(n)<<f
#define all(x) x.begin(), x.end()
#define M_PI 3.14159265358979323846
#define epsilon (double)(0.00000000001)
#define side 1e9
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
ll mod(ll a, ll b)
{
	if(a%b<0)
	{
		return a%b + b;
	}
	return a%b;
}
 
 
ll mod_exp(ll a, ll b, ll c)
{
	ll res=1;
	a=a%c;
	while(b>0)
	{
		if(b%2==1)
		{
			res=(res*a)%c;
		}
		b/=2;
		a=(a*a)%c;
	}
	return res;
}
ll mymod(ll a,ll b)
{
    return ((a%b)+b)%b;
}
bool prime[200001];
void SieveOfEratosthenes() 
{ 
    memset(prime, true, sizeof(prime)); 
    prime[1]=false;
    for (int p=2; p*p<=200000; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=200000; i += p) 
                prime[i] = false; 
        } 
    } 
    return;
}
ll powe[200005];
void power()
{
    powe[0]=1;
    REP(i,1,200005)
    {
        powe[i]=mymod(2*powe[i-1],num);
    }
}
ll gcdExtended(ll,ll,ll *,ll *);
ll modInverse(ll a, ll m) 
{ 
    ll x, y; 
    ll g = gcdExtended(a, m, &x, &y); 
        ll res = (x%m + m) % m;
        return res;
} 
ll gcdExtended(ll a, ll b, ll *x, ll *y) 
{ 
    if (a == 0) 
    { 
        *x = 0, *y = 1; 
        return b; 
    } 
    ll x1, y1; 
    ll gcd = gcdExtended(b%a, a, &x1, &y1); 
    *x = y1 - (b/a) * x1; 
    *y = x1; 
    return gcd; 
}
struct node
{
	vpll adj;
    ll biggest;
    ll op;
    ll size;
};

ll find(ll n, ll wt, ll nm)
{
    ll st = 1;
    ll en = nm;
    ll mid = (st) + (en - st)/2;
    while(st<=en)
    {
        if(wt+3*(nm+mid)>=n && wt+2*(nm+mid)<=n)
        {
            return mid;
        }
        else if(wt+3*(nm+mid)<n)
        {
            st = mid+1;
        }
        else
        {
            en = mid-1;
        }
        mid = (st) + (en - st)/2;
    }
    if(wt+3*(nm+mid)>=n && wt+2*(nm+mid)<=n)
    {
            return mid;
     }
    return 0;
}
bool my(pair<ll, char> p1, pair<ll, char> p2)
{
    return p1.first > p2.first;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,k;
    set<ll> s;
    cin>>n>>k;
    REP(i,0,k)
    {
        ll d;
        cin>>d;
        REP(i,0,d)
        {
            ll a;
            cin>>a;
            s.insert(a);
        }
    }
    cout<<n-s.size()<<"\n";
    return 0;
}


Measured memory_bytes: 3652
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000

void CountingSort(int *, int *, int *, int);

int main(){
  int *A, *B;
  int C[VMAX+1];
  int n, i, j;

  scanf("%d", &n);

  A = malloc(sizeof(int)*n+1);
  B = malloc(sizeof(int)*n+1);

  /* your code */
  for (i = 1; i <= n; i++) {
    scanf("%d", &A[i]);
  }

  CountingSort(A, B, C, n);

  for (i = 1; i <= n; i++) {
    printf("%d", B[i]);
    if (i == n) {
      printf("\n");
    }
    else {
      printf(" ");
    }
  }

  return 0;
}


void CountingSort(int *a, int *b, int *c, int n) {
  int i, j;

  for (i = 0; i <= VMAX; i++) {
    c[i] = 0;
  }

  for (j = 1; j <= n; j++) {
    c[a[j]]++;
  }

  for (i = 1; i <= VMAX; i++) {
    c[i] = c[i] + c[i-1];
  }

  for (j = n; j > 0; j--) {
    b[c[a[j]]] = a[j];
    c[a[j]]--;
  }

}



Measured memory_bytes: 17384
#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
int main()
{
    char p[2]={'H','D'};
    char a,b;
    cin>>a>>b;
    int t=1;
    cout << ( a=='H'?b:(b=='D'?p[t^1]:p[t]) ) << endl;
    return 0;
}

Measured memory_bytes: 256