akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<climits>

#define pb push_back
#define rep(i, a, n) for(int (i)=a; (i)<(n); (i)++)
#define FOR(i, n) rep(i, 0, n)
#define F(n) FOR(i, n)
#define FF(n) FOR(j, n)
#define repi(i, a, n) for(int (i)=a; (i)<=(n); (i)++)
#define FORI(i, n) repi(i, 1, n)
#define FI(n) FORI(i, n)
#define FFI(n) FORI(j, n)
#define IN(x) int x; cin>>(x);
#define SIN(x) string x; cin>>(x);
#define INN(x, y) int x, y; cin>>(x)>>(y);
#define INFO(a) cout<<"info "<<a<<endl
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int, int>
#define vpii vector<pair<int, int> >
#define sortv(x) sort((x).begin(), (x).end())
#define sortvd(x) sort((x).begin(), (x).end(), greater<int>())
#define lboundv(x,v) lower_bound((x).begin(),(x).end(),(v))-(x).begin();
#define uboundv(x,v) upper_bound((x).begin(),(x).end(),(v))-(x).begin();
#define ite iterator
#define fi first
#define se second
#define mems(a, v) memset((a), (v), sizeof((a)))
#define lmid(l, r) ((l)+(r)-1)/2
#define rmid(l, r) ((l)+(r))/2+1
#define mp make_pair

typedef long long ll;
typedef long double LD;

using namespace std;

#define N 300005

int main() {
	ios::sync_with_stdio(0);
    IN(n);
    int ans = 0;
    FI(1000) {
        if(i*(i-1) == 2*n) {
            ans = i;
            break;
        }
    }
    if(!ans) {
        cout<<"No"<<endl;
        return 0;
    }
    cout<<"Yes"<<endl;
    int x=1;
    vector< vi > v(ans);
    F(ans) {
        rep(j, i+1, ans) {
            v[i].pb(x);
            v[j].pb(x);
            x++;
        }
    }
    cout<<ans<<endl;
    F(ans) {
        cout<<v[i].size()<<' ';
        FF(v[i].size()) cout<<v[i][j]<<' '; cout<<endl;
    }
	return 0;
}


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

int main() {
  long long a=0,b=0,c=0,d=0,m=0,n=0,p=0,q=0;
  string s;
  cin >> s;
  for(int i=0;i<s.size();i++)
  {
	  if(s.at(i)=='?')
	  {
		  s.at(i)='D';
	  }
  }
  cout << s;
}



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

int main(){

    int a[3];
  	rep(i,3)cin>>a[i];
    sort(a,a + 3);
    cout << (a[1] - a[0]) + (a[2] - a[1]) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;
using namespace std;
int gcd(int a,int b){
    if(a<b)swap(a,b);
    a%=b;
    if(a==0)return b;
    return gcd(a,b);
}
int main(){
    int a,b;
    cin>>a>>b;
    cout<<a+b+1-gcd(a,b)<<endl;
    return 0;
}



Measured memory_bytes: 3100
import java.util.Scanner;
import java.util.TreeSet;
public class Main {
	public static void main(String[] args){
		int i, j, q, order, x, L, R, next;
		TreeSet<Integer> set = new TreeSet<Integer>();
		try (Scanner sc = new Scanner(System.in)) {
			q = sc.nextInt();
			for(i = 0; i < q; i++) {
				order = sc.nextInt();
				x = sc.nextInt();
				switch(order) {
				case 0 :
					set.add(x);
					System.out.println(set.size());
					break;
				case 1 :
					System.out.println(set.contains(x) ?  "1" : "0");
					break;
				case 2 :
					set.remove(x);
					break;
				case 3 :
					for(Integer output : set.subSet(x, true, sc.nextInt(), true)) {
						System.out.println(output);
					}
					break;
				}
			}
		}
	}
}



Measured memory_bytes: 181980
#include<stdio.h>
int main(void)
{
	int W, H, x, y, r;
	scanf("%d %d %d %d %d",&W, &H, &x, &y, &r);
	if(x-r<0||x+r>W)
	{
		printf("No\n");
	}
	else if(y-r<0||y+r>H)
	{
		printf("No\n");
	}
	else
	{
		printf("Yes\n");
	}
	return 0;
}


Measured memory_bytes: 2668
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
 
int tot=0,h[3005];
int n,x,y,f[3005],val[3005];
struct Edge{
    int x,next;
}e[6005];
 
inline void add_edge(int x,int y){
    e[++tot].x=y;
    e[tot].next=h[x],h[x]=tot;
}
 
void dfs(int x){
    f[x]=0;
    for(int i=h[x];i;i=e[i].next){
        if(~f[e[i].x])continue;
        dfs(e[i].x);
        if(val[e[i].x]<val[x]&&f[e[i].x]==0)f[x]=1;
    }
}
 
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++)scanf("%d",val+i);
    for(int i=1;i<n;i++){
        scanf("%d%d",&x,&y);
        add_edge(x,y);
        add_edge(y,x);
    }
    for(int i=1;i<=n;i++){
        memset(f,-1,sizeof(f));
        dfs(i);
        if(f[i])printf("%d ",i);
    }
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
typedef long long ll;
#define mod 1000000007
#define pb push_back
#define mp(a,b) make_pair(a,b)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vll vector <ll>
#define vii vector <int>
#define vpii vector <pii>
#define vpll vector <pll>
#define ff first
#define ss second
#define matrix vector <vll>
#define all(v) v.begin(),v.end()
#define PQ priority_queue
using namespace std;
ll pow(ll a, ll b){
	ll res = 1;
	while(b > 0){
		if(b&1) res*=a;
		b/=2;
		a*=a;
	}
	return res;
}
int n;
double p[3000];
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n;
	for(int i = 0; i < n; i++) cin >> p[i];
	vector < vector <double> > v(n, vector <double> (n+1));
	v[0][0] = 1 - p[0];
	v[0][1] = p[0];
	double t = 1-p[0];
	for(int i = 1; i < n; i++){
		t*=1-p[i];
		v[i][0] = t;
	}
	for(int i = 1; i < n; i++){
		for(int j = 1; j <= i+1; j++){
			v[i][j] = v[i-1][j]*(1-p[i]) + v[i-1][j-1]*p[i];
		}
	}
	double ans = 0;
	for(int i = n; i > n/2; i--){
		ans+=v[n-1][i];
	}
	cout << setprecision(10) << ans << "\n";
	return 0;
}


Measured memory_bytes: 70656
import java.util.Scanner;
import java.lang.Math;
import java.math.BigDecimal;

class Main{

    public static void main(String[] args){

        Scanner scanner = new Scanner(System.in);
        int r = scanner.nextInt();
        scanner.close();
        BigDecimal bd1 = new BigDecimal(2.0 * r);
        BigDecimal bd2 = new BigDecimal(Math.PI);
        BigDecimal result = bd1.multiply(bd2);
        System.out.println(result.setScale(2, BigDecimal.ROUND_HALF_UP));

    }

}

Measured memory_bytes: 27340
using namespace std;
#include <bits/stdc++.h>
#define rep(i, s) for (int i = 0; i < s; ++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 all(v) (v.begin(), v.end())
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define VEC(a, n) vector<int>a(n)
#define PQ(a) priority_queue<int>a
#define PQmin(a) priority_queue< int, :vector<int>, greater<int> >a
#define PAIR pair<int, int>
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define EPS (1e-7)
#define INF (1e10)
#define PI (acos(-1))
const ll mod = 2019;
bool f(string s){
  bool ans=true;
  rep(i,s.size()/2){
    if(s[i]!=s[s.size()/2+i]){
      ans=false;
      break;
    }
  }
  return ans;
}



int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll L,R;
  cin>>L>>R;
  ll lmod=L%mod;
  ll rmod=R%mod;
  ll ans=INF;
  if(R-L<2019&&lmod<rmod){
    FOR(i,lmod,rmod){
      FOR(j,i+1,rmod+1){
        ans=min(ans,(i*j)%mod);
      }
    }
  }
  else
    ans=0;
  cout<<ans<<endl;
}
  

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++)
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; }
int main(){
    ll x; cin>>x;
    ll res=0;
    res+=2*(x/11);
    x%=11;
    if(x>6) res+=2;
    else if(x>0) res++;
    cout<<res<<endl;
}

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

class Main{
	public static void main(String[] a) {

		Scanner sc = new Scanner(System.in);

		List <String> senro = new ArrayList<String>();



		while(sc.hasNext()) {

			String num = sc.next();

			if(num.equals("0")) {
				int index = senro.size() -1;
				System.out.println(senro.get(index));
				senro.remove(index);

			}else{
				senro.add(num);
			}


		}


	}
}

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

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> h(N);
    for (int i = 0; i < N; i++)
    {
        cin >> h[i];
    }

    sort(h.begin(), h.end());
    int ans = 1000000000;
    for (int i = N - 1; i >= K - 1; i--)
    {
        int temp = h[i] - h[i - K + 1];
        ans = min(ans, temp);
    }
    cout << ans << endl;
    
  return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <stdio.h>
#include <algorithm>
using namespace std;
/*
最小i子を足して、最大i子を足したものを引けばいい+1
*/
// 負の数にも対応した % 演算
long long mod(long long val, long long m)
{
    long long res = val % m;
    if (res < 0)
        res += m;
    return res;
}
int main()
{
    long long  mon = 1000000007;
    int N,K;
    cin >> N >> K;
    long long res =0,maxx;

    for(int i = K; i <= N+1; i++){
        //maxx = mod(mod(i*N,mon)  -mod(i*(i-1),mon) + 1,mon);
        maxx = ((long long)i*(N-i+1))%mon;
        if (maxx < 0){
            maxx += mon;
        }
        //cout << i*(i-1)/2 << "~" << N*i-(i-1)*i/2 << " " << maxx+1<< endl;
        res = (res + maxx)%mon+1;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3196
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define p (int)(1e9 + 7)

int MOD(int a){
	return (a %= p) >= 0 ? a : a + p;
}

signed main(){
	int N, M, i, j;
	scanf("%lld%lld", &N, &M);
	vector<int> S(N + 1), T(M + 1);
	for(i = 1; i <= N; i++){
		scanf("%lld", &S[i]);
	}
	for(j = 1; j <= M; j++){
		scanf("%lld", &T[j]);
	}
	vector<vector<int>> dp(N + 1, vector<int>(M + 1, 1));
	for(i = 1; i <= N; i++){
		for(j = 1; j <= M; j++){
			dp[i][j] = MOD(dp[i - 1][j] + dp[i][j - 1] - dp[i - 1][j - 1]);
			if(S[i] == T[j]){
				dp[i][j] = MOD(dp[i][j] + dp[i - 1][j - 1]);
			}
		}
	}
	printf("%lld\n", dp[N][M]);
	return 0;
}

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

#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPL(i,a,n) for(ll i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"
#define SORTVG(v) sort(v.begin(),v.end(),greater<>())
#define SORTV(v) sort(v.begin(),v.end())
#define ALL(v) (v).begin(),(v).end()
//#define MOD 1000000007
#define MOD 998244353
#define INF LLONG_MAX/2

typedef long long ll;
typedef tuple<int,int,bool> Tb;
typedef pair<int,int> Pii;
typedef vector<int> Vi;

template<class T> void chmax(T& a, T b) {if(a < b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a > b){a=b;}}
template<class T> void YesNo(T& a) {if(a){cout << "Yes" << ENT;}else{cout << "No" << ENT;}}
template<class T> void YESNO(T& a) {if(a){cout << "YES" << ENT;}else{cout << "NO" << ENT;}}
template<class T> void AorB(T& a, string A,string B) {if(a){cout << A << ENT;}else{cout << B << ENT;}}

int atcoder(){
    string s;
    cin>>s;
    reverse(ALL(s));
    ll ans=0,tmp=0;
    
    REP(i,0,s.length()){
        if(s[i]=='B') ans+=tmp;
        else tmp++;
    }
    cout<<ans<<ENT;
    return 0;
}

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


Measured memory_bytes: 720
N = int(input())
S = [input() for _ in range(N)]
M = int(input())
T = [input() for _ in range(M)]

ans = 0

for s in S:
    point_S = S.count(s)
    point_T = T.count(s)
    ans = max(ans, point_S - point_T)

print(ans)

Measured memory_bytes: 9172
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
#define endl '\n';
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;



int main() {
    
    int pos=-1;
    int n,l;
    cin>>n>>l;
    vi v(n);
    rep(i,n)cin>>v[i];
    rep(i,n-1){
        if(v[i]+v[i+1]>=l){
            pos=i;
        }
    }
    if(pos>=0){
        fin("Possible");
    } else {
        fin("Impossible");
        return 0;
    }
    rep(i,pos){
        cout<<i+1<<endl;
    }
    for(int i=n-2;i>pos;i--){
        cout<<i+1<<endl;
    }
    cout<<pos+1<<endl;
}


Measured memory_bytes: 1152
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tommy6073
 */

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

class BDigits {
public:
    void solve(std::istream& in, std::ostream& out) {
        int N, K;
        in >> N >> K;

        int digits = 1;
        int remain = N;
        while (remain >= K) {
            remain /= K;
            ++digits;
        }

        out << digits;
    }
};


int main() {
	BDigits solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

int main(){
    int n;
    int A;
    int ans=0;
    cin >>n;
    for (int i=0;i<n;i++){
        cin >>A;
        while(A%2==0){
        A/=2;
        ans++;
      }
    }
        cout <<ans;
}

Measured memory_bytes: 256
#include <iostream>
#include<cstdio>
#include<cctype>
#include<string.h>
#include<stdio.h>
using namespace std;

int main()
{   string s;
    cin>>s;
    string p;
    cin>>p;
    string c=s+s;
    if (c.find(p)!=string::npos){
        cout<< "Yes"<<endl;
    }else{
         cout<<"No"<<endl;
    }
return 0;
}


Measured memory_bytes: 3216
/* ALDS1_10_C: LongestCommonSubsequence */
/* 20181202 AOJ */

#define _CRT_SECURE_NO_WARNINGS
#define N 1002
#define max(x, y) (x > y)? x : y
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int lcs(int A[][N], char *X, char *Y);

int main(void) {
	int A[N][N] = {0};
	char *X = (char *)malloc(sizeof(char) * N);
	char *Y = (char *)malloc(sizeof(char) * N);
	int q, i;


	scanf("%d", &q);
	for(i = 0; i < q; i++) {
		scanf("%s %s", X, Y);
		printf("%d\n", lcs(A, X, Y));
	}

	return 0;
}

int lcs(int A[][N], char *X, char *Y) {
	int i, j, m, n, ret;

	ret = 0;
	m = strlen(X);
	n = strlen(Y);

	for(i = 0; i <= m; i++) {
		for(j = 0; j <= n; j++) {
			A[i][j] = 0;
		}
	}

	for(i = 0; i < m; i++) {
		for(j = 0; j < n; j++) {
			if(X[i] == Y[j]) {
				A[i + 1][j + 1] = A[i][j] + 1;
			}else {
				A[i + 1][j + 1] = max(A[i][j + 1], A[i + 1][j]);
			}
			ret = max(A[i + 1][j + 1], ret);
		}
	}

	return ret;
}


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

int main(int argc, char const *argv[]) {
    int n;
    cin >> n;
    vector<int> p(n);
    for (size_t i = 0; i < n; i++) cin >> p[i];

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

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


Measured memory_bytes: 3608
# coding: utf-8
# Your code here!

def selectionSort(A, N):
    cnt = 0
    for i in range(0, N-1):
        minj = i
        mink = i
        for j in range(i, N):
            if A[mink] > A[j]:
                mink = j
        if minj != mink:
            A[minj], A[mink] = A[mink], A[minj]
            cnt += 1

                
    showResult(A, cnt)

def showResult(A, cnt):
    for i in range(N-1):
        print(A[i], end=" ")
    print(A[N - 1])
    print(cnt)
        
#A = [6, 5, 4, 3,2,1]
#N = len(A)
N = int(input())
A = list(map(int, input().split())) 
selectionSort(A,N)


Measured memory_bytes: 5612
import math

def main() :
    A, B, H, M = list(map(int, input().split()))

    theta = abs((H+ M/ 60)* 30- M* 6)
    #print(theta)
    
    result = B**2 + A**2 - 2* B* A* math.cos(math.radians(theta))
    result = math.sqrt(result)

    print('{:.020f}'.format(result))

if __name__ == "__main__":
    main()

Measured memory_bytes: 9500
while True:
  try:
    count = 0
    c1, c2, c3 = map(int, raw_input().split())
    for i in range(1, 11):
      if i in [c1, c2, c3]: continue
      if c1 + c2 + i <= 20: count += 1

    if count/7.0 >= 0.5:
      print 'YES'
    else:
      print 'NO'
  except:
    break

Measured memory_bytes: 4228
from fractions import gcd
from itertools import accumulate

# 入力
N = int(input())
A = list(map(int, input().split()))

# 先頭から連続する要素の最大公約数の列
L = [0] + list(accumulate(A, gcd))
# 末尾から連続する要素の最大公約数
R = [0] + list(accumulate(reversed(A), gcd))

# Aの各要素について、それを使用しない場合の最大公約数の最大値をL, Rを用いて求める
ans = max(
    gcd(L[k], R[-(k + 2)])
    for k in range(N)
)

# 出力
print(ans)


Measured memory_bytes: 16152
#include<queue>
#include<cstdio>
#include<algorithm>
using namespace std;

const int Maxn=2e5;

int N;
struct Node {
	int t1,t2;
	bool operator < (const Node &rhs) const {return t2<rhs.t2;}
}A[2*Maxn+5];
priority_queue<int> q;
int main() {
	#ifdef LOACL
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
	#endif
	scanf("%d",&N);
	for(int i=1;i<=N;i++)
		scanf("%d %d",&A[i].t1,&A[i].t2);
	sort(A+1,A+N+1);
	int t=0,tot=0;
	for(int i=1;i<=N;i++) {
		if(t+A[i].t1<=A[i].t2) {
			tot++;
			t+=A[i].t1;
			q.push(A[i].t1);
		} else {
			if(q.empty())continue;
			int maxx=q.top();
			if(A[i].t1<maxx){
                q.pop();
                q.push(A[i].t1);
                t=t-maxx+A[i].t1;
            }
		}
	}
	if(tot==N)puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 2936
#include<bits/stdc++.h>
#define LL long long
#define INF 1e10

using namespace std;

LL ans, N, A, B;
vector<LL> h;

bool f(LL K){
    LL res = 0;
    for(int i = 0; i < N; ++i){
        LL remain = h[i] - B * K;
        if(remain > 0) res += (remain + A - B - 1) / (A - B);
    }
    return res <= K;
}

LL meguru_search(LL ok, LL ng){
    while(abs(ok - ng) > 1){
        LL mid = ng + (ok - ng) / 2;
        if(f(mid)) ok = mid;
        else ng = mid;
    }
    return ok;
}

int main(){
    cin >> N >> A >> B;
    h = vector<LL>(N);
    for(int i = 0; i < N; ++i) cin >> h[i];
    ans = meguru_search(INF, 0);
    cout << ans << endl;
}

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

int n;
int m;

vector<vector<int>> G;

int A,B;

struct GraphScanning{
    vector<int> R;

    GraphScanning(const vector<vector<int>>& G,int s){
        queue<int> Q;
        Q.push(s);
        R.assign(G.size(),0);
        R[s] = 1;

        while(!Q.empty()){
            int v = Q.front();
            Q.pop();

            for(int w : G[v]){
                if(R[w]) continue;
                if(v == A && w == B) continue;
                if(v == B && w == A) continue;
                R[w] = 1;
                Q.push(w);
            }
        }
    }
};

int main(){
  cin >> n >> m;
  vector<int> a(m),b(m);
  G.resize(n);
  rep(i,0,m - 1){
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
    G[a[i]].push_back(b[i]);
    G[b[i]].push_back(a[i]);
  }
  int ans = 0;
  rep(i,0,m - 1){
    A = a[i];
    B = b[i];
    GraphScanning gs(G,0);
    int s = 1;
    rep(i,0,n - 1){
      s &= gs.R[i];
    }
    if(!s) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <numeric>
#include <functional>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define VVVI vector<vector<vector<ll>>>
#define VVVVI vector<vector<vector<vector<ll>>>>
#define REP(i,n) for(ll i=0,_n=(n);(i)<(ll)_n;++i)
#define REPR(i,n) for(ll i=(ll)(n)-1;0<=(i);--i)
#define RANGE(i,a,b) for(ll i=(ll)a,_b=(ll)(b);(i)<_b;++i)
#define RANGER(i,a,b) for(ll i=(ll)(b)-1,_a=(ll)(a);(_a)<=i;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
#define FI first
#define SE second
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template<typename T>void maxUpdate(T& a, T b) {a = max(a, b);}
template<typename T>void minUpdate(T& a, T b) {a = min(a, b);}
string YN(bool v) { return v ? "Yes":"No"; }
void uniq(VI& es) { sort(ALL(es)); es.erase(unique(ALL(es)), es.end()); }

#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N,M,W,H,K;
	string s;
	while(cin>>N) {
		ll ans=N/11*2;
		N=N%11;
//		DD(N);
		if(0<N) {N-=6;ans++;}
		if(0<N) {N-=5;ans++;}
//		DD(N);
		cout<<ans<<endl;
	}
	
	return 0;
}


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

int main(){
    int n, i;
    cin >> n;
    long long res = 0, a[3*n];
    for(i=0; i<3*n; i++){
        cin >> a[i];
    }
    sort(a, a+3*n, greater<int>());
    for(i=0; i<2*n; i++){
        if(i%2 == 1){
            res += a[i];
        }
    }
    cout << res;
    return 0;
}

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

#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define eb emplace_back
#define rep(i, a, b) for (long i = (a); i <= (b); ++i)
#define per(i, a, b) for (long i = (a); i >= (b); --i)
#define mmst(v) memset(v, 0, sizeof(v))

const long kMax2 = 109;
const long kMax3 = 1009;
const long kMax4 = 10009;
const long kMax5 = 100009;
const long kMax6 = 1000009;
const long kInfI = 0x3F3F3F3F;
const float kInfF = 1e15;
const long long kMod = 1000000007;

const long kMAX = 1000000000;

using namespace std;
using ll = long long;

inline int readInt() {
  char c = getchar();
  while(!isdigit(c) && c != '-') c = getchar();
  int sigma = 1;
  if (c == '-') {
    sigma = -1;
    c = getchar();
  }
  int x = 0;
  while (isdigit(c)) {
    x = x * 10 + c - '0';
    c = getchar();
  }
  return x * sigma;
}

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

  const int kMaxA = 2000;
  ll ans = 0, ans0 = 0, ans1 = 0, tmp_sum = 0;
  vector<ll> a;
  ll count[kMaxA + 1];
  vector<string> sl;
  string s;

  mmst(count);
  ll n, k;
  cin >> n >> k;
  rep(i, 0, n - 1) {
    ll a0;
    cin >> a0;
    a.pb(a0);
    count[a0]++;
  }
  rep(i, 0, n - 2) {
    rep(j, i + 1, n - 1) {
      if (a[i] > a[j]) ++ans0;
    }
  }
  rep(i, 0, kMaxA) {
    if (count[i] == 0) continue;

    ans1 += tmp_sum * count[i];
    tmp_sum += count[i];
  }
  ans = ((ans0 * k) % kMod + (ans1 * ((k * (k - 1) / 2) % kMod)) % kMod) % kMod;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  for(int i=0;i<s.size();i++){
    for(int j=0;j<s.size();j++){
      string tmp=s;
      tmp.erase(i,j);
      if(tmp=="keyence"){
        cout<<"YES"<<endl;
        return 0;
      }
    }
  }
  cout<<"NO"<<endl;
}


Measured memory_bytes: 256
N = gets.chomp.to_i
numbers = gets.split.map(&:to_i)

gcd_l = [0]
(N).times do |n|
  gcd_l.push gcd_l[n].gcd(numbers[n])
end

gcd_r = [0]
N.times do |n|
  gcd_r.unshift gcd_r.first.gcd(numbers[N-1-n])
end

gcds = []
N.times do |i|
  gcds.push gcd_l[i].gcd gcd_r[i+1]
end

puts gcds.max


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

#define ll long long

int main(){
    int N,S;
    cin >> N >> S;
    vector<ll>A(N);
    const ll MOD= 998244353;
    for(int i=0;i<N;i++)cin>>A[i];

    ll dp[3030][3030][3];
    dp[0][0][0]=1;
    for(int i=0;i<N;i++){
        for(int s=0;s<=S;s++){
            //from 0
            dp[i+1][s][0] += dp[i][s][0];//何もしない
            if(s+A[i]<=S){
                dp[i+1][s+A[i]][1]+= (dp[i][s][0]*(i+1))%MOD;//iをLとする。
                dp[i+1][s+A[i]][2]+=(((dp[i][s][0]*(i+1))%MOD)*(N-i))%MOD;//iをL,Rとする
            }

            // frmo 1
            dp[i+1][s][1] += dp[i][s][1];
            if(s+A[i]<=S){
                dp[i+1][s+A[i]][1] += dp[i][s][1];
                dp[i+1][s+A[i]][2] += (dp[i][s][1]*(N-i))%MOD;//iをRとする
            }
            
            //from2
            dp[i+1][s][2] += dp[i][s][2];//Rが決まっているから、これ以上足せない
        }
        for(int s=0;s<=S;s++){
            for(int k=0;k<3;k++){
                dp[i+1][s][k]%=MOD;
                dp[i][s][k]%=MOD;
            }
        }
    }
    cout<< dp[N][S][2]<<endl;
    return 0;
}


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

void solve1()
{
    int A, B, C;
    cin >> A >> B >> C;
    if(A + B+C >= 22) {
        cout<<"bust"<<endl;
    } else {
        cout << "win" <<endl;
    }

}

void solve2() {
    string S;
    cin>>S;

    int ans = 0;
    for (int i = 0; i < S.length()/2; i++)
    {
        if(S[i] != S[S.length() - i- 1]) {
            ans++;
        }
    }
    cout << ans <<endl;
    
}

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

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<string>
#include<vector>
#include<set>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<limits>
#include<list>
#include<math.h>
using namespace std;
#define ll long long
#define f(i,x,n) for (int i = x;i < n;++i)

vector<int> x;

int main() {
	int n;
	scanf("%d", &n);
	n <<= 1;
	f(i, 0, n) {
		int t;
		scanf("%d", &t);
		x.push_back(t);
	}
	sort(x.begin(), x.end());
	int an = 0;
	for (int i = 0; i < n; i += 2) {
		an += x[i];
	}
	printf("%d\n", an);
	return 0;
}

Measured memory_bytes: 256
import bisect
n=int(input())
A=sorted(list(map(int,input().split())))
B=list(map(int,input().split()))
C=sorted(list(map(int,input().split())))
lc=len(C)
ans=0
for b in B:
  ma = bisect.bisect_left(A, b)
  mc = lc-bisect.bisect_right(C, b)
  ans += ma*mc
print(ans)

Measured memory_bytes: 29496
#!/usr/bin/env python3
import sys, math, fractions, itertools


def solve(N: int, a: "List[int]"):
    s = sum(a)
    k1 = math.floor(s / N)
    k2 = math.ceil(s / N)

    d1 = 0
    d2 = 0
    for i in range(N):
        d1 += (a[i] - k1) ** 2
        d2 += (a[i] - k2) ** 2
    print(min(d1, d2))
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, a)

if __name__ == '__main__':
    main()


Measured memory_bytes: 5332
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr ll mod=998244353;
constexpr int N=1800000;

inline unsigned long xor128() {
	static unsigned long x=123456789, y=362436069, z=521288629, w=88675123;
	unsigned long t=(x^(x<<11));
	x=y; y=z; z=w;
	return (w=((w>>19)^t^(t>>8)));
}

int D,c[26],s[200000][26],t[200000],T[200000];
set<int>st[26];

int main(){
	scanf("%d",&D);
	for(int i=0;i<26;i++){
		scanf("%d",&c[i]);
	}
	for(int i=0;i<D;i++){
		for(int j=0;j<26;j++){
			scanf("%d",&s[i][j]);
		}
	}
	for(int i=0;i<D;i++){
		pair<int,int>mx={-1,-1};
		for(int j=0;j<26;j++){
			mx=max(mx,{s[i][j],j});
		}
		t[i]=mx.second;
		st[mx.second].insert(i);
	}
	for(int i=0;i<26;i++){
		st[i].insert(-1);
		st[i].insert(D);
	}
	for(int i=0;i<N;i++){
		int K=xor128()%D;
		pair<int,int>mx={-100000000,-1};
		auto it1=st[t[K]].find(K);
		auto it2=it1;
		it1--;
		auto it3=it2;
		it3++;
		int a=c[t[K]]*((*it3-*it1)*(*it3-*it1-1)/2-(*it3-*it2)*(*it3-*it2-1)/2-(*it2-*it1)*(*it2-*it1-1)/2);
		for(int j=0;j<26;j++){
			if(j==t[K])continue;
			auto it=st[j].lower_bound(K);
			auto jt=it;
			jt--;
			mx=max(mx,{s[K][j]-s[K][t[K]]+c[j]*((*it-*jt)*(*it-*jt-1)/2-(*it-K)*(*it-K-1)/2-(K-*jt)*(K-*jt-1)/2)-a,j});
		}
		if(mx.first>=0){
			st[t[K]].erase(it2);
			t[K]=mx.second;
			st[mx.second].insert(K);
		}
		else if(mx.first>=-(N-i)/256){
			st[t[K]].erase(it2);
			t[K]=mx.second;
			st[mx.second].insert(K);
		}
	}
	for(int i=0;i<D;i++){
		printf("%d\n",t[i]+1);
	}
}


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

const int64_t MOD = 1e9+7;
void add(int64_t& a, int64_t b){
    a = (a+b) % MOD;
}
void mul(int64_t& a, int64_t b){
    a = a*b % MOD;
}

vector<int64_t> fact, seq_inv, fact_inv;

void create_fact_mod(int num){
    fact[0] = 1;
    fact[1] = 1;
    for(int i=2; i<=num; i++){
        fact[i] = fact[i-1] * i % MOD;
    }
}

void create_seq_inv_mod(int num){
    seq_inv[0] = 1;
    seq_inv[1] = 1;
    for(int i=2; i<=num; i++){
        seq_inv[i] = (MOD - MOD/i) * seq_inv[MOD%i] % MOD;
    }
}

void create_fact_inv_mod(int num){
    fact_inv[0] = 1;
    fact_inv[1] = 1;
    for(int i=2; i<=num; i++){
        fact_inv[i] = fact_inv[i-1] * seq_inv[i] % MOD;
    }
}

void create_mod_tables(int num){
    fact.resize(num+1);
    seq_inv.resize(num+1);
    fact_inv.resize(num+1);
    create_fact_mod(num);
    create_seq_inv_mod(num);
    create_fact_inv_mod(num);
}

int64_t comb_mod(int n, int k){
    return fact[n] * fact_inv[n-k] % MOD * fact_inv[k] % MOD;
}

int64_t perm_mod(int n, int k){
    return fact[n] * fact_inv[n-k] % MOD;
}

int64_t power_mod(int64_t num, int64_t power){
    int64_t prod = 1;
    num %= MOD;
    while(power > 0){
        if(power&1) prod = prod * num % MOD;
        num = num * num % MOD;
        power >>= 1;
    }
    return prod;
}

int64_t extgcd(int64_t a, int64_t b, int64_t& x, int64_t& y){
    int64_t d = a;
    if(b != 0){
        d = extgcd(b, a%b, y, x);
        y -= (a/b) * x;
    }else{
        x = 1; y = 0;
    }
    return d;
}

int64_t inv_mod(int64_t a){
    int64_t x, y;
    extgcd(a, MOD, x, y);
    return (MOD + x%MOD) % MOD;
}

int main(){
    int64_t N, A, B, C;
    cin >> N >> A >> B >> C;
    create_mod_tables(200002);
    mul(A, inv_mod(100));
    mul(B, inv_mod(100));
    mul(C, inv_mod(100));
    int64_t alpha = inv_mod(1+MOD-C);
    mul(A, alpha);
    mul(B, alpha);

    int64_t ans = 0;
    int64_t sum = 1;
    for(int i=0; i<=2*N-2; i++){
        add(ans, sum);
        if(i >= N-1){
            int64_t res = 0;
            int a = N-1;
            int b = i-a;
            add(res, comb_mod(i, a) * power_mod(A, a) % MOD * power_mod(B, b) % MOD * A % MOD);
            add(res, comb_mod(i, b) * power_mod(A, b) % MOD * power_mod(B, a) % MOD * B % MOD);
            add(sum, MOD - res);
        }
    }
    mul(ans, alpha);
    cout << ans << endl;
    return 0;
}


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


int main()
{
    int n;
    std::string s;
    std::cin >> n;
    std::cin >> s;
    int cnt = 0;
    for(int i = 2; i < n; i++){
        if(s[i] == 'C' && s[i - 1] == 'B' && s[i - 2] == 'A')cnt++;
    }
    std::cout << cnt << std::endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
using namespace std;
#define LL long long
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define pii pair < int , int >

int n;
int h[100005];
int dp[100005];

int rek( int pos ){
	if ( pos == n-1 ) return 0;

	int &ans = dp[pos];
	if ( ans != -1 ) return ans;
	ans = 0;
	if ( h[pos] >= h[pos+1] ) ans = max( ans, rek(pos+1) + 1 );
	return ans;
}

int main(){

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

	cin >> n;
	for ( int i = 0; i < n; i++ ) cin >> h[i];
	memset(dp,-1,sizeof(dp));

	int ans = 0;
	for ( int i = 0; i < n; i++ ){
		ans = max( ans, rek(i) );
	}	
	cout << ans << endl;
	return 0;
}

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


int main(){
    vector<vector<int>> a(3,vector<int>(3));
    rep(i,3){
        rep(j,3) cin >> a[i][j];
    }
    int n;
    cin >> n;
    bool ok = false;
    rep(i,n){
        int s;
        cin >> s;
        rep(i,3){
            rep(j,3)if(a[i][j] == s) a[i][j] = 0;
        }
    }
    rep(i,3) if(a[i][0] == a[i][1] && a[i][0] == a[i][2]) ok = true;
    rep(j,3) if(a[0][j] == a[1][j] && a[0][j] == a[2][j]) ok = true;
    if(a[0][0] == a[1][1] && a[1][1] == a[2][2]) ok = true;
    if(a[0][2] == a[1][1] && a[1][1] == a[2][0]) ok = true;
    if(ok) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#define N 100
#define W 0
#define X 1
#define Z 2

int n,m[N][N];
int c[N],d[N],f[N],tt;

void dfs_visit(int u){
  int i;
  c[u] = X;
  ++tt;
  d[u] = tt;
  for(i=0;i<n;i++){
    if(m[u][i] == 0) continue;
    else if(c[i]==W){
      dfs_visit(i);
    }
  }
  c[u]=Z;
  ++tt;
  f[u]=tt;
}

void dfs(){
  int i;
  for(i=0;i<n;i++){
    c[i] = W;
  }
  tt = 0;

  for(i=0;i<n;i++){
    if(c[i]==W)dfs_visit(i);
  }
  for(i = 0 ;i<n;i++){
    printf("%d %d %d\n", i+ 1,d[i],f[i]);
  }
}

int main(){
  int u,v,k,i,j;

  scanf("%d",&n);
  for(i = 0;i<n;i++){
    for(j=0;j<n;j++)m[i][j]=0;
  }

  for(i=0;i<n;i++){
    scanf("%d %d",&u,&k);
    u--;
    for(j=0;j<k;j++){
      scanf("%d",&v);
      v--;
      m[u][v]=1;
    }
  }
  dfs();

  return 0;
}

Measured memory_bytes: 2700
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; 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 sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int N;
  cin >> N;
  vi D(N);
  rep(i,N) {
    cin >> D[i];
  }
  sort(rng(D));
  int ans = 0;
  srep(s,1,13) {
    bool ok = true;
    if(D[0] < s) {
      ok = false;
    }
    else if(N > 2) {
      rep(i,N-2) {
        if(D[i+2]-D[i] < s) {
          ok = false;
        }
      }
    }
    rep(i,N-1) {
      if(24-D[i+1]-D[i] < s) {
        ok = false;
      }
    }
    if(ok) ans = s;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <cmath>
#include <map>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < n; i++)
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    int n, p;
    cin >> n >> p;
    int cntodd = 0;
    rep(i, n) {
        int a;
        cin >> a;
        if (a % 2 == 1) cntodd++;
    } 
    if (cntodd > 0) cout << (ll)pow(2, n-1) << endl;
    else if (p % 2 == 0) cout << (ll)pow(2, n) << endl;
    else cout << 0 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <functional>
#include <utility>
#include <unordered_map>
#include <map>
#include <set>
#include <array>
#define INF 2147483647
#define INF_LL 9223372036854775807
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

int main() {
	int N;
	cin >> N;
	vector<string> word(N);
	set<string> d;
	for (int i = 0; i < N; i++) {
		cin >> word[i];
		d.insert(word[i]);
	}
	if (word.size() != d.size()) {
		cout << "No" << endl;
		return 0;
	}
	else {
		char end = word[0].back();
		for (int i = 1; i < word.size(); i++) {
			if (word[i].front() == end) {
				end = word[i].back();
			}
			else {
				cout << "No" << endl;
				return 0;
			}
		}
		cout << "Yes" << endl;
		return 0;
	}
}

Measured memory_bytes: 256
//teja349
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
using namespace __gnu_pbds;

#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
#define flush fflush(stdout) 
#define primeDEN 727999983
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

// find_by_order()  // order_of_key
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

int p[1234];
vector<vi> vec(1234);
int main(){
    std::ios::sync_with_stdio(false); cin.tie(NULL);
    int n,m;
    cin>>n>>m;
    int i,j,k,val,hh;
    rep(i,m){
    	cin>>val;
    	rep(j,val){
    		cin>>hh;
    		hh--;
    		vec[i].pb(hh);
    	}
    }
    rep(i,m){
    	cin>>p[i];
    }
    int ans=0;
    int gg,cnt;
    rep(i,(1<<n)){
    	gg=0;
    	cnt=0;
    	rep(j,m){
    		cnt=0;
    		rep(k,vec[j].size()){
    			if(i&(1<<vec[j][k]))
    				cnt++;
    		}
    		//cout<<cnt<<" "<<p[j]<<" "<<i<<endl;
    		if(cnt%2==p[j])
    			gg++;
    	}

    	if(gg==m)
    		ans++;
    }
    cout<<ans<<endl;
    return 0;   
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>

using namespace std;

int main(void)
{
	int N, K, X, Y, ans;
	cin >> N >> K >> X >> Y;

	if (N > K)
	{
		ans = X * K + (N - K) * Y;
	}
	else
	{
		ans = N * X;
	}

	printf("%d\n", ans);

	return 0;
}

Measured memory_bytes: 256
from collections import deque
n, q = [int(x) for x in input().split() ]
name, time = deque([]), deque([])
for _ in range(n):
    tmp = [x for x in input().split()]
    name.append(tmp[0])
    time.append(int(tmp[1]))

if __name__ == '__main__':
    count = 0
    while name:
        if time[0] <= q:
            count += time.popleft()
            print(name.popleft(), count)
        else:
            count += q
            time.append(time.popleft() - q)
            name.append(name.popleft())


Measured memory_bytes: 9888
#include<stdio.h>

int dp[50];

int fib(int);

int main(){

  int i,n;
  
  for(i=0;i<50;i++){
    dp[i] = -1;
  }

  scanf("%d",&n);
  printf("%d\n",fib(n));

  return 0;
}

int fib(int n){

  if(n==0||n==1)return dp[n]=1;
  if(dp[n]!=-1)return dp[n];
  return dp[n] = fib(n-1)+fib(n-2);
}

Measured memory_bytes: 596
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
using namespace std;

#define Getsign(n) ((n > 0) - (n < 0))
#define QWERTYR(c) (c == 'y' || c == 'u' || (c >= 'h' && c <= 'p') ?	true : false)
typedef vector<int> Ivec;
typedef pair<int, int> Pos;

int main() {
	char s[33];
	while(scanf("%s",s)){
		if (!strcmp(s, "#"))
			return 0;
		int cou = 0;
		bool QwertyR = QWERTYR(s[0]);
		for (int i = 0; strlen(s) > i; i++) {
			if (QWERTYR(s[i]) != QwertyR) {
				cou++;
				QwertyR = QWERTYR(s[i]);
			}
		}
		printf("%d\n", cou);
	}




	return 0;
}

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

#define rep(i,z) for(int i = 0; i<(int)(z); i++)
#define rep1(i,z) for(int i = 1; i<=(int)(z); i++)
 
using namespace std;

typedef long long ll;
const ll MOD=1e9+7;
using pear = pair<int,int>;


int main(){
  int n,k; cin>>n>>k;
  vector<double>p(n);
  vector<double>dp(n-k+1);
  rep(i,n){
      ll now; cin>>now;
      p[i] = (double)(now+1)/2;
  }
  double ans = 0;
  rep(i,k) dp[0] +=p[i];
  rep1(i,n-k)dp[i] = dp[i-1]-p[i-1]+p[i+k-1];
  rep(i,n-k+1) ans = max(ans,dp[i]);
  cout<<fixed << setprecision(15)<<ans<<endl;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
#define fil(x) memset(x, 0, sizeof(x))
#define fillb(x) memset(x,false,sizeof(x))
#define fillm(x) memset(x, -1, sizeof(x))
#define mp make_pair
#define pll pair<int, int>
#define pf printf
#define sf scanf
#define all(x) x.begin(),x.end()
#define pb push_back
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define np std::string::npos
#define fo(i,n) for(int i=0;i<n;i++)
#define of(i,n) for(int i=n-1;i>=0;i--)
#define highest(x) numeric_limits<x>::max()
#define lowest(x) numeric_limits<x>::min()
#define Inf INFINITY
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define cases(cs,t) for(int cs=1;cs<=t;cs++)
#define PI acos(-1)

typedef unsigned long long lll;
typedef long long ll;
int knigtx8[] = {2, 2, -2, -2, 1, 1, -1, -1}; ///knight move in chess
int knigty8[] = {1, -1, 1, -1, 2, -2, 2, -2}; ///knight move in chess
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1}; ///for 8 directions
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1}; ///for 8 directions
int dx4[] = {0, 0, 1, -1}; ///for 4 directions
int dy4[] = {1, -1, 0, 0}; ///for 4 directions
const int maxx=100005;

//this fuction sorts vector pair according to first element in descending order.
bool sortinrev(const pair<int,int> &a,const pair<int,int> &b)
{
    return a.first>b.first;
}

int atoz(){
    int frnt,bck,nibo,present,i;string s;
        frnt = abs(s[i]-present);
        bck = 26-frnt;
        nibo = min(frnt,bck);
}

template<typename T>inline T Bigmod(T base, T power, T MOD){
    T ret=1;
    while(power)
    {
        if(power & 1)ret=(ret*base)%MOD;
        base=(base*base)%MOD;
        power>>=1;
    }
    return ret;
}

int main()
{
    IOS;
    //int a,b,c;
    int n,m;
    cin>>n>>m;
    int a[n];
    double s=0.0;
    fo(i,n)
    {
        cin>>a[i];
        s+=a[i];
    }
    double k = s/(4.0*(double)m);
    bool bl = false;
    sort(a,a+n,greater<int>());
    fo(i,m){
        if(a[i]>=k){
            bl = true;
        }
        else{
            bl = false;
            break;
        }
    }
    if(bl) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (int i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,v) for (int i = 0; i < v.size(); i++)
#define RREPALL(i,v) for (int i = v.size()-1; i >= 0; i--)
#define SORT(v) sort(v.begin(), v.end())
#define MIN_ELEMENT(v) min_element(v.begin(), v.end())
#define MAX_ELEMENT(v) max_element(v.begin(), v.end())
#define COUNT(v,n) count(v.begin(), v.end(), n);
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
typedef long long ll;
typedef unsigned long long ull;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

string s;
vector<bool> done(26, false);

int hoge(string s, char c)
{
    //cout<<s<<"_"<<c<<endl;
    bool flag = true;
    string ns;
    
    REP(i,s.size()-1) {
        if (s[i] == c) {
            ns.push_back(c);
        } else {
            ns.push_back(s[i+1]);
            flag = false;
        }
    }
    if (s[s.size()-1] != c)
        flag = false;
    
    if (!flag)
        return hoge(ns, c) + 1;
    else
        return 0;
}

int main()
{
    cin>>s;
    int ans = INF;
    REPALL(i,s) {
        if (!done[s[i]-'a']) {
            ans = min(ans, hoge(s,s[i]));
        }
        done[s[i]-'a'] = true;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <iostream>
using namespace std;

long long int s(long long int);

int main() {
	long long int n;
	cin >> n;
	if (n%s(n) == 0)
		cout << "Yes";
	else
		cout << "No";
	cout << endl;
	return 0;

}

long long int s(long long int n) {
	long long int ans = 0;
	while (n > 0) {
		ans += n % 10;
		n /= 10;
	}
	return ans;
}

Measured memory_bytes: 256