akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
#define mod 1000000007
#define pi 3.141592653589793
typedef vector<int> vi;
typedef vector<ll> vl;
ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll g=gcd(a,b);
    return a/g*b;
}
ll rep_jijo(ll n,ll x){
    if(x==0) return 1;
    if(x%2==0){
        ll t=rep_jijo(n,x/2);
        return t*t%mod;
    }
    return n*rep_jijo(n,x-1)%mod;
}
ll com(ll n,ll r){
    ll x=1,y=1;
    ll tmp=n;
    while(tmp>=n-r+1){
        x=x*tmp%mod;
        tmp--;
    }
    while(r>0){
        y=y*r%mod;
        r--;
    }
    return x*rep_jijo(y,mod-2)%mod;
}


int main (){
    int d,n;
    cin >> d >>n;
    int x=pow(100,d);
    int ans;
    if(d==0){
        ans=n;
        if(ans==100) ans++;
    }
    else if(d==1){
        ans=x*n;
        if(ans==10000) ans=10100;
    }
    else{
        ans=x*n;
        if(ans==1000000) ans=1010000;
    }
    cout << ans <<endl;
    return 0;
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef int ll;
typedef long double ld;
const ll N = 100005;
char en = '\n';

vector<pair<ll, ll>> adj[N];
ll color[N];
void dfs(ll curr, ll prev1 = -1, ll prevVal = -1) {
  if (prevVal == -1)
    color[curr] = 0;
  else
    color[curr] = 1 - prevVal;
  for (pair<ll, ll> &x : adj[curr]) {
    if (prev1 == x.first)
      continue;

    if (x.second == 0) {
      dfs(x.first, curr, 1 - color[curr]);
    } else {
      dfs(x.first, curr, color[curr]);
    }
  }
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll n;
  cin >> n;
  for (ll i = 1; i < n; i++) {
    ll u, v, w;
    cin >> u >> v >> w;
    w &= 1;
    adj[u].push_back({v, w});
    adj[v].push_back({u, w});
  }
  dfs(1);

  for (ll i = 1; i <= n; i++)
    cout << color[i] << en;

  return 0;
}

Measured memory_bytes: 10240
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <bitset>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;

int main(int argc, const char * argv[]) {
    string S;
    cin >> S;
    if (S[0] == S[1] && S[1] == S[2]) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }

    return 0;
}

Measured memory_bytes: 888
// AOJ 2600: Koto Distance
// 2017.10.31 bal4u@cc

#include <stdio.h>

int width[200002], height[200002];

char buf[32], *p;
int getint()
{
	int n = 0;
	while (*p >= '0') n = (n<<3) + (n<<1) + (*p++ & 0xf);
	return n;
}

int check(int *a, int sz)
{
	int s = 0;
	while (sz--) {
		s += *a++;
		if (s <= 0) return 0;
	}
	return 1;
}

int main()
{
	int n, w, h, x, y, k, t;

	fgets(p=buf, sizeof(buf), stdin);
	n = getint(), p++, w = getint(), p++, h = getint();

	while (n--) {
		fgets(p=buf, sizeof(buf), stdin);
		x = getint(), p++, y = getint(), p++, k = getint();

		t = x - k; if (t < 0) t = 0;
		width[t]++;
		t = x + k; // if (t > w) t = w;
		width[t]--;

		t = y - k; if (t < 0) t = 0;
		height[t]++;
		t = y + k; // if (t > h) t = h;
		height[t]--;
	}

	puts(check(width, w) || check(height, h) ? "Yes" : "No");
	return 0;
}

Measured memory_bytes: 3084
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main(){
    int N;
    cin >> N;
    string s[N];
    for(int i = 0; i < N; i++) cin >> s[i];

    vector<vector<char>> c(2 * N, vector<char>(2 * N));
    for(int i = 0; i < 2 * N; i++){
        for(int j = 0; j < 2 * N; j++){
            c[i][j] = s[i % N][j % N];
        }
    }

    int ans = 0;

    for(int i = 0; i < N; i++){
        bool check = true;

        for(int x = 0; x < N; x++){
            for(int y = 0; y < N; y++){
                if(c[i + x][y] != c[i + y][x]) check = false;
            }
        }

        if(check){
            ans += N - i;
        }
    }

    for(int j = 1; j < N; j++){
        bool check = true;

        for(int x = 0; x < N; x++){
            for(int y = 0; y < N; y++){
                if(c[x][j + y] != c[y][j + x]) check = false;
            }
        }

        if(check){
            ans += N - j;
        }
    }

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

Measured memory_bytes: 768
n = int(input())

ans = 0
for i in range(1, n + 1):
    ans += i * (i + 1) // 2

for _ in range(n - 1):
    u, v = map(int, input().split())
    if v < u:
        u, v = v, u
    ans -= u * (n - v + 1)

print(ans)


Measured memory_bytes: 9156
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + (ll)b) % mod
#define MUL(a, b) a = (a * (ll)b) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = a; i < b; i++)
#define rer(i, a, b) for(int i = a - 1; i >= b; i--)
#define all(a) (a).begin(), (a).end()
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef pair<int, pi> ppi;
typedef vector<ll> vec;

const int MAX_N = 200010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 27;

void Debug() {cout << '\n'; }

template<class FIRST, class... REST> 
void Debug(FIRST arg, REST... rest) { cout << arg << " "; Debug(rest...); }

template<class T>
ostream& operator<< (ostream& out, const vector<T>& v) {
	out << "[";
	if(!v.empty()) {
		rep(i, 0, (int)v.size() - 1) out << v[i] << ", ";
		out << v.back();
	}
	out << "]";
  return out;
}

template<class S, class T>
ostream& operator<< (ostream& out, const pair<S, T>& v) {
	out << "(" << v.first << ", " << v.second << ")";
	return out;
}

///g++ -g3 -std=c++0x -DLOCAL -Wall -ftrapv -D_GLIBCXX_DEBUG -Wl,-stack,268435456 -o
///g++ -O2 -std=c++0x -DLOCAL -Wall -Wl,-stack,268435456 -o

////////////////////////////////////////////////////////////////////////

int N;
int dp[110][10];
int A[110];

void solve() {
	cin >> N;
	rep(i, 0, N) cin >> A[i];
	rep(i, 0, N + 1) 
		rep(j, 0, 10) dp[i][j] = -inf; 
	dp[0][0] = 0;
	rep(i, 0, N) {
		rep(j, 0, 10) {
		MAX(dp[i + 1][j], dp[i][(j - A[i] + 10000) % 10] + A[i]);
		MAX(dp[i + 1][j], dp[i][j]);
		}
		//debug(vec(dp[i + 1], dp[i + 1] + 10));
	}
	int res = 0;
	rep(j, 1, 10) MAX(res, dp[N][j]);
	cout << res << '\n';
}

int main() {
	ios::sync_with_stdio(false);
    cin.tie(0);	
    cout << fixed;
	cout.precision(20);
#ifdef LOCAL
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

int N;
int A[200001];
int E[400001], ne[400001], he[200001];
int V[200001], v;
void dfs(int p, int mae) {
	if (V[v - 1] < A[p]) {
		V[v++] = A[p];
		for (auto to = he[p]; to; to = ne[to]) {
			if (E[to] != mae) {
				dfs(E[to], p);
			}
		}
		he[p] = v--;
	}
	else {
		int itr = lower_bound(V, V + v, A[p]) - V;
		swap(V[itr], A[p]);
		for (auto to = he[p]; to; to = ne[to]) {
			if (E[to] != mae) {
				dfs(E[to], p);
			}
		}
		he[p] = v;
		V[itr] = A[p];
	}
}

const int CM = 1 << 17, CL = 12;
char cn[CM + CL], * ci = cn + CM + CL, * owa = cn + CM, ct;
const ll ma0 = 1157442765409226768;
const ll ma1 = 1085102592571150095;
const ll ma2 = 71777214294589695;
const ll ma3 = 281470681808895;
const ll ma4 = 4294967295;
inline int getint() {
	if (ci - owa > 0) {
		memcpy(cn, owa, CL);
		ci -= CM;
		fread(cn + CL, 1, CM, stdin);
	}
	ll tmp = *(ll*)ci;
	int dig = 68 - __builtin_ctzll((tmp & ma0) ^ ma0);
	tmp = tmp << dig & ma1;
	tmp = tmp * 10 + (tmp >> 8) & ma2;
	tmp = tmp * 100 + (tmp >> 16) & ma3;
	tmp = tmp * 10000 + (tmp >> 32) & ma4;
	ci += 72 - dig >> 3;
	return tmp;
}
inline int getintA() {
	if (ci - owa > 0) {
		memcpy(cn, owa, CL);
		ci -= CM;
		fread(cn + CL, 1, CM, stdin);
	}
	ll tmp = *(ll*)ci;
	int dig = ((tmp & ma0) ^ ma0) ? 68 - __builtin_ctzll((tmp & ma0) ^ ma0) : 0;
	tmp = tmp << dig & ma1;
	tmp = tmp * 10 + (tmp >> 8) & ma2;
	tmp = tmp * 100 + (tmp >> 16) & ma3;
	tmp = tmp * 10000 + (tmp >> 32) & ma4;
	ci += (64 - dig >> 3);
	while ((ct = *ci++) >= '0') tmp = tmp * 10 + ct - '0';
	return tmp;
}
char dn[1300000], *di = dn;
inline void putint(int X) {
	int keta = 0;
	char C[10];
	while (X) {
		*(C + keta) = '0' + X % 10;
		X /= 10;
		keta++;
	}
	for (int i = keta - 1; i >= 0; i--)* di++ = (*(C + i));
	*di++ = '\n';
}

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

	N = getint();
	rep1(i, N) A[i] = getintA();
	int k = 1;
	rep(i, N - 1) {
		int u = getint(), v = getint();
		E[k] = v;
		ne[k] = he[u];
		he[u] = k++;
		E[k] = u;
		ne[k] = he[v];
		he[v] = k++;
	}

	V[v++] = 2000000000;
	dfs(1, -1);

	rep1(i, N) putint(he[i]);
	fwrite(dn, 1, di - dn, stdout);

	Would you please return 0;
}

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

int main()
{
    int n;
    queue< int > q;
    cin >> n;
    int p[n+9];
    for  (int i = 1; i <= n ; i++ )
        cin >> p[i];
    int dem = n;
    int minn = p[1];
    for  ( int i = 1 ; i <= n ; i ++ )
    {
        
        if (p[i]>minn) {dem--;}
        else minn = p[i];
        

    }
    cout << dem;
    return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>

int main(void)
{
	int mhi, mlo, np, t, f1, f2, n, m;
	scanf("%d",&n);
	for(f1 = 0; f1 < n; f1++)
	{
		mhi = 0; mlo = 0;
		scanf("%d",&m);
		for(f2 = 0; f2 < m; f2++)
		{
			scanf("%d",&np);
			if(f2 == 0)
				t = np;
			else
			{
				//降下
				if(t > np){
					if(mlo == 0 || mlo < t - np)
						mlo = t - np;
				}
				//登上
				else if(t < np){
					if(mhi == 0 || mhi < np - t)
						mhi = np - t;
				}
				t = np;
			}
			
		}
		printf("%d %d\n",mhi,mlo);
	}
	return 0;
}

Measured memory_bytes: 0
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
using namespace std;

typedef long long s64;

int main()
{
	s64 l, r;
	cin >> l >> r;

	if (l == r)
	{
		cout << 1 << endl;
		return 0;
	}

	int k = 61;
	while (k--)
	{
		if ((l ^ r) >> k)
		{
			l &= (1ll << k + 1) - 1;
			r &= (1ll << k + 1) - 1;
			break;
		}
	}

	s64 bin = 1ll << k;

	s64 res = bin - l;

	s64 l2 = bin + l, r2 = bin + bin - 1;
	s64 l1 = bin, r1 = bin;

	for (int i = 60; i >= 0; --i)
		if ((1ll << i) + bin <= r)
		{
			r1 = bin + (1ll << i + 1) - 1;
			break;
		}

	if (l2 > r1)
		res += r1 + r2 - l1 - l2 + 2;
	else if (r2 >= r1)
		res += r2 - l1 + 1;
	else
		res += r1 - l1 + 1;

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {

  void solve(InputReader in, PrintWriter out) {
    int a = in.nextInt();
    int b = in.nextInt();
    int m = in.nextInt();

    int[] arr = new int[a];
    int[] brr = new int[b];

    int lowa = Integer.MAX_VALUE;
    for (int i = 0; i < a; ++i) {
      arr[i] = in.nextInt();
      lowa = Math.min(lowa, arr[i]);
    }

    int lowb = Integer.MAX_VALUE;
    for (int i = 0; i < b; ++i) {
      brr[i] = in.nextInt();
      lowb = Math.min(lowb, brr[i]);
    }


    Pair[] p = new Pair[m];
    for (int i = 0; i < m; ++i) {
      int x = in.nextInt() - 1;
      int y = in.nextInt() - 1;
      int c = in.nextInt();
      p[i] = new Pair(arr[x], brr[y], c);
    }

    Arrays.sort(p);

    out.println(Math.min(p[0].price(), lowa + lowb));
  }

  public static void main(String[] args) throws Exception {
    InputReader in = new InputReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    Main solver = new Main();
    solver.solve(in, out);
    out.close();
  }

  static class InputReader {
    BufferedReader in;
    StringTokenizer st;

    public InputReader(InputStream is) {
      in = new BufferedReader(new InputStreamReader(is));
    }

    public String next() {
      try {
        while (st == null || !st.hasMoreTokens()) {
          st = new StringTokenizer(in.readLine());
        }
        return st.nextToken();
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }

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

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


class Pair implements Comparable<Pair> {
  int p1, p2, c;

  public Pair(int p1, int p2, int c) {
    this.p1 = p1;
    this.p2 = p2;
    this.c = c;
  }

  public int price() {
    return p1 + p2 - c;
  }

  @Override
  public int compareTo(Pair p) {
    return this.price() - p.price();
  }
}

Measured memory_bytes: 60508
N, L = map(int,input().split())

apples = [L+i for i in range(N)]
total = sum(apples)

min_d, ans = 10**9, 0
for i in range(N):
    d = abs(apples[i])
    if d < min_d:
        min_d = d
        ans = total - apples[i]

print(ans)

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

using namespace std;

const int maxn = 1e5+5;

int a[maxn];
int b[maxn];

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

int main()
{
	int N, H;
	while(~scanf("%d %d",&N,&H))
	{
		int maxa = 0;
		for(int i=1;i<=N;i++)
		{
			cin >> a[i] >> b[i];
			maxa = max(maxa, a[i]);
		}
		for(int i=1;i<=N;i++)
		{
			if(b[i] < maxa)
				b[i] = 0;
		}
		sort(b+1, b+N+1, cmp);
		int flag = 0;
		int cnt = 0;
		int sum = 0;
		for(int i=1;i<=N;i++)
		{
			if(b[i] == 0)
				break;
			sum += b[i];
			cnt++;
			if(sum >= H)
			{
				flag = 1;
				break;
			}
		}
		if(flag)
			cout << cnt << endl;
		else
		{
            cnt += (H - sum) / maxa;
            if((H - sum) % maxa != 0)
			{
                cnt++;
            }
            printf("%d\n",cnt);
        }
	}
	return 0;
}

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

int main() {
	int n;
	cin >> n;
	vector<ll>a(n);
	for (int i = 0; i < n; i++)cin >> a.at(i);
	vector<ll>sig(n);
	for (int i = 0; i < n; i++) {
		if (i == 0)sig.at(0) = a.at(0);
		else sig.at(i) = sig.at(i-1) + a.at(i);
	}
	sig.push_back(0);
	sort(sig.begin(), sig.end());
	ll ans = 1;
	ll tmp = sig.at(0);
	vector<ll>cmb;
	for (int i = 1; i < n+1; i++) {
		if (sig.at(i) == tmp)ans++;
		else {
			cmb.push_back(ans);
			ans = 1;
			tmp = sig.at(i);
		}
	}
	cmb.push_back(ans);
	ans = 0;
	for (int i = 0; i < cmb.size(); i++) {
		if (cmb.at(i) >= 2)ans += cmb.at(i) * (cmb.at(i) - 1) / 2;
	}
	cout << ans << endl;
	/*
	1,3,-4,2,2,-2
	sig = 0,1,4,0,2,4,2
	sort sig=0,0,1,2,2,4,4
	cmb = 2,1,2,2
	*/
}

Measured memory_bytes: 7012
#include <iostream>

using namespace std;

char f(int x, int a, int b) {
    if (abs(x - a) < abs(x - b)) {
        return 'A';
    }
    return 'B';
}

int main() {

    int x, a, b;
    cin >> x >> a >> b;

    char result = f(x, a, b);
    cout << result << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		while(true){
			int k = stdIn.nextInt();
			if(k==0){
				return;
			}
			int s = 0;
			for(int i=0;i<k*(k-1)/2;i++){
				s += stdIn.nextInt();
			}
			System.out.println(s/(k-1));
		}
	}
}

Measured memory_bytes: 12000
#include<iostream>
#include<algorithm>
using namespace std;
int C[21],T[50100];
int n,m;
const int INFTY=10100;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main(){
    cin>>n>>m;
    for(int i=0;i<m;++i){
        cin>>C[i];
    }
    Fill(T,INFTY);
    T[0]=0;

    for(int i=0;i<m;++i){
        for(int j=1;j<=n;++j){
            if(j>=C[i]){
                T[j]=min(T[j],T[j-C[i]]+1);
            }
        }
    }
    cout<<T[n]<<endl;


}


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

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)a, i##_len=(b); i<i##_len; i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define int long long

using namespace std;
using P = pair<int, int>;
using ll = long long;
const ll INF = LLONG_MAX/3;

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

struct UnionFind{
	std::vector<int> par,siz;
	void init(int n){
		par.resize(n);
		for(int i=0;i<n;i++)par[i]=i;
		siz.resize(n,1);
	}
	UnionFind(int n){
		init(n);
	}
	int root(int n){
		if(par[n]==n)return n;
		else return par[n]=root(par[n]);
	}
	bool issame(int x,int y){
		return (root(x)==root(y));
	}
	bool marge(int a,int b){
		if(issame(a,b))return false;
		else{
			a=root(a),b=root(b);
			if(siz[a]<siz[b])swap(a,b);
			siz[a]+=siz[b];
			par[a]=par[b];
			return true;
		}
	}
	int size(int n){
		return siz[root(n)];
	}
};

long long gcd(long long a,long long b){
    if(b==0)return a;
    return gcd(b,a%b);
}
long long lcm(long long i,long long j){
    return i*(j/gcd(i,j));
}

bool isprime(int x){
	rep(i,1,sqrt(x)+1)if(gcd(i,x)!=1)return false;
	return true;
}
int dp[110000][3]={};
signed main(){
    int n,k;
	cin>>n>>k;
	int s[3];
	cin>>s[0]>>s[1]>>s[2];
	string t;
	cin>>t;
	int p[110000];
	rep(i,n){
		if(t[i]=='r')p[i]=2;
		else if(t[i]=='s')p[i]=0;
		else p[i]=1;
	}
	rep(i,n){
		if(i<k){
			rep(j,3)dp[i][j]=0;
			dp[i][p[i]]+=s[p[i]];
		}else{
			dp[i][0]=max(dp[i-k][1],dp[i-k][2]);
			dp[i][1]=max(dp[i-k][0],dp[i-k][2]);
			dp[i][2]=max(dp[i-k][1],dp[i-k][0]);
			dp[i][p[i]]+=s[p[i]];
		}
	}
	int ans=0;
	for(int i=n-1;i>=n-k;i--){
		ans+=max(dp[i][0],max(dp[i][1],dp[i][2]));
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h> 
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define size_of_array(array) (sizeof(array)/sizeof(array[0]))
#define DEBUG 0 
#define LIMIT (LONG_MAX / 10)
#define POSITIVE_LAST_D (LONG_MAX % 10)
using ll =long long;
using namespace std;
using Graph=vector<vector<int>>;

int main(){
    ll n;
    cin>>n;
    ll x=26;
    int i=1;
    while(n>x){
        x*=26;
        x+=26;
        ++i;
    }
    string ans;
    rep(j,i){
        --n;
        ans+=n%26+'a';
        n/=26;
    }
    reverse(ans.begin(),ans.end());
    cout<<ans<<endl;
    return 0;

}

Measured memory_bytes: 3616
import java.util.*;

public class Main {

	public static void main(
			String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		boolean result = true;
		String w = sc.next();
		ArrayList wList = new ArrayList();
		wList.add(w);
		char s = w.charAt(w.length() - 1);
		for (int i = 1; i < n; i++) {
			w = sc.next();
			if (wList.contains(w)) {
				result = false;
				break;
			}
			wList.add(w);
			if (s != w.charAt(0)) {
				result = false;
				break;
			}
			s = w.charAt(w.length() - 1);
		}
		System.out.println(result ? "Yes" : "No");
	}
}


Measured memory_bytes: 23508
#include<stdio.h>
#include<stdlib.h>

int main(){
  long long int a,b,c;
  scanf("%lld %lld %lld",&a,&b,&c);
  long long int ans=0,k,t;
  k=(long long int)a/(b+c);
  t=a%(b+c)<b? a%(b+c):b;
  ans=k*b+t;
  printf("%lld",ans);

  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main() {
	string s;
	cin>>s;
	for(int i=0;i<s.size();i++)
	{
		if(s[i]=='1')
			s[i]='9';
		else if(s[i]=='9')
			s[i]='1';
	} 
	cout<<s;
	return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  vector<int> num(100000,0);
  long long sum=0;
  for(int i=0;i<N;i++){
    cin >> A.at(i);
    sum+=A.at(i);
    num.at(A.at(i)-1)++;
  }
  int Q;
  cin >> Q;
  vector<int> B(Q),C(Q);
  for(int i=0;i<Q;i++){
    cin >> B.at(i) >> C.at(i);
  }
  for(int i=0;i<Q;i++){
    int count=num.at(B.at(i)-1);
    num.at(B.at(i)-1)=0;
    num.at(C.at(i)-1)+=count;
    sum-=count*(B.at(i)-C.at(i));
    cout << sum << endl;
  }
}

Measured memory_bytes: 4844
#include <bits/stdc++.h>
#define ri register int
using namespace std;
const int rlen = 1 << 20 | 5;
char buf[rlen], *ib = buf, *ob = buf;
#define gc() (((ib == ob) && (ob = (ib = buf) + fread(buf, 1, rlen, stdin))), ib == ob ? -1 : *ib++)
#define pb push_back
#define rez resize
#define fi first
#define se second
typedef long long ll;
typedef pair <int, int> pii;
inline int read() {
  static int ans, f;
  static char ch;
  for (ans = 0, f = 1, ch = gc(); !isdigit(ch); ch = gc()) f ^= ch == '-';
  while (isdigit(ch)) ans = ((ans << 2) + ans << 1) + (ch ^ 48), ch = gc();
  return f ? ans : -ans;
}
const int N = 2e5 + 5;
int n, m, a, b;
int main() {
  #ifdef ldxcaicai
  freopen("lx.in", "r", stdin);
  #endif
  n = read(), m = read(), a = read(), b = read();
  for (ri i = 1; i <= n; ++i, puts("")) for (ri j = 1; j <= m; ++j) cout << ((j <= a) ^ (i <= b));
  return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
set<long long> s;
int primeFactors(long long n) 
{ 
	while (n % 2 == 0) { 
		s.insert(2);
		n = n/2; 
	}  
	for (int i = 3; i <= sqrt(n); i = i + 2) { 
		while (n % i == 0) { 
			s.insert(i); 
			n = n/i; 
		} 
	} 
	if (n > 2) 
		s.insert(n);
	return s.size(); 
} 
int main()
{

long long a, b;
cin >> a >> b;
long long c = __gcd(a,b);
int ans = primeFactors(c) + 1;
cout << ans;
}

Measured memory_bytes: 256
import sys
from itertools import permutations
times = [int(sys.stdin.readline().rstrip()) for _ in range(5)]
ans = 10**10
for prm in permutations(range(5)):
    res = 0
    for i, p in enumerate(prm):
        res += times[p]
        r = times[p] % 10
        if i < 4:
            if r != 0:
                res += 10 - r
    ans = min(ans, res)
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>

#define MOD 1000000007
#define ll long long

using namespace std;

ll N;
int main(){
  ll inp;
  cin >> N;

  if((N/100)==(N%10)) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
#define inf 1000000001
#define bpc(x) __builtin_parityll(x)
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define rep(n) for(ll i = 0; i < n; i++)
#define repi(i,n) for(ll i = 0; i < n; i++)

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 

using namespace std;

bool comp(pair<ll,ll> a, pair<ll,ll> b)
{
    if(a.ff == 0 && b.ff == 0)
        return a.ss<b.ss;
    return (a.ff*(b.ss+1) > b.ff*(a.ss+1));
}

int main()
{
   FAST/**/
   
   ll n,t;
   cin>>n>>t;
   
   pair<ll,ll> arr[n];
   rep(n)
        cin>>arr[i].ff>>arr[i].ss;
   
   sort(arr,arr+n,comp);
   ll inde = 0;
   for(ll i=0;i<n;i++)
   {
       if(arr[i].ff == 0)
           break;
       
       inde++;
   }
   
   if(inde == 0)
   {
       ll curr = 0;
       ll ct = 0;
       
       for(ll i=0;i<n;i++)
       {
           ll temp = (ll)ct + 1 + arr[i].ss;
           if(temp>(ll)t)
                break;
           curr++;
           ct = temp;
       }
       cout<<curr;
       return 0;
   }
   
   ll lim = ceil(log2(t))+2;
   lim = min(lim,inde);
   //cout<<inde<<" "<<lim<<"\n";
   ll dp[inde+1][lim+1];
   rep(inde+1)
        repi(j,lim+1)
            dp[i][j] = inf;            
   
   dp[0][0] = 0;
   
   for(ll i=1;i<=inde;i++)
   {
       repi(j,lim+1)
            dp[i][j] = dp[i-1][j];
       for(ll j=0;j<lim;j++)
       {
           if(dp[i-1][j] > t)
                continue;
           ll temp = (dp[i-1][j] + (ll)1) +  arr[i-1].ff*((dp[i-1][j] + 1)) + arr[i-1].ss;
           if(temp>(ll)t)
                continue;
           dp[i][j+1] = min(dp[i][j+1],temp);        
       }
   }
   
   ll ans = 0;
   rep(lim+1)
        if(dp[inde][i]<=t)
            ans = max(ans, i);
   for(ll i=0;i<=lim;i++)
   {
       //cout<<"at "<<i<<" = "<<dp[inde][i]<<"\n";
       ll curr = i;
       ll ct = dp[inde][i];
       if(ct>t)
            continue;
       for(ll j=inde;j<n;j++)
       {
           ll temp = (ll)ct + 1 + arr[j].ss;
           if(temp>(ll)t)
                break;
           curr++;
           ct = temp;
       }
       ans = max(ans, curr);
   }
   cout<<ans;
   
   return 0;        
}  
   

Measured memory_bytes: 54912
import java.io.*;

class Main{
  public static void main(String[] args) throws Exception{
   int x, ans;
   
   BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
   x = Integer.parseInt(br.readLine());

   ans = x*x*x;
   System.out.println(ans);
  }
}

Measured memory_bytes: 24068
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#define INF 2147483647
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long

using namespace std;
int main(){
  int x,y,s;
  while(cin>>x>>y>>s,x+y+s){
  vector<pair<int,int> >pii;
  pii.clear();
    for(int i=1;i<s;i++){
      for(int j=i;j<s;j++){
	//cout<<((i*(100+x))/(100))+((j*(100+x))/(100))<<endl;
	if((i*(100+x))/(100)+(j*(100+x))/(100)==s){
	  pii.pb(mp(i,j));
	  //cout<<"!"<<endl;
	}
      }
    }
    int ans=0;
    for(int i=0;i<pii.size();i++){
      //cout<<pii[i].F<<" "<<pii[i].S<<endl;
      ans=max(ans,(pii[i].F*(100+y))/(100)+(pii[i].S*(100+y))/(100));
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 3008
def main():
    # 下、右、上、左
    dyx = ((1, 0), (0, 1), (-1, 0), (0, -1))
    H, W = map(int, input().split())
    s = ["." * (W + 2)]
    s += ["." + input() + "." for i in range(H)]
    s.append("." * (W + 2))
    for y in range(1, H + 1):
        for x in range(1, W + 1):
            if s[y][x] == ".":
                continue
            if "." == s[y + dyx[0][0]][x + dyx[0][1]]\
                    == s[y + dyx[1][0]][x + dyx[1][1]]\
                    == s[y + dyx[2][0]][x + dyx[2][1]]\
                    == s[y + dyx[3][0]][x + dyx[3][1]]:
                print("No")
                return
    print("Yes")
    return


main()


Measured memory_bytes: 3064
# A - Remaining Time

# 現在の時刻は、24時間表記（0:00 ~ 23:59）で A時 ちょうど
# コンテストはちょうど B 時間後に始まる

# コンテストの開始時刻は、24時間表記で何時ちょうどですか？

# A B を標準入力から得る
A, B = map(int, input().split())
# print(A, B)

# A + B が24を超えた場合、 (A + B) - 24 を行う必要がある。

# (A + B) % 24 ⇔ (A + B) を 24 で 割った余りを表示
# こうすることで、24以上の時も同様に表示できる

answer = (A + B) % 24

# 結果を出力
print(answer)


Measured memory_bytes: 9000
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    string s, t;
    cin >> s >> t;
    int n = s.size();
    int res = 0;
    rep(i, n) if (t[i] != s[i]) res++;
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3916
l=int(input())
a=[int(input()) for x in range(l)]
def ds_tu(i):
    if a[i]==0:return 2
    return a[i]%2
ans=[[0 for i in range(5)] for j in range(l)]
ans[0][0]=a[0]
ans[0][1]=ds_tu(0)
ans[0][2]=(a[0]+1)%2
ans[0][3]=ds_tu(0)
ans[0][4]=a[0]
for i in range(1,l):
    ans[i][0]=ans[i-1][0]+a[i]
    ans[i][1]=min(ans[i-1][0:2])+ds_tu(i)
    ans[i][2]=min(ans[i-1][0:3])+(a[i]+1)%2
    ans[i][3]=min(ans[i-1][0:4])+ds_tu(i)
    ans[i][4]=min(ans[i-1])+a[i]
    
print(min(ans[l-1]))
    

Measured memory_bytes: 74068
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define len(arr) (int)(sizeof(arr)/sizeof((arr)[0]))
#define Sort(arr) sort(arr,arr+len(arr))
#define For(i,s,n) for(int i=s;i<n;i++)	
#define Rep(i,n) for(int i=0;i<n;i++)
#define Per(i,n) for(int i=n;i>=0;i--)
#define All(x) (x).begin(),(x).end()
#define in(arr,n) Rep(i,n) cin >> arr[i];
#define in2(arr1,arr2,n) Rep(i,n) cin >> arr1[i] >> arr2[i];
#define in3(arr1,arr2,arr3,n) Rep(i,n) cin >> arr1[i] >> arr2[i] >> arr3[i];
#define LL_MAX 9223372036854775807
#define LL_MIN -9223372036854775808
#define MOD 1000000007
#define MOD9 1000000009

//{ ライブラリ

// 標準出力の高速化
#define endl "\n"

// 出力
template<typename Type>
void print(Type a[],int n){
	Rep(i,n) cout << a[i] << endl;
}
template<typename Type1,typename Type2>
void print(Type1 a[],Type2 b[],int n){
	Rep(i,n) cout << a[i] << " " << b[i] << endl;
}
template<typename Type1,typename Type2,typename Type3>
void print(Type1 a[],Type2 b[],Type3 c[],int n){
	Rep(i,n) cout << a[i] << " " << b[i] << " " << c[i] << endl;
}

// 配列の最大値
template<typename Type>
Type max(Type a[],int n){
	Type ret=a[0];
	For(i,1,n) ret=max(ret,a[i]);
	return ret;
}

// 配列の最小値
template<typename Type>
Type min(Type a[],int n){
	Type ret=a[0];
	For(i,1,n) ret=min(ret,a[i]);
	return ret;
}

// 最大公約数
template<typename Type>
Type gcd(Type a,Type b){return(b==0)?a:gcd(b,a%b);}
template<typename Type>
Type gcd(Type a[],int n){
	Type ret=a[0];
	For(i,1,n) ret=gcd(ret,a[i]);
	return ret;
}

// 最小公倍数
template<typename Type>
Type lcm(Type a,Type b){return (a/gcd(a,b))*b;}
template<typename Type>
Type lcm(Type a[],int n){
	Type ret=a[0];
	For(i,1,n) ret=lcm(ret,a[i]);
	return ret;
}

// aを元にしてペアでソート
template<typename Type1,typename Type2>
void PairSort(Type1 a[],Type2 b[],int left,int right){
	int i=left,j=right;
	Type1 p=a[(left+right)/2];
	while(true){
		while(a[i]<p) i++;
		while(p<a[j]) j--;
		if(i>=j) break;
		swap(a[i],a[j]);
		swap(b[i],b[j]);
		i++;j--;
	}
	if(left<i-1) PairSort(a,b,left,i-1);
	if(j+1<right) PairSort(a,b,j+1,right);
}
template<typename Type1,typename Type2,typename Type3>
void PairSort(Type1 a[],Type2 b[],Type3 c[],int left,int right){
	int i=left,j=right;
	Type1 p=a[(left+right)/2];
	while(true){
		while(a[i]<p) i++;
		while(p<a[j]) j--;
		if(i>=j) break;
		swap(a[i],a[j]);
		swap(b[i],b[j]);
		swap(c[i],c[j]);
		i++;j--;
	}
	if(left<i-1) PairSort(a,b,c,left,i-1);
	if(j+1<right) PairSort(a,b,c,j+1,right);
}

// 配列を逆順にする
template<typename Type>
void Reverse(Type a[],int n){Rep(i,n/2) swap(a[i],a[n-i-1]);}

// 文字列を逆順にする
// reverse(All(str));

//}

int main(){
	int N;
	cin >> N;
	int A[N];
	in(A,N);
	
	double ans=0;
	Rep(i,N) ans+=1.0/A[i];
	cout << 1.0/ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define all(v)    (v).begin(), (v).end()
#define in        ([]{int n; cin>>n; return n;}())
using namespace std;
using lint = int64_t;

//  1-indexed vector
template<typename T> struct vector1 : vector<T> {
    using vector<T>::vector;
    T& operator[]( const size_t n ) {
        return vector<T>::operator[](n-1);
    }
};

int gcd( const int a, const int b ) {
	if( b == 0 ) {
		return a;
	} else {
		return gcd( b, a%b );
	}
}


int main() { cin.tie(0); ios::sync_with_stdio(false);
    int N = in;
    vector1<lint> A(N);
    for(int i=1; i<=N; i++) A[i] = in;

    vector1<int> left(N), right(N);
    left[1] = A[1];
    right[N] = A[N];
    for( int i=2; i<=N; i++ ) {
        left[i] = gcd(left[i-1], A[i]);
        right[N-i+1] = gcd(right[N-i+2], A[N-i+1]);
    }

    int ans = max( left[N-1], right[2] );
    for( int i=2; i<=N-1; i++ ) {
        ans = max( ans, gcd(left[i-1],right[i+1]) );
    }

    cout << ans << "\n";
}


Measured memory_bytes: 1792
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

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

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

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

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

// PfsMap :
func PfsMap(n int) map[int]int {
	pfs := make(map[int]int)
	for n%2 == 0 {
		pfs[2] = pfs[2] + 1
		n = n / 2
	}

	for i := 3; i*i <= n; i = i + 2 {
		for n%i == 0 {
			pfs[i] = pfs[i] + 1
			n = n / i
		}
	}

	if n > 2 {
		pfs[n] = pfs[n] + 1
	}

	return pfs
}

// Pfs :　素因数分解し、スライスを作成
func Pfs(n int) (pfs []int) {
	for n%2 == 0 {
		pfs = append(pfs, 2)
		n = n / 2
	}

	for i := 3; i*i <= n; i = i + 2 {
		for n%i == 0 {
			pfs = append(pfs, i)
			n = n / i
		}
	}

	if n > 2 {
		pfs = append(pfs, n)
	}

	return
}

type pair struct {
	x, y int
}

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

	N := getInt()
	a := PfsMap(N)
	p := make([]pair, 0)
	for i, v := range a {
		p = append(p, pair{i, v})
	}
	sort.Slice(p, func(i, j int) bool {
		return p[i].x < p[j].x
	})
	b := make([]int, 0)
	for _, x := range p {
		xx := x.x
		for x.y > 0 {
			b = append(b, x.x)
			x.x *= xx
			x.y--
		}
	}

	sort.Ints(b)

	ans := 0
	for _, x := range b {
		if N%x != 0 {
			continue
		}
		if N < x {
			break
		}
		N /= x
		ans++
	}

	out(ans)
}


Measured memory_bytes: 1740
#include<bits/stdc++.h>
using namespace std;
int n,c[500],s[500],f[500];
int main()
{
	cin>>n;
	for(int i=0;i<n-1;i++) cin>>c[i]>>s[i]>>f[i];
	for(int i=0;i<n;i++)
	{
		int t=0;
		for(int j=i;j<n-1;j++)
		{
			if(t<s[j]) t=s[j];
			else if (t%f[j]==0);
			else t=t+f[j]-t%f[j];
			t+=c[j];
		}
		cout<<t<<endl;
	}
	return 0;
}

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

typedef long long ll;
typedef pair<int, pair<int, int>> piii;
//loop
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)
//STL
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

//const
#define MOD 1000000007 //10^9+7:合同式の法

//acronym
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first      //pairの一つ目の要素
#define S second     //pairの二つ目の要素

const int INF = 1e9;

#define deg_to_rad(deg) ((deg)*M_PI / 180.0)

// const int MOD = 998244353;

void Main()
{
    int A, B, C;
    cin >> A >> B >> C;

    if (A == B)
    {
        cout << C << endl;
    }
    else if (A != C)
    {
        cout << A << endl;
    }
    else
    {
        cout << B << endl;
    }
    
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    Main();
    return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <math.h>

using namespace std;


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

	vector<int> vec(N, 0);

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


	

	int maxn=0;
	int maxj=0;
	int maxn2 = 0;
	int maxj2=0;


	for (int j = 0; j < N; j++) {
		

		if (vec[j] >= maxn) {
			maxn = vec[j];
			maxj = j;
		}
		

	}

	vec.erase(vec.begin() + maxj);


	for (int j = 0; j < N-1; j++) {


		if (vec[j] >= maxn2) {
			maxn2 = vec[j];
			maxj2 = j;
		}


	}

	for (int k = 0; k < N; k++) {
		if (k == maxj) {
			cout << maxn2 << endl;
		}
		else {
			cout << maxn << endl;
		}
	}


}

Measured memory_bytes: 2432
<?php
$n = intval(fgets(STDIN));
for($i=0;$i<$n;++$i)$a[]=intval(fgets(STDIN));
sort($a);
$max = 0;
$n2 = intdiv($n, 2);
$sum1 = 0;
$sum2 = 0;
if($n % 2 == 1){
  for($i = 0; $i < $n2; $i++)$sum1 -= $a[$i]*2;
  for($i = $n2; $i < $n; $i++)$sum1 += $a[$i]*2;
  for($i = $n2; $i < $n2+2; $i++)$sum1 -= $a[$i];//2個は端
  $a = array_reverse($a);
  for($i = 0; $i < $n2; $i++)$sum2 += $a[$i]*2;
  for($i = $n2; $i < $n; $i++)$sum2 -= $a[$i]*2;
  for($i = $n2; $i < $n2+2; $i++)$sum2 += $a[$i];//2個は端
  echo max($sum1, $sum2);
}else{
  for($i = 0; $i < $n2; $i++)$sum2 -= $a[$i]*2;
  for($i = $n2; $i < $n; $i++)$sum2 += $a[$i]*2;
  $sum2+=$a[$n2-1];
  $sum2-=$a[$n2];
  echo $sum2;
}



Measured memory_bytes: 12788
import java.lang.*;
import java.io.*;
import java.util.*;

class Main{
	public static void main(String args[]) throws FileNotFoundException{
		FScanner sc=new FScanner();
		//Scanner sc=new Scanner(System.in);
		
		int n=sc.readInt();
		String[] text=new String[n];
		for(int i=0; i<n; i++){
			text[i]=sc.readString();
		}
		
		boolean s=true;
		
		for(int i=0; i<n; i++){
			for(int j=0; j<n; j++){
				if(i!=j){
					if(text[i].equals(text[j])){
						s=false;
					}
				}
			}
		}
		
		for(int i=1; i<n; i++){
			if(text[i-1].charAt(text[i-1].length()-1)!=text[i].charAt(0)){
				s=false;
			}
		}
		
		System.out.println((s==true)? "Yes": "No");
	}
	
	static void solve(){}

	static void disp(int[] data){
		for(int i=0; i<data.length; i++){
				System.out.printf("%d ",data[i]);
		}
			System.out.println();
	}
	
	static void disp(String[] data){
		for(int i=0; i<data.length; i++){
				System.out.printf("%s ",data[i]);
		}
			System.out.println();
	}
	
	static class FScanner{
		Scanner sc;
		FScanner() throws FileNotFoundException{
			sc=new Scanner(System.in);
		}
		boolean hasNextLine(){
			boolean has=true;
			if(!sc.hasNextLine()){
				has=false;
			}
			return has;
		}
		int readInt(){
			String buf=sc.nextLine();
			return Integer.parseInt(buf);
		}
		long readLong(){
			long i=Long.parseLong(sc.nextLine());
			return i;
		}
		int[] readIntL(){
			String[] buf=sc.nextLine().split(" ");
			int[] num=new int[buf.length];
			for(int i=0; i<buf.length; i++){
				num[i]=Integer.parseInt(buf[i]);
			}
			return num;
		}
		
		String readString(){
			return sc.nextLine();
		}
		String[] readStringL(String dlm){
			String[] s=sc.nextLine().split(dlm);
			return s;
		}
	}
}


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

ll mPrime = 1000 * 1000 * 1000 + 7;

ll mMul(ll x, ll y) {
  return (x * y) % mPrime;
}

ll fact(ll n) {
  ll ans = 1;
  for (ll i = 1; i <= n; i++) {
    ans = mMul(ans, i);
  }
  return ans;
}

ll f(ll n) {
  ll x = fact(n);
  return mMul(2, mMul(x, x));
}

ll g(ll n) {
  ll x = fact(n);
  return mMul(x, mMul(x, n+1));
}

int main() {
  ll n, m;
  cin >> n >> m;
  ll ans = n == m ? f(n) : n == m+1 ? g(m) : m == n+1 ? g(n) : 0;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<int> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

int main() {
	int n;
	cin >> n;
	int b;
	VI a(n), c(n);
	ll ans = 0;
	REP(i, n)
		cin >> a[i];
	REP(i, n) {
		cin >> b;
		ans += b;
	}
	REP(i, n - 1)
		cin >> c[i];
	REP(i, n - 1) {
		if (a[i + 1] - a[i] == 1)
				ans += c[a[i] - 1];
	}
	cout << ans;
}

Measured memory_bytes: 256
#include <cstdio>
int main() {
    char c;
    scanf("%c", &c);

    if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u') {
        printf("vowel");
    }
    else
        printf("consonant");

    return 0;
}


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

int n, A[2000001], B[2000001];

void CountingSort(int A[], int B[], int n){
  int C[10010] = {0};
  for(int i=0;i<n;i++){
    C[A[i]]++;
  }
  for(int j=1;j<10001;j++){
    C[j] += C[j-1];
  }
  for(int i=0;i<n;i++){
    B[C[A[i]]] = A[i];
    C[A[i]]--;
  }
}

int main(){
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> A[i];
  }

  CountingSort(A, B, n);

  for(int i=1;i<=n;i++){
    if(i-1) cout << " ";
    cout << B[i];
  }
  cout << endl;
  return 0;
}



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

int main(){
    string s;
    int q, r = 0;
    cin >> s >> q;

    for(int i = 0; i < q; i++){
        int n;
        cin >> n;
        if(n == 1) r++;
        else{
            int f;
            char c;
            cin >> f >> c;
            if((f + r) % 2 == 1){
                string cc;
                cc.push_back(c);
                s.insert(0, cc);
            }
            else{
                s.push_back(c);
            }
        }
    }

    if(r % 2 == 1) reverse(s.begin(), s.end());
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 900
#include <iostream>
#include <list>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <algorithm>

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define MOD 1000000007

typedef long long ll;

using namespace std;
int main(){
    int N;
    cin >> N;
    ll A[N+1], B[N];
    REP(i, N + 1) {
    	cin >> A[i];
    }
    REP(i, N) {
    	cin >> B[i];
    }

    // 残りのモンスターの数
    ll C[N+1];
    REP(i, N + 1) {
    	C[i] = A[i];
    } 

    ll ans = 0;
    REP(i, N) {
    	if (C[i] > B[i]) {
    		C[i] = C[i] - B[i];
    		ans += B[i];
    	}
    	else {
    		ll r = B[i] - C[i];
    		ans += C[i];
    		C[i] = 0;
    		if (C[i + 1] > r) {
    			C[i + 1] = C[i + 1] - r;  
    			ans += r;
    		}
    		else {
    			ans += C[i + 1];
    			C[i + 1] = 0;
    		}
    	}
    }

    cout << ans << endl;
}


Measured memory_bytes: 2560
#include<iostream>
#include<vector>
#define rep(i,n) for(int i = 0; i < (n); ++i)

using namespace std;
typedef long long ll;
typedef long double ld;

int main(){
    ll  W,H,x,y;
    cin >> W >> H >> x >> y;

    cout << ( (double)W * (double)H ) / 2 << " ";

    int ans = 0;

    if( W%2 == 0 && H%2 == 0 ){
        if( x == (W/2) && y == (H/2) ) ans = 1;
    }
    
    cout << ans << endl;
    return 0;
}

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

using namespace std;

typedef pair<double, int> P;
struct point{
  double x, y, z, r;
  point(){}
  point(double x, double y, double z, double r):x(x), y(y), z(z), r(r){}
};
bool used[111];
int n;

point pos[111];

double dist(point p, point q)
{
  double x = p.x - q.x, y = p.y - q.y, z = p.z - q.z;
  double d = sqrt(x*x + y*y + z*z);
  return max(d - p.r - q.r, 0.0);
}

double prim()
{
  priority_queue<P, vector<P>, greater<P> > que;
  double total = 0.0;
  fill(used, used + 111, false);
  que.push(P(0.0, 0));
  while(!que.empty()){
    P p = que.top(); que.pop();
    int now = p.second;
    double d = p.first;
    if(used[now]) continue;
    used[now] = true;
    total += d;
    for(int i = 0; i < n; i++){
      if(i == now) continue;
      que.push(P(dist(pos[now], pos[i]), i));
    }
  }
  return total;
}

int main()
{
  while(cin >> n, n){
    for(int i = 0; i < n; i++){
      double x, y, z, r;
      cin >> x >> y >> z >> r;
      pos[i] = point(x, y, z, r);
    }
    printf("%.3f\n", prim());
  }
  return 0;
}

Measured memory_bytes: 1636
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <numeric>
#include <algorithm>
#include <utility>


using std::cout;
using std::cin;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;


ll gcd(ll a, ll b) {
    while (b != 0) {
        auto tmp = a;
        a = b;
        b = tmp % a;
    }
    return a;
}

ll lcm(ll a, ll b) {
    return (a * b) / gcd(a, b);
}

int isPrime(int a) {
    for (int i = 2; i * i <= a; ++i) {
        if (a % i == 0) {
            return 0;
        }
    }
    return 1;
}




void oneCase () {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> edges(n, vector<int>(n, 0));
    for (int i = 0; i < m; ++i) {
        int a, b;
        cin >> a >> b;
        --a;
        --b;
        edges[a][b] = 1;
        edges[b][a] = 1;
    }
    vector<int> ord(n);
    for (int i = 1; i < n; ++i) {
        ord[i] = i;
    }
    int counter = 0;
    do {
        int c = 0;
        for (int pos = 0; pos + 1 < n; ++pos) {
            c += edges[ord[pos]][ord[pos + 1]];
        }
        counter += (c == n - 1);
    } while (next_permutation(ord.begin() + 1, ord.end()));
    cout << counter << "\n";

}





int main() {
    int t = 1;
//    cin >> t;
    while (t > 0) {
        oneCase();
        --t;
    }

    return 0;
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
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;}


int main2() {
  int N; cin >> N;

  double ans = 0;
  REP(_, N) 
  {
    double x; cin >> x;
    string u; cin >> u;
    if (u == "BTC") x *= 380000.0;
    ans += x;
  }
  printf("%.10f\n", ans);
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            var KS = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var K = KS[0];
            var S = KS[1];

            var output = 0;
            for (var X = 0; X <= Math.Min(K, S); X++)
            {
                for (var Y = 0; Y <= Math.Min(K, S - X); Y++)
                {
                    var Z = S - X - Y;
                    if (Z <= K)
                    {
                        output++;
                    }
                }
            }

            Console.WriteLine(output);
        }
    }
}


Measured memory_bytes: 13268
#include<stdio.h>
int main(void)
{
	int a,b,c,d;
	d=0;
	scanf("%d%d%d",&a,&b,&c);
	while(a<=b){
		if(c%a==0){
			d++;
		}
		a++;
	}
	printf("%d\n",d);
	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
#define itn int
#define nibu(K,x) binary_search(K.begin(),K.end(),x)
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()
#define sz(x) x.size()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define out(x) cout<<x<<endl
#define put(x) out(x)
#define in(x) cin>>x
#define maxx(a,b,c) max(a,max(b,c))
#define minn(a,b,c) min(a,min(b,c))
using ll = long long;
using vl = vector<ll>;
using vs = vector<string>;
const double pi = 3.14159265358979;
const ll mod = 1000000007;

int main() {
int N;
  in(N);
  vl A(N);
  rep(i,N) in(A[i]);
  sort(all(A));
  A[N-1] /= 2;
  int wa = 0;
  rep(i,N) wa += A[i];
  out(wa);
}

Measured memory_bytes: 256