akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<algorithm>
#include<stdio.h>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<set>
#include<math.h>
#include<stack>
#include<sstream>
#include<queue>
#include<list>
#include<iomanip>
#include<bitset>
#include<limits.h>
#define MOD  1000000007
#define BIG  200001
#define ii pair<int,int>
#define iii pair<int,pair<int,int> >
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define vi vector<int>
#define pi pair<int,int>
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define all(n) n.begin(),n.end()

typedef  long long ll;
using namespace std;

int main()
{
    // freopen("input.txt", "r", stdin);
    IO ;
    int n ;
    vector<int> w ;
    vector<int > e ;
    string str ;
    cin >> n >> str ;
    for(int i =0 ; i<n ; i++)
    {
        if(i == 0 )
        {
            if(str[i] =='W')
            {
                w.push_back(1) ;
                e.push_back(0) ;
            }
            else
            {
                e.push_back(1) ;
                w.push_back(0) ;
            }
        }
        else
        {
            if(str[i] =='W')
            {
                w.push_back(w[i-1]+1) ;
                e.push_back(e[i-1]+0) ;
            }
            else
            {
                e.push_back(1+e[i-1]) ;
                w.push_back(0+w[i-1]) ;
            }
        }

    }
    int res1 =0, res2 = 0,mn = 1e9 ;
    res1 = str[0] == 'W' ? e[n-1] : e[n-1]-1 ;
    res2 = str[n-1] == 'W' ? w[n-1]-1 : w[n-1] ;
    mn = min(res1, res2 ) ;
    for(int i = 1 ; i<n-1 ; i++)
    {
        res1 = w[i-1] + e[n-1] - e[i] ;
        mn = min(res1, mn ) ;
    }
    cout << mn << endl ;
    return 0 ;
}


Measured memory_bytes: 3976
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <iostream>
#include <map>
#include <set>
#include <utility>
#include <vector>
using namespace std;
int find(vector<int>& parent, int x){
  if (parent[x] == x){
    return x;
  }else{
    return (parent[x] = find(parent, parent[x]));
  }
}

void unite(vector<int>& parent, vector<int>& rank, int x, int y){
  x = find(parent, x);
  y = find(parent, y);
  if (x == y) return;
  if (rank[x] < rank[y]){
    parent[x] = y;
  }else{
    parent[y] = x;
    if (rank[x] == rank[y]){
      rank[x]++;
    }
  }
}

bool same(vector<int>& parent, int x, int y){
  return find(parent, x) == find(parent, y);
}

int main(){
  int N;
  int K, L;
  scanf("%d%d%d", &N, &K, &L);
  vector<pair<int,int> > pq;
  vector<pair<int,int> > rs;
  for (int i = 0; i < K; i++){
    pair<int,int> temppq;
    scanf("%d%d", &(temppq.first), &(temppq.second));
    pq.push_back(temppq);
  }
  for (int i = 0; i < L; i++){
    pair<int,int> temprs;
    scanf("%d%d", &(temprs.first), &(temprs.second));
    rs.push_back(temprs);
  }
  vector<int> parentpq(N+1, 0);
  vector<int> rankpq(N+1, 0);
  for (int i = 1; i <= N; i++){
    parentpq[i] = i;
    rankpq[i] = 0;
  }
  vector<int> parentrs(N+1, 0);
  vector<int> rankrs(N+1, 0);
  for (int i = 1; i <= N; i++){
    parentrs[i] = i;
    rankrs[i] = 0;
  }
  for (int i = 0; i < K; i++){
    unite(parentpq, rankpq, pq[i].first, pq[i].second);
  }
  for (int i = 0; i < L; i++){
    unite(parentrs, rankrs, rs[i].first, rs[i].second);
  }
  map<int, set<int> > pqsets;
  map<int, set<int> > rssets;
  for (int i = 1; i <= N; i++){
    int rootpq = find(parentpq, i);
    int rootrs = find(parentrs, i);
    if (pqsets.find(rootpq) == pqsets.end()){
      pqsets[rootpq] = set<int>();
      pqsets[rootpq].insert(rootpq);
    }
    pqsets[rootpq].insert(i);
    if (rssets.find(rootrs) == rssets.end()){
      rssets[rootrs] = set<int>();
      rssets[rootrs].insert(rootrs);
    }
    rssets[rootrs].insert(i);
  }
  vector<int> num(N+1, 0);
  for (int i = 1; i <= N; i++){
    if (num[i] == 0){
      int rootpq = find(parentpq, i);
      int rootrs = find(parentrs, i);
      set<int>& pqset = pqsets[rootpq];
      set<int>& rsset = rssets[rootrs];
      set<int> unionset;
      if (pqset.size() < rsset.size()){
        for (set<int>::iterator iter = pqset.begin(); iter != pqset.end(); iter++){
          if (rsset.find(*iter) != rsset.end()){
            unionset.insert(*iter);
          }
	}
      }else{
        for (set<int>::iterator iter = rsset.begin(); iter != rsset.end(); iter++){
          if (pqset.find(*iter) != pqset.end()){
            unionset.insert(*iter);
          }
	}
      }
      for (set<int>::iterator iter = unionset.begin(); iter != unionset.end(); iter++){
        num[*iter] = unionset.size();
      }
    }
    cout << num[i];
    if (i <= (N-1)){
      cout << ' ';
    }
  }

  return 0;
}


Measured memory_bytes: 58356
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
int main(){
	int N; cin >> N; 
	int A[18] = {1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8192,16384,32768,65536,131072}; 
	bool possible = true; 
	for(int i = 0; i <= 17; i++){
		if(N == A[i]){
			cout << "No" << endl; return 0; 
		}
	}
	cout << "Yes" << endl; 
	cout << N + 1 << " " << N + 2 << endl; 
	for(int i = 1; i < (N+1) / 2; i++){
		cout << 1 << " " << 2*i << endl; 
		cout << 2*i << " " << 2*i+1 << endl; 
		cout << 1 << " " << 2*i+1+N << endl; 
		cout << 2*i+N << " " << 2*i+1+N << endl;
	}
	if(N % 2 == 0){
		int M = (lower_bound(A, A+18, N) - A) - 1; 
		int a = A[M]; int b = N - A[M]; 
		cout << N << " " << a << endl; 
		cout << N*2 << " " << b + 1 + N << endl; 
	}
}

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

int main()
{
    int a[5];
    int k;

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

    cin >> k;

    int distance;
    bool flg = true;

    int i, j;
    for (int i = 0; i < 5; i++)
    {
        for (int j = i + 1; j < 5; j++)
        {

            distance = a[j] - a[i];

            if (distance > k)
            {
                flg = false;
            }
        }
    }

    if (flg == true)
    {
        cout << "Yay!" << endl;
    }
    else
    {
        cout << ":(" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
long long const mod = 1000000007;

long long mod_pow(long long a, long long b){
    long long res = 1;
    a %= mod;
    while(b > 0){
        if(b%2 == 1) res = (res * a) % mod;
        a = (a * a) % mod;
        b /= 2;
    }
    return res;
}

long long mod_div(long long a){
    return mod_pow(a, mod-2);
}

vector< vector<int> > edg;
vector<int> cc, par;

int f(int v, int p){
    int res = 1;
    par[v] = p;
    for(int i=0;i<edg[v].size();i++){
        int w = edg[v][i];
        if(w == p) continue;
        res += f(w, v);
    }
    return cc[v] = res;
}

int main(void){
    int n;
    long long ans = 0;
    cin >> n;
    edg.assign(n, vector<int>());
    for(int i=0;i<n-1;i++){
        int a, b;
        cin >> a >> b;
        a--; b--;
        edg[a].push_back(b);
        edg[b].push_back(a);
    }

    cc.assign(n, -1);
    par.assign(n, -1);
    f(0, -1);
    long long r2 = mod_div(2), pn = mod_pow(r2, n);
    for(int i=0;i<n;i++){
        long long res = r2 + mod - pn;
        if(edg[i].size() == 1) continue;
        if(i > 0){
            long long t = n-cc[i];
            res += mod - mod_pow(r2, n-t) + pn;
        }
        for(int j=0;j<edg[i].size();j++){
            if(edg[i][j] == par[i]) continue;
            long long t = cc[edg[i][j]];
            res += mod - mod_pow(r2, n-t) + pn;
        }
        ans += res % mod;
        ans %= mod;
    }
    cout << ans << endl;
}


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

int main() {
    char c;
    cin >> c;
    if (isupper(c)) cout << 'A' << endl;
    else cout << 'a' << endl;
    return 0;
}

Measured memory_bytes: 3592
import java.io.*;
public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line[] = br.readLine().split(" ");
		int abc[] = new int[3];
		int max = 0;
		int maxi = -1;
		for (int i = 0; i < line.length; i++) {
			abc[i] = Integer.parseInt(line[i]);
			if (abc[i] > max) {
				max = abc[i];
				maxi = i;
			}
		}
		int sum = 0;
		for (int i = 0; i < line.length; i++) {
			if (i != maxi) {
				sum += abc[i];
			}
		}
		if (sum == max) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 8276
#include<bits/stdc++.h>
using namespace std;
int main() {
  using D = double;
  int N;
  cin >> N;
  vector<D> a(N);
  for(auto& i: a) cin >> i;
  sort(begin(a), end(a));
  D ans = 0;
  for(auto j = 1; j < N; ++j) for(auto i = 0; i < j; ++i) {
    auto y = N - 1;
    for(auto k: {j, i}) if(y == k) --y;
    auto x = y - 1;
    for(auto k: {j, i}) if(x == k) --x;
    ans = max(ans, (a[y] + a[x]) / (a[j] - a[i]));
  }
  cout << setprecision(8) << fixed << ans << endl;
}

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

const ll MAX = 200000;
const ll INF = 1001001001;
const ll MOD = 1000000007;
const double PI=3.1415926535897932;

ll N, ans=0, tmp=0;
vector<ll> A;
string S;

signed main(){
    cin >> S;
    for(int i=0;i<S.size();i++) {
        ll a;
        a = S[i]-'0';
        ans += a;
        ans %= 9;
        if(ans<0) ans += 9;
    }
    if(ans==0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3740
#include<cstdio>
#include<vector>
#include<utility>
using namespace std;

int main(){
    unsigned H, W, K, left = 0, answer = 0;
    scanf("%u %u %u", &H, &W, &K);
    vector<pair<unsigned, unsigned> > black;
    for (unsigned i = 0; i < H; i++){
        scanf("\n");
        for (unsigned j = 0; j < W; j++){
            char tmp;
            scanf("%c", &tmp);
            if(tmp == '#') black.emplace_back(1u << i, 1u << j);
        }
    }
    size_t sz = black.size();
    for (unsigned i = 0; i < 1u << H; i++){
        for (unsigned j = 0; j < 1u << W; j++){
            left = 0;
            for (size_t k = 0; k < sz; k++){
                if(!(black[k].first & i) && !(black[k].second & j)) left++;
            }
            if(left == K) answer++;
        }
    }
    printf("%u\n", answer);
	return 0;
}

Measured memory_bytes: 3184
# -*- coding: utf-8 -*-       
from collections import Counter

n = int(input())
a = sorted(list(map(int,input().split())))

if(n==1):
    print('1')
else:
    ans = 0
    cnt = Counter(a)
    for i in range(1,max(a)+2):
        tmpsum = cnt[i-1]+cnt[i]+cnt[i+1]
        ans = max(tmpsum,ans)
    print(ans)

Measured memory_bytes: 14548
N = gets.to_i
keta = N.to_s.length
list = {
1 => 9,
3 => 900,
5 => 90000,
}
case keta
when 1
    puts N
when 2
    puts list[1]
when 3
    puts list[1] + N - 99
when 4
    puts list[1] + list[3]
when 5
    puts list[1] + list[3] + N - 9999
when 6
    puts list[1] + list[3] + list[5]
end

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
const int mod=1e9+7;

int main() {
  int64_t N,M;
  cin>>N>>M;
  string s,t;
  cin>>s>>t;
  int64_t L=N/__gcd(N,M)*M;
  if(s[0]!=t[0]){cout<<-1<<endl;return 0;}
  if(__gcd(N,M)==1){cout<<L<<endl;}
  else{
    vector<char>X(L,'1');
    for(int i=0;i<N;i++){
      X[i*L/N]=s[i];
    }
    for(int i=0;i<M;i++){
      if(X[i*L/M]!='1'&&X[i*L/M]!=t[i]){cout<<-1<<endl;return 0;}
    }
    cout<<L<<endl;
  }
  return 0;
}

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

int arr[300005];
ll li[300005];
ll ri[300005];
int main(){

	priority_queue<int, vector<int>, greater<int>> pq;
	priority_queue<int> pq2;
	int n;
	scanf("%d",&n);

	ll sum = 0;
	for(int i=1;i<=3*n;i++){
		scanf("%d",&arr[i]);
	}

	for(int i=1;i<=3*n;i++){
		sum+=arr[i];
		pq.push(arr[i]);
		while((int)pq.size()>n){
			sum-=pq.top();
			pq.pop();
		}
		li[i] = sum;
	}
	sum = 0;	
	for(int i=3*n;i;i--){
		sum+=arr[i];
		pq2.push(arr[i]);
		while((int)pq2.size()>n){
			sum-=pq2.top();
			pq2.pop();
		}
		ri[i] = sum;
	}
	ll res = -1e18;
	for(int i=n;i<=2*n;i++){
		res = max(res,li[i]-ri[i+1]);
	}
	cout<<res;
}

Measured memory_bytes: 7032
import Data.List

substrings :: String -> [String]
substrings str = nub [substring a b | a <- ns, b <- ns] 
 where len = length str
       ns = [0..len]
       substring x y = take (len-x-y) $ drop x str

main = do
  s <- getLine
  let acgts = filter (\s' -> foldr (\c acc -> acc && elem c "ACGT") True s') $ substrings s
  print $ maximum $ map length acgts

Measured memory_bytes: 508
n, m = map(int, input().split())
SC = [tuple(map(int, input().split())) for i in range(m)]
if n == 1:
	r = range(0, 10)
elif n == 2:
	r = range(10, 100)
else:
	r = range(100, 1000)
for i in r:
	si = str(i)
	for s, c in SC:
		if si[s-1] != str(c):
			break
	else:
		print(i)
		exit()
else:
	print(-1)

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define BUF 1e5
#define INF 1 << 30
#define vi vector<int>
#define vvi vector<vector<int>>
#define all(a) (a).begin(), (a).end()
#define bit(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
constexpr ll mod = 1e9 + 7;
ll A, B, C, D, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

signed main() {
    cin >> N;
    vector<double> a(N);
    cin >> a;
    sort(all(a));
    double res = a[0];
    for (int i = 1; i < N; i++) {
        res = (res + a[i]) / 2;
    }
    cout << setprecision(9) << res << endl;
}

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

#define rng(i, a, b) for(int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define pb push_back
#define eb emplace_back
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed

int main() {
  int n, m, a, b, ans = 0;
  //string s;
  cin >> n;
  //vector<int> v(n), c(n);
  n %= 10;
  if(n == 3) cout << "bon";
  else if(n <= 1 || n == 6 || n == 8) cout << "pon";
  else cout << "hon";
  cout << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C, D, X, Y;
//  string op;
  cin >> A >> B >> C >> D;
  X = A + B;
  Y = C + D;
  if (X > Y) {
    cout << "Left"<< endl;
  }
  else if (X < Y ) {
    cout << "Right" << endl;
  }
  else {
    cout << "Balanced" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
typedef long long ll ;
const ll INF = 9999999999;

int main(){
    ll N, M, X;
    cin >> N >> M >> X;
    ll C[N];
    ll A[N][M];
    for(int i=0; i<N; i++){
        cin >> C[i];
        for(int j=0; j<M; j++){
            cin >> A[i][j];   
        }
    }
    ll ans = INF;
for(int s = 0; s < (1LL<<N); s++){
    ll Csum = 0;
    vector<ll> Ajsum(M);
    for(int i = 0; i < (N); i++){
      if (s&((1LL)<<i)) {
        Csum += C[i];
        for(int j = 0; j < M; j++) {
            Ajsum[j] += A[i][j];
        }
      }
    }
    bool flag = true;
    for(int j = 0; j < M; j++){
        if (Ajsum[j] < X) flag = false;
    }
    if (flag) ans = min(ans, Csum);
  }
if(ans==INF)ans=-1;
cout << ans << endl;
return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
#define _GLIBCXX_DEBUG
#define ll long long
#define rep(i,n) for (ll i = 0; i < n; i++)
#define vl vector<ll>
#define vpl vector<pair<ll,ll>>
#define vvl vector<vector<ll>> //a(縦行,vector<ll>(横列));
#include<algorithm>//__gcd(a,b)
#include <iostream>
#include <vector>
#include <cstdlib>
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const long long INF = 1LL << 60;

int main(){
    int a,b;
    cin>>a>>b;
    cout<<a*b<<endl;
}

Measured memory_bytes: 3672
# -*- coding: utf-8 -*-
import heapq
n,m = map(int, input().split())
q = []
s = 0
for a in input().split():
    a = int(a)
    s += a
    q.append(-a)

heapq.heapify(q)

for _ in range(m):
    x = q[0]
    heapq.heappop(q)
    heapq.heappush(q,-1*((-x)//2))

print(-1*sum(q))


Measured memory_bytes: 14180
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <limits>
const int mod = 1e9 + 7;
#define INF 1000000000000000
typedef long long int ll;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
long long gcd(long long a, long long b) {
    if (a < b)
        swap(a, b);
    long long r = a % b;
    if (r == 0)
        return b;
    else
        return gcd(b, r);
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    string s, t;
    cin >> s >> t;
    cout << t + s << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <typeinfo>
#include <cxxabi.h>
#ifdef LOCAL
#include "dbgtoki.hpp"
#define DUMP(i) dump((string)TOSTRING(i), demangle(typeid(i).name()), __LINE__ , i) 
#else
#define DUMP(i)
#endif

using namespace std;
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(s) (s).begin(), (s).end()
#define dis distance
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());
#define pub push_back
#define sec second
#define fir first

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector <int> > vvi;
const int EPS = 1e-9;
const int MOD = 1e9+7;
const int INF = (1 << 30);
const double PI = acos(-1);

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	int minp = INT_MAX;
	int minr = 0;
	REP(i,n){
		int a,b;
		cin >> a >> b;
		if(minr < a){
			minr = a;
			minp = b;
		}
	}
	cout << minr + minp << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		int ans = Math.max(c - (a - b), 0);
		System.out.println(ans);

	}

}


Measured memory_bytes: 21972
import collections
import bisect
import sys

sys.setrecursionlimit(10 ** 8)

def f(v):
    state[v] = 1
    a=As[v]
    idx = bisect.bisect_left(D,a)
    stack.append( (idx,D[idx]) ) # push
    D[idx] = a
    
    ans[v] = bisect.bisect_left(D,float('inf'))

    for u in V[v]:
        if state[u] == 0:
            f(u)

    # 巻き戻し
    i_pre,d_pre=stack.pop()
    D[i_pre] = d_pre



N=int(input())
As=list(map(int,input().split()))

D=[float('inf')]*N
stack=collections.deque([])
ans=[0]*N
state=[0]*N

V=[[] for _ in range(N)]
for _ in range(N-1):
    u,v=map(int,input().split())
    V[u-1].append(v-1)
    V[v-1].append(u-1)

f(0)

print(*ans,sep='\n')

Measured memory_bytes: 239248
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<map>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define P pair<int,int>
#define ll __int64
string n;
int ans=0;

int main(){
	cin>>n;
	int sum=0;
	int ns=n.size();
	rep(i,ns)ans+=(n[i]-'0');
	for(int i=0;i<n.size();i++){
		int now=n[i]-'0';

		if(now>0){
			ans=max(ans,now-1+9*(ns-i-1));
		}

		sum+=now;
	}
	cout<<ans<<endl;
	return 0;
}

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

int main() {
	int n;
	cin >> n;
	int v[n],c[n];
	int count=0;
	for (int i=0;i<n;i++){
		cin >> v[i];
	}
	for (int i=0;i<n;i++){
		cin >> c[i];
	}
	for (int i=0;i<n;i++){
		if(v[i]-c[i]>0)
		count += v[i]-c[i];
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<functional>
#include<map>
#include<cmath>

using namespace std;

typedef long long ll;
#define INF 1000000007

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

    int countR = 0, countB = 0;

    for(int i = 0; i < n; i++)
    {
        if(s[i] == 'R') countR++;
        else countB++;
    }

    if(countR > countB) cout << "Yes" << "\n";
    else cout << "No" << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>

using namespace std;

int main(){

	int n, m, inp, ac=0, wa=0;
	string ins;
	vector<int> pa, pw;

	cin>> n >> m;
	pa.resize(n, 0);
	pw.resize(n, 0);

	for (int i = 0;i < m;i++) {
		cin >> inp >> ins;
		if (pa[inp-1] == 0) {
			if (ins == "AC") {
				pa[inp-1]=1;
			}
			else pw[inp-1]++;
		}
	}

	for (int i = 0;i < n;i++) {
		ac += pa[i];
		if(pa[i]==1) wa += pw[i];
	}

	cout<< ac << " " << wa << endl;

}


Measured memory_bytes: 1024
class UnionFind:
    def __init__(self, n):
        self.parent = [i for i in range(n + 1)]
        self.rank = [0] * (n + 1)
        self.size = [1] * (n + 1)

    # 根の検索
    def find(self, x):
        if self.parent[x] == x:
            return x
        else:
            self.parent[x] = self.find(self.parent[x])
            return self.parent[x]

    # 併合
    def union(self, x, y):
        x, y = self.find(x), self.find(y)
        if self.rank[x] < self.rank[y]:
            self.parent[x] = y
            self.size[y] += self.size[x]
        else:
            self.parent[y] = x
            self.size[x] += self.size[y]
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    # 同じ集合に属するか判定
    def is_same(self, x, y):
        return self.find(x) == self.find(y)

    # グループのサイズ
    def get_size(self, x):
        return self.size[self.find(x)]


N, M = map(int, input().split())
bridges = []

for i in range(M):
    a, b = map(int, input().split())
    bridges.append((a, b,))
bridges = list(reversed(bridges))

ans = [N * (N - 1) // 2]
uf = UnionFind(N)
for i in range(M):
    a, b = bridges[i]
    tmp = 0
    if uf.is_same(a, b):
        tmp = ans[i]
    else:
        tmp = ans[i] - uf.get_size(a) * uf.get_size(b)
        uf.union(a, b)

    ans.append(tmp)

for i in range(M - 1, -1, -1):
    print(ans[i])


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

using namespace std;

#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 REP(i, n) for(int i = 0; i < (n); ++i)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"

typedef long long ll;
typedef vector<int> V;
typedef vector<ll> VL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef priority_queue<int> PQ;
typedef priority_queue<int, V, greater<int>> PQG;

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int N;
PQ pq;
V c, v;

int main() {
    cin >> N;
    REP(i, N) { v.push_back(IN()); }
    REP(i, N) { c.push_back(IN()); }
    // int ans = 0;
    // for(int i = 0; i < (1 << N); i++) {
    //     int sum = 0, dif = 0;
    //     REP(j, N) {
    //         if(i & 1 << j) {
    //             sum += v[j];
    //             dif += c[j];
    //         }
    //     }
    //     ans = max(ans, sum - dif);
    // }
    REP(i, N) { pq.push(v[i] - c[i]); }
    int sum = 0, ans = 0;
    REP(i, N) {
        sum += pq.top();
        pq.pop();
        ans = max(ans, sum);
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def make_divisors(n):
    divisors = []
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n // i)
    return divisors


def solve():
    _ = int(rl())
    A = list(map(int, rl().split()))
    
    one = A.count(1)
    if one == 1:
        print(1)
        return
    if 2 <= one:
        print(0)
        return
    
    counter = [0] * (10 ** 6 + 1)
    for ai in A:
        for m in range(ai, 10 ** 6 + 1, ai):
            counter[m] += 1
    
    ans = 0
    for ai in A:
        if counter[ai] == 1:
            ans += 1
    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 96704
#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) ;
	}
	int cnt = 0;
	
	while(true){
		bool exist_odd = false;
		for(int i = 0;i<N;i++){
			if(A.at(i) %2 !=0)exist_odd = true;
		}
		
		if(exist_odd) break;
		
		for(int i = 0;i<N;i++){
			A.at(i) /= 2;
		}
		cnt++;
	}
	
	cout << cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MX = 200005;

    // 整数スキャン（複数）
    /*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&z);

    // n個の整数のスキャン
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // 文字列スキャン
    /*
    string s;
    cin >> s;
    */

    // n個の文字列スキャン
    /*
    vector<string> slist;
    rep(i,n){
        string s;
        cin >> s;
        slist.push_back(s);
    }
    */

int main() {
    string s;
    cin >> s;
    if(s=="AKIHABARA"||s=="KIHABARA"||s=="AKIHBARA"||s=="AKIHABRA"||s=="AKIHABAR"||s=="KIHBARA"||s=="KIHABRA"||s=="KIHABAR"||s=="AKIHBRA"||s=="AKIHBAR"||s=="KIHBRA"||s=="KIHBAR"||s=="KIHABR"||s=="AKIHBR"||s=="KIHBR"||s=="AKIHABARA")yn;


    return 0;
}
 
 


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(v) v.begin(),v.end()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int INF=1e9;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};

int main() {
  int N;
  cin>>N;
  vector<tuple<string,int,int>> a;
  for(int i=1;i<=N;i++){
    string s;
    int p;
    cin>>s>>p;
    p=-p;
    a.push_back(tie(s,p,i));
  }
  sort(all(a));
  rep(i,N) cout<<get<2>(a[i])<<endl;
}

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


int main() {
    long long X, Y;
    cin >> X >> Y;

    long long th = Y / X;
    long long t = 1;
    int ans = 0;
    while(t <= th){
        ans++;
        t <<= 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
/**
*    created: 03.07.2020 01:48:56
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) __builtin_popcountll(bit)
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> bool chmin(T &a, const T &b) {if (b < a) {a = b; return 1;} return 0;}
const long double pi = acos(-1.0);
const int INF = 1LL << 60;
const int MOD = 1000000007;
// const int MOD = 998244353;

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);

    int n, a, b;
    cin >> n >> a >> b;

    auto ctoi = [&] (char c) {
        if (c >= '0' && c <= '9') return c - '0';
        return -1;
    };

    int ans = 0;

    rep2(i,1,n+1) {
        string s = to_string(i);
        int l = s.size();
        int sum = 0;
        rep(j,l) sum += ctoi(s[j]);
        if (a <= sum && sum <= b) ans += i;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3688
#include <iostream>
#include <vector>
#include <stack>
#include <queue>

using namespace std;

static const long long FAR = (1LL << 21);
static const int N = 100;

int n, m[N][N];
bool visited[N];
int d[N], p[N];

void dijskra(){
	for (int i = 0; i < n; ++i) {
		d[i] = FAR;
		visited[i] = false;
	}

	d[0] = 0;
	while (true) {
		int mi = FAR;
		int u = -1;
		for (int i = 0; i < n; ++i) {
			if (!visited[i] && d[i] < mi){
				u = i;
				mi = d[i];
			}
		}

		if (-1 == u) break;
		visited[u] = true;

		for (int v = 0; v < n; ++v) {
			if (!visited[v] && (m[u][v] != FAR) && (d[u] + m[u][v] < d[v])) {
				d[v] = d[u] + m[u][v];
			}
		}
	}

	for (int i = 0; i < n; ++i)
		cout << i << " " << ((d[i] == FAR) ? -1 : d[i]) << endl;
}

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

	for (int i = 0; i < n; ++i) {
		int u, k; cin >> u >> k;
		for (int j = 0; j < k; ++j)	{
			int v, e; cin >> v >> e;
			m[u][v] = e;
		}
	}
	dijskra();

	return 0;
}

Measured memory_bytes: 3064
package main

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

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() (int, []int) {
	n := readInt()
	return n, readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

func eprintf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(os.Stderr, f, args...)
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int

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

func main() {
	defer stdout.Flush()
	n := readInt()
	W := readInt()
	w := make([]int, n+1)
	v := make([]int64, n+1)
	for i := 1; i <= n; i++ {
		w[i] = readInt()
		v[i] = readInt64()
	}
	dp := make([][]int64, n+1)
	for i := range dp {
		dp[i] = make([]int64, W+1)
	}

	for i := 1; i <= n; i++ {
		for j := 0; j <= W; j++ {
			dp[i][j] = dp[i-1][j]
			k := j - w[i]
			if 0 <= k {
				dp[i][j] = max(dp[i][j], dp[i-1][k]+v[i])
			}
		}
	}
	//for i := range dp {
	//	eprintln(dp[i])
	//}
	println(dp[n][W])
}

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

func max(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}


Measured memory_bytes: 81792
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <limits>
#include <numeric>
#include <vector>
using namespace std;


int main()
{


	bool r = true;


	std::string s;
	cin >> s;

	for (int i = 1; i < s.length(); i++) {
		if (s[i-1] != 'h' || s[i] != 'i') {
			r = false;
			break;
		}
		i++;
	}
	if (s.length() % 2 == 1)r = false;
	if (r)cout << "Yes";
	else cout << "No";

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<ll,ll> P;
 
long long int INF = 3e18;
double Pi = 3.1415926535897932384626;
 
//vector<ll> G[550010];
//vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop
 
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//ll bit[500005];
//↓,→,↑,←
 
 
#define p(x) cout<<x<<"\n";
#define el cout<<endl;
#define pe(x) cout<<(x)<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define CLEAR(a) a = decltype(a)(); 
 
 
ll mod = 1000000007;
/*
2000000011 is prime
2000000033 is prime
*/

ll rui(ll number1,ll number2){
 
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
 
    if(number1 > number2){
        swap(number1,number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1,number1);
    }
}
void YES(bool condition){
 
    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){
 
    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}

/*
ll fact[800005],rfact[800005];

void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<=800000; i++){
        fact[i] = (fact[i-1]*i) % mod;
    }
    rfact[800000] = rui(fact[800000],mod - 2);
    for(ll i=800000; i>=1; i--){
       rfact[i-1] = rfact[i] * i;
       rfact[i-1] %= mod;
    }
    return;}
ll c3(ll n,ll r){
    return (((fact[n] * rfact[r]) % mod) * rfact[n-r]) % mod;}
*/
 
ll n,m,num,sum,a,b,c,d,e,g,h,w,i,j,q,r,l;
ll k,ans;
float x[500005],y[500005],z[500005];

ll x1,x2,x3,x4;
ll y11,y2,y3,y4;
int main(){
    cin >> n;
    for(i=0;i<n;i++){
        cin >> x[i];
    }
    sort(x,x+n);
    float ans = (x[0] + x[1]) / 2;
    for(i=2;i<n;i++){
        ans = (ans + x[i]) / 2;
    }
    ps(ans);
    return 0;
}






Measured memory_bytes: 2304
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long i,j,s=0,n;
    cin>>n;
    long long a[n+1];
    for(i=1;i<=n;i++)
    {
        for(j=i;j<=n;j=j+i)
        {
            s=s+j;
        }
    }
    cout<<s;
return 0;}


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

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

int main() {
  int N, K;
  cin >> N >> K;
  cout << N - K + 1 << endl;
}










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


int main()
{
	int n, h,cnt = 0,ans = 0;
	cin >> n >> h;
	vector<int> a(n), b(n);
	for (int i = 0; i < n; i++)
	{
		cin >> a[i] >> b[i];
	}
	sort(a.begin(), a.end(),greater<int>());
	sort(b.begin(), b.end(),greater<int>());
	for (int i = 0; i < n; i++)
	{
		if (b[i] > a[0]) cnt++;
	}

	for (int i = 0; i < cnt;i++)
	{
		h -= (b[i]);
		ans++;
		if(h <= 0){
		    cout << ans << endl;
		    return 0;
		}
	}
	if(h % a[0] == 0){
	    ans += (h/a[0]);
	}else{
	    ans += (h/a[0]);
	    ans++;
	}
	cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1152
<?php
	while (true) {
		$result = trim(fgets(STDIN));
		list($n, $x) = explode(" ", $result);

		if ($n == 0 && $x == 0) break;

		$result = array();
		for ($i = 1; $i <= $n; $i++) {
			for ($j = 1; $j <= $n; $j++) {
				if ($i == $j) continue;
				for ($k = 1; $k <= $n; $k++) {
					if ($i == $k || $j == $k) continue;
					if ($i + $j + $k == $x) {
						$arr = array($i, $j, $k);
						sort($arr);
						$val = implode("", $arr);
						if (!array_key_exists($val, $result)) {
							$result[$val] = 1;
						}
					}
				}
			}
		}

		print count($result) . "\n";
	}

Measured memory_bytes: 6796
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <utility>
#include <tuple>
using namespace std;

const double pi = acos(-1);

#define nyan cout<<"(=^•ω•^=)"<<endl;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)

string w[200];

signed main(){
    int n;cin>>n;
    rep(i,n)cin>>w[i];
    rep(i,n)rep(j,n){
        if(i!=j&&w[i]==w[j]){
            cout<<"No"<<endl;
            return 0;
        }
    }
    rep(i,n-1){
        if(w[i][w[i].length()-1]!=w[i+1][0]){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 256
n,k = map(int,input().split())
s = list(map(int,input().strip()))

data = [[],[]]
key = 1
cnt = 0
for i in range(n):
    if s[i] == key:
        cnt += 1
    
    else:
        data[key].append(cnt)
        key ^= 1
        cnt = 1
        
    if i == n-1:
        data[key].append(cnt)
    
if len(data[0]) == len(data[1]):
    data[1].append(0)

m = len(data[0])


if m <= k:
    print(n)
    exit()

tmp = data[1][0]
for i in range(k):
    tmp += data[0][i]
    tmp += data[1][i+1]

ans = tmp

for i in range(k,m):
    tmp -= data[0][i-k]
    tmp -= data[1][i-k]
    tmp += data[0][i]
    tmp += data[1][i+1]
    ans = max(ans,tmp)

print(ans)

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;
using ll = long long;

const ll MOD = 1000000007LL; // = 10^9 + 7
const double PI = 3.14159265358979;

void solve()
{
	int n, k;
  char s[55];
  cin >> n  >> k >> s;
  s[k-1] += 'a' - 'A';
  cout << s;
}

int main()
{
	fastio;
	solve();

	return 0;
}

Measured memory_bytes: 3600
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <deque>
#include <ctime>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define mp make_pair
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
#define println(X) cout<<X<<endl;
#define DBG(X) cout<<#X<<" : "<<X<<endl;
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;
const double PI = acos(-1);


struct Input{
	int n;
	char c;
	string s;

	int nextInt(){
		scanf("%d", &n);
		return n;
	}
};

int main(){
	Input in;
	int n = in.nextInt();
	while(n--){
		int ax = 0, ay = 0;
		int x = 0, y= 0;
		int dx, dy;
		while(1){
			dx = in.nextInt();
			dy = in.nextInt();
			if(dx == 0 && dy == 0) break;
			x += dx;
			y += dy;
			if(ax*ax+ay*ay < x*x+y*y){
				ax = x;
				ay = y;
			}
			else if(ax*ax+ay*ay == x*x+y*y && ax < x){
				ax = x;
				ay = y;
			}
		}
		cout<<ax<<" "<<ay<<endl;
	}

}

Measured memory_bytes: 1208
#include <iostream>
#include <map>
#include <utility>
#define MOD 1000000007
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) {
  if (b == 0) {
    return a;
  }
  return gcd(b, a % b);
}
ll mod_pow(ll x, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) {
      res = res * x % mod;
    }
    x = x * x % mod;
    n = n >> 1;
  }
  return res;
}
int main() {
  ll n, ans = 1LL, a, b, x = 0LL, y = 0LL, xy = 0LL, g;
  map<pair<ll, ll>, ll> m;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a >> b;
    if (!a && !b) {
      xy++;
    } else if (!a) {
      x++;
    } else if (!b) {
      y++;
    } else if (a < 0 && b > 0) {
      g = gcd(-a, b);
      m[{a / g, b / g}]++;
    } else if (a > 0 && b < 0) {
      g = gcd(a, -b);
      m[{-a / g, -b / g}]++;
    } else if (a < 0 && b < 0) {
      a *= -1LL;
      b *= -1LL;
      g = gcd(a, b);
      m[{a / g, b / g}]++;
    } else {
      g = gcd(a, b);
      m[{a / g, b / g}]++;
    }
  }
  n -= xy;
  ans *= (mod_pow(2, x, MOD) + mod_pow(2, y, MOD) - 1LL) % MOD;
  n -= x + y;
  map<pair<ll, ll>, ll>::iterator it = m.begin();
  while (it != m.end() && it->first.first < 0) {
    ll a = mod_pow(2, it->second, MOD);
    n -= it->second;
    if (m.find({it->first.second, -it->first.first}) != m.end()) {
      a += mod_pow(2, m[{it->first.second, -it->first.first}], MOD) - 1LL;
      a %= MOD;
      n -= m[{it->first.second, -it->first.first}];
    }
    ans *= a;
    ans %= MOD;
    ans += MOD;
    ans %= MOD;
    it++;
  }
  ans *= mod_pow(2, n, MOD);
  cout << (ans + xy - 1LL + MOD) % MOD << endl;
}

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

using ll = long long;
using ull = unsigned long long;
const int INF = 1e9;
const ll MOD = 1e9+7;

/**グローバル変数**/
ll n,cnt;
string s;
ll a[60] = {};

int main(){
//  ios::sync_with_stdio(false);
//  cin.tie(0);
  ll k;
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    ll tmp;
    cin >> tmp;
    for (int j = 0; j <= 40; j++) {
      a[j] += tmp & 1;
      tmp >>= 1;
    }
  }
  ll ans = 0;
  for (ll i = 40; i >= 0; i--) {
    if (a[i] < n-a[i] && k >= (1LL << i)) {
      ans += (1LL<<i) * (n-a[i]);
      k -= (1LL<<i);
    } else {
      ans += a[i] * (1LL << i);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const llint mod=1000003;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
llint zyou(llint a,llint b){
	llint c=1;
	for(int h=0;h<30;h++){
		if(b&(1<<h)){c*=a;c%=mod;}
		a*=a;a%=mod;
	}
	return c;
}
int main(void){
	cin.tie(0);ios::sync_with_stdio(false);
	//modが小さい!?
	//Dで割るのか...
	//天才すぎでは?
	llint i,m=mod-1,Q;cin>>Q;
	vector<llint>kai(m+1);
	kai[0]=1;
	for(i=1;i<=m;i++){kai[i]=kai[i-1]*i%mod;}
	vector<llint>gya(m+1);
	gya[m]=zyou(kai[m],mod-2);
	for(i=m;i>0;i--){gya[i-1]=gya[i]*i%mod;}
	//cerr<<"de";
	while(Q--){
		llint x,d,n;cin>>x>>d>>n;
		if(d==0){cout<<zyou(x,n)<<endl;continue;}
		if(n>=mod){cout<<0<<endl;continue;}
		llint L=(mod-1+x*zyou(d,mod-2))%mod;
		llint R=(L+n)%mod;
		//cerr<<"aa"<<gya[2542]<<endl;
		if(L<=R){cout<<kai[R]*gya[L]%mod*zyou(d,n)%mod<<endl;}
		else{cout<<0<<endl;}
	}
	return 0;
}


Measured memory_bytes: 16512
S,D,s;main(d){for(;~scanf("%*d%d%d"+!!D*3,&s,&d);printf("%.*s\n",D-S+1,S))if(D=strchr(S=strchr("5 6 7 8 9 5 4 3 2 1 0 1 2 3 4 5 6 7 8 9",s+=48),d+=48),(s=strchr(S+1,s))&&(d=strchr(s,d))&&d-s<D-S)S=s,D=d;}

Measured memory_bytes: 0