akhauriyash/Code-Regression huggingface dataset:
//#define _GLIBCXX_DEBUG
#include "bits/stdc++.h"

using namespace std;

//------------------------------- Type Names -------------------------------//

using i64 = int_fast64_t;

using seika = string;
//{akari : 1D, yukari : 2D, maki : 3D} vector
template <class kizuna>
using akari = vector<kizuna>;
template <class yuzuki>
using yukari = akari<akari<yuzuki>>;
template <class tsurumaki>
using maki = akari<yukari<tsurumaki>>;
//{akane : ascending order, aoi : decending order} priority queue
template <class kotonoha>
using akane = priority_queue<kotonoha, akari<kotonoha>, greater<kotonoha>>;
template <class kotonoha>
using aoi = priority_queue<kotonoha>;

//------------------------------- Libraries ---------------------------------//

//------------------------------- Dubug Functions ---------------------------//

inline void print()
{
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest)
{
    cout << first << ' ';
    print(rest...);
}

//------------------------------- Solver ------------------------------------//

void solve()
{
    int n;
    seika s;
    cin >> n >> s;
    int ans = 0;
    for (int i = 0; i + 2 < n; i++)
    {
        ans += s.substr(i, 3) == "ABC";
    }
    cout << ans << endl;
}

int main()
{
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <queue>
#include <vector>
using namespace std;

const int N = 100000;
vector<int> g[N];
bool u[N];
int p[N];

void bfs() 
{
	queue<int> q;
	q.push(0);
	u[0] = true;
	while (!q.empty()) {
		int v = q.front();
		q.pop();
		for (int i = 0; i < g[v].size(); ++i) if (!u[g[v][i]]) {
			u[g[v][i]] = true;
			q.push(g[v][i]);
			p[g[v][i]] = v;
		}
	}
}

int main() 
{
	int n, m;
	scanf("%d%d", &n, &m);
	int a, b;
	for (int i = 0; i < m; ++i) {
		scanf("%d%d", &a, &b);
		g[a - 1].push_back(b - 1);
		g[b - 1].push_back(a - 1);
	}
	bfs();
	printf("Yes\n");
	for (int i = 1; i < n; ++i) printf("%d\n", p[i] + 1);
	return 0;
}


Measured memory_bytes: 10176
import Data.List

inc 1 v (t:ts) = (t+v):ts
inc i v (t:ts) = t:(inc (i-1) v ts)

rnk :: Int -> [(Int,Int)] -> [(Int,Int,Int)]
rnk _ [] = []
rnk n ((a,b):[]) = [(a,b,n)]
rnk n x@((a,b):xs) =
  let a1 = takeWhile (\(a',b') -> b == b') x
      rs = dropWhile (\(a',b') -> b == b') x
      a2 = map (\(a,b) -> (a,b,n)) a1
      ln = length a1
  in
    a2 ++ (rnk (n+ln) rs)

chk [a,b,c,d] t
  = if c == d
    then inc b 1 $ inc a 1 t
    else if c > d
         then inc a 3 t
         else inc b 3 t

ans n i =
  let t = replicate n 0
      r = foldr chk t i
      t'= zip [1..] r
      r'= rnk 1 $ sortBy (\(_,a) (_,b) -> compare b a) t'
      rr= map (\(a,b,c)->c) $ sortBy (\(a,b,c) (d,e,f) -> compare a d) r'
  in
    rr

main = do
  n <- getLine
  c <- getContents
  let n' = read n :: Int
      i  = map (map read) $ map words $ lines c :: [[Int]]
      o  = ans n' i
  mapM_ print o
  

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

int main() {
	int N, K, Q;
	cin >> N >> K >> Q;
	vector<int> A(N, K - Q);
	for (int i = 0; i < Q; i++) {
		int tmp;
		cin >> tmp;
		A.at(tmp - 1)++;
	}

	for (int i = 0; i < N; i++) {
		if (A.at(i) > 0) cout << "Yes" << endl;
		else {
			cout << "No" << endl;
		}
	}
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<ll, P> E;
#define cost first
#define from second.first
#define to second.second
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

int main(void){
	int n,m,a,b,i,cnt=0;
	ll c,d[1234];
	vector<E> g;
	E e;
	bool flag = true,done[1234],neg[1234];
	fill(d,d+1234,INFLL);
	fill(neg,neg+1234,false);
	cin >> n >> m;
	d[1] = 0ll;
	done[1] = true;
	for(i=0; i<m; ++i){
		cin >> a >> b >> c;
		g.push_back(E(-c,P(a,b)));
	}
	while(true){
		for(i=0; i<m; ++i){
			e = g[i];
			if(d[e.from] < INFLL && d[e.to] > d[e.from] + e.cost){
				d[e.to] = d[e.from] + e.cost;
			}
		}
		cnt++;
		if(cnt == n){
			break;
		}
	}
	cnt = 0;
	while(true){
		for(i=0; i<m; ++i){
			e = g[i];
			if(d[e.from] < INFLL && d[e.to] > d[e.from] + e.cost){
				d[e.to] = d[e.from] + e.cost;
				neg[e.to] = true;
			}
		}
		cnt++;
		if(cnt == n){
			break;
		}
	}
	if(neg[n]){
		cout << "inf" << endl;
	}else{
		cout << (-d[n]) << endl;
	}
	return 0;
}

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

using namespace std; 
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>; 

#define INF INT_MAX/2 //(1<<(4*4-1))
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()


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

  int N;
  cin>>N;
  vector<int>h(N);
  for(int i=0;i<N;i++)cin>>h[i];

  vector<int>dp(N,0);
  for(int i=1;i<N;i++){
    if(i-2>=0)dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
    else if(i-1>=0)dp[i]=dp[i-1]+abs(h[i]-h[i-1]);
  }

  cout<<dp[N-1]<<endl;
  return 0;
}



Measured memory_bytes: 1024
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;
ll mod=1000000007;
typedef pair<int, int> P;

int main()
{
    int N,M;
    cin >> N >> M;
    vector<ll> x(N), y(M);
    ll sum_x=0, sum_y=0;
    for(int i=0; i<N; i++){
        cin >> x[i];
        sum_x+=x[i];
    }
    for(int i=0; i<M; i++){
        cin >> y[i];
        sum_y+=y[i];
    }

    //xに関して
    ll ans1=0;
    for(int i=0; i<N-1; i++){
        sum_x-=x[i];
        ll tmp=sum_x-(N-1-i)*x[i];
        while(tmp<=0) tmp+=mod;
        ans1+=tmp;
        ans1%=mod;
    }
    //yに関して
    ll ans2=0;
    for(int i=0; i<M-1; i++){
        sum_y-=y[i];
        ll tmp=sum_y-(M-1-i)*y[i];
        while(tmp<=0) tmp+=mod;
        ans2+=tmp;
        ans2%=mod;
    }

    cout << (ans1*ans2)%mod << endl;
    return 0;
}


Measured memory_bytes: 1792
#include"bits/stdc++.h"
#include<iostream>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
#define rep(i, c) for(int i = 0; i < (int)c; i++)
const ll inf = ll(1e18)+1;

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

	int a = s.size();

	rep (i,a) {
		s[i] = 'x';
	}

	cout << s<< endl;
	return 0;
}

Measured memory_bytes: 3628
import sys
input=sys.stdin.readline
n,T=map(int,input().split())
t_list=list(map(int,input().split()))
ans=0
for i in range(n-1):
    if t_list[i+1]-t_list[i]>T:
        ans+=T
    else:
        ans+=t_list[i+1]-t_list[i]
ans+=T
print(ans)
        








Measured memory_bytes: 77520
#include <iostream>

using namespace std;

int main() {
  int n;
  cin >> n;
  bool lucky = false;
  while (n) {
    int d = n % 10;
    if (d && d % 7 == 0) {
      lucky = true;
      break;
    }
    n /= 10;
  }
  cout << (lucky ? "Yes" : "No") << endl;
  return 0;
}


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

const int N = 18, M = 1<<N;
typedef long long ll;
const ll inf = 1e18;

int n, a[20];
ll dp[N+1][N+1][M];

ll solve(int l, int r, ll xl, ll xr, int mask) {
	if (l > r) return 0;
	if (dp[l][r][mask] != -1) return dp[l][r][mask];
	ll mn = inf, tmp;
//	int k;
	for (int i = l; i <= r; ++i) {
		tmp = solve(l, i-1, xl, xr+xl, mask<<1)+solve(i+1, r, xl+xr, xr, mask<<1|1)+(xl+xr)*a[i];
		if (tmp < mn) {
			mn = tmp;
//			k = i;
		}
	}
//	printf("[%d, %d] *%lld, *%lld=%lld(%d)\n", l, r, xl, xr, mn, k);
	return dp[l][r][mask] = mn;
}

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) {
		scanf("%d", a+i);
	}
	memset(dp, -1, sizeof(dp));
	cout << solve(2, n-1, 1, 1, 1)+a[1]+a[n] << endl;
}


Measured memory_bytes: 739712
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<V>;
using VVV = vector<VV>;
using VL = vector<ll>;
using VVL = vector<VL>;
using VVVL = vector<VVL>;
template<class T> using VE = vector<T>;
template<class T> using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
ll upper = MOD + MOD;
ll under = -upper;
ll UPPER = MOD * MOD;
ll UNDER = -UPPER;
const long double pi = 3.141592653589793;
const int N = 64;
int main() {
	int n; ll k;
	cin >> n >> k;
	V a(n);
	rep(i, n) {
		cin >> a[i];
		a[i]--;
	}
	VV dbl(N, V(n));
	rep(i, n) {
		dbl[0][i] = a[i];
	}
	rep(i, N - 1) rep(j, n) {
		dbl[i + 1][j] = dbl[i][dbl[i][j]];
	}
	ll ans = 0;
	rep(i, N) {
		if (k & (1LL << i)) ans = dbl[i][ans];
	}
	cout << ans + 1 << endl;
	return 0;
}

Measured memory_bytes: 54984
#include <bits/stdc++.h>
#include <algorithm>
#include <map>
#include <cstdlib>
#include <cmath>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
const double pi=acos(-1);

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

int main(){
    int n,k;
    cin >> n >> k;
    vector<int> p(n);
    for(int i=0;i<n;i++) cin >> p[i];
    sort(p.begin(),p.end());
    int sum=0;
    for(int i=0;i<k;i++) sum+=p[i];
    cout << sum << endl;
}


Measured memory_bytes: 3624
package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

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

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
func modPow(a, n, mod int) int {
	res := 1
	for n > 0 {
		if (n & 1) > 0 {
			res = res * a % mod
		}
		a = a * a % mod
		n >>= 1
	}
	return res
}

func main() {
	mod := int(1e+9) + 7
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	N := sc.nextInt()
	A := sc.nextIntSlice(N)
	// no bit
	S := make([]int, 60)
	// bit
	M := make([]int, 60)
	pows := make([]int, 60)
	for i := 0; i < 60; i++ {
		pows[i] = modPow(2, i, mod)
	}
	ans := 0
	for i := 0; i < N; i++ {
		for j := 0; j < 60; j++ {
			if A[i]&(1<<uint(j)) == 0 {
				S[j]++
				ans += M[j] * pows[j]
				ans %= mod
			} else {
				M[j]++
				ans += S[j] * pows[j]
				ans %= mod
			}
		}
	}

	fmt.Fprintln(wtr, ans)
	wtr.Flush()
}


Measured memory_bytes: 6912
def main():
  e=enumerate
  (h,w),*a=[list(map(int,t.split()))for t in open(0)]
  dp=[0]*w
  c=12800
  for i,a in e(zip(a,a[h:])):
    for j,(x,y)in e(zip(*a)):
      x=abs(x-y)
      t=0
      if j:t|=dp[j-1]<<x|dp[j-1]>>x
      if i:t|=dp[j]<<x|dp[j]>>x
      dp[j]=t if i+j else 2**c<<x
  *a,=map(int,(bin(dp[w-1])[2:]).zfill(c-~c))
  print([i for i,(f,g)in e(zip(a[c:],a[c::-1]))if f+g][0])
main()

Measured memory_bytes: 4132
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <stdio.h>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional> //operator[]
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define Rep(i,n) for(int i=1;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define Rrep(i,n) for(int i=n-1;i>0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
#define P pair<int,int>
#define Pll pair<ll,ll>
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

const ll MOD = 1000000007;
ll powmod(ll x, ll n){
    ll ret=1;
    while(n>0){
        if(n&1){
            ret*=x;
            ret%=MOD;
            n-=1;
        }
        else{
            x*=x;
            x%=MOD;
            n>>=1;
        }
    }
    return ret;
}

int main(){
    int n; cin >> n;
    ll a[n];
    map<ll,ll> mp;
    rep(i,n){
        cin >> a[i];
        ll res=a[i];
        for(int j=2;j*j<=a[i];j++){
            if(res%j==0){
                int k=0;
                while(res%j==0){
                    res/=j;
                    k++;
                }
                chmax(mp[j],k);
            }
        }
        if(res>1) chmax(mp[res],1LL);
    }
    ll k=1;
    for(auto u:mp){
        k*=powmod(u.fi,u.se);
        k%=MOD;
    }
    //cout << k << endl;
    ll ans=0;
    rep(i,n){
        ans+=(k*(powmod(a[i],MOD-2)%MOD))%MOD;
        ans%=MOD;
    }
    cout << ans << endl;
}


Measured memory_bytes: 896
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
#include <map>
#include <set>
#include <deque>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int mod = 1e9+7;
typedef pair<int, int> P;
const int inf = 1<<30;

class UnionFind {
  public:
    // 親の番号を格納する。親だった場合は-(その集合のサイズ)
    vector<int> Parent;

    // 作る時はParentの値を全て-1にする
    // こうすると全てバラバラが表現できる。
    UnionFind(int N) {
      Parent = vector<int>(N, -1);
    }

    // Aがどのグループに属しているか調べる
    int root(int A) {
      if(Parent[A] < 0) return A;
      return Parent[A] = root(Parent[A]);
    }

    int size(int A) {
      return -Parent[root(A)]; // 親を取ってきたい
    }

    bool connect(int A, int B) {
      // AとBを直接繋ぐのではなく、root(A)をroot(B)をくっつける
      A = root(A);
      B = root(B);
      if(A == B) {
        //すでにくっついているからくっつけない
        return false;
      }

      // 大きい方に小さい方をくっつけたい
      // 代償が逆だったらひっくり返す
      if(size(A) < size(B)) swap(A, B);
      // Aのsizeを更新
      Parent[A] += Parent[B];
      // Bの親をAに変更する
      Parent[B] = A;

      return true;
    }

    bool same(int A, int B) {
      return root(A) == root(B);
    }
};

int main() {
  int n, m, k; cin >> n >> m >> k;
  UnionFind uni(n);
  int g[n] = {0};
  vector<vector<int>> to(n);
  rep(i, m) {
    int a, b; cin >> a >> b; a--, b--;
    uni.connect(a, b);
    g[a]++, g[b]++;
  }

  rep(i, k) {
    int a, b; cin >> a >> b; a--, b--;
    to[a].push_back(b);
    to[b].push_back(a);
  }

  rep(i, n) {
    int ans = uni.size(i) - g[i] - 1;
    for(int u: to[i]) {
      if(uni.same(i, u)) ans--;
    }
    if(i) cout << " ";
    cout << ans;
  }
  cout << endl;


  return 0;
}


Measured memory_bytes: 6784
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
const int maxn = 2000; //
struct node {
    long long a,b,c,s;
} g[maxn];
int n,m;
long long s[maxn];

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


int main() {
      cin >> n >> m;
        memset(s,0,sizeof(s));
      long long ans=-1e9;
        for(int i = 1; i <= n; i++) 
		  cin >> g[i].a >> g[i].b >> g[i].c,g[i].s = g[i].a + g[i].b + g[i].c;
	for(int l=-1;l<=1;l+=2)
        for(int j=-1;j<=1;j+=2)
            for(int k=-1;k<=1;k+=2)
        {  
		 for(int i = 1; i <= n; i++)
        	
		   {long long sum=0;
		    if(l==1) sum += g[i].a;
              else sum -= g[i].a;
            if(j==1) sum += g[i].b;
               else sum-= g[i].b;
            if(k==1) sum += g[i].c;
               else sum -= g[i].c;
			s[i]=sum;
		   }
		   sort(s+1,s+n+1,cmp);
		     long long sum1 = 0;
               for(int i = 1; i <= m; i++)
                  sum1 += s[i];
               ans=max(ans,sum1);
		}
       
        cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	int n;
	int a[105];
	int b[105];
	cin>>n;
	ll ans;
	for(int i=1; i<n; i++)
	{
		cin>>b[i];
		if(i==1)
			ans=b[1];
		if(b[i-1]>b[i])
			b[i-1]=b[i];
	}

	for(int i=1; i<n; i++)
	{
		ans+=b[i];
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime> 
#include <memory.h>
#include <assert.h>

using namespace std;

using ll = long long;
using pii = pair<int, int>;
const int INF = 1e9 + 1;
const ll LLINF = 1e18 + 1;

int main() {
    int A, B;
    cin >> A >> B;

    cout << max({A+B, A+A-1, B+B-1});

    return 0;
}

Measured memory_bytes: 256
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
//#include <unordered_set> //unordered_set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
#define endl "\n";
using namespace std;

const long long INF = 100100100100100;
const int MOD = 1000000007;
const int inf = 1001001001;
typedef pair<int,int> P;

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}

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



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

    int N;cin >> N;
    string S;cin >> S;
    int ans = 0;
    int left = 0,right = N-1;
    bool alreadyW = false,alreadyR = false;
    while(left < N && right >= 0 && left < right ){
        if(alreadyW && alreadyR){
            ans++;
            alreadyW = false;
            alreadyR = false;
            left++;
            right--;
        }
        if(S.at(left) == 'W'){
            alreadyW = true;
        }
        else{
            left++;
        }
        if(S.at(right) == 'R'){
            alreadyR = true;
        }
        else{
            right--;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3740
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<set>
#include<tuple>
#include<ctime>
#include<functional>
#include<cmath>
#include<cassert>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> p; 
#define rep(i,n) for(ll i=0;i<(n);i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))

 int main(){
     ll N,A[101],min=10000000000,max=0;
     cin>>N;
     rep(i,N) cin>>A[i];
     rep(i,N) {
         if(min>A[i]) min=A[i];
         if(max<A[i]) max=A[i];
     }
     p(max-min);
 }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll          long long int
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mod         1000000007
#define F           first
#define S           second
#define ld          long double
#define rep(i,a,b)  for(ll i=a;i<b;i++)

const int N = 55, M = 110;
ll n, t, a[N], dp[N][N][M];

ll recur(ll l, ll r, ll k)
{
    if(k<=0) return 0;
    if(l==r) return a[l];
    ll &ans=dp[l][r][k];
    if(ans != -1) return ans;
    /*ll op1 = recur(l+1, r, k-1) + a[l];
    ll op2 = recur(l, r-1, k-1) + a[r];
    ll op3 = recur(l+1, r, k-2);
    ll op4 = recur(l, r-1, k-2);
    ll op5 = 0;
    ans = max(op1, op2);
    ans = max(ans, op3);
    ans = max(ans, op4);
    ans = max(ans, op5);*/
    ans = max(ans, a[l] + recur(l+1, r, k-1));
    ans = max(ans, a[r] + recur(l, r-1, k-1));
    ans = max(ans, recur(l+1, r, k-2));
    ans = max(ans, recur(l, r-1, k-2));
  	ans = max(ans, 0LL);
    //return ans;
    return ans;
    
}
 
void solve()
{
    cin>>n>>t;
    memset(dp, -1, sizeof dp);
    rep(i, 1, n+1) cin>>a[i];
    ll ans=recur(1, n, t);
    cout<<ans<<endl;
}

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


Measured memory_bytes: 2816
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
inline int read() {
	int  x = 0, f = 1, c = getchar();
	for (;!isdigit(c); c = getchar()) if (c == '-') f ^= 1;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	return f ? x : -x;
}
int cal(int a, int b, int c) {
	int L = (a + b) / (min(a, b) + 1);
	int x = (c - 1) / L, y = a - c;
	return max({
		1LL * L,
		c - 1LL * x * L,
		b - 1LL * y * L - x,
		y != 0 ?
			a - c <= b - x ?
			1LL * (a - c + b - x) / (a - c + 1) :
			a - 1LL * x * L <= 1LL * (b - x + 1) * L ?
			1LL * L :
			1LL * L + 1
		: 1LL * L
	});
}
int main() {
	int q = read();
	for (; q --; ) {
		int a = read(), b = read();
		int c = read(), d = read();
		int L = (a + b) / (min(a, b) + 1);
		int lb = 0, rb = a;
		while (lb < rb) {
			int md = (lb + rb + 1) >> 1;
			if ((md - 1) / L <= b && cal(a, b, md) <= L) lb = md;
			else rb = md - 1;
		}
		int lenL = lb + (lb - 1) / L;
		for (int i = c; i <= min(d, lenL); ++ i) {
			if (i % (L + 1) == 0) putchar('B');
			else putchar('A');
		}
		for (int i = max(lenL + 1, c); i <= d; ++ i) {
			if ((a + b - i + 1) % (L + 1) == 0) putchar('A');
			else putchar('B');
		}
		puts("");
	}
	return 0;
}


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

int main() {
  int N;
  cin >>N;
   if(N%7 == 0)
     cout << "Yes" << endl;
  else 
   for ( ; ; N -= 7) {
     if(N < 4){
      cout << "No" << endl;
     break;
     }
    if(N%4 == 0){
     cout << "Yes" << endl;
     break;
      }
  } 
}    

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define LL long long 
#define LLU long long unsigned
#define rarr(arr, n) for(int aab = 0; aab < n; aab++){cin >> arr[aab];}
#define parr(arr, n) for(int aab = 0; aab < n; aab++){cout << arr[aab] << " ";}
#define pb push_back
#define f first
#define s second
#define all(x) x.begin(), x.end()
#define debug(x) cout << #x << " = " << x << "\n";

#define freopen freopen("in.txt", "r", stdin);freopen("out.txt", "w", stdout);ios_base::sync_with_stdio(0);cin.tie(0);

int main(){
	char c;
	cin >> c;
	if(isupper(c)){
		cout << "A";
	}
	else{
		cout << "a";
	}
} 

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const double pi = 3.141592654;

int main()
{

    //freopen("Input.txt","r",stdin);
    ios_base :: sync_with_stdio(false);
    ll t;
    //cin>>t;
    t=1;
    while(t--)
    {
        ll k;
        cin>>k;
        ll a,b;
        cin>>a>>b;
        string s="NG";
        for(int i=a; i<=b; i++)
        {
            if(i%k==0)
            {
                s="OK";
                break;
            }
        }
        cout<<s<<endl;
    }
}


Measured memory_bytes: 3648
#include<cstdio>
#include<algorithm>
using namespace std;
struct ss{
	int rank;
    int p;
    int y;
}a[100005];
int cmp(ss x,ss y){
    if(x.p!=y.p) return x.p<y.p;
    else return x.y<y.y;
}
int main()
{
    int n ,m;
    scanf("%d%d",&n,&m);
    int b[100005];
    for(int i=0;i<m;i++){
    	a[i].rank=i;
        scanf("%d%d",&a[i].p,&a[i].y); 	
        b[i]=a[i].p;
	}
    sort(a,a+m,cmp);
    int f=a[0].p,flag=1;
    int x[100005];
    
    for(int i=0;i<m;i++){
    	if(a[i].p!=f) {flag=1;f=a[i].p;}
    	x[a[i].rank]=flag++;
	}
    // for(int i=0;i<m;i++)
    //    cout<< a[i].rank<<" "<<a[i].p<<" " <<a[i].y<<endl;
    for(int i=0;i<m;i++)
        printf("%06d%06d\n",b[i],x[i]);
    return 0;
}


Measured memory_bytes: 4088
import java.util.*;
public class Main {
        static Scanner sc = new Scanner(System.in);
        static void myout(Object t){System.out.println(t);}//standard output
        static void myerr(Object t){System.err.println(t);}//standard error
        static String getStr(){return sc.next();}
        static int getInt(){return Integer.parseInt(getStr());}
        static long getLong(){return Long.parseLong(getStr());}
        static boolean isNext(){return sc.hasNext();}
        static char[] mySplit(String str){return str.toCharArray();}
        public static void main(String[] args){
          int H = getInt();
          int W = getInt();
          char[][] masu = new char[H][W];
          //q内要素が多いと時間かかる
          ArrayDeque<int[]> q = new ArrayDeque<int[]>();
          for(int i = 0; i < H; i++){
            masu[i] = mySplit(getStr());
          }
          
          for(int i = 0; i < H; i++){
            for(int j = 0; j < W; j++){
              if(masu[i][j] == '#'){
                //4方のうち、1か所でも.があればqに追加
                if(true){
                  int[] mp = {i, j ,0};
                  q.add(mp);
                }
              }
            }
          }
          
          int output = 0;
          
          
          //myerr(q);
          while(!q.isEmpty()){
            int[] tmp = q.poll();
            int y = tmp[0];
            int x = tmp[1];
            int count = tmp[2];
            //myerr(y + " " + x);
            output = Math.max(output,count);
            if(y != 0 && masu[y - 1][x] == '.'){
                int[] mp = {y- 1, x ,count + 1};
                masu[y - 1][x] = '#';
                q.add(mp);
            }
            if(x != 0 && masu[y][x - 1] == '.'){
                int[] mp = {y, x - 1, count + 1};
              	masu[y][x - 1] = '#';
                q.add(mp);
            }
            if(y != H - 1 && masu[y + 1][x] == '.'){
                int[] mp = {y + 1, x, count + 1};
              	masu[y + 1][x] = '#';
                q.add(mp);
            }
            if(x != W - 1 && masu[y][x + 1] == '.'){
              	int[] mp = {y, x + 1, count + 1};
              	masu[y][x + 1] = '#';
                q.add(mp);
            }
          }
          myout(output);
        }
        //Method addition frame start

        //Method addition frame end
}


Measured memory_bytes: 66884
while True:
    n = int(input())
    if n == 0:
        break
    a = list(map(int, input().split()))
    b = []
    cnt = 0
    while True:
        for i in a:
            b.append(a.count(i))
        if a == b:
            break
        else:
            a, b = b[:], []
            cnt+=1
    print(cnt)
    print(*a)


Measured memory_bytes: 5600
#include <iostream>

using lint = long long;

void solve() {
    lint x1, v1, x2, v2, t;
    std::cin >> x1 >> v1 >> x2 >> v2 >> t;
    lint dx = std::abs(x1 - x2),
         dv = v1 - v2;

    std::cout << (dx <= dv * t ? "YES" : "NO") << "\n";
}

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

    solve();

    return 0;
}


Measured memory_bytes: 3616
#include<stdio.h>
#include<math.h>

int main(void){
    int i,n;
    double s[10000];
    double v=0.0,ta=0.0;
    for(;;){
        v=0.0;
        ta=0.0;
        scanf("%d",&n);
        if(n==0){
            break;
        }

        for(i=0;i<n;i++){
            scanf("%lf",&s[i]);
            ta += s[i];
        }
        ta = ta/n;
        for(i=0;i<n;i++){
            v += (s[i]-ta)*(s[i]-ta);
        }
        v=v/n;
        printf("%.8f\n",sqrt(v));
    }
    return 0;
}


Measured memory_bytes: 2080
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

const int INF = INT_MAX / 4;

template <class T>
class EdgeBase
{
public:
    int to;
    T cost;
    EdgeBase(){};
    EdgeBase(int to0, T cost0){to = to0; cost = cost0;}
};
typedef EdgeBase<int> Edge;

template<class T>
void shortestPath(const vector<vector<EdgeBase<T> > >& edges, int start, vector<T>& dist)
{
    dist.assign(edges.size(), INF);
    dist[start] = 0;
    priority_queue<pair<T,int>, vector<pair<T,int> >, greater<pair<T,int> > > q;
    q.push(make_pair(0, start));

    while(!q.empty()){
        pair<T, int> p = q.top();
        q.pop();
        int v = p.second;
        if(dist[v] < p.first)
            continue;
        for(unsigned i=0; i<edges[v].size(); ++i){
            EdgeBase<T> e = edges[v][i];
            if(dist[v] + e.cost < dist[e.to]){
                dist[e.to] = dist[v] + e.cost;
                q.push(make_pair(dist[e.to], e.to));
            }
        }
    }
}

template <class T>
void shortestPath(const vector<vector<EdgeBase<T> > >& edges, vector<vector<int> >& dist)
{
    dist.resize(edges.size());
    for(unsigned i=0; i<edges.size(); ++i)
        shortestPath(edges, i, dist[i]);
}

int main()
{
    int n, r;
    cin >> n >> r;
    vector<vector<Edge> > edges(n);
    for(int i=0; i<r; ++i){
        int s, t, d;
        cin >> s >> t >> d;
        -- s;
        -- t;
        edges[s].push_back(Edge(t, d));
        edges[t].push_back(Edge(s, d));
    }

    vector<vector<int> > dist;
    shortestPath(edges, dist);
    int maxDist = 0;
    for(int i=0; i<n; ++i){
        for(int j=0; j<n; ++j){
            if(dist[i][j] < INF)
                maxDist = max(maxDist, dist[i][j]);
        }
    }

    vector<bool> check(n, true);
    for(int i=0; i<n; ++i){
        queue<int> q;
        vector<bool> used(n, false);
        for(int j=0; j<n; ++j){
            if(dist[i][j] == maxDist){
                q.push(j);
                check[j] = false;
                used[j] = true;
            }
        }
        while(!q.empty()){
            int a = q.front();
            q.pop();
            for(const Edge& e : edges[a]){
                if(!used[e.to] && dist[i][e.to] + e.cost == dist[i][a]){
                    q.push(e.to);
                    check[e.to] = false;
                    used[e.to] = true;
                }
            }
        }
    }

    vector<int> ans;
    for(int i=0; i<n; ++i){
        if(check[i])
            ans.push_back(i+1);
    }
    cout << ans.size() << endl;
    for(int a : ans)
        cout << a << endl;

    return 0;
}

Measured memory_bytes: 11840
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
		// 出力
      	double b = Math.floor((double)a/100);
		double c = a - b*100;
      	if(c>5*b){
        	System.out.println(0);
        }else{
        	System.out.println(1);
        }
      	
	}
}

Measured memory_bytes: 21844
#[allow(unused_imports)]
use std::cmp;
use std::io::Write;

// Input macro from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
  (source = $s:expr, $($r:tt)*) => {
    let mut iter = $s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
  ($($r:tt)*) => {
    let s = {
      use std::io::Read;
      let mut s = String::new();
      std::io::stdin().read_to_string(&mut s).unwrap();
      s
    };
    let mut iter = s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
}

macro_rules! input_inner {
  ($iter:expr) => {};
  ($iter:expr, ) => {};

  ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
    let $var = read_value!($iter, $t);
    input_inner!{$iter $($r)*}
  };
}

macro_rules! read_value {
  ($iter:expr, ( $($t:tt),* )) => {
    ( $(read_value!($iter, $t)),* )
  };

  ($iter:expr, [ $t:tt ; $len:expr ]) => {
    (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
  };

  ($iter:expr, chars) => {
    read_value!($iter, String).chars().collect::<Vec<char>>()
  };

  ($iter:expr, usize1) => {
    read_value!($iter, usize) - 1
  };

  ($iter:expr, $t:ty) => {
    $iter.next().unwrap().parse::<$t>().expect("Parse error")
  };
}

fn is_sq(x: i32) -> bool {
  for i in 0 .. x + 1 {
    if i * i == x {
      return true;
    }
  }
  false
}

fn main() {
  let out = std::io::stdout();
  let mut out = std::io::BufWriter::new(out.lock());
  macro_rules! puts {
    ($($format:tt)*) => (write!(out,$($format)*).unwrap());
  }
  input! {
    n: usize,
    d: usize,
    x: [[i32; d]; n],
  }
  let mut count = 0;
  for i in 0 .. n {
    for j in 0 .. i {
      let mut ds = 0;
      for k in 0 .. d {
        ds += (x[i][k] - x[j][k]).pow(2);
      }
      if is_sq(ds) {
        count += 1;
      }
    }
  }

  puts!("{}\n", count);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll n,W,cost[105],weight[105];
ll func()
{
   ll i, w;
   ll dp[n+1][W+1];

   for (i = 0; i <= n; i++)
   {
       for (w = 0; w <= W; w++)
       {
           if (i==0 || w==0)
               dp[i][w] = 0;
           else if (weight[i-1] <= w)
                 dp[i][w] = max(cost[i-1] + dp[i-1][w-weight[i-1]],  dp[i-1][w]);
           else
                 dp[i][w] = dp[i-1][w];
       }
   }

   return dp[n][W];
}

int main()
{
    scanf("%lld%lld",&n,&W);
    //memset(dp,-1,sizeof(dp));
    for(ll i=0;i<n;i++)
        scanf("%lld%lld",&weight[i],&cost[i]);
    ll ans=func();
    printf("%lld\n",ans);
}


Measured memory_bytes: 79104
#include <bits/stdc++.h>
using namespace std;
//using ll = long long;
#define ll long long
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll tmp1,tmp2,tmp3,ans;
const ll mod = 998244353;
const int INF = 1e9;
const ll INFLONG = 1e18;
//void swap(ll *x,ll *y){
//  ll z = *x;
//  *x = *y;
//  *y = z;
//}
//ll gcd(ll x,ll y){
//  if(y == 0){
//    return x;
//  }
//  return gcd(y,x%y);
//}
int main(){
  ll n;
  cin >> n;
  vector<ll> vec(n);
  rep(i,n){
    cin >> vec[i];
  }
  ll sum = 0;
  rep(i,n){
    REP(j,i+1,n){
      sum += vec[i] * vec[j];
    }
  }
  cout << sum << endl;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const ll INF = LLONG_MAX;

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n), asum(n);
  cin >> a[0];
  asum[0] = a[0];

  for (ll i = 1; i < n; ++i) cin >> a[i], asum[i] = asum[i - 1] + a[i];

  ll mind = INF;
  for (ll i = 0; i < n - 1; ++i) mind = min(mind, abs(asum[n - 1] - 2LL*asum[i]));

  cout << mind << endl;
  return 0;
}


Measured memory_bytes: 3328
def finding_word(target_w, w_list):
    n = w_list.count(target_w)

    print(str(n))

if __name__ == "__main__":

    target_w = input()
    w_list   = list()

    while(True):
        line = input()

        if line == "END_OF_TEXT":
            break

        line = line.split(" ")
        for w in line:
            w_list.append(w.lower())

    finding_word(target_w, w_list)



Measured memory_bytes: 5556
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define FOR0(i,n) for(i=0;i<n;i++)
#define FOR(i,j,n) for(i=j;i<n;i++)
#define FORD(i,j,k) for(i=j;i>=k;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 1000000000
#define ninf -1000000000
#define endl '\n' 
#define she_told_me_dont_worry ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// Use cout.flush() for interactive problems.
// Use this for increased stack size: g++ -o a.exe -Wl,--stack=256000000 -O2 source.cpp
inline long long  MAX2(long long  a, long long int b){return (a)>(b)?(a):(b);}
inline long long  MAX3(long long  a, long long  b,long long  c){return (a)>(b)?((a)>(c)?(a):(c)):((b)>(c)?(b):(c));}
inline long long  MIN2(long long  a, long long  b){return (a)<(b)?(a):(b);}
inline long long  MIN3(long long  a, long long b,long long c){return (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c));}
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< ii > vii;
vi p, r, ssi; 
void initialize(int N) 
{
        r.assign(N, 0);
        ssi.assign(N, 1);
        p.assign(N, 0); for (int i = 0; i < N; i++) p[i] = i; 
}
int findSet(int i) { return (p[i] == i) ? i : (p[i] = findSet(p[i])); }
bool isSameSet(int i, int j) { return findSet(i) == findSet(j); }
void unionSet(int i, int j)
{
    if (!isSameSet(i, j))
    {
        int x = findSet(i), y = findSet(j);
        if (r[x] > r[y]) 
        {
            p[y] = x; 
            ssi[x] +=ssi[y];
        }
        else 
        {
            p[x] = y;
            ssi[y] += ssi[x];
            if (r[x] == r[y]) r[y]++;
        }
    }
}
int sizeOfSet(int i){return ssi[findSet(i)];}
int main()
{
    she_told_me_dont_worry
    int n, m, k;
    cin>>n>>m>>k;
    initialize(n+5);
    vector < vi > f(n+5), b(n+5);
    int i;
    FOR0(i, m)
    {
        int u, v;
        cin>>u>>v;
        u--;v--;
        f[u].pb(v);
        f[v].pb(u);
        unionSet(u, v);
    }
    FOR0(i, k)
    {
        int u, v;
        cin>>u>>v;
        u--;v--;
        b[u].pb(v);
        b[v].pb(u);
    }
    FOR0(i, n)
    {
        int cur = sizeOfSet(i)-1;
        cur -= f[i].size();
        int j, si = b[i].size();
        FOR0(j, si)
        {
            int v = b[i][j];
            if(isSameSet(v, i)) cur--;
        }
        cout<<cur<<" ";
    }
    cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
}

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

map<string, bool> Map;

int main() {
	string str; int Tot; char Last;
	cin >> Tot;
	cin >> str; Map[str] = true; Last = str[str.size() - 1];

	for (int pos = 2; pos <= Tot; pos++) {
		cin >> str;
		if (Last != str[0] || Map[str]) {
			puts("No"); return 0;
		}
		Map[str] = true;
		Last = str[str.size() - 1];
	}
	puts("Yes");
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <iomanip>
#include <bits/stdc++.h>
#include <fstream>
#include <map>
using namespace std;
typedef long long ll;
#define INF 1000000000000 //10^12:極めて大きい値,∞
#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--)


int main(){
  vector<ll> A{0,0,0};
  bool flag = false;
  cin >> A[0] >> A[1] >> A[2];
  sort(A.begin(),A.end());
  REP(i,3){
    if(A[i]%2==0){
      flag = true;
      break;
    }
  }
  if(flag){
    cout << 0 << endl;
    return 0;
  }
  else{
    ll result = A[0]*A[1];
    cout << result << endl;
    return 0;
  }
}

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


class SegmentTree():
    # リストSの部分リストからなる集合を葉とするセグメント木
    def __init__(self, S, n):
        self.size = n
        self.array = [set()] * (2**(self.size + 1) - 1)
        for i, c in enumerate(S):
            self.array[i + 2**self.size - 1] = {c}
        for i in range(2**self.size - 1)[::-1]:
            self.array[i] = self.array[2 * i + 1] | self.array[2 * i + 2]

    def subquery(self, l, r, k, i, j):
        # 区間[i,j)の中で区間[l,r)の文字列の集合を返す
        if j <= l or r <= i:
            return set()
        elif l <= i and j <= r:
            return self.array[k]
        else:
            l_set = self.subquery(l, r, 2 * k + 1, i, (i + j) // 2)
            r_set = self.subquery(l, r, 2 * k + 2, (i + j) // 2, j)
            return l_set | r_set

    def query(self, l, r):
        # [l,r)に含まれる文字の種類数
        return len(self.subquery(l, r, 0, 0, 2**self.size))

    def update(self, i, c):
        # 配列のi番目をcに更新する
        tmp = i + 2**self.size - 1
        self.array[tmp] = {c}
        while tmp > 0:
            tmp = (tmp - 1) // 2
            self.array[tmp] = self.array[2 * tmp + 1] | self.array[2 * tmp + 2]


def main():
    n = int(input())
    S = list(input())
    S = [ord(s) for s in S]
    segtree = SegmentTree(S, 19)
    for _ in range(int(input())):
        t, i, c = input().split()
        if t == '1':
            segtree.update(int(i)-1, ord(c))
        if t == '2':
            print(segtree.query(int(i)-1, int(c)))


main()


Measured memory_bytes: 471752
n,k=map(int,input().split())
list_1=[]
for _ in range(n):
    list_1.append(0)
#print(list_1)

for i in range (k):
    d=int(input())
    list_temp=list(map(int,input().split()))
    for j in list_temp:
        list_1[j-1]+=1
#print(list_1)

print(list_1.count(0))


Measured memory_bytes: 9180
#include <algorithm>
#include<stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include<stack>
#include <queue>
#include<map>
#include <set>
#include<math.h>
using namespace std;
#define int long long
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define elif else if
#define P pair<ll,ll>
const int inf = 1000000007;
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2) * pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % inf;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	return kai(x)* mod_pow(kai(x - y), inf - 2, inf) % inf * mod_pow(kai(y), inf - 2, inf) % inf;
}
struct union_find {
	int par[200010], size_[200010];
	void init(int x) {
		rep(i, x) { par[i] = i; size_[i] = 1; }
	}
	int find(int x) {
		if (par[x] == x)return x;
		return par[x] = find(par[x]);
	}
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y)return;
		if (size_[x] < size_[y]) {
			par[x] = y;
			size_[y] += size_[x];
		}
		else {
			par[y] = x;
			size_[x] += size_[y];
		}
	}
};
struct edge { int to, cost; };

signed main() {
	int a, b;
	cin >> a >> b;
	if (a < b)cout << 0 << endl;
	else cout << 10 << endl;
}



Measured memory_bytes: 256
def io_tmp():
    global input
    import io
    f = io.StringIO(open(0).read())
    input = f.readline

io_tmp()


from scipy.sparse.csgraph import floyd_warshall
import numpy as np

N, M, L = map(int, input().split())
graph = np.zeros((N, N), dtype=np.int64)
for _ in range(M):
    s, t, w = map(int, input().split())
    graph[s-1, t-1] = graph[t-1, s-1] = w
dist = floyd_warshall(graph, directed=False)
graph = np.ones((N, N))
np.fill_diagonal(graph, 0)
graph[dist > L] = np.inf
dist = floyd_warshall(graph, directed=False)
dist[np.isinf(dist)] = 0
dist = dist.astype(int)

Q = int(input())
ans = []
for _ in range(Q):
    s, t = map(int, input().split())
    ans.append(dist[s-1][t-1] - 1)
print(*ans, sep='\n')


Measured memory_bytes: 26948
#include <iostream>

int main(){
    int a, b, c, d;
    std::cin >> a >> b >> c >> d;

    int taka_count = (c + b - 1) / b;
    int ao_count = (a + d - 1) / d;

    std::cout << (taka_count <= ao_count ? "Yes" : "No") << std::endl;    

    return 0;
}

Measured memory_bytes: 3620
<?php
    $N = array_fill(1, 100, "");
    for($i = 1; $i <= 100; $i++){
        $N[$i] = trim(fgets(STDIN));
    }
    $count_num = array_count_values($N);
    unset($count_num[""]);
    $max_num = max($count_num);
    for($i = 1; $i <= count($count_num); $i++){
        if(in_array($max_num,$count_num)){
            $ans_num = array_search($max_num,$count_num);
            unset($count_num[$ans_num]);
            $answer[] = $ans_num;
        }
    }
    sort($answer);
    foreach ($answer as $value) {
        echo ($value).PHP_EOL;
    }


Measured memory_bytes: 9316
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	static Scanner scanner;

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

        int A=gi();
        int B=gi();
        int K=gi();
        
        if(2*K-1>=B-A) {
            for (int i=A; i<=B;i++) {
            	System.out.println(i);
            }
        } else {
        	for (int i=A; i<A+K;i++) {
            	System.out.println(i);
            }
        	for (int i=B-K+1; i<=B;i++) {
            	System.out.println(i);
            }
        }


	   // System.out.println(c);

//	    if (isNumber(s1) && isNumber(s2) && s.charAt(a) == '-') {
//	    	System.out.print("Yes");
//	    }else {
//	    	System.out.print("No");
//	    }



	}

	public static long d(long n) {
		String a=String.valueOf(n);
		return (long)a.length();
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 36012
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
int main() {
    string S;
    cin>>S;
    vector<int>ans(S.size()+1);

    int i = 0;
    int count =1;

    while (true)
    {
        while (S[i] == S[i + 1]) {
            count++;
            i++;
            if(i+1>=S.size()){
                break;
            }

        }

        if (S[i] == '<') {
            for (int j = 0; j <= count; ++j) {
                ans[(i + 1) - j] = max(count - j,ans[(i+1)-j]);
            }
        } else if (S[i] == '>') {
            for (int j = 0; j <= count; ++j) {
                ans[(i + 1) - j] = max(j,ans[(i+1)-j]);
            }
        }

        if (i + 1 >= S.size()) {
            break;
        }
        i++;
        count = 1;
    }


    auto answer= std::accumulate(ans.begin(),ans.end(),0LL);
    cout<<answer<<endl;

}

Measured memory_bytes: 2820