akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;
using ll = long long;

int constexpr N = 2005, MOD = 1e9 + 7;
int n, m, s[N], t[N], dp[N][N];

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    cin >> n >> m;
    for(int i = 1; i <= n; ++i) {
        cin >> s[i];
    }
    for(int i = 1; i <= m; ++i) {
        cin >> t[i];
    }
    for(int i = 0; i < N; ++i) {
        dp[0][i] = dp[i][0] = 1;
    }
    for(int i = 1; i <= n; ++i) {
        for(int j = 1; j <= m; ++j) {
            if(s[i] == t[j])
                dp[i][j] = dp[i - 1][j - 1];
            dp[i][j] += ((dp[i - 1][j] + dp[i][j - 1]) % MOD - dp[i - 1][j - 1]) % MOD;
            if(dp[i][j] >= MOD)
                dp[i][j] -= MOD;
            else if(dp[i][j] < 0)
                dp[i][j] += MOD;
        }
    }
    cout << dp[n][m] << '\n';
}

Measured memory_bytes: 16000
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <utility>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>


using namespace std;

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


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

	int size = s.size();

	// 通り数 = dp[i][j][k]
	// i桁目まで決めた時
	// j個の非ゼロ
	// k = 0 : そのまではNと一緒、1 : N以下が確定してる 

	int dp[size][K + 1][2]; 
	int cur = s[0] - '0';
	rep(i, size) {
		rep(j, K + 1) {
			dp[i][j][0] = 0;
			dp[i][j][1] = 0;
		}
	}

	dp[0][0][0] = 0;        // 0個の非ゼロ c****  c > 0 （全部0）
	dp[0][1][0] = 1;        // 1個の非ゼロ c****  c > 0

	dp[0][0][1] = 1;        // 0個の非ゼロ x**** x = 0　（全部0）
	dp[0][1][1] = cur - 1;  // 1個の非ゼロ x**** x < c

	for (int i = 1; i < size; i++) {
		int cur = s[i] - '0';
		dp[i][0][0] = 0;
		dp[i][0][1] = 1;

		for (int j = 1; j < K + 1; j++) {
			if (cur == 0) {
				dp[i][j][0] = dp[i - 1][j][0];

				dp[i][j][1] = dp[i - 1][j - 1][0] * 0 
							+ dp[i - 1][j - 1][1] * 9
							+ dp[i - 1][j][0] * 0
							+ dp[i - 1][j][1] * 1;
			} else {
				dp[i][j][0] = dp[i - 1][j - 1][0];

				dp[i][j][1] = dp[i - 1][j - 1][0] * (cur - 1) 
							+ dp[i - 1][j - 1][1] * 9
							+ dp[i - 1][j][0] * 1
							+ dp[i - 1][j][1] * 1;
			}

		}

	}

	cout << dp[size - 1][K][0] + dp[size - 1][K][1] << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], *ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

int gcd(int A, int B) {
	if (B == 0) return A;
	return gcd(B, A % B);
}

int main() {
	int N = getint();
	int A[100000];
	rep(i, N) A[i] = getint();

	int B[100000];
	B[0] = A[0];
	rep1(i, N - 2) B[i] = gcd(A[i], B[i - 1]);

	int kotae = B[N - 2];
	int C = A[N - 1];
	rep1(i, N - 2) {
		kotae = max(kotae, gcd(C, B[N - 2 - i]));
		C = gcd(A[N - i - 1], C);
	}
	kotae = max(C, kotae);

	co(kotae);

	Would you please return 0;
}

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

using namespace std;

int main()
{
    string s;
    cin >> s;
  	if (s == "ILIL")
      cout << "Yes";
    else if (s[0]==s[1] && s[0] != s[2])
    {
        if (s[2]==s[3])
            cout << "Yes";
        else cout << "No";
    }
    else if (s[0]==s[2] && s[0] != s[1])
    {
        if (s[1]==s[3])
            cout << "yes";
        else cout << "No";
    }
    else if (s[0]==s[3] && s[0] != s[1])
    {
        if (s[1]==s[2])
            cout <<  "Yes";
        else cout << "No";
    }
    else cout << "No";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];

  sort(a.begin(), a.end());
  int idx = 0;
  rep(i, n) {
    if (min(a[idx], a[n - 1] - a[idx]) < min(a[i], a[n - 1] - a[i])) idx = i;
  }
  cout << a[n - 1] << " " << a[idx] << endl;



  
  return 0;
}

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

// typedef long long ll;
// typedef long double ld;

// #define imx INT_MAX
// #define imn INT_MIN
// #define llmx LLONG_MAX
// #define llmn LLONG_MIN

// #define fi first
// #define se second
// #define pb push_back


int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n, flag=0;
	cin>>n;
	while(n)
	{
		if(n%10==7)
		{
			flag=1;
			break;
		}
		n/=10;
	}
	if(flag) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

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

int main()
{
    int N;
    int ans = 1;
    cin >> N;
    string S[N];
    for(int i = 0;i< N; i++) cin >> S[i];
    sort(S,S+N,greater<string>());
    for(int i = 1; i < N; i++){
        if(S[i - 1] != S[i]){
            ans += 1;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 9888
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
#include <random>
#include <queue>
#include <deque>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N,K;
  cin>>N>>K;
  int max=(N-1)*(N-2)/2;
  if(K>max){
    cout<<-1<<endl;
  }else{
    cout<<N-1+(max-K)<<endl;
    for(int i=0;i<N-1;i++){
      cout<<i+1<<" "<<N<<endl;
    }
    bool flag=false;
    int cnt=0;
    for(int i=0;i<N-1;i++){
      for(int j=0;j<i;j++){
        if(cnt>=max-K)flag=true;
        if(flag)break;
        cout<<i+1<<" "<<j+1<<endl;
        cnt++;
      }
      if(flag)break;
    }
  }
}


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

public class Main {

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner();
		PrintWriter out = new PrintWriter(System.out);
		int n=sc.nextInt();
		int[]a=new int[n],b=new int[n],tmpA=new int[n],tmpB=new int[n];
		for(int i=0;i<n;i++) 
			tmpA[i]=sc.nextInt();
			
		for(int i=0;i<n;i++)
			tmpB[i]=sc.nextInt();
		int ans=0;
		for(int k=0;k<30;k++) {
			int T=1<<k;
			for(int i=0;i<n;i++) {
				a[i]=tmpA[i]%(2*T);
				b[i]=tmpB[i]%(2*T);
			}
			

			Arrays.sort(a);
			Arrays.sort(b);
			for(int i=0;i<n/2;i++) {
				int x=b[n-i-1];
				b[n-i-1]=b[i];
				b[i]=x;
			}

			int xor=0;
			int []t=new int [5];
			for(int i=0;i<n;i++) {
				for(int j=1;j<=4;j++)
					while(t[j]<n && a[i]+b[t[j]]>=T*j)
						t[j]++;
				
				int one=Math.max(0, t[1]-t[2]),two=Math.max(0, t[3]-t[4]);
				xor^=one;
				xor^=two;
			}
			if((xor&1)==1)
				ans+=T;

		}
		out.println(ans);
		out.close();

	}

	static class Scanner {
		BufferedReader br;
		StringTokenizer st;

		Scanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		Scanner(String fileName) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(fileName));
		}

		String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		String nextLine() throws IOException {
			return br.readLine();
		}

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

		long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		double nextDouble() throws NumberFormatException, IOException {
			return Double.parseDouble(next());
		}

		boolean ready() throws IOException {
			return br.ready();
		}

	}

}

Measured memory_bytes: 63780
#import math
#import copy
#import sys
#import bisect
#input = sys.stdin.readline
mod=10**9+7
def factorial(x): #階乗計算
    n=1
    for i in range(x):
        n=(n*(i+1))%mod
    return n

def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a%b)
def lcm(a, b):
    return((a*b)//gcd(a,b))
def div(x): #約数配列
    div=[1]
    check=2
    while(x!=1 and check <= int(x**0.5)+2):
        if(x%check==0):
            div.append(check)
            while(x%check==0):
                x=x//check
        check+=1
    if x != 1:
      div.append(x)
    return div
def div2(x): #素因数分解配列
    div2=[]
    check=2
    while(x!=1 and check <= int(x**0.5)+2):
        while x%check==0:
            div2.append(check)
            x/=check
        check+=1
    if x != 1:
      div2.append(x)
    return div2

def main():
    # x,y = map(int,input().split())           x=1,y=2
    # a = input().split()                      a=['1','2','3',...,'n']
    # a = list(map(int,input().split()))       a=[1,2,3,4,5,...,n]
    # li = input().split('T')	              FFFTFTTFF => li=['FFF', 'F', '', 'FF']
    # 複数行の「1 2 3 4」型の入力を一配列に
    # x = sorted([list(map(int, input().split())) for _ in range(n)])
    # ソート x.sort(key=lambda y:y[1])
    # [chr(i) for i in range(97, 97+26)] 英語小文字リスト
    # [chr(i) for i in range(65, 65+26)] 英語大文字リスト atcoder
    # ord(c) chr(2) alphabet <=> number
    n=int(input())
    a = list(map(int,input().split())) 
    b = list(map(int,input().split())) 
    if sum(a)<sum(b):
        print(-1)
    else:
        p=[]
        m=[]
        for i in range(n):
            if a[i]>=b[i]:
                p.append(a[i]-b[i])
            else:
                m.append(b[i]-a[i])
        if m==[]:
            print(0)
            exit()
        ans=len(m)
        debit=sum(m)
        p.sort(reverse=True)
        index=0
        while debit>0:
            debit-=p[index]
            index+=1
            ans+=1
        print(ans)
main()

Measured memory_bytes: 83504
import sys
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, d=DVSR): return pow(x, d - 2, d)
def DIV(x, y, d=DVSR): return (x * INV(y, d)) % d
def LI(): return [int(x) for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()
def II(): return int(input())

N,K=LI()

if K > (N-1)*(N-2)//2:
    print(-1)
    exit()

out = []
for i in range(N-1):
    out.append((1, 2+i))

cnt = 0
for i in range(2, N+1):
    for j in range(i+1, N+1):
        if cnt < ((N-1)*(N-2)//2-K):
            cnt += 1
            out.append((i, j))

print(len(out))
for li in out:
    print(li[0],li[1])

Measured memory_bytes: 43504
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

template <class T> using oset = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;

void usaco(string name = "")
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    if(name.size())
    {
        freopen((name+".in").c_str(), "r", stdin);
        freopen((name+".out").c_str(), "w", stdout);
    }
}

#define int long long

const int mod = 1e9+7;

int32_t main()
{
    usaco();
    int n;
    cin >> n;
    vector <int> dp(2001, 1);
    dp[1] = dp[2] = 0;
    for (int i = 6; i <= n; ++i)
        for (int j = 3; j <= i-3; ++j)
            dp[i] = (dp[i] + dp[j]) % mod;
    cout << dp[n] << '\n';
}


Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

int main()
{
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;

    char c = s[k - 1];
    c = c - ('A' - 'a');
    s[k - 1] = c;
    cout << s << endl;

    return 0;
}

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

typedef long long ll;

int h, w;
string a[1005];
ll dp[1005][1005];
ll MOD = 1e9+7;

long long recur(int i , int j){
    if(i == h-1 && j == w-1) return 1;
    ll &r = dp[i][j];
    if(r != -1) return r;
    r = 0;
    if ( i+1 < h and a[i+1][j] != '#' )
        r += recur ( i+1, j );
    if ( j+1 < w and a[i][j+1] != '#' )
        r += recur ( i, j+1 );
    r %= MOD;
    return r;
}


int main(){
    cin>>h>>w;
    memset(dp,-1,sizeof dp);
    for(int i = 0; i < h; i++){
        cin>>a[i];
    }
    cout<<recur(0,0) % MOD;
}


Measured memory_bytes: 9344
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<functional>
#include<numeric>
#include<queue>
#include<stack>
#include<map>
#include<unordered_map>
#include<set>
#include<bitset>
#include<random>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,y,x) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define pb push_back
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
const ll inf = 2222222222222222222LL;
const ll mod = 1000000007LL;

ll n = 0, m = 0, ans = 0, tmp = 0, ma = -inf, mi = inf;
string s;
bool ok;
ll dx[9] = { 0,1,-1,0,0,1,1,-1,-1 }, dy[9] = { 0,0,0,1,-1,1,-1,1,-1 };
#define endl '\n'
#pragma endregion
#define MAX 222222






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


  cin >> n;
  rep(i, n) {
    cin >> m;
    if (ma <= m) ans++;
    ma = max(ma, m);
  }
  cout << ans << endl;



  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

#define N 15

struct Link{
  int linkkey;
  struct Link *Next;
  struct Link *Before;
};

typedef struct Link * LinkSearch;

LinkSearch Target;

void LinkIn(int );
void DelFast();
void DelLast();
void Dellinkkey(int );
void DelLink(LinkSearch );
LinkSearch Search(int );


int main(){
  LinkSearch link;
  int count=0;
  int loop,linknum;
  char order[N];
  int i;

  Target=malloc(sizeof(struct Link));
  Target->Next=Target;
  Target->Before=Target;

  scanf("%d",&loop);

  for(i=0;i<loop;i++){
    scanf("%s",order);
    
    if(order[0]=='i'){
      scanf("%d",&linknum);
      LinkIn(linknum);
    }
    
    else if(order[0]=='d'){
      if(strlen(order)==6){
	scanf("%d",&linknum);
	Dellinkkey(linknum);
      }
      
      else if(strlen(order)>6){
	
	if(order[6]=='F'){
	DelFast();
	}

	else if(order[6]=='L'){
	  DelLast();
	}
	
      }
    }
  }
  
  link=Target->Next;
  
  while(link!=Target){
   
    if(count>=1){
      printf(" ");
    }

    printf("%d",link->linkkey);
    link=link->Next;
    count++;
  }

  printf("\n");
  
  
  return 0;
}

void LinkIn(int number){
  LinkSearch insert;

  insert=malloc(sizeof(struct Link));
  
  insert->linkkey=number;
  
  insert->Next=Target->Next;
  
  Target->Next->Before=insert;
  
  Target->Next=insert;
  
  insert->Before=Target;
  
}

void DelFast(){
  LinkSearch First;

  First=Target->Next;
  
  if(First==Target){
    return;
  }
  
  DelLink(First);
}

void DelLast(){
  LinkSearch Last;

  Last=Target->Before;
  
  if(Last==Target){
    return;
  }
  
  DelLink(Last);
}

void Dellinkkey(int number){
  
  DelLink(Search(number));
  
}

void DelLink(LinkSearch Erase){

  if(Erase==Target){
    return;
  }

  Erase->Before->Next=Erase->Next;
  
  Erase->Next->Before=Erase->Before;
  
  free(Erase);
  
}

LinkSearch Search(int linknum){
  LinkSearch Sear;

  Sear=Target->Next;

  while((Sear!=Target) && (Sear->linkkey!=linknum)){
    Sear=Sear->Next;
  }

  return Sear;
}





Measured memory_bytes: 33112
import java.util.*;
import java.math.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int d = sc.nextInt();

		int result = 0;
		
		if(d/1000 ==2){
			result++;
		}
		if((d/100)%10 ==2){
			result++;
		}
		if((d%100)/10 ==2){
			result++;
		}
		if(d%10 ==2){
			result++;
		}
		System.out.println(result);



	}
}

Measured memory_bytes: 21844
n, q = map(int, input().split())
s = input()
lst = [0] * (n + 1)
reach = False
for i in range(n):
  if s[i] == 'A':
    reach = True
    lst[i + 1] = lst[i]
  else:
    if reach and s[i] == 'C':
      lst[i + 1] = lst[i] + 1
    else:
      lst[i + 1] = lst[i]
    reach = False
lst.pop(0)
#print(lst)
for i in range(q):
  l, r = map(int, input().split())
  print(lst[r - 1] - lst[l - 1])

Measured memory_bytes: 11604
#include <iostream>
#include <vector>
using namespace std;
int main(){
  int n,d,x;
  cin >> n >> d >> x;
  int i;
  vector<int> a(101);
  for(i=0;i<n;i++) cin >> a[i];
  int count = 0;
  for(i=0;i<n;i++){
    int c = 1;
    while(c <= d){
      count++;
      c = c+a[i];
    }
  }
  cout << count+x << "\n";
  return 0;
}


Measured memory_bytes: 256
/*    BAJUKA     */
#include<bits/stdc++.h>
#define lld long long int
#define ve vector
#include<ios>
#define rep(i,a,b) for(i=a;i<b;i++) 
#define per(i,a,b) for(i=b;i>=a;i--)
#define all(v) v.begin(),v.end()
#define pb push_back
#define mp make_pair
#define Max 10000000000000000
#define M 1000000007
using namespace std;




int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	
    string st[105];
    map<string,lld> m;
    lld i,j,n;
    char c;
    cin>>n;
    rep(i,0,n)
    {
    	cin>>st[i];
    	m[st[i]]=0;
    }
    m[st[0]]=1;
    rep(i,1,n)
    {
    	c = st[i-1][st[i-1].length()-1];
    	if(m[st[i]])
    	{
    		cout<<"No";exit(0);
    	}
    	if(st[i][0] != c)
    	{
    		cout<<"No";exit(0);
    	}
    	m[st[i]] = 1;
    }
    cout<<"Yes";


	return(0);
}

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

signed main() {
  string S;
  cin >> S;

int ans = 0;
for( int i = 1; i < S.size(); i++ ){
if( S.at(i) != S.at(i-1) ) ans++;
}
cout << ans << endl;
}

Measured memory_bytes: 512
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <climits>
#include <cstdlib>
#include <vector>
#include <queue>
#include <unordered_map> 
#include <iomanip>
#include <random>
#include <future>
#include <thread>
#include <utility>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define INF (INT_MAX/3)
#define INF_L (LLONG_MAX/3)
#define PSB push_back
#define PN 1000000007
typedef long long LL;
#define int long long


// booooooooooooost
// #include <boost/multiprecision/cpp_int.hpp>
// #include <boost/multiprecision/cpp_dec_float.hpp>
// namespace mp = boost::multiprecision;	//多倍長整数(mp::cpp_int), 多倍長小数(mp::cpp_dec_float_100)


signed main() {

	int N;
	string s1, s2;
	cin >> N;
	cin >> s1;
	cin >> s2;

	int ans = 0, bak = 0;;
	if (s1[0] == s2[0]) {
		ans = 3;
		bak = 0;
	}
	else {
		ans = 6;
		bak = 1;
	}

	for (int i = ans == 3 ? 1 : 2; i < s1.size();) {
		if (s1[i] == s2[i] && bak == 0) {
			ans *= 2;
			++i;
			bak = 0;
		}
		if (s1[i] != s2[i] && bak == 0) {
			ans *= 2;
			i += 2;
			bak = 1;
		}
		if (s1[i] == s2[i] && bak == 1) {
			++i;
			bak = 0;
		}
		if (s1[i] != s2[i] && bak == 1) {
			ans *= 3;
			i += 2;
			bak = 1;
		}
		ans %= PN;
	}

	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi M_PI
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main() {
    string s;
    cin >> s;
    int n = s.length();
    int win;
    if (s[0] == s[n-1]){
        if (n % 2 == 0) win = 1;
        else win = 2;
    }else{
        if (n % 2 == 0) win = 2;
        else win = 1;
    }

    cout << (win == 1 ? "First" : "Second") << endl;
    return 0;
}

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

lst=[0]*n

for _ in range(n):
    work=list(map(int,input().split()))
    lst[work[0]-1]=work[2:]

dis=[-1]*n
dis[0]=0
work=lst[0][:]
work_next=[]
token=0

while work:
    token+=1
    for x in work:
        if dis[x-1]==-1: dis[x-1]=token
        for y in lst[x-1]:
            if dis[y-1]==-1 : work_next.append(y)
    work=work_next[:]
    work_next=[]

for i in range(n):
    print("{} {}".format(i+1,dis[i]))


Measured memory_bytes: 6512
package main

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

func main() {
	n := getInt()
	hs := make([]int, n)
	for i := range hs {
		hs[i] = getInt()
	}

	ans := 0
	cnt := 0
	for i := 1; i < n; i++ {
		if hs[i-1] < hs[i] {
			cnt = 0
		} else {
			cnt++
		}
		ans = max(ans, cnt)
	}

	fmt.Println(ans)
}

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

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	// buf := 200001
	// sc.Buffer(make([]byte, buf), buf)
	sc.Split(bufio.ScanWords)
}

func getInt() int {
	i, err := strconv.Atoi(getString())
	if err != nil {
		panic(err)
	}
	return i
}

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


Measured memory_bytes: 3072
n = int(input())
n_1 = -1
n_2 = -1
index1 = -1
index2 = -1
for i in range(n):
    a = int(input())
    if a >= n_1:
        n_1 , n_2 = a ,n_1 
        index1, index2 = i, index1
    elif a >= n_2:
        n_2 = a
        index2 = i
    
for i in range(n):
    if i == index1:
        print(n_2)
    else:
        print(n_1)
        

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

int main(){
  int64_t N;
  cin>>N;
  int64_t d=pow(10,12);
  for(int64_t i=1;i<=sqrt(N);++i){
    if(N%i==0){
      if((i-1)+(N/i-1)<d){
        d=(i-1)+(N/i-1);
      }
    }
  }
  cout<<d<<endl;
}


Measured memory_bytes: 256
x1,x2,x3,x4,x5 = map(int, input().split())
if x1 == 0:
    print(1)
elif x2 == 0:
    print(2)
elif x3 == 0:
    print(3)
elif x4 == 0:
    print(4)
else:
    print(5)


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

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

    sort(a, a + N);
    int al = 0, b = 0;
    for (int i = N - 1; i >= 0; i -= 2) al += a[i];
    for (int i = N - 2; i >= 0; i -= 2) b += a[i];

    cout << al - b << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner reader = new Scanner(System.in);
		String str = reader.next();
		int maxR = 0, currR = 0;
		for (int i = 0; i < str.length(); i++) {
			char curr = str.charAt(i);
			if (curr == 'S') {
				currR = 0;
			}
			else {
				currR++;
				maxR = Math.max(maxR, currR);
			}
		}
		System.out.println(maxR);
		
		reader.close();
	}
	
}


Measured memory_bytes: 35628
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

struct UnionFind {
  vector<int> d;
  UnionFind(int n) : d(n, -1) {}
  int root(int x) {
    if(d[x] < 0) return x;
    return d[x] = root(d[x]);
  }
  bool unite(int x, int y) {
    x = root(x);
    y = root(y);
    if(x == y) return false;
    if(d[x] > d[y]) swap(x, y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y) { return root(x) == root(y); }
  int size(int x) { return -d[root(x)]; }
};

int main() {
  ll n, m;
  cin >> n >> m;
  vector<P> p(m);
  rep(i, m) {
    cin >> p[i].first >> p[i].second;
    p[i].first--;
    p[i].second--;
  }
  reverse(all(p));
  UnionFind uf(n);
  vl ans(m + 1, n * (n - 1) / 2);
  rep(i, m) {
    ll a = p[i].first;
    ll b = p[i].second;
    ll sa = uf.size(a);
    ll sb = uf.size(b);
    ans[m - i - 1] = ans[m - i];
    ans[m - i - 1] += sa * (sa - 1) / 2;
    if(uf.root(a) != uf.root(b)) ans[m - i - 1] += sb * (sb - 1) / 2;
    uf.unite(a, b);
    ll s = uf.size(a);
    ans[m - i - 1] -= s * (s - 1) / 2;
  }
  rep(i, m) cout << ans[i + 1] << '\n';
}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef pair<P,P> PP;

int d[11111][3][201];
int main() {
  int n,m,k;
  cin >> n >> m >> k;
  int a[n];
  for(int i=0; i<n; i++) cin >> a[i];
  vector<P> v[m];
  for(int i=0; i<m; i++) {
    int x,y,z;
    cin >> x >> y >> z;
    x--,y--;
    v[x].push_back(P(y,z));
    v[y].push_back(P(x,z));
  }
  priority_queue<PP,vector<PP>,greater<PP> > que;
  que.push(PP(P(0,0),P(a[0],0)));
  for(int i=0;i<n;i++)for(int j=0;j<3;j++)for(int l=0;l<=k;l++)d[i][j][l]=1<<29;
  d[0][a[0]][0]=0;
  int ans=1<<29;
  while(!que.empty()) {
    PP p=que.top();que.pop();
    int c=p.first.first,x=p.first.second,s=p.second.first,t=p.second.second;
    if(x==n-1) {
      ans=c;
      break;
    }
    if(d[x][s][t]<c) continue;
    for(int i=0; i<v[x].size(); i++) {
      int y=v[x][i].first,cc=v[x][i].second;
      int tt=min(k,t+cc),ss=s;
      if(abs(s-a[y])==2&&tt!=k) continue;
      if(a[y]!=1) tt=0,ss=a[y];
      if(d[y][ss][tt]>d[x][s][t]+cc) {
        d[y][ss][tt]=d[x][s][t]+cc;
        que.push(PP(P(d[y][ss][tt],y),P(ss,tt)));
      }
    }
  }
  cout << ans << endl;
  return 0;
}


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

vector<int> h, a;

long long segtree[800002];
vector<pair<int,int> > order;

void update(int node,int l,int r , int in, long long val){
    if(l==r) {
        segtree[node]=val;
        return ;
    }
    int m = (l+r)/2;
    if(in<=m)
        update(2*node+1,l,m,in,val );
    else
        update(2*node + 2, m+1, r, in , val);
    segtree[node]  = max(segtree[2*node+1], segtree[2*node+2]);
}
 
long long query(int node, int l,int r, int ql, int qr ){
    //cout<<node<<", "<<ql<<", "<<qr<<"\n";
    if(ql>qr) return 0;
    if(qr < l || ql >r ) return 0;
    if(ql<=l && qr>=r) return segtree[node];
    if(l==r)  return segtree[node];
    int m = (l+r)/2;
    long long a1 = query(2*node + 1, l, m, ql, qr);
    long long a2 = query(2*node + 2, m+1, r, ql, qr);
    long long ans= max(a1, a2);
    //cout<<node<<", "<<ql<<", "<<qr<<": "<<ans<<"\n";
    return ans;
}
void print() {
    int i;
    for(i=0;i<=16;i++)
        cout<<segtree[i]<<" ";
    cout<<"\n";
}
int main() {
    int n;
    cin>>n;
    int i;
    for(i=1;i<=n;i++){
        int hh;
        cin>>hh;
        h.push_back(hh);
        order.push_back({-hh, i-1});
    }
    for(i=1;i<=n;i++){
        int aa;
        cin>>aa;
        a.push_back(aa);
    }
    sort(order.begin(), order.end() );
    
    long long ans = 0;
    for(auto p: order) {
        
        int in = p.second;
        int val =a[in];
       // cout<<"("<<val<<", "<<in<<")\n";
        long long max_value_in_right = query(0,1,n-1,in+1, n-1);
       // cout<<"maxValue: "<<max_value_in_right<<"\n";
        update(0,0,n-1,in, max_value_in_right +val);
       // print();
        ans  = max(ans, max_value_in_right + val);
    }
    cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 10600
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int k,a=7;
    cin >> k;
    for(int i=1;i<=k;i++){
        if(a%k==0){
            cout << i << endl;
            return 0;
        } 
        else a = (a*10+7)%k;
    }
    cout << -1 << endl;
}


Measured memory_bytes: 3656
#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.at(i);
  }
  sort(A.begin(),A.end());
  reverse(A.begin(),A.end());
  int answer=0;
  for(int i=0;i<N;i++){
    if(i%2==0){
      answer+=A.at(i);
    }
    else{
      answer-=A.at(i);
    }
  }
  cout << answer << endl;
}


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

IL int gi(){
    int data = 0 , m = 1; char ch = 0;
    while(ch!='-' && (ch<'0'||ch>'9')) ch = getchar();
    if(ch == '-'){m = 0 ; ch = getchar() ; }
    while(ch >= '0' && ch <= '9'){data = (data<<1) + (data<<3) + (ch^48) ; ch = getchar(); }
    return (m) ? data : -data ; 
}

int deg[10] , dsu[10] ;

IL int Find(int u) {return dsu[u] ^ u ? dsu[u] = Find(dsu[u]) : u ; }

int main() {
	int a , b ;
	for(int i = 1; i <= 4; i ++) dsu[i] = i ;
	for(int i = 1; i <= 3; i ++) {
		a = gi() ; b = gi() ;
		deg[a] ++ ; deg[b] ++ ;
		dsu[Find(a)] = Find(b) ;
	}
	int cnt = 0 ;
	for(int i = 1; i <= 4; i ++) if(Find(i) != Find(1)) return puts("NO") , 0 ;
	for(int i = 1; i <= 4; i ++) if(deg[i] & 1) ++ cnt ;
	if(cnt != 2 && cnt != 0) return puts("NO") , 0 ;
	return puts("YES") , 0 ;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<vector<int>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VP = vector<P>;
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 (a>b) { a=b; return true; } return false; }

int main(){
    int n;
    cin >> n;
    VI a(n);
    rep(i,n) cin >> a[i];
    sort(all(a));
    ll ans = 0;
    rep(i,n-1) ans += a[i+1] - a[i];
    cout << ans << endl;
    return 0;
}

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

using namespace std;

const int N = 100005;
int n, a[N], dp[N];
bool solved[N];

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


Measured memory_bytes: 1024
#include<bits/stdc++.h>                                                                                               
using namespace std;
 
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define int long long
#define mk_p(a,b)   make_pair((a),(b))
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;

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

signed main(){
    int x;
    cin >> x;
    int n = x;
    reps(i,n){
        x -= i;
        if(x <= 0){ 
            cout << i << '\n';
            return 0;
        }
    }   
    return 0;
}


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

long long vec[510][510],seen[510][510];
void iru(long long x,long long ai,long long aj,long long n) {

    if (ai>0) {
      if (vec[ai-1][aj]>0 && vec[ai-1][aj]>vec[ai][aj]+x) {
        vec[ai-1][aj]=vec[ai][aj]+x;
        if (seen[ai-1][aj]==1) iru(1,ai-1,aj,n);
        else iru(0,ai-1,aj,n);
      }
    }
    if (ai<n-1) {
      if (vec[ai+1][aj]>0 && vec[ai+1][aj]>vec[ai][aj]+x) {
        vec[ai+1][aj]=vec[ai][aj]+x;
        if (seen[ai+1][aj]==1) iru(1,ai+1,aj,n);
        else iru(0,ai+1,aj,n);
      }
    }
    if (aj>0) {
      if (vec[ai][aj-1]>0 && vec[ai][aj-1]>vec[ai][aj]+x) {
        vec[ai][aj-1]=vec[ai][aj]+x;
      if (seen[ai][aj-1]==1) iru(1,ai,aj-1,n);
        else iru(0,ai,aj-1,n);}
    }
    if (aj<n-1) {
      if (vec[ai][aj+1]>0 && vec[ai][aj+1]>vec[ai][aj]+x) {
        vec[ai][aj+1]=vec[ai][aj]+x;
        if (seen[ai][aj+1]==1) iru(1,ai,aj+1,n);
        else iru(0,ai,aj+1,n);
      }
    }

}



int main() {
  long long n;cin >> n;
  for (long long i=0;i<n;i++) {
    for (long long j=0;j<n;j++) {
	  vec[i][j]=min(min(i,j),min(n-i-1,n-j-1));
      seen[i][j]=1;
	}
  }
  long long count=0;
  for (long long i=0;i<n*n;i++) {
    long long a;cin >> a;
    long long ai,aj;
    ai=(a-1)/n;
    aj=(a-1)%n;
    count+=vec[ai][aj];
    seen[ai][aj]=0;
    iru(0,ai,aj,n);
  }
  cout << count << endl;
}

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

using namespace std;

int main(){

    int n1, n2, n3, num;

    cin >> n1 >> n2 >> n3;

    n1 *= 100;
    n2 *= 10;
    num =  n1 + n2 + n3;

    if(num % 4 == 0){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }

    return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = (1LL << 31) - 1;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll n, m;

vector<int> vi[100100];
bool f[100100];
int s = 0;

//bool dfs(int now, int pre) {
//	cout << "!" << now << endl;
//	bool res = true;
//	if (f[now]) {
//		cout << (now == s) << endl;
//		return now == s;
//	}
//	f[now] = true;
//	REP(i, vi[now].size()) {
//		int to = vi[now][i];
//		if (to != pre) {
//			res &= dfs(to, now);
//		}
//	}
//	return res;
//}

int main() {
	cin >> n >> m;
	REP(i, m) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		vi[a].push_back(b);
		vi[b].push_back(a);
	}
	REP(i, n) {
		if (vi[i].size() % 2) {
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
}

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

int a[100];

int main() {
	ll x, k, d;
	cin >> x >> k >> d;
	if(x >= 0) {
		ll div = x/d;
		if(div <= k) {
			x -= (div*d);
			ll moves_left = k-div;
			if(moves_left % 2 == 0) {
				cout << x << endl;
			}
			else{
				cout << abs(x-d) << endl;
			}
		}
		else{
			x -= (k*d);
			cout << x << endl;
		}	
	}
	else{
		ll div = x/d;
		if(abs(div) <= k) {
			x += (abs(div)*d);
			ll moves_left = k-abs(div);
			if(moves_left % 2 == 0) {
				cout << abs(x) << endl;
			}
			else{
				cout << x+d << endl;
			}
		}
		else{
			x += (k*d);
			cout << abs(x) << endl;
		}
	}
}

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


int main(){
ll n,rc=0,co=0;
  string c;
  cin >> n >> c;
  rep(i,n){
    

    if(c.at(i)=='R')
      rc++;
  }

  rep(i,rc){
    if(c.at(i)=='W')
      co++;
  }
  cout << co << endl;
  
}

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

constexpr int lim = 55555;
bool eratosthenes[lim];

void init(){
  for(int i=1; i<lim; i++) eratosthenes[i] = true;
  eratosthenes[1] = false;

  for(int i=2; i<lim; i++){
    if(eratosthenes[i]){
      for(int j=2; i * j < lim; j++){
        eratosthenes[i * j] = false;
      }
    }
  }
}

void solve(vector<int>& ans){
  int index = 0;
  for(int i=0; i<lim && index < ans.size(); i++){
    if(eratosthenes[i] && i % 5 == 1){
      ans[index] = i;
      index++;
    }
  }
}

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

  vector<int> ans(n);
  solve(ans);

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

Measured memory_bytes: 256
import heapq

n, m = map(int, input().split())
graph = [[] for i in range(n)]
for i in range(m):
    l, r, d = map(int, input().split())
    graph[l-1].append((r-1,d))
    graph[r-1].append((l-1,-d))


visited = [False for i in range(n)]
pos = [0 for i in range(n)]

for i in range(n):
    if visited[i]:
        continue
    hq = [(i, 0)]
    while hq:
        v, p = heapq.heappop(hq)
        if visited[v]:
            if p != pos[v]:
                print("No")
                exit()
            continue
        visited[v] = True
        pos[v] = p
        for nv, d in graph[v]:
            if visited[nv]:
                if pos[nv] != p + d:
                    print('No')
                    exit()
                continue
            heapq.heappush(hq, (nv, p+d))
print('Yes')




Measured memory_bytes: 73360
# @author 

import sys

class ATriangle:
    def solve(self):
        import math
        s = int(input())
        x2 = math.ceil(s ** .5)
        y2 = 1
        y3 = math.ceil(s ** .5)
        x3 = x2 * y3 - s
        print(0, 0, x2, y2, x3, y3)


solver = ATriangle()
input = sys.stdin.readline

solver.solve()


Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
template<typename T>
void print(T x) {
    cout << x << endl;
}
int main(void) {
    int n, k;
    cin >> n >> k;
    int ans = 0;
    while(n > 0) {
        n /= k;
        ans ++;
    }
    cout << ans;
}


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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

int main(void){
  int n; cin >> n;
  vector<string> w(n); rep(i,n) cin >> w[i];

  bool ok = true;
  rep(i,n){
    for(int j = i+1;j<n;j++) if(w[i]==w[j]) ok = false;
  }

  for(int i = 1;i<n;i++){
    if(w[i-1][w[i-1].size()-1]!=w[i][0]){
      ok = false;
    }
  }
  
  if(ok) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}


Measured memory_bytes: 3612
N, K = [int(_) for _ in input().split()]
mod = 10**9 + 7
A = [0] * (K + 1)
for i in range(K, 0, -1):
    A[i] = pow(K // i, N, mod)
    for j in range(2, K // i + 1):
        A[i] -= A[i * j]
        A[i] %= mod
print(sum(i * a for i, a in enumerate(A)) % mod)


Measured memory_bytes: 11316
MOD = 10**9 + 7

def comb(n,r):
  if (r<0 and r>n):
    return 0
  r = min(r,n-r)
  return g1[n] * g2[r] * g2[n-r] % MOD

N = 10**6
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]
for i in range(2, N+1):
  g1.append((g1[-1]*i)%MOD)
  inverse.append((-inverse[MOD%i]*(MOD//i))%MOD)
  g2.append((g2[-1]*inverse[-1])%MOD)
  
X,Y = map(int, input().split())


if not (X+Y) % 3:
    m = (2*X - Y)//3
    n = (2*Y - X)//3
    if n >= 0 and m >= 0:
        print(comb(n+m,n))
    else:
        print(0)
else:
    print(0)


Measured memory_bytes: 127932
open Batteries
(* 文字列をcharのlistにする *)
let explode s = List.init (String.length s) (String.get s)
(* charのlistをstringに *)
let string_of_chars chars = 
  let buf = Buffer.create 16 in
  List.iter (Buffer.add_char buf) chars;
  Buffer.contents buf

let t = List.nth (read_line () |> explode) 0
let c = List.nth (read_line () |> explode) 1
let u = List.nth (read_line () |> explode) 2
let _ = print_endline @@ string_of_chars [t;c;u]

Measured memory_bytes: 1152
N = int(input())
monslist = list(map(int, input().split()))
monslist.reverse()
while max(monslist)!=0:
    mn = monslist[-1]
    for i in range(len(monslist)-1):
        monslist[i] = monslist[i]%mn
    monslist.reverse()
    for i in range(len(monslist)):
        if(monslist[-1]==0):monslist.pop()
    if(len(monslist) == 1): break
print(monslist[0])

Measured memory_bytes: 14252
#include <cstdio>
#include <vector>
#define repeat(i, n) for (int i = 0; (i) < int(n); ++(i))
using ll = long long;
using namespace std;

constexpr int mod = 1e9+7;
int main() {
    // input
    int n, m; scanf("%d%d", &n, &m);
    vector<int> x(m+1); repeat (i, m) scanf("%d", &x[i]);
    // solve
    ll result = 1;
    ll preserved = 0;
    ll delta = 0;
    ll acc = 0;
    int j = 0;
    int x_j = x[j];
    repeat (i, n) {
        acc += result;
        preserved += 2 * delta + acc;
        delta += acc;
        if (i % 17 == 0) {
            preserved %= mod;
            delta %= mod;
            acc %= mod;
        }
        result = preserved;
        if (x_j == i+1) {
            result = 0;
            x_j = x[++ j];
        }
    }
    // output
    printf("%lld\n", result % mod);
    return 0;
}


Measured memory_bytes: 888
using LIB;
using System;
using System.Linq;
using System.Text;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {
        while (true)
        {
            int[] n = io.r<int>(' ');
            if (n[0] == n[1] && n[0] == 0) { break; }
            for (int i = 0; i < n[0]; i++)
            {
                for (int j = 0; j < n[1]; j++)
                {
                    if ((i + j) % 2 == 0)
                    {
                        io.w("#", false);
                    }
                    else
                    {
                        io.w(".", false);
                    }
                }
                io.w("");
            }
            io.w("");
        }
        io.wflush();
    }
}

namespace LIB
{
    public class io
    {
        private const int WMAX = 1000;
        private static StringBuilder S = new StringBuilder();
        public static T r<T>() { return util.parse<T>(r()); }
        public static T[] r<T>(char s = ' ') { return r().Split(s).Select(util.parse<T>).ToArray(); }
        public static T[] r<T>(int l) { T[] r = new T[l]; for (int i = 0; i < l; i++) { r[i] = r<T>(); } return r; }
        public static T[][] r<T>(int l, char s = ' ') { T[][] r = new T[l][]; for (int i = 0; i < l; i++) { r[i] = r<T>(s); } return r; }
        private static string r() { return Console.ReadLine(); }
        public static void w(object v, bool lf = true) { S.Append(util.parse<string>(v)); if (lf == true) { S.Append('\n'); } if (S.Length >= WMAX) { wflush(); } }
        public static void wflush() { Console.Write(S.ToString()); S.Length = 0; }
    }
    public class util
    {
        public static T parse<T>(object value) { return (T)(Convert.ChangeType(value, typeof(T))); }
    }
    public class memo<Key, Result>
    {
        private Dictionary<Key, Result> R;
        public memo() { R = new Dictionary<Key, Result>(); }
        public Result exec(Key k, Func<Key, Result> f) { Result r; if (R.ContainsKey(k)) { r = R[k]; } else { r = f(k); R.Add(k, r); } return r; }
    }
}

Measured memory_bytes: 10444
#include<iostream>
#include<cstddef>

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

	std::int64_t count{};
	while( a % 2 != 1 && b % 2 != 1 && c%2 != 1 )
	{
		auto ta = b / 2 + c / 2;
		auto tb = a / 2 + c / 2;
		auto tc = a / 2 + b / 2;

		a = ta; b = tb; c = tc;
		if( a == b && b == c )
		{
			count = -1;
			break;
		}

		++count;
	}

	std::cout << count << "\n";

	return 0;
}

Measured memory_bytes: 888
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;
long long int di[] = {-1, 0, 1, 0, -1, 1, 1, -1};
long long int dj[] = {0, 1, 0, -1, 1, 1, -1, -1};

template<typename T1,typename T2>inline void chmin(T1 &a,const T2 &b){if(a>b) a=b;}
template<typename T1,typename T2>inline void chmax(T1 &a,const T2 &b){if(a<b) a=b;}

#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()

/* do your best */

int main() {
  
  char c; cin >> c;
  c++;
  cout << c << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s,t;
    cin >> s >> t;
    int x = stoi(s+t);
    for(int i=1;i<=1000;i++){
        if(x==i*i){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3612
# -*- coding: utf-8 -*-

import sys
from collections import Counter

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

def factorize(num: int) -> dict:
    """ 素因数分解 """
    from math import sqrt
    from collections import Counter

    d = Counter()
    # 終点はルート切り捨て+1
    for i in range(2, int(sqrt(num))+1):
        # 素因数分解：小さい方から割れるだけ割って素数をカウント
        while num % i == 0:
            num //= i
            d[i] += 1
        # 1まで分解したら終了
        if num == 1:
            break
    # 最後に残ったnumは素数(ただし1^1は1^0なので数に入れない)
    if num != 1:
        d[num] += 1
    return d

N = INT()

# N!までを全部素数冪でまとめる
primes = Counter()
for i in range(2, N+1):
    primes.update(factorize(i))

# 約数が75になる素数冪の組み合わせを数える
primes = sorted(primes.values())
M = len(primes)
cnt = 0
for i, v1 in enumerate(primes):
    # 1種類使う
    if v1 >= 74:
        cnt += 1
    for j, v2 in enumerate(primes[i+1:], i+1):
        # 2種類使う
        if v1 >= 2 and v2 >= 24:
            cnt += 1
        if v1 >= 4 and v2 >= 14:
            cnt += 1
        if v1 >= 24 and v2 >= 2:
            cnt += 1
        if v1 >= 14 and v2 >= 4:
            cnt += 1
        for k, v3 in enumerate(primes[j+1:], j+1):
            # 3種類使う
            if v1 >= 2 and v2 >= 4 and v3 >= 4:
                cnt += 1
            if v1 >= 4 and v2 >= 2 and v3 >= 4:
                cnt += 1
            if v1 >= 4 and v2 >= 4 and v3 >= 2:
                cnt += 1
print(cnt)


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

using namespace std;


int main() {
  //ios::sync_with_stdio(false);
  //cin.tie(0);
  int ant[10], k;
  for (int i = 0; i < 5; i++) {
      cin >> ant[i];
  }
  cin >> k;
  string ans = "Yay!";
  for (int i = 0; i < 5; i++) {
      for (int j = i + 1; j < 5; j++) {
          if (ant[j] - ant[i] > k) ans = ":(";
      }
  }
  cout << ans;
  return 0;
}

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

int main()
{
  int kazoe=0;
  int hikaku=0;
  string S;
  cin>>S;
  for(int i=0;i<S.size();i++){
    if(S.at(i)=='A'||S.at(i)=='T'||S.at(i)=='C'||S.at(i)=='G')
      kazoe++;
    else{
      if(hikaku<kazoe){
        hikaku=kazoe;
        kazoe=0;}
      else
        kazoe=0;
   		}
  	}
     if(hikaku<kazoe)
       cout<<kazoe<<endl;
     else  
       cout<<hikaku<<endl;
}


Measured memory_bytes: 256