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

template < unsigned mod >
class Modint
{
public:
        using uint = unsigned;
        using u64 = uint64_t;
        using i64 = int64_t;

        Modint (const i64 dat = 0) : dat(dat >= 0 ? dat % mod : (mod - (-dat) % mod) % mod) {}

        constexpr Modint operator + (const Modint &v) const { return ( Modint(dat + v.dat) ); }
        constexpr Modint operator - () const { return ( Modint(-((i64)dat)) ); }
        constexpr Modint operator - (const Modint &v) const { return ( (*this) + -v ); }
        constexpr Modint operator * (const Modint &v) const { return ( Modint((u64)dat * v.dat) ); }
        
        constexpr Modint operator ~ () const
        {
                i64 a = dat, b = mod, x1 = 1, x2 = 0, t;
                
                while ( b > 0 ) {
                        t = a / b;
                        swap(a -= t * b, b);
                        swap(x1 -= t * x2, x2);
                }
                
                return ( Modint(x1) );
        }
        
        constexpr Modint operator / (const Modint &v) const { return ( (*this) * ~v ); }

        Modint &operator = (const i64 &v) { return ( (*this) = Modint < mod > (v) ); }
        Modint &operator += (const Modint &v) { return ( (*this) = (*this) + v ); }
        Modint &operator -= (const Modint &v) { return ( (*this) = (*this) - v ); }
        Modint &operator *= (const Modint &v) { return ( (*this) = (*this) * v ); }
        Modint &operator /= (const Modint &v) { return ( (*this) = (*this) / v ); }

        constexpr Modint operator ^ (u64 n) const
        {
                Modint < mod > ret(1), mul(dat);
                while ( n > 0 ) {
                        if ( n & 1 ) ret *= mul;
                        mul *= mul;
                        n >>= 1;
                }
                return ( ret );
        }
        
        bool operator == (const Modint &v) { return ( dat == v.dat ); }
        bool operator != (const Modint &v) { return ( dat != v.dat ); }

        friend ostream& operator << (ostream &os, const Modint &p )
        {
                return ( os << p.dat );
        }
        
        friend istream& operator >> (istream &is, Modint &p )
        {
                i64 data;
                is >> data;
                p = Modint < mod >(data);
                return ( is );
        }

private:
        uint dat;
};

constexpr int MOD = 1000000007;

Modint < MOD > memo[200005];

Modint < MOD > fact(int n)
{
        if ( memo[n] == Modint < MOD >(0) ) {
                if ( n >= 2 ) memo[n] = Modint < MOD >(n) * fact(n - 1);
                else memo[n] = 1;
        }
        return ( memo[n] );
}

Modint < MOD > Choose(int n, int r)
{
        return ( fact(n) / fact(r) / fact(n - r) );
}

int main()
{
        int H, W, R, C;
        Modint < MOD > sum = 0;
        cin >> H >> W >> R >> C;
        
        for ( int i = C; i < W; i++ ) {
                int h = H - R - 1;
                int n = h + i;
                sum += Choose(n, h) * Choose(R + (W - i) - 2, R - 1);
        }

        cout << sum << endl;
        
        return ( 0 );
}


Measured memory_bytes: 2560
#include <stdio.h>
#include <string.h>

char S[11];

int main()
{
	int i, cnt=0;
	
	scanf("%s", S);
	
	if(S[0] != 'A'){
		printf("WA");
		return 0;
	}
	
	for(i=2;i<strlen(S)-1;i++){
		if(S[i] == 'C'){
			S[i] = 'a';
			cnt++;
		}
	}
	if(cnt != 1){
		printf("WA");
		return 0;
	}
	
	S[2] = 'a';
	for(i=1;i<strlen(S);i++){
		if(S[i] < 'a' || S[i] > 'z'){
			printf("WA");
			return 0;
		}
	}
	
	printf("AC");
	
	return 0;
}

Measured memory_bytes: 128
def main():
    N = int(input())
    i = 1
    ans = 0
    while 10**i <= N:
        ans += ((10**i) - (10**(i-1)))
        i += 2
    ans += max(0, N-10**(i-1)+1)
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int N, M; 
vector<int> E[500010]; 
vector<int> F[500010];
vector<int> order; 
vector<int> scc[500010]; 
bool used[500010]; 
void dfs(int v){
	used[v] = true; 
	for(int p : E[v]){
		if(used[p]) continue; 
		dfs(p); 
	}
	order.emplace_back(v); 
}
void dfs2(int v, int k){
	used[v] = true; 
	scc[k].emplace_back(v); 
	for(auto p : F[v]){
		if(used[p]) continue; 
		dfs2(p, k); 
	}
}
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cin >> N >> M;
	for(int i = 0; i < M; i++){
		int u, v; cin >> u >> v; 
		E[u].emplace_back(v); 
		F[v].emplace_back(u); 
	}
	for(int i = 0; i < N; i++){
		if(used[i]) continue; 
		dfs(i); 
	}
	fill(used, used + N, false); 
	reverse(order.begin(), order.end()); 
	int k = 0; 
	for(auto p : order){
		if(used[p]) continue; 
		dfs2(p, k); k++; 
	}
	cout << k << "\n";
	for(int i = 0; i < k; i++){
		cout << scc[i].size() << " "; 
		for(auto p : scc[i]) cout << p << " ";
		cout << "\n"; 
	}	
}

Measured memory_bytes: 78536
num,loc = map(int,input().split())
dummy = ["" for i in range(num)]
moj = input()
count = 0
for j in moj:
  dummy[count] = j
  count = count + 1
S = dummy[loc-1]
W = S.swapcase()
dummy[loc-1] = W
ans = ""
for l in dummy:
  ans = ans + l
print(ans)

Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Per(i,sta,n) for(int i=n-1;i>=sta;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};

int a,b;

void solve(){
    cin >> a >> b;
    if(a<=0 && b>=0){
        cout << "Zero" << endl;
    }
    if(a>0){
        cout << "Positive" << endl;
    }
    if(b<0){
        if((b-a+1)%2==0) cout << "Positive" << endl;
        else cout << "Negative" << endl;
    }
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(50);
    solve();
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#define ll long long
#define mod 998244353
using namespace std;
int n,x;
int cnt[1000010];
ll ans=1;
ll ksm(ll x,ll i){
	ll res=1;
	for(;i;i>>=1,x=x*x%mod)
		if(i&1)res=res*x%mod;
	return res;
}
int main(){
	scanf("%d",&n);
	for(register int i=1;i<=n;i++){
		scanf("%d",&x);
		if(i==1&&x!=0){
			printf("0");
			return 0;
		}
		cnt[x]++;
	}
	if(cnt[0]!=1){
		printf("0");
		return 0;
	}
	for(register int i=1;i<=100000;i++){
		if(!cnt[i]){
			for(register int j=i+1;j<=100000;j++){
				if(cnt[j]){
					printf("0");
					return 0;
				}
			}
			break;
		}
		ans=ans*ksm(cnt[i-1],cnt[i])%mod;
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 768
# -*- coding: utf-8 -*-
# 標準入力を取得
n = int(input())

# 求解処理
# dp[i+1]: フィボナッチ数列の第i項
dp = [0 for _ in range(n + 1)]

# 初期条件
dp[0] = 1
dp[1] = 1

for i in range(1, n):
    # DP漸化式
    dp[i + 1] = dp[i] + dp[i - 1]
ans = dp[n]

# 結果出力
print(ans)


Measured memory_bytes: 5608
package main

import (
	"fmt"
	"math"
)

func log(x, max int) float64 {
	ans := 0
	for {
		if x >= max {
			return float64(ans)
		}
		x *= 2
		ans++
	}
}

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	var sum float64
	if n <= k {
		for i := 1; i <= n; i++ {
			sum += math.Pow(0.5, log(i, k))
		}
	} else {
		for i := 1; i <= k; i++ {
			sum += math.Pow(0.5, log(i, k))
		}
		sum += float64(n - k)
	}
	fmt.Println((1 / float64(n)) * sum)
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String s = scan.next();
		char[] c = new char[s.length()];
		for (int i = 0; i < s.length(); i++) {
			c[i] = s.charAt(i);
		}
		for (int i = s.length()-1; 0 < i; i--) {
			s = s.substring(0, i);
			String s1 = s.substring(0, s.length()/2);
			String s2 = s.substring((s.length()/2));
			if (s1.equals(s2)) {
				System.out.println(s.length());
				return;
			}
		}
		return;
	}
}


Measured memory_bytes: 21972
import sys
sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque
#deque(l), pop(), append(x), popleft(), appendleft(x)
##listでqueの代用をするとO(N)の計算量がかかってしまうので注意
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate,combinations,permutations#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
#import fractions#古いatcoderコンテストの場合GCDなどはここからimportする
from functools import lru_cache#pypyでもうごく
#@lru_cache(maxsize = None)#maxsizeは保存するデータ数の最大値、2**nが最も高効率
from decimal import Decimal

def input(): 
    x=sys.stdin.readline()
    return x[:-1] if x[-1]=="\n" else x
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def main():
    mod = 1000000007
    #w.sort(key=itemgetter(1),reversed=True)  #二個目の要素で降順並び替え

    N = int(input())
    #N, K = map(int, input().split())
    #A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列
    count=[[0]*10 for i in range(10)]
    for i in range(1,N+1):
        si=str(i)
        head=int(si[0])
        tail=int(si[-1])
        count[head][tail]+=1
    ans=0
    for a in range(1,10):
        for b in range(1,10):
            ans+=count[a][b]*count[b][a]
    print(ans)







if __name__ == "__main__":
    main()

Measured memory_bytes: 72988
#include <iostream>

using namespace std;

int main(int argc, char const *argv[])
{
    int n, limit, cost, time;
    cin >> n >> limit >> cost >> time;

    for(int i = 1; i < n; i++)
    {
        int a, b;
        cin >> a >> b;

        if(b <= limit && a < cost)
        {
            cost = a;
            time = b;
        }
    }

    if(time <= limit)
        cout << cost << endl;
    else
        cout << "TLE" << endl;

    return 0;
}


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

#define pb push_back
#define mp make_pair
#define size(n) ( int( n.size() ) )
#define sqr(n) ( (n) * (n) )
#define fi first
#define se second

using namespace std;

typedef long long ll;
typedef long double ld;

int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int n, x, cnt1 = 0, cnt2 = 0, cnt4 = 0;
    scanf("%d",&n);
    for ( int i = 1; i <= n; i++ ){
        scanf("%d",&x);
        if ( x % 2 != 0 ){
            cnt1++;
        }
        else
        if ( x % 4 == 0 ){
            cnt4++;
        }
        else{
            cnt2++;
        }
    }
    if ( ( cnt4 >= cnt1 ) || ( ( cnt4 == cnt1 - 1 ) && ( cnt2 == 0 ) ) ){
        puts("Yes");
    }
    else{
        puts("No");
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
 
int main() {
    int n,m,a[10] = {0,0,0,0,0,0,0,0,0,0};
    string s,t;
    string s1(".,!? ");
    string s2("abc");
    string s3("def");
    string s4("ghi");
    string s5("jkl");
    string s6("mno");
    string s7("pqrs");
    string s8("tuv");
    string s9("wxyz");
    cin >> n;
    for(int i = 0;i < n;i++){
        cin >> s;
        for(int j = 0;j < s.size();j++){
            if(s[j] == '0' && a[1]+a[2]+a[3]+a[4]+a[5]+a[6]+a[7]+a[8]+a[9] == 0)continue;
            else if(s[j] == '1'){
                t = s1;
                m = 1;
                a[1]++;
            }else if(s[j] == '2'){
                t = s2;
                m = 2;
                a[2]++;
            }else if(s[j] == '3'){
                t = s3;
                m = 3;
                a[3]++;
            }else if(s[j] == '4'){
                t = s4;
                m = 4;
                a[4]++;
            }else if(s[j] == '5'){
                t = s5;
                m = 5;
                a[5]++;
            }else if(s[j] == '6'){
                t = s6;
                m = 6;
                a[6]++;
            }else if(s[j] == '7'){
                t = s7;
                m = 7;
                a[7]++;
            }else if(s[j] == '8'){
                t = s8;
                m = 8;
                a[8]++;
            }else if(s[j] == '9'){
                t = s9;
                m = 9;
                a[9]++;
            }
            else if(s[j] == '0' && a[1]+a[2]+a[3]+a[4]+a[5]+a[6]+a[7]+a[8]+a[9] != 0){
                if(m == 1){
                    cout << t[(a[m]-1)%5];
                    a[m] = 0;
                }
                else if(m == 7 || m == 9){
                    cout << t[(a[m]-1)%4];
                    a[m] = 0;
                }
                else{
                    cout << t[(a[m]-1)%3];
                    a[m] = 0;
                }
            }
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 1212
#include "bits/stdc++.h"
using namespace std;
int main(){
    int x[5];
    cin >> x[0] >> x[1] >> x[2] >> x[3] >> x[4];
    for (int i =0; i<5; ++i){
        if (x[i] == 0)
            cout << i +1 << endl;
    }
}

Measured memory_bytes: 3556
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using ii=pair<ll,ll>;
using vi=vector<ll>;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define INF (ll)1e18
#define all(x) (x).begin(),(x).end()
#define print(a); for(auto x:a)cout<<x<<" "; cout<<"\n";
#define mset(a); memset(a,0,sizeof(a));

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
    ll a,b;cin>>a>>b;
    if(a<6)cout<<"0\n";
    else if(a<13)cout<<b/2<<"\n";
    else cout<<b<<"\n";
}


Measured memory_bytes: 3652
#include<stdio.h>
#define N 20
#define Q 200
int solve(int,int);
int A[N],S[Q];
int n;
int main(){
  int i,q,j;
  scanf("%d",&n);
  for(i=0;i<n;i++)
    scanf("%d",&A[i]);
  scanf("%d",&q);
  for(i=0;i<q;i++)
    scanf("%d",&S[i]);
  
  for(j=0;j<q;j++){
    if(solve(0,S[j])==1)
      printf("yes\n");
    else if(solve(0,S[j])==0)
      printf("no\n");
    
    
  }
  return 0;
}

int solve(i,m){
  int res=0;
  if(m==0)return 1;
  else if(m<=0)return 0;
  if(i>=n)return 0;
  res+=solve(i + 1, m) + solve(i + 1, m - A[i]);
  if(res>=2)res=1;
  return res;
}

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

origin = [list(input()) for _ in range(H)]
ans = 0
for i in range(2**H):
    for j in range(2**W):
        cnt = 0
        for h_shift in range(H):
            for w_shift in range(W):
                if i >> h_shift & 1 == 1 or j >> w_shift & 1: #赤で塗られるマス
                    continue
                if origin[h_shift][w_shift] == "#":
                    cnt += 1
        if cnt == K:
            ans += 1
print(ans)


Measured memory_bytes: 9040
L, R = map(int, input().split())

ans = 2019
if(R-L >= 2019):
  for i in range(2019):
    for j in range(i+1, 2019):
      tmp = (i * j) % 2019
      if(tmp < ans):
        ans = tmp
else:
  d = L // 2019
  l = L % 2019
  r = R - (d*2019)
  for i in range(l, r+1):
    for j in range(i+1, r+1):
      tmp = (i * j) % 2019
      if(tmp < ans):
        ans = tmp
        
print(ans)

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main()
{
	int map[4][4];
	int n,in;
	for(int i = 0;i < 4;i++){
		for(int j = 0;j < 4;j++){
			map[i][j] = 0;
		}
	}
	for(int i = 0;i < 3;i++){
		for(int j = 0;j < 3;j++){
			cin >> map[i][j];
		}
	}
	cin >> n;
	for(int i = 0;i < n;i++){
		cin >> in;
		for(int j = 0;j < 3;j++){
			for(int k = 0;k < 3;k++){
				if(map[j][k] == in){
					map[j][k] = -1;
				}
			}
		}
	}
	if(map[0][0] == -1 && map[0][1] == -1 && map[0][2] == -1){
		cout << "Yes" << endl;
	}else if(map[1][0] == -1 && map[1][1] == -1 && map[1][2] == -1){
		cout << "Yes" << endl;
	}else if(map[2][0] == -1 && map[2][1] == -1 && map[2][2] == -1){
		cout <<"Yes" << endl;
	}else if(map[0][0] == -1 && map[1][0] == -1 && map[2][0] == -1){
		cout << "Yes" << endl;
	}else if(map[0][1] == -1 && map[1][1] == -1 && map[2][1] == -1){
		cout << "Yes" << endl;
	}else if(map[0][2] == -1 && map[1][2] == -1 && map[2][2] == -1){
		cout << "Yes" << endl;
	}else if(map[0][0] == -1 && map[1][1] == -1 && map[2][2] == -1){
		cout << "Yes" << endl;
	}else if(map[0][2] == -1 && map[1][1] == -1 && map[2][0] == -1){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return(0);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,x,n) for(int i=(x);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define int long long
using namespace std;
const int MOD=1e9+7;
const int INF=1e9;
template<typename T> void cmax(T &a, T b) {a = max(a, b);}
template<typename T> void cmin(T &a, T b) {a = min(a, b);}

int inf=2147483647;
int size=1;
vector<int> tree;
void init(int n){
  while(size<n)size*=2;
  tree.assign(size*2,inf);
}

//Range add Query [ )
void update(int l,int r,int x){
  l+=size,r+=size;
  int nl=l,nr=r;
  stack<int> s;

  for(l/=2;1<=l;l/=2)s.emplace(l);
  while(!s.empty()){
    int tmp=s.top();s.pop();
    if(tree[tmp]==-1)continue;
    tree[2*tmp]=tree[2*tmp+1]=tree[tmp];
    tree[tmp]=-1;
  }
  for(r=(r-1)/2;1<=r;r/=2)s.emplace(r);
  while(!s.empty()){
    int tmp=s.top();s.pop();
    if(tree[tmp]==-1)continue;
    tree[2*tmp]=tree[2*tmp+1]=tree[tmp];
    tree[tmp]=-1;
  }

  for(;nl<nr;nl/=2,nr/=2){
    if(nl%2==1)tree[nl++]=x;
    if(nr%2==1)tree[--nr]=x;
  }
  return ;
}

int getvalue(int i){
  i+=size;
  int res=tree[i];
  while(i/=2){
    if(tree[i]!=-1){
      res=tree[i];
    }
  }
  return res;
}

signed main(){
  int n,q;
  cin>>n>>q;
  init(n);
  rep(i,q){
    int a;
    cin>>a;
    if(a){
      int x;
      cin>>x;
      cout<<getvalue(x)<<endl;
    }else{
      int s,t,x;
      cin>>s>>t>>x;
      t++;
      update(s,t,x);
    }
  }
 return 0;
}



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

typedef long long ll;
typedef pair<int,int> ii;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	string s; cin>>s;
	set<char> st(s.begin(), s.end());
	for (char ch='a'; ch<='z'; ch++)
		if(st.find(ch)==st.end()) {
			cout << ch << endl;
			return 0;
		}
	cout << "None" << endl;
	return 0;
}


Measured memory_bytes: 512
/*
name:       Egyptian Tourist
PlatForm:   CodeForces/SPOJ...etc
LANG:       C++
DIV:        Training
TIME:       *
RATE:       *
*/

/*
Time Consumed:*
Problem Topics: *
*/
#include <bits/stdc++.h>
#include <iostream>

using namespace std;
//----------------------------------//

typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;

//-------------------------------------------------------//
#define rep(i,a,b) for (int i = (a), _b = (b); i <= _b; i++)
#define repr(i,a,b) for (int i = (a), _b = (b); i >= _b; i--)
#define lp(i,n) for (int i = 0, _n = (n); i < _n; i++)
#define lpr(i,n) for (int i = (n) - 1; ~i; i--)
#define foreach(it, ar) for ( typeof(ar.begin()) it = ar.begin(); it != ar.end(); it++ )
//-------------------------------------------------------------------------------------//

#define clr(ar, val) memset(ar, val, sizeof(ar))
//----------------------------------------------//

#define inn freopen("in.in","r",stdin)
#define outt freopen("out.out","w",stdout)
#define PI 3.1415926535897932385
#define ll long long
#define ull unsigned long long
#define mp make_pair
#define pb push_back
#define pob pop_back
#define bit(n) (1<<(n))
#define Last(i) ( (i) & (-i) )
#define all(v) ((v).begin()), ((v).end())
#define sq(x) ((x) * (x))
#define INF INT_MAX
#define Ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);

//-------------------------------------------------------------//
#ifndef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1)
{
    cerr << name << " : " << arg1 << std::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 debug(...)
#endif
//------------------------------------------------------------//
template<class T, class T2>
T _f_pow(T a, T2 b)
{
    T res = 1;
    while (b > 0)
    {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}
#define N (int)1e5 + 5
int _h[N];
int dp[N];
int n, k;

int solve()
{
    //printf("Solve(%d)\n", i);
    for(int i = 2; i <= n; i++)
    {
        dp[i] = dp[i-1] + abs(_h[i] - _h[i-1]);
        for(int _k = 1; _k <= k && _k < i; _k++)
                dp[i] = min(dp[i], dp[i - _k] + abs(_h[i] - _h[i -_k]));
    }
    return dp[n];
}
int main()
{
    Ios;
    //inn;//outt;
    //auto tt = clock();
    cin >> n >> k;
    rep(i, 1, n)
        cin >> _h[i];
//    lp(i, n)
//      printf("%d\t", _h[i]);
//      system("pause 5");
    //clr(dp, -1);
    printf("%d\n", solve());
    //cout << (double(clock() - tt)/CLOCKS_PER_SEC * 1.00) << endl;
    return 0;
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A, B; cin >> A >> B;
    string S; cin >> S;
    rep(i, A) {
        if (!('0' <= S[i] && S[i] <= '9')) {
            cout << "No" << endl;
            return 0;
        } 
    }
    if (S[A] != '-') {
        cout << "No" << endl;
        return 0;
    }
    rep(i, B) {
        if (!('0' <= S[i+A+1] && S[i+A+1] <= '9')) {
            cout << "No" << endl;
            return 0;
        } 
    }
    cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 256
<?php
fscanf(STDIN, '%d', $cnt);
$words = [];
for ($i=0; $i < $cnt; $i++) { 
    $words[] = str_split(trim(fgets(STDIN)));
}
$len = count($words);
$temps = [];
for ($i=0; $i < $len; $i++) { 
    asort($words[$i]);
    $temps[] = implode('', $words[$i]);
}
$acv = array_count_values($temps);
$ans = 0;
foreach ($acv as $key => $value) {
    if ($value > 2) {
        $ans +=  ($value * ($value - 1)) / 2;
    } elseif ($value === 2) {
        $ans += 1;
    }
}
echo $ans;


Measured memory_bytes: 123760
// #pragma comment(linker, "/stack:200000000")
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")
#include<bits/stdc++.h>

using namespace std;

using ll = long long;
using ld = long double;
using ull = unsigned long long;

#define F first
#define S second
#define int long long
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()


void accell() {
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);
}

const int N = 2e5;
map<string, int>mp;

signed main() {
    accell();
    int n;
    cin >> n;
    int mx = 0;
    for (int i = 0; i < n; ++i) {
        string s;
        cin >> s;
        mp[s]++;
        mx = max(mx, mp[s]);
    }
    for (auto it : mp) {
        if (it.S == mx) {
            cout << it.F << '\n';
        }
    }
    return 0;
}


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

int main() {
    cin.tie(0)->sync_with_stdio(false);

    string s; cin >> s;
    if (s.find("AC") != std::string::npos) cout << "Yes" << '\n';
    else cout << "No" << '\n';
    return 0;
}

Measured memory_bytes: 256
import sys
n=input()
sys.setrecursionlimit(n+1000)
value=map(int, raw_input().split())
adj=[[] for i in range(n)]
for i in range(n-1):
	a, b=map(int, raw_input().split())
	a, b=a-1, b-1
	adj[a].append(b)
	adj[b].append(a)
if n==2:
	print "YES" if value[0]==value[1] else "NO"
	exit()
def dfs(cur, father):
	if len(adj[cur])==1:
		return value[cur]
	child_cnt=0
	child_max=-1
	for to in adj[cur]:
		if to!=father:
			result=dfs(to, cur)
			child_cnt+=result
			child_max=max(child_max, result)
	result=value[cur]*2-child_cnt
	if result<0 or result-child_cnt>0 or child_max>child_cnt-child_max+result:
		raise Exception, [value[cur], child_cnt, child_max, result]
	return result
for i in range(n):
	if len(adj[i])>1:
		try:
			result=dfs(i, -1)
			print>>sys.stderr, result
			print "NO" if result else "YES"
		except Exception, e:
			print>>sys.stderr, e.message
			print "NO" 
		exit()

Measured memory_bytes: 100088
#include<bits/stdc++.h>
using namespace std;
  int n=100005;
  int dp[100005];
   vector<int> v(n);

int main()
{
  
    cin>>n;
 
    for(int i=0;i<n;i++)
    {cin>>v[i];}
    dp[0]=0;
    dp[1]=abs(v[1]-v[0]);
    for(int i=2;i<=n;i++)
	dp[i]=min(dp[i-1]+abs(v[i]-v[i-1]),dp[i-2]+abs(v[i]-v[i-2]));
 cout<<dp[n-1];
}

Measured memory_bytes: 1024
package main

import (
        "fmt"
)

func main() {
        var k, s int
        fmt.Scanf("%d %d", &k, &s)

        var cnt int

        for i := 0; i <= k; i++ {
                for j := 0; j <= k && i+j <= s; j++ {
                        r := s - i - j

                        if r >= 0 && r <= k && i+j+r == s {
                                cnt++
                        }
                }
        }
        fmt.Println(cnt)

}


Measured memory_bytes: 512
#include<iostream>
#include<vector>
using namespace std;
int n,m,mp[1000][1000] ;
main()
{

	vector<int> store;
	int sum=0;
	cin>>n>>m;
	for(int i=1;i<=n;i++)      
 		for(int j=1;j<=m;j++)         
     	scanf("%d",&mp[i][j]);    
	for(int i=1;i<=n;i++)
	{       
		for(int j=1;j<m;j++)
		{           
     		if(mp[i][j]%2==1)
			{               
     			mp[i][j]--; 
    				mp[i][j+1]++;  
     			store.push_back(i);
       			store.push_back(j);
       			store.push_back(i);
       			store.push_back(j+1);
     			sum++;       
       		}  
     	}   
     }  
   	for(int i=1;i<n;i++)
   	{
          if(mp[i][m]%2==1)
          {
          	mp[i][m]--; 
       		mp[i+1][m]++; 
        		store.push_back(i);
          	store.push_back(m );
          	store.push_back(i+1);
          	store.push_back(m );
          	sum++;
          }
	}
   	cout<<sum<<endl; 
   	for(int i=0;i<store.size();i=i+4)  
   	{
     	cout<<store[i]<<" "<<store[i+1]<<" "<<store[i+2]<<" "<<store[i+3];
       	cout<<endl;
   	}
}


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

using namespace std;

int main(){
    long long N, M;
    cin >> N >> M;
    long long arr[N], sum = 0;
    for(long long i = 0; i < N; i++){
        cin >> arr[i];
        sum += arr[i];
    }
    long long cnt = 0;
    for(long long i = 0; i < N; i++){
        if(arr[i] >= sum * (1 / (4.0 * M))){
            cnt++;
        }
    }
    if(cnt >= M){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

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


int N, back =0, pre =0;
int num =0;
long long sum =0;

vector <int> A,tmp;

int getmax(int a,int b)
{
  int max =a;
  if(a>b){
    max =a;
  }else
  {
    max =b;
  }
  return max;
}


int main(){

    cin >>N;


    for (int i =0; i<N; i++)
    {
        cin >> num;
        A.push_back(num);
    }
  
      for (int i =1; i<N; i++)
    {

        /*back = getmax(back, A[i-1]);       
        pre = A[i]; 
        if(back >pre)
		{
            sum += (back - pre);
            A[i] = back;
        } 
        */

       if(A[i-1] > A[i])
       {
           sum += A[i-1] - A[i];
           A[i] = A[i-1];
       }
    
    }

    cout << sum;


    return  0;
}






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

using namespace std;

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

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

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

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

int main() {
	int n, m, t;
	cin >> n >> m >> t;
	vi visit(n);
	REP(i, n)
		cin >> visit[i];
	int ans = visit[0] - m;
	REP(i, n - 1) {
		if (visit[i + 1] - visit[i] > m * 2)
			ans += visit[i + 1] - visit[i] - m * 2;
	}
		ans += max(0, t - visit[n-1] - m);
		cout << ans << endl;
}

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

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

    if ( N >= 500 && (N % 500) <= A){
        cout << "Yes" << endl;
    }
    else if ( N < 500 && N < A){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

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

using ll = long long;
#define repi(n) for (int i = 0; i < (n); i++)
#define repj(n) for (int j = 0; j < (n); j++)
#define repk(n) for (int k = 0; k < (n); k++)
#define rep(i, n) for (int i = 0; (i) < (n); i++)
#define repr(i, a, b) for (auto i = (a); i < (b); i++)
#define repv(itr) for (auto&& v : (itr))
#define updatemax(t, v) (t = max((t), (v)))
#define updatemin(t, v) (t = min((t), (v)))
const int dx[] = {-1, 0, 0, 1, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, -1, 1, -1, 1};
template <typename T>
T minptr(T begin, T end) {
  T re = begin;
  for (T i = begin + 1; i != end; i++) {
    if (*i < *re) re = i;
  }
  return re;
}
template <typename T>
T maxptr(T begin, T end) {
  T re = begin;
  for (T i = begin + 1; i != end; i++) {
    if (*i > *re) re = i;
  }
  return re;
}
int __vmax(int x) {
  return INT_MAX;
}
double __vmax(double x) {
  return 1e+300;
}
ll __vmax(ll x) {
  return LLONG_MAX;
}
int __vmin(int x) {
  return INT_MIN;
}
double __vmin(double x) {
  return -1e+300;
}
ll __vmin(ll x) {
  return LLONG_MIN;
}
template <typename T>
vector<T> lis(T begin, T end, bool allowequal = false, bool lds = false) {
  using V = typename iterator_traits<T>::value_type;
  int n = end - begin;
  vector<V> a(n, lds ? __vmin(*begin) : __vmax(*begin));
  vector<int> id(n);
  if (lds && allowequal) {
    for (int i = 0; i < n; i++) {
      id[i] = n - 1 -
              (lower_bound(a.rbegin(), a.rend(), begin[i]) - 1 - a.rbegin());
      a[id[i]] = begin[i];
    }
  } else if (lds) {
    for (int i = 0; i < n; i++) {
      id[i] = n - 1 -
              (upper_bound(a.rbegin(), a.rend(), begin[i]) - 1 - a.rbegin());
      a[id[i]] = begin[i];
    }
  } else if (allowequal) {
    for (int i = 0; i < n; i++) {
      id[i] = upper_bound(a.begin(), a.end(), begin[i]) - a.begin();
      a[id[i]] = begin[i];
    }
  } else {
    for (int i = 0; i < n; i++) {
      id[i] = lower_bound(a.begin(), a.end(), begin[i]) - a.begin();
      a[id[i]] = begin[i];
    }
  }
  int m = *maxptr(id.begin(), id.end());
  vector<T> re(m + 1);
  for (int i = n - 1; i >= 0; i--) {
    if (id[i] == m) re[m--] = begin + i;
  }
  return re;
}

typedef struct city {
  int i, p, y, yi;
  bool operator<(struct city x) { return p < x.p || (!(x.p < p) && (y < x.y)); }
} City;
int main() {
  int n, m;
  cin >> n >> m;
  vector<City> c(m);
  repi(m) {
    c[i].i = i;
    cin >> c[i].p >> c[i].y;
  }
  sort(c.begin(), c.end());
  int pp = -1, ppc;
  repi(m) {
    if (c[i].p != pp) {
      pp = c[i].p;
      ppc = 0;
    }
    c[i].yi = ++ppc;
  }
  sort(c.begin(), c.end(), [](City a, City b) { return a.i < b.i; });
  repi(m) {
    cout << setfill('0') << right << setw(6) << c[i].p;
    cout << setfill('0') << right << setw(6) << c[i].yi << endl;
  }
}


Measured memory_bytes: 3072
require 'set'

H, W = gets.chomp.split(" ").map(&:to_i)
S = []
H.times{
  S << gets.chomp
}

def breadth_first_search(f)
  trace = Set[f]
  bef = Set[f]
  stp = 0
  while not bef.empty? do
    nxt = Set.new
    stp += 1
    bef.each{|h, w|
      trace << [h, w]
      nxt << [h+1, w] if (not trace.include?([h+1, w])) && h+1 < H && S[h+1][w] == '.'
      nxt << [h-1, w] if (not trace.include?([h-1, w])) && h   > 0 && S[h-1][w] == '.'
      nxt << [h, w+1] if (not trace.include?([h, w+1])) && w+1 < W && S[h][w+1] == '.'
      nxt << [h, w-1] if (not trace.include?([h, w-1])) && w   > 0 && S[h][w-1] == '.'
    }
    bef = nxt
  end
  stp - 1
end

ans = 0
f = []
H.times{|h|
  s = S[h]
  W.times{|w|
    if s[w] == '.' then
      stp = breadth_first_search([h, w])
      ans = stp if ans < stp
    end
  }
}

puts ans


Measured memory_bytes: 2556
//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	int N, X, A;
	int minA = INF;
	int sum = 0;
	cin >> N >> X;
	rep(i, 0, N)
	{
		cin >> A;
		chmin(minA, A);
		sum += A;
	}

	cout << N + (X - sum) / minA << endl;

	return 0;
}

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

int main() {

  int a, b;
  cin >> a >> b;
  
  if (a / 2 * 2 == a || b / 2 * 2 == b) {
    cout << "Even" <<endl;
  }
 
  else {
    cout << "Odd" <<endl;
  }
  
}


Measured memory_bytes: 3632
(defun main ()
  (let* ((n (read))
         (y (read)))
    (format t "~A~%"
      (loop named outer
        for i from 0 to n 
        finally (return-from outer (format nil "~a ~a ~a" -1 -1 -1))
        do
        (loop for j from 0 to (- n i) do
            (if (= y (+ (* i 10000)
                        (* j 5000)
                        (* (- n i j) 1000)))
                (return-from outer (format nil "~a ~a ~a" i j (- n i j)))))))))
(main)

Measured memory_bytes: 15976
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAX = 2e9;
typedef pair<int, int> pi;
int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n;
    cin >> n;
    cout << !n;
}

Measured memory_bytes: 3644
#include <iostream>
using namespace std;
#define MOD 1000000007

int main(){
  int N;
  cin >> N;
  long long ans = 1;
  for(long long i = 1; i <= N; i++){
    ans *= i;
    ans %= MOD;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
require "prime"
N = gets.to_i
arr = N.prime_division.flat_map { |i,j| [i] * j }
if arr.empty?
  arr = [1]
end

def f(a, b)
  [a,b].max.to_s.length
end
min = 9999
(1..arr.size).each do |n|
  arr.combination(n) do |m|
    a = m.inject(:*)
    b = N / a
    c = f(a, b)
    if min > c
      min = c
    end
  end
end
p min


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2018/04/20  Problem: ABC 052 D / Link: http://abc052.contest.atcoder.jp/tasks/abc052_d  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

LL N,A,B;

LL ans = 0LL;

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

	cin >> N>>A>>B;
	VL a(N);
	FOR(i, 0, N) {
		cin >> a[i];
	}

	FOR(i, 0, N-1) {
		LL d = a[i + 1] - a[i];
		ans += min(B, A*d);
	}
	cout << ans << "\n";

	return 0;
}


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

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

    int ans = 0;
    int shortage = B;
    while (shortage > 1)
    {
        ans++;
        shortage -= A - 1;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include <string>
#include <iomanip>
#include <sstream>

using uint = unsigned int;

const uint sign = 0b10000000000000000000000000000000;
const uint inte = 0b01111111111111111111111110000000;
const uint flot = 0b00000000000000000000000001111111;

int n;

uint input() {
    uint u;

    std::cin >> std::hex >> u;

    return u;
}

std::string format(double d) {
    std::stringstream ss;

    ss << std::fixed << std::setprecision(30) << d;

    std::string str;

    ss >> str;

    str = str.substr(2, str.size() - 1);

    int i;
    for(i = str.size() - 1; i >= 0 && str[i] == '0'; --i) {}

    return str.substr(0, i + 1);
}

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

    for(int i = 0; i < n; ++i) {
        uint a = input();

        if(sign & a){
            std::cout << "-";
        }

        std::cout << ((inte & a) >> 7) << ".";

        if((flot & a) == 0){
            std::cout << 0 << std::endl;
        }else {
            double d = 0.5;
            double sum = 0;

            for(int i = 0; i < 7; ++i) {
                if(a & (1 << (6 - i))) {
                    sum += d;
                }
                d /= 2;
            }
            std::cout << format(sum) << std::endl;
        }
    }
}

Measured memory_bytes: 3280
#include <iostream>
#include <vector>
#include <map>

using namespace std;

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

int main(void)
{
	int n;
	cin >> n;
	string prev;
	cin >> prev;
	map<string, int> mp;
	mp[prev] = 1;
	rep(i, n - 1) {
		string cur;
		cin >> cur;
		if (mp[cur]) {
			cout << "No" << endl;
			return 0;
		}
		mp[cur] = 1;
		if (prev[prev.length() - 1] != cur[0]) {
			cout << "No" << endl;
			return 0;
		}
		prev = cur;
	}
	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 256
import kotlin.math.abs
import kotlin.math.min

fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)
fun <T> Array<Array<T>>.print() {
    this.forEach {
        println(it.joinToString(" "))
    }
}

fun main() {
    val (n, x, y) = readIntList()

    val ans = Array(n) { 0 }

    for (i in 1..n) {
        for (j in i + 1..n) {
            val d = min(j-i, abs(i-x) + abs(j-y) + 1)
            ans[d] += 1
        }
    }

    ans.drop(1).forEach { println(it) }
}


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

    typedef long long int ll;
    #define pb         push_back
    #define mp         make_pair
    #define F          first
    #define S          second
    #define fl(i,a,b)  for(ll i=a;i<b;i++)
    #define pll        pair<ll,ll>
    #define pii        pair<int,int>
    #define all(v)     v.begin(),v.end()
    #define M 1000000007
    #define tr(v, it) for(auto it = v.begin(); it != v.end(); it++)
    #define fast   ios::sync_with_stdio(false);cin.tie(0);cout.precision(10);cout << fixed;
    using namespace std;
    int d[100005];
    int dfs(vector<int> graph[], int s)
    {
        int ans=0;
        if(d[s]!=-1)
            return d[s];
        for(int i=0; i<graph[s].size(); i++)
        {
            int v = graph[s][i];
            ans =max(ans,dfs(graph,v));
        }
        return d[s]=ans+1;
    }
    int main()
    {
            fast
          int v,e;
          cin>>v>>e;
          vector<int> graph[v+1];
          for(int i=0;i<e; i++)
          {
              int u,v;
              cin>>u>>v;
              graph[u].pb(v);
          }
          memset(d,-1,sizeof(d));
          for(int i=1;i<=v; i++)
          {
              if(d[i]==-1)
                dfs(graph, i);
          }

    cout<<*max_element(d,d+v+1)-1;

        return 0;

    }



Measured memory_bytes: 12180
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#define ll long long
using namespace std;
template <class T>
inline void rd(T &x) {
	x=0; char c=getchar(); int f=1;
	while(!isdigit(c)) { if(c=='-') f=-1; c=getchar(); }
	while(isdigit(c)) x=x*10-'0'+c,c=getchar(); x*=f;
}
const int mod=998244353;
const int N=(1<<14)+10;
int Pow(int x,int y) {
	int res=1;
	while(y) {
		if(y&1) res=res*(ll)x%mod;
		x=x*(ll)x%mod,y>>=1;
	}
	return res;
}
int wn[2][N];
void getwn(int l) {
	for(int i=1;i<(1<<l);i<<=1) {
		int w0=Pow(3,(mod-1)/(i<<1)),w1=Pow(3,mod-1-(mod-1)/(i<<1));
		wn[0][i]=wn[1][i]=1;
		for(int j=1;j<i;++j)
			wn[0][i+j]=wn[0][i+j-1]*(ll)w0%mod,
			wn[1][i+j]=wn[1][i+j-1]*(ll)w1%mod;
	}
}
int rev[N];
void getr(int l) { for(int i=1;i<(1<<l);++i) rev[i]=(rev[i>>1]>>1)|((i&1)<<l-1); }
void FFT(int *A,int len,int f) {
	for(int i=0;i<len;++i) if(rev[i]<i) swap(A[i],A[rev[i]]);
	for(int l=1;l<len;l<<=1)
		for(int i=0;i<len;i+=(l<<1))
			for(int k=0;k<l;++k) {
				int t1=A[i+k],t2=A[i+l+k]*(ll)wn[f][l+k]%mod;
				A[i+k]=(t1+t2)%mod;
				A[i+l+k]=(t1-t2+mod)%mod;
			}
	if(f==1) for(int inv=Pow(len,mod-2),i=0;i<len;++i) A[i]=A[i]*(ll)inv%mod;
}
int A[N],B[N];
int f[210][8010];
int fac[8010],inv[8010];
void getfac(int n) {
	fac[0]=1; for(int i=1;i<=n;++i) fac[i]=fac[i-1]*(ll)i%mod;
	inv[n]=Pow(fac[n],mod-2); for(int i=n;i>=1;--i) inv[i-1]=inv[i]*(ll)i%mod;
}
int C(int n,int m) { return fac[n]*(ll)inv[m]%mod*inv[n-m]%mod; }
int n,m;
int main() {
	rd(n),rd(m);
	getfac(n+2),getwn(14);
	int len=1,cnt=0; while(len<=n*2) len<<=1,cnt++; getr(cnt);
	
	for(int i=1;i<=n;++i) B[i]=inv[i+2];
	FFT(B,len,0);
	
	f[0][0]=1;
	for(int i=1;i<=m;++i) {
		for(int j=0;j<=n;++j) A[j]=f[i-1][j]*(ll)inv[j]%mod;
		for(int j=n+1;j<len;++j) A[j]=0;
		FFT(A,len,0);
		for(int j=0;j<len;++j) A[j]=A[j]*(ll)B[j]%mod;
		FFT(A,len,1);
		for(int j=0;j<=n;++j) f[i][j]=A[j]*(ll)fac[j+2]%mod;
		for(int j=0;j<=n;++j) f[i][j]=(f[i][j]+f[i-1][j]*(ll)(C(j+1,2)+1))%mod;
//		cout<<i<<':';
//		for(int j=0;j<=n;++j) printf("%d ",f[i][j]); puts("");
	}
	int ans=0;
	for(int i=0;i<=n;++i) ans=(ans+f[m][i]*(ll)C(n,i)%mod)%mod;
	printf("%d",ans);
	return 0;
}

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

using v1 = vector<int>;
using v2 = vector<vector<int>>;
using ll = long long;

int main(){
	long long a;
	double b;
	cin >> a >> b;
	int b2 = b*100+0.5;
	cout << a*b2 /100 << endl;
}


Measured memory_bytes: 3720
H, W, K = map(int,(input().split()))
c = []
for _ in range(H):
  c.append(input())
ans = 0
for maskR in range((1<<H)-1):
  for maskC in range((1<<W)-1):
    black=0
    for i in range(H):
      for j in range(W):

        if ((maskR >> i) & 1) == 0 and ((maskC >> j) & 1) == 0 and  c[i][j] == '#': 
           black += 1
    if black == K:

      ans += 1
print(ans)


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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

bool dp1[10] = {0};
bool dp2[10][10] = {0};
bool dp3[10][10][10] = {0};

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  string s;
  int n;
  cin >> n >> s;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 10; j++) {
      for (int k = 0; k < 10; k++) if (dp2[j][k]) dp3[j][k][s[i] - '0'] = true;
    }
    for (int j = 0; j < 10; j++) if (dp1[j]) dp2[j][s[i] - '0'] = true;
    dp1[s[i] - '0'] = true;
  }
  int ans = 0;
  for (int i = 0; i < 10; i++) for (int j = 0; j < 10; j++) for (int k = 0; k < 10; k++) ans += dp3[i][j][k];
  cout << ans << endl;
  return 0;
}


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

int main(){
    bool correct_flag = false;
    vector<vector<int>> c(3, vector<int>(3));
    int b_first, b_second, b_third;
    for (int i = 0; i < 3; i++){
        cin >> c[i][0] >> c[i][1] >> c[i][2];
    }
    for (int a_first = 0; a_first <= 100; a_first++){
        b_first = c[0][0] - a_first;
        b_second = c[0][1] - a_first;
        b_third = c[0][2] - a_first;
        if (correct_flag == false){
            for (int a_second = 0; a_second <= 100; a_second++){
                if (b_first == c[1][0] - a_second && b_second == c[1][1] - a_second && b_third == c[1][2] - a_second){
                    for (int a_third = 0; a_third <= 100; a_third++){
                        if (b_first == c[2][0] - a_third && b_second == c[2][1] - a_third && b_third == c[2][2] - a_third){
                            correct_flag = true;
                        }
                    }
                }
            }
        }
    }

    if (correct_flag == true) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256