akhauriyash/Code-Regression huggingface dataset:
n = int(input())
def dist(x1,y1,x2,y2):
    return abs(y1-y2)+abs(x1-x2)
result = "Yes"
pre_t,pre_x,pre_y = (0,0,0)
for i in range(n):
    tmp_t,tmp_x,tmp_y = map(int,input().split())
    if (dist(pre_x,pre_y,tmp_x,tmp_y) > tmp_t - pre_t) or ((dist(pre_x,pre_y,tmp_x,tmp_y)-(tmp_t - pre_t))%2!=0):
        result = "No"
    pre_t,pre_x,pre_y = tmp_t,tmp_x,tmp_y
print(result)

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


def main():
    N = int(input())
    P = list(map(int, input().split()))

    cnt = 0
    for i in range(N-1):
        if P[i] != i+1:
            cnt += 1
    
    if cnt <= 2:
        print('YES')
    else:
        print('NO')


if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename Q_temp>
using smaller_queue = priority_queue <Q_temp, vector<Q_temp>, greater<Q_temp> >;

const ll MOD = (ll) 998244353;
const int INF = (int) 1e9;
const ll LINF = (ll) 4e18;
const double PI = acos(-1.0);

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbg2(x_) for(auto a_ : x_) cerr << a_ << " "; cerr << endl;
#define dbg3(x_ , sx_) rep(i, sx_) cerr << x_[i] << " "; cerr << endl;
vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

inline ll CEIL(ll a, ll b) {
    return (a + b - 1) / b;
}

void finish() {
    cout << -1 << endl;
    exit(0);
}

//------------------------------------------------------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(20) << setiosflags(ios::fixed);
    int n, m;
    cin >> n >> m;
    int a[1001], b[1001], c[1001][12];

    rep(i, m) {
        cin >> a[i] >> b[i];

        rep(j, b[i]) {
            cin >> c[i][j];
            c[i][j]--;
        }
    }

    int dp[1001][(1 << 12)];
    rep(i, 1001) rep(j, (1 << 12)) dp[i][j] = INF;

    dp[0][0] = 0;

    rep(i, m) rep(j, (1 << n)) {
        //鍵を買う場合
        bitset<12> bs(j);

        rep(k, b[i]) {
            bs[c[i][k]] = 1;
        }
        dp[i + 1][(int) bs.to_ulong()] = min(dp[i + 1][bs.to_ulong()], dp[i][j] + a[i]);

        //鍵を買わない場合
        dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
    }

    cout << (dp[m][(1 << n) - 1] == INF ? -1 : dp[m][(1 << n) - 1]) << endl;
    return 0;
}


Measured memory_bytes: 16384
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>
#define vi vector<int>
#define vii vector<vi>

const double pi = 3.14159265358979323846264;
const int mod=1000000007;

int main(){
	int a,s,d;
	cin>>a>>s>>d;
	a+=s+d;
	if(a>=22){
		cout<<"bust"<<endl;
	}else{
		cout<<"win";
	}


}


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

 int func(int n, int a) {
   int res = 0;
   while (n > 0) {
     res += n % a;
     n /= a;
   }
   return res;
 }

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

   int ans = N;

   rep(i, 0, N + 1) {
     int tmp = func(i, 6) + func(N - i, 9);
     ans = min(ans, tmp);
   }

   cout << ans << endl;
 }


Measured memory_bytes: 256
from collections import deque
N = int( input())
D = dict()
Path = [ [] for _ in range(N)]
for _ in range(N-1):
    a, b, c = map( int, input().split())
    a, b = a-1, b-1
    D[1000000*a+b] = c
    D[1000000*b+a] = c
    Path[a].append(b)
    Path[b].append(a)
Q, K = map( int, input().split())
foot = [ 0 for _ in range(N)]
foot[K-1] = 1
length = [ 0 for _ in range(N)]
A = deque([])
for d in Path[K-1]:
    foot[d] = 1
    A.append(d)
    length[d] = D[1000000*d + K-1]
while len(A) != 0:
    d = A.pop()
    foot[d] = 1
    for g in Path[d]:
        if foot[g] == 0:
            length[g] = length[d] + D[1000000*d + g]
            A.append(g)
for _ in range(Q):
    x, y = map( int, input().split())
    print(length[x-1]+length[y-1])

Measured memory_bytes: 53056
package main

import (
  "fmt"
)

func maxInt(a ...int) int {m := a[0]; for _, x := range a {if x > m {m = x}}; return m}
func minInt(a ...int) int {m := a[0]; for _, x := range a {if x < m {m = x}}; return m}

func main() {
  var w, a, b int 
  fmt.Scan(&w, &a, &b)
  if a > b {a, b = b, a}
  fmt.Println(maxInt(0, b - (a + w)))
}

Measured memory_bytes: 512
use std::collections::VecDeque;
use std::io;

fn main() {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    let k: i64 = buf.trim().parse().unwrap();
    let mut queue: VecDeque<i64> = VecDeque::new();

    for i in 1..10 {
        queue.push_back(i);
    }

    let mut count: i64 = 0;

    loop {
        // k番目のlunlunNumberかの判定処理
        let previous_digit_num: i64 = queue.pop_front().unwrap();
        count += 1;
        if count == k {
            println!("{}", previous_digit_num);
            break;
        }
        // lunlunNumberの追加処理
        let basic_digit: i64 = previous_digit_num * 10;
        let remainder: i64 = previous_digit_num % 10;
        if remainder != 0 {
            queue.push_back(basic_digit + remainder - 1);
        }

        queue.push_back(basic_digit + remainder);

        if remainder != 9 {
            queue.push_back(basic_digit + remainder + 1);
        }
    }
}


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

#define fto(i, x, y) for(int i = (x); i <= (y); ++i)
#define fdto(i, x, y) for(int i = (x); i >= (y); --i)
#define ftoa(i, x, y, a) for(int i = (x); i <= (y); i += a)
#define ftoit(it, var) for (__typeof(var.begin()) it = var.begin(); it != var.end(); ++it)

#define ii pair<int, int>
#define mp make_pair
#define FF first
#define SS second

#define vi vector<int>
#define vii vector<ii>
#define ll long long
#define vll vector<ll>

#define eb emplace_back
#define ef emplace_front
#define lb lower_bound
#define ub upper_bound

#define oo 1000000007
#define OO 1000000000000000007LL

using namespace std;

#define Pro "tmp"
#define maxN 300007

bool a[maxN];
string s;

ll ans = 0LL;
map <pair <string, string>, int> m;

void gen(int k, int l, int r) {
    if (k > r) {
        string str = "";
        fto (i, l, r) if (a[i]) str += s[i];

        string str2 = "";
        fdto (i, r, l) if (!a[i]) str2 += s[i];

        if (l == 1) ++m[mp(str, str2)];
        else ans += m[mp(str2, str)];

        return;
    }

    a[k] = 0;
    gen(k+1, l, r);

    a[k] = 1;
    gen(k+1, l, r);

    return;
}
int main() {

//    int T;
//    scanf("%d", &T);
//
//    fto (i_test, 1, T) {
//        ll a, b, c, d;
//        scanf("%lld%lld%lld%lld", &a, &b, &c, &d);
//
//        if (d < b || a < b) {
//            puts("No");
//            continue;
//        }
//        if (c >= b) {
//            puts("Yes");
//            continue;
//        }
//
//        bool valid = 1;
//        fto (k, 1, 1000) {
//            if (c+k >= b) break;
//            ll tmp = ((c+k-a)%b+b)%b;
//            //(k*d)%b = ((c+1-a)%b+b)%b;
//            if (tmp%__gcd(d, b) == 0) {
//                puts("No");
//                valid = 0;
//                break;
//            }
//        }
//
//        if (valid) puts("Yes");
//    }

    int n;
    cin >> n;

    cin >> s;
    s = '#'+s;

    gen(1, 1, n);
    gen(n+1, n+1, 2*n);

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


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

using namespace std;

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

    vector<int> a(n);
    int odd = 0;

    for (int i : a)
    {
        cin >> i;
        if (i % 2 != 0)
            odd++;
    }

    if (odd % 2 == 0)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 3768
#include <iostream>

using namespace std;

int main() {
	int c[101] = {};
	int a, mx = 0;
	while (cin >> a) {
		mx = max(mx, ++c[a]);
	}
	for (int i=0; i<101; ++i) {
		if (mx == c[i]) cout << i << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
input_num=input().split()
num=[]

for i in input_num:
	if i=='+' or i=='-' or i=='*' or i=='/':
		n1=int(num.pop())
		n2=int(num.pop())
		
		if i=='+':
			num.append(n2+n1)
		elif i=='-':
			num.append(n2-n1)
		elif i=='*':
			num.append(n2*n1)
		else:
			num.append(n2/n1)
	else:
		num.append(int(i))
print(num[0])


Measured memory_bytes: 5600
//
//  AOJ0027.c
//  
//
//  Created by 中野 優 on 2014/02/22.
//
//

#include <stdio.h>
int main(void){
    int i=0,j,k,sum,n,month[100],date[100],md[12]={31,29,31,30,31,30,31,31,30,31,30,31};
    while(1){
        scanf("%d %d",&month[i],&date[i]);
        if(month[i]==0) break;
        i++;
    }
    for(j=0;j<i;j++){
        sum=0;
        for(k=0;k<month[j]-1;k++) sum+=md[k];
        sum+=date[j];
        n=sum%7;
        switch (n) {
            case 1:
                printf("Thursday\n");
                break;
            case 2:
                printf("Friday\n");
                break;
            case 3:
                printf("Saturday\n");
                break;
            case 4:
                printf("Sunday\n");
                break;
            case 5:
                printf("Monday\n");
                break;
            case 6:
                printf("Tuesday\n");
                break;
            case 0:
                printf("Wednesday\n");
                break;
                
        }
    }
    return 0;
}

Measured memory_bytes: 584
#include<iostream>
#include <cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;


int main(){
  ll N; cin >> N;
  ll cnta[62]={0}; ll cntb[62] = {0};
  rep(i, N){
    ll a;
    cin >> a;
    rep(j, 60){
      if((a) & (1ll<<j)){
        cnta[j]++;
      }
      else cntb[j]++;
    }
  }
  ll tmp; ll ans = 0;
  rep(i, 60){
    tmp= 1;
    rep(j, i){
      tmp *= 2; tmp %= mod;
    }
    tmp *= cnta[i];
    tmp %= mod;
    tmp *= cntb[i];
    tmp %= mod;
    ans += tmp;
    ans %= mod;
  }
  cout << ans%mod << endl;  
 
 }

Measured memory_bytes: 384
/**
 *   
 *   Date: 17 August 2019
 *   Time: 17:35:30
**/
#include <iostream>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <vector>
#include <cmath>
#include <cstring>
#include<queue>
#include<stack>
#include<climits>
#include<iomanip>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pi;
typedef vector<ll> vec;
typedef vector<vector<ll> > matrix;

int main(){
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);
	string s1="",st,s2;
	ll k=1,n;
	cin>>st;
	n=st.length();
	s1+=st[0];
	for(ll i=1;i<n;i++)
	{
		s2="";
		for(ll j=i;j<n;j++)
		{
			s2+=st[j];
			if(s1 != s2)
			{
				k+=1;
				s1=s2;
				i=j;
				//b=true;
				break;
			}

		}
	}
	cout<<k<<endl;


return 0;
}

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

typedef long long lint;
typedef long double louble;

template<typename T1,typename T2> inline T1 max(T1 a,T2 b){return a<b?b:a;}
template<typename T1,typename T2> inline T1 min(T1 a,T2 b){return a<b?a:b;}

namespace ae86
{
	const int bufl = 1<<15;
	
	char buf[bufl],*s=buf,*t=buf;
	
	inline int fetch()
	{
		if(s==t){t=(s=buf)+fread(buf,1,bufl,stdin);if(s==t)return EOF;}
		return *s++;
	}
	
	inline lint ty()
	{
		lint a=0;int b=1,c=fetch();
		while(!isdigit(c))b^=c=='-',c=fetch();
		while(isdigit(c))a=a*10+c-48,c=fetch();
		return b?a:-a;
	}
}
using ae86::ty;

const int _ = 100007;

struct cxk
{
	lint x,t;
	cxk(lint _x=0,lint _t=0){x=_x,t=_t;}
	inline friend int operator < (cxk a,cxk b){return a.x<b.x;}
};
priority_queue<cxk> q;

int n,qn;
lint val[_],stk[_],chaf[_]={0};int top=0;

int main()
{
	n=ty(),qn=ty();

	val[0]=n;
	for(int i=1;i<=qn;i++)val[i]=ty();

	top=1,stk[top]=val[0];
	for(int i=1;i<=qn;i++)
	{
		while(top && stk[top]>=val[i])top--;
		stk[++top]=val[i];
	}

	q.emplace(cxk(stk[top],1));

	for(int i=top-1;i>=1;i--)
	{
		cxk a=q.top();
		lint cnt=0,len=stk[i];
		while(a.x>len)
		{
			q.pop(),cnt+=a.t*(a.x/len),a.x%=len;
			if(a.x)q.emplace(a);
			if(q.empty())break;
			a=q.top();
		}
		if(cnt)q.emplace(stk[i],cnt);
	}

	while(!q.empty())chaf[q.top().x]+=q.top().t,q.pop();
	for(int i=n;i>=1;i--)chaf[i]+=chaf[i+1];
	for(int i=1;i<=n;i++)printf("%lld\n",chaf[i]);

	return 0;
}


Measured memory_bytes: 5744
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, long long> P;
int main(){
    long long N, M;
    cin >> N >> M;
    vector<int> G[N];
    for(int i = 0; i < M; i++){
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    vector<int> used(N, -1);
    vector<long long> d(N, 1e9);
    queue<P> q;
    q.push(P(0, 0));
    used[0] = 0;
    d[0] = 0;
    while(!q.empty()){
        P t = q.front();
        q.pop();
        for(int j: G[t.first]){
            if(used[j] != -1) continue;
            d[j] = d[t.first] + 1;
            used[j] = t.first;
            q.push(P(j, d[j]));
        }
    }
    for(int i = 0; i < N; i++){
        if(used[i] == -1){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    for(int i = 1; i < N; i++){
        cout << used[i] + 1 << endl;
    }
}

Measured memory_bytes: 12196
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define Fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define MOD 1000000007

ll a,b,k,i; 

int main()
{
    Fast;
    cin>>k;
    a=100;
    for(i=1;;i++)
    {
        a=a*(1.01);
        if(a>=k)
        {
            cout<<i<<endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int maxn = 5050, mod = 1e9 + 7;

int main() {
	cin.tie(0)->sync_with_stdio(0);
	ll x, k, d;
	cin >> x >> k >> d;
	ll t = min(abs(x)/d, k);
	if(x < 0) x += t*d;
	else x -= t*d;
	k -= t;
	if(k&1) cout << min(abs(x-d), abs(x+d)) << endl;
	else cout << abs(x) << endl;
}


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

int main() {
	int n;long long a;
	cin >> n;
	long long count=0, ans=1e9;
	for (int i = 0; i < n; i++) {
		cin >> a;
		while (1) {
			if (a % 2 != 0) {
				break;
			}
			a /= 2;
			count++;
		}
		ans = min(count, ans);
		count = 0;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
//by yjz
#include<bits/stdc++.h>
using namespace std;
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
#define foreach(it,s) for(__typeof((s).begin()) it=(s).begin();it!=(s).end();it++)
#ifndef LOCAL
#define cerr if(0)cout
#endif
typedef long long ll;
const int mod=1e9+7;
//My i/o stream
struct fastio
{
	char s[100000];
	int it, len;
	fastio() {it=len=0;}
	inline char get()
	{
		if (it<len) return s[it++]; it=0;
		len=fread(s, 1, 100000, stdin);
		if (len==0) return EOF; else return s[it++];
	}
	bool notend()
	{
		char c=get();
		while (c==' '||c=='\n') c=get();
		if (it>0) it--;
		return c!=EOF;
	}
}_buff;
#define geti(x) x=getnum()
#define getii(x,y) geti(x),geti(y)
#define getiii(x,y,z) getii(x,y),geti(z)
#define puti(x) putnum(x),putchar(' ')
#define putii(x,y) puti(x),puti(y)
#define putiii(x,y,z) putii(x,y),puti(z)
#define putsi(x) putnum(x),putchar('\n')
#define putsii(x,y) puti(x),putsi(y)
#define putsiii(x,y,z) putii(x,y),putsi(z)
inline ll getnum()
{
	ll r=0; bool ng=0; char c; c=_buff.get();
	while (c!='-'&&(c<'0'||c>'9')) c=_buff.get();
	if (c=='-') ng=1, c=_buff.get();
	while (c>='0'&&c<='9') r=r*10+c-'0', c=_buff.get();
	return ng?-r:r;
}
template <class T> inline void putnum(T x)
{
	if (x<0) putchar('-'), x=-x;
	register short a[20]={}, sz=0;
	while (x) a[sz++]=x%10, x/=10;
	if(sz==0) putchar('0');
	for (int i=sz-1; i>=0; i--) putchar('0'+a[i]);
}
inline char getreal() {char c=_buff.get(); while (c<=32) c=_buff.get(); return c;}
ll qpow(ll x, ll k) {return k==0? 1: 1ll*qpow(1ll*x*x%mod,k>>1)*(k&1?x:1)%mod;}
int mx[55][55], n, a[55], b[55];
bool f[55][55];
void prework()
{
	for (int i=0; i<=50; i++)
	{
		for (int j=0; j<=50; j++)
		{
			mx[i][j] = 60;
			if (i==j) mx[i][j] = 0;
			else
			{
				for (int k=1; k<=j; k++)
				{
					if (mx[i][j%k]<60)
					{
						mx[i][j] = k;
						break;
					}
				}
			}
		}
	}
}
int main()
{
	prework();
	cin>>n;
	for (int i=0; i<n; i++)
	{
		int x;
		cin>>x;
		a[i] = x;
		f[i][x] = 1;
	}
	for (int i=0; i<n; i++)
	{
		cin>>b[i];
	}
	ll ans = 0;
	while (true)
	{
		int cur = 0;
		for (int i=0; i<n; i++)
		{
			int mn = 60;
			for (int j=0; j<=50; j++)
			{
				if (f[i][j])
				{
					mn = min(mn, mx[b[i]][j]);
				}
			}
			if (mn==60)
			{
				puts("-1");
				return 0;
			}
			cur = max(cur, mn);
		}
		if (cur==0) break;
		ans |= 1ll<<cur;
		for (int i=0; i<n; i++)
		{
			for (int j=0; j<=50; j++)
			{
				if (f[i][j])
				{
					f[i][j%cur] = 1;
				}
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}


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

struct primegroup{
    vector<int> r;

    primegroup(int n){
        r = vector<int>(1000001, 0);
        r[1] = n;
    }

    void unite(int x){
        for(int i=2; i*i<=x; i++){
            if(x%i != 0) continue;

            while(x%i == 0){
                x/=i;
            }

            r[i]++;
        }    

        if(x != 1) r[x]++;
    }

    void judge(){
        int maxval=0;

        for(auto i=2; i<r.size(); i++){
            if(r[i]>0)
                maxval = max(maxval, r[i]);
        }

        if(maxval <= 1)
            cout<<"pairwise coprime"<<endl;
        else if(maxval != r[1])
            cout<<"setwise coprime"<<endl;
        else
            cout<<"not coprime"<<endl;
        
    }
};

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

    for(int i=0; i<n; i++){
        int m;
        cin>>m;
        pg.unite(m);
    }

    pg.judge();
    
    return 0;
}


Measured memory_bytes: 7200
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long int lli;
int main()
{
    ios::sync_with_stdio(0); 
    cin.tie(0); cout.tie(0);
    lli n;
    cin>>n;
    lli i,j,ans=0;
    
    for(i=2;i*i<=n;i++)
    {
        if(n%i==0)
        {
            lli cur=n;
            while(cur%i==0)
            {
                cur/=i;
            }
            if(cur==1) ans++;
            else 
            {
                cur--;
                if(cur%i==0) ans++;
            }
            if(i==(n/i)) continue;
            lli store=i;
            i=n/i;
            if(n%i==0)
            {
                lli cur=n;
                while(cur%i==0)
                {
                    cur/=i;
                }
                if(cur==1) ans++;
                else 
                {
                    cur--;
                    if(cur%i==0) ans++;
                }
            }
            i=store;
        }
        //cout<<i<<" "<<ans<<endl;
    }
    
    n--;
    for(i=2;i*i<=n;i++)
    {
        if(n%i==0)
        {
            ans++;
        }
        if(i==(n/i)) continue;
        
        lli store=i;
        i=n/i;
        if(n%i==0)
        {
            ans++;
        }
        i=store;
    }
    
    if(n+1==2) ans=1;
    else     ans+=2;
    cout<<ans;
    return 0;
}

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

int main() {
    vector<int> a(3);
    rep(i,3) cin>>a[i];
    int ans=0;
    sort(a.begin(),a.end());
    int maxi=a[2];
    a[0]=maxi-a[0];
    a[1]=maxi-a[1];
    if (a[0]%2==a[1]%2) {
        ans+=a[1]+(a[0]-a[1])/2;
    } else {
        ans++;
        a[0]++;
        ans+=a[1]+(a[0]-a[1])/2;        
    }
    cout<<ans<<endl;

}


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

int main()
{
	int n;
	cin >> n;
	int a[n+1];
	for (int i = 1; i <= n; i++)
		cin >> a[i];
	int rev[n+1];
	for (int i = 1; i <= n; i++)
		rev[a[i]] = i;
	for (int i = 1; i <= n; i++)
		cout << rev[i] << " ";
	return (0);
}


Measured memory_bytes: 1536
H, W = map(int, input().split())

A = []

for i in range(H):
    A.append(list(map(int, input().split())))
    
ans_loc = []
ans_count = 0

for i in range(H):
    for j in range(W):
        if i == H-1 and j == W-1:
            break
        elif i%2 == 0:
            x = j
            y = i
            if j == W-1:
                x_d = 0
                y_d = 1
            else:
                x_d = 1
                y_d = 0
             
        else:
            x = (W-j-1)
            y = i
            if j == W-1:
                x_d = 0
                y_d = 1
            else:
                x_d = -1
                y_d = 0
                
        if A[y][x]%2 == 1:
            A[y][x] -= 1
            A[y+y_d][x+x_d] += 1
            ans_loc.append((y+1,x+1,y+y_d+1,x+x_d+1))
            ans_count += 1

print(ans_count)

for i in ans_loc:
    print(' '.join(map(str, i)))
            
            




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

int main() {
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  
  if((A + B) > (C + D)){
    cout << "Left" << endl;
  }
  else if((A + B) == (C + D)){
    cout << "Balanced" << endl;
  }
  else{
    cout << "Right" << endl;
  }
}


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

using ll = long long;

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

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

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

    int N;
    string S;
    int Q;
    cin >> N >> S >> Q;
    vector<int> K(Q); cin >> K;

    vector<int> sumd(N);
    vector<int> summ(N);
    vector<ll> sumdm(N);
    for (int i = 0; i < N; i++) {
        sumd[i] = (i == 0 ? 0 : sumd[i-1]) + (S[i] == 'D' ? 1 : 0);
        summ[i] = (i == 0 ? 0 : summ[i-1]) + (S[i] == 'M' ? 1 : 0);
        sumdm[i] = (i == 0 ? 0LL : sumdm[i-1]) + (S[i] == 'M' ? sumd[i] : 0);
    }

    for (int k : K) {
        ll ans = 0;
        for (int i = 0; i < N; i++) {
            if (S[i] == 'C') {
                ll dm = 0;
                if (i - 1  >= 0) {
                    dm = sumdm[i-1];
                    if (i - k >= 0) {
                        dm -= sumdm[i-k];
                        dm -= (ll)sumd[i-k] * (summ[i-1] - summ[i-k]);
                    }
                }
                ans += dm;
            }
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 17052
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

const MOD: u64 = 1_000_000_000 + 7;
fn main() {
    input! {
        n: usize,
        a: [usize; n],
    }
    let mut ans = 1;
    let mut cnt = vec![0; n+1];
    cnt[0] = 3;
    
    for &a_ in a.iter() {
        ans *= cnt[a_];
        ans %= MOD;
        if ans == 0 {
            break;
        }
        cnt[a_] -= 1;
        cnt[a_+1] += 1;
    }
    println!("{}", ans);
}


Measured memory_bytes: 6396
#include <iostream>
    #include <string>
    using namespace std;
     
    int main()
    {
      string S;
      cin >> S;
      
      int i;
      int flag = 0;
      for (i=0;i<3;i++){
        if (S[i] == S[i+1]){
          flag = 1;
        }
      }
      
      if (flag){
        cout << "Bad" << endl;
      }else {
        cout << "Good" << endl;
      }
      
      return 0;
    }

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

int main(){
  int n;cin>>n;
  ll maxpls=-1e11,minpls=1e11,maxmns=-1e11,minmns=1e11;
  REP(i,n){
    ll x,y;
    cin>>x>>y;
    maxpls=max(maxpls,x+y);
    minpls=min(minpls,x+y);
    maxmns=max(maxmns,x-y);
    minmns=min(minmns,x-y);
  }

  cout<<max({maxpls-minpls, -minmns+maxmns, maxmns-minmns, -minpls+maxpls});
}

Measured memory_bytes: 3624
#include<stdio.h>

int main(){
  int a,b,c;
  
  scanf("%d%d%d",&a,&b,&c);

  if(a>b) a^=b^=a^=b;
  if(b>c) b^=c^=b^=c;
  if(a>b) a^=b^=a^=b;

  printf("%d %d %d\n",a,b,c);
  
    return 0;

}



Measured memory_bytes: 2728
import java.util.Scanner;
 
class Main {
  public static void main(String[] args) {
      for (int i = 1; i < 10; i++) {
          for (int j = 1; j < 10; j++) {
              System.out.println( i + "x" + j + "=" + i*j);
          }
      }
  }
}

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

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

    int ans = 0;
    for(int i = 2; i < n; i++){
        if((p[i-1] <= p[i] && p[i] <= p[i+1]) ||
             (p[i+1] <= p[i] && p[i] <= p[i-1])){
                 ans++;
        }
    }

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

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

int main(){
  int n,a,b,c; cin>>n>>a>>b>>c;
  vector<int> l(n);
  for(int i=0; i<n; ++i)cin>>l[i];

  int ans=100000000;
  for(int i=0; i<1<<2*n; ++i){
    int j=i;
    vector<int> aa, bb, cc;
    for(int k=0; k<n; ++k){
      if(j%4==1)aa.push_back(l[k]);
      else if(j%4==2)bb.push_back(l[k]);
      else if(j%4==3)cc.push_back(l[k]);
      j/=4;
    }

    int as=aa.size(), bs=bb.size(), cs=cc.size();
    if(as==0 || bs==0 || cs==0)continue;
    int costa=max(as-1, 0)*10, costb=max(bs-1, 0)*10, costc=max(cs-1, 0)*10;
    costa+=abs(a-accumulate(aa.begin(), aa.end(), 0));
    costb+=abs(b-accumulate(bb.begin(), bb.end(), 0));
    costc+=abs(c-accumulate(cc.begin(), cc.end(), 0));

    ans=min(ans, costa+costb+costc);
  }

  cout<<ans<<endl;
}


Measured memory_bytes: 256
import sys

n, l = map(int, sys.stdin.readline().split())

def main():
    s = (l - 1) * n + (1 + n) * n // 2
    res = []
    for i in range(1, n+1):
        f = l + i - 1
        res.append((abs(f), s - f))
    
    res.sort()
    return res[0][1]

if __name__=='__main__':
    ans = main()
    print(ans)

Measured memory_bytes: 3060
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
MOD = 998244353
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N, K = LI()
    LR = [LI() for _ in range(K)]

    dp = [0] * (N + 1)
    dp[0] = 1
    a = [0] * (N + 1)
    a[0] = 1
    a[1] = -1
    for i in range(N):
        for l, r in LR:
            left = min(i + l, N)
            right = min(i + r + 1, N)
            a[left] += dp[i]
            a[right] -= dp[i]
        dp[i+1] += dp[i] + a[i+1]
        dp[i+1] %= MOD
        # print(a)
        # print(dp)

    print(dp[-2])

if __name__ == '__main__':
    resolve()


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

int main(){
    int n,m,c,temp,ans;
    cin >> n >> m >> c;
    vector<int> b(m),a(m);
    rep(i,0,m) cin >> b.at(i);
    ans = 0;
    rep(i,0,n){
        temp = c;
        rep(k,0,m){ 
            cin >> a.at(k);   
            temp += a.at(k)*b.at(k);
        }
        if(temp>0) ans++;

    }
    cout << ans << endl;
}

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

int main()
{
	int N;
	cin >> N;
	vector<int> A(N);
	for (int i = 0; i < N; ++i)
		cin >> A[i];
	int c = 0;
	while (true) {
		if (all_of(A.begin(), A.end(), [](int a) { return (a & 1) == 0; })) {
			transform(A.begin(), A.end(), A.begin(), [](int a) { return a >> 1; });
			++c;
		}
		else {
			break;
		}
	}
	cout << c << endl;
	return 0;
}

Measured memory_bytes: 256
def main():
  s = str(input())
  s_ = set(list(s))
  t =  str(input())
  t_ =  set(list(t))
  alphabet = "abcdefghijklmnopqrstuvwxyz"
  if t_ <= s_:
    length_s = len(s)
    
    res = [[length_s]*(26)  for _ in range(length_s+1)]
    for i in range(length_s-1, -1, -1):
      for j in range(26):
        if s[i] == alphabet[j]:
          res[i][j] = i+1
        else:
          res[i][j] = res[i+1][j]
    ans = 0
    now = 0
    for i in range(len(t)):
      for j in range(26):
        if t[i] == alphabet[j]:
          ans += res[now][j]-now
          now = res[now][j]
          if now == length_s:
            if t[i] == s[-1]:
              now = 0
            else:
              ans += res[0][j]
              now = res[0][j]
    print(ans)
  else:
    print(-1)
if  __name__  == "__main__":
  main()

Measured memory_bytes: 72580
#include <bits/stdc++.h>
#include <vector>
#include <queue>
#include <iostream>
#include <iomanip>
using namespace std;
typedef long long LL;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)

int main(){
    int N;
    cin >> N;
    vector<int> h(N);
    REP(i,N)cin>>h[i];

    int count = h[0];
    FOR(i,1,N){
        if(h[i] - h[i-1] >= 0){
            count += h[i] - h[i-1];
        }
    }

    cout << count << endl;
    return 0;
    
}

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

int main(){
    int n;
    cin >> n;
    vector<char> color(n);

    int flag = 0;
    for (int i = 0; i < n; i++){
        cin >> color.at(i);
        if (color.at(i)=='Y') {
            cout << "Four";
            flag++;
            break;
        }
    }
    if (flag == 0)
        cout << "Three";
}

Measured memory_bytes: 256
import math
N=int(input())
list=[]
for i in range(N):
  list.append(input().split())
pathlengths=0
for i in range(N-1):
  for j in range(i+1,N):
    pathlengths=pathlengths+math.sqrt((int(list[i][1])-int(list[j][1]))**2+(int(list[i][0])-int(list[j][0]))**2)
print(pathlengths*2/N)

Measured memory_bytes: 3064
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	int n; cin>>n;
	ll a[100010];
	for(int i=0; i<=n; i++) cin>>a[i];
	if(n==0){
		if(a[0]==1){
			cout<<1<<endl;
		}else{
			cout<<-1<<endl;
		}
		return 0;
	}
	if(a[0]>0){
		cout<<-1<<endl;
		return 0;
	}
	ll l[100010], r[100010];
	l[n-1]=(a[n]+1)/2, r[n-1]=a[n];
	for(int i=n-2; i>=0; i--){
		l[i]=(l[i+1]+a[i+1]+1)/2;
		r[i]=(r[i+1]+a[i+1]);
	}
	if(l[0]>1 || r[0]<1){
		cout<<-1<<endl;
		return 0;
	}
	ll l2[100010], r2[100010];
	l2[0]=1, r2[0]=1;
	const ll INF=1e18;
	for(int i=1; i<n; i++){
		l2[i]=l2[i-1]-a[i];
		r2[i]=min(INF, 2*r2[i-1]-a[i]);
	}
	ll ans=0;
	for(int i=0; i<=n; i++) ans+=a[i];
	for(int i=0; i<n; i++){
		ans+=min(r[i], r2[i]);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 6760
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

void solve(){
    vector<char> vc(9);
    rp(i,9) cin >> vc[i];
    cout << vc[0] << vc[4] << vc[8];
    cout << endl;
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define COUT(x) cout<<(x)<<endl
#define dump(x)  cout << #x << " = " << (x) << endl;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
using M = map<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int, vector<int>, greater<int>>;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  int a,b; cin >> a >> b;
  COUT((1+(b-a))*(b-a)/2-b);
  return 0;
}

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


public class Main {
	public static void main(String[] args) {
		ArrayList<Integer> caseNum = new ArrayList<Integer>();
		int num;
		Scanner sc = new Scanner(System.in);

		//??\??????????????????0?????§??°?????????
		while (sc.hasNext()) {
			num=sc.nextInt();

			//0??\??????????????????
			if(num==0){
				break;
			}
			//??\???????????´??°?????????????????????
			caseNum.add(num);
		}
		//??\???????????´??°?????¨???
		for (int i = 0; i < caseNum.size(); i++) {
			System.out.println("Case "+(i+1)+": "+caseNum.get(i).intValue());
		}
	}
}

Measured memory_bytes: 42216
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define endl '\n'
#define pb push_back
#define fi first
#define se second
#define all(c) (c).begin(),(c).end()
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

const ll inf = 2e18;
const int mod = 1e9 + 7;
const int N = 2e5 + 10;

signed main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

	int n;
	cin >> n;
	int a[n];
	for(int i = 0; i < n; i++) {
		cin >> a[i];
	}
	int ans = 0;
	for(int i = 0; i < n; i++) {
		for(int j = i + 1; j < n; j++) {
			for(int k = j + 1; k < n; k++) {
				if(a[i] != a[j] && a[i] != a[k] && a[j] != a[k] && a[i] + a[j] > a[k] && a[i] + a[k] > a[j] && a[k] + a[j] > a[i]) {
					ans++;
				}
			}
		}
	}
	cout << ans;

	return 0;
}

Measured memory_bytes: 3632
import sys
#import numpy as np

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in ss]
ss2nnn = lambda ss: [s2nn(s) for s in ss]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline().rstrip() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    N, K = i2nn()
    V = i2nn()
    n = 0
    for l in range(K+1):
        for r in range(K+1-l):
            if l + r > N:
                continue
            v = V[:l]
            if r > 0:
                v += V[-r:]
            vp = []
            vn = []
            for t in v:
                if t > 0:
                    vp.append(t)
                elif t < 0:
                    vn.append(t)
            vn.sort()
            k = K-l-r
            n2 = sum(vn[k:]) + sum(vp)
            if n < n2:
                n = n2
    print(n)

main()


Measured memory_bytes: 42604
#include <bits/stdc++.h>
#define ll long long
#define CEIL(a,b) ((a) / (b) + ((a) % (b) == 0 ? 0 : 1))
#define rep(i,b) for(ll i=0;i<b;i++)
using namespace std;

ll n,bi;
vector<ll> b;
vector<ll> ans;

int main(){
    cin >> n;
    rep(i, n) {
        cin >> bi;
        b.push_back(bi);
    }
    rep(i, n) {
        bool flag = false;
        rep(j, b.size()) {
            int idx= b.size()-j-1;
            if (b[idx] == idx+1) {
                ans.push_back(b[idx]);
                b.erase(b.begin()+idx);
                flag = true;
                break;
            }
        }
        if (!flag) {
            cout << -1 << endl;
            return 0;
        }
    }
    rep(i, n)cout << ans[n-i-1] << endl;
}

Measured memory_bytes: 256
import sys

N = int(input())
word = list()
for i in range(N):
	word.append(input())

word_set = set(word)
if len(word) != len(word_set): # 同じ単語が使われた時
	print('No')
	sys.exit()

for i in range(N):
	alphabet = list(word[i])
	if i != 0 and last != alphabet[0]:
		print('No')
		sys.exit()	
	last = alphabet[-1]
print('Yes')

Measured memory_bytes: 3064
N,Y = map(int,input().split())
for x in range(N+1):
    if x*10000 > Y: break
    for y in range(N-x+1):
        if x*10000 + y*5000 > Y: break
        z = N-x-y
        if z < 0: break
        if z * 1000 == Y - x*10000 - y*5000:
            print(x,y,z)
            exit()
print('-1 -1 -1')

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

int a[100010];

int main(){
    int n; cin>>n;
    for(int i=0;i<n;i++){
        int t; cin>>t;
        a[t]++;
    }
    int ans=-1;
    for(int i=1;i<100000;i++){
        ans=max(ans,a[i-1]+a[i]+a[i+1]);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

int dp[2010][2010];
int sum[2010][2010];

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<int> s(n), t(m);
    rep(i, 0, n) cin >> s[i];
    rep(i, 0, m) cin >> t[i];
    rep(i, 0, m + 1) dp[0][i] = 1;
    rep(i, 0, n){
        rep(j, 0, m){
            if(s[i] == t[j]){
                (dp[i + 1][j + 1] += dp[i][j]) %= mod;
            }
        }
        rep(j, 0, m){
            (dp[i + 1][j + 1] += dp[i + 1][j]) %= mod;
        }
        rep(j, 0, m + 1){
            (dp[i + 1][j] += dp[i][j]) %= mod;
        }
    }
    cout << dp[n][m] << endl;
}

Measured memory_bytes: 32512
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Map;
import java.util.TreeMap;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int n = Integer.parseInt(sa[0]);
		int d = Integer.parseInt(sa[1]);
		int a = Integer.parseInt(sa[2]);
		Obj[] arr = new Obj[n];
		for (int i = 0; i < n; i++) {
			sa = br.readLine().split(" ");
			Obj o = new Obj();
			o.x = Integer.parseInt(sa[0]);
			o.h = Integer.parseInt(sa[1]);
			arr[i] = o;
		}
		br.close();

		Arrays.parallelSort(arr, (o1, o2) -> o1.x - o2.x);

		long ans = 0;
		long now = 0;
		TreeMap<Integer, Long> map = new TreeMap<>();
		for (int i = 0; i < n; i++) {
			Obj o = arr[i];
			Map<Integer, Long> map2 = map.headMap(o.x - d);
			for (Long val : map2.values()) {
				now -= val;
			}
			map2.clear();
			long rem = Math.max(o.h - now, 0);
			long cnt = (rem + a - 1) / a;
			ans += cnt;
			rem = a * cnt;
			now += rem;
			map.put(o.x + d, rem);
		}
		System.out.println(ans);
	}

	static class Obj {
		int x, h;
	}
}


Measured memory_bytes: 80748
#include<stdio.h>
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <map>
#include <functional>
#include <stdio.h>
#include <array>
#include <algorithm>
#include <string>
#include <string.h>
#include <assert.h>
#include <stdio.h>
#include <queue>
#include<iomanip>
#include<bitset>
#include<stack>
#include<set>
#include<limits>
#include <complex>
#include<cstdlib>
using namespace std;

int memo[203][203][6];
int field[203][203];
int sx, sy, gx, gy;

pair<int, int>tmove(const int x,const int y, const int way) {
	if ((x % 2)) {
		if (way == 0) {
			return{ x,y + 1 };
		}
		else if (way == 1) {
			return{ x + 1,y };
		}
		else if (way == 2) {
			return{ x + 1,y - 1 };
		}
		else if (way == 3) {
			return{ x,y - 1 };
		}
		else if (way == 4) {
			return{ x - 1,y - 1 };
		}
		else if (way == 5) {
			return{ x - 1,y };
		}
		else {
			return{ x,y };
		}
	}
	else {
		if (way == 0) {
			return{ x,y + 1 };
		}
		else if (way == 1) {
			return{ x + 1,y+1 };
		}
		else if (way == 2) {
			return{ x + 1,y };
		}
		else if (way == 3) {
			return{ x,y - 1 };
		}
		else if (way == 4) {
			return{ x - 1,y };
		}
		else if (way == 5) {
			return{ x - 1,y+1 };
		}
		else {
			return{ x,y };
		}
	}
}

struct a {
	int y;
	int x;
	int t;
	int ign;
};
class Compare {
public:
	//keiroが昇順に並ぶ
	bool operator()(const a&l, const a&r) {
		return l.ign> r.ign;
	}
};

int main() {
	int t; cin >> t;
	for (int i = 0; i < t; ++i) {
		int n, k; cin >> n >> k;
		vector<int>sas;
		int pre;
		int fst, lst;
		for (int i = 0; i < n; ++i) {
			int x; cin >> x;
			if (i != 0) {
				sas.push_back(x - pre);
			}
			else {
				fst = x;
			}
			if (i == n - 1) {
				lst = x;
			}
			pre = x;
		}
		if (n <= k) {
			cout << 0 << endl;

		}
		else {
			int ans = 0;
			sort(sas.begin(),sas.end());
			for (int i = 0; i < n - k; ++i) {
				ans += sas[i];
			}
			cout << ans << endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
signed main(){
  int A,B;
  cin>>A>>B;
  cout<<max(A+B,max(A-B,A*B));
  }


Measured memory_bytes: 256
A,B,C,D = map(int,input().split())

def gcd(a,b):
    while b:
        a,b = b,a%b
    return a

n_c = B//C - (A-1)//C
n_d = B//D - (A-1)//D
lcm_cd = C*D // gcd(C,D)
n_cd = B//lcm_cd - (A-1)//lcm_cd

print(B-A+1 - (n_c+n_d-n_cd))



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

int main()
{
  int n;
  cin>>n;
  bool ok = false;
  for(int i=1;i<=9;i++)
  {
    int div = n/i;
    if((div < 10) && (i*div == n))
      ok = true;
  }
  if(ok)
    cout<<"Yes";
  else
    cout<<"No";
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main()
{
	int N, K;
	std::cin >> N >> K;

	unsigned long long counter = 0;

	for ( int i = 0; i < N - K + 1; i++ )
	{
		counter++;
	}

	std::cout << counter << std::endl;

	return ( 0 );
}


Measured memory_bytes: 888