akhauriyash/Code-Regression huggingface dataset:
from sys import stdin, setrecursionlimit


def main():
    input = stdin.readline
    s = list(input()[:-1])
    N = len(s)
    if s != list(reversed(s)):
        print('No')
    elif s[0: (N - 1) // 2] != list(reversed(s[0: (N - 1) // 2])):
        print('No')
    elif s[(N + 1) // 2:N] != list(reversed(s[(N + 1) // 2:N])):
        print('No')
    else:
        print('Yes')


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()


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

int main() {
  string a , b;
  cin >> a >> b;
  int an,bn;
  cin >> an >> bn;
  string ball ;
  cin >> ball;
  if (ball ==a){
    an--;}
  else bn--;
  cout << an <<" "<< bn << endl;
  
  
  
}




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

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

  int N;
  cin >> N;

  for (int i = 1; i <= 9; ++i) {
    for (int j = 1; j <= 9; ++j) {
      if (i * j == N) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }

  cout << "No" << endl;
  return 0;
}


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

using namespace std;

typedef long long int llint;
typedef pair<int, int> pii;
typedef pair<llint, llint> pll;
typedef vector<int> vi;
typedef vector<llint> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define ci cin
#define co cout
#define en endl
#define ln cout<< '\n'
#define rep(i, n) for(int i = 0; i < n; i++)
#define outl(x) cout<< (x) << '\n'
#define pb push_back
#define fi first
#define se second
#define MOD 1000000007

template<typename Tn> Tn gcd(Tn a, Tn b)
{
    return (b ? gcd(b, a % b) : a);
}

template<typename Tn> Tn lcm(Tn a, Tn b)
{
    return a / gcd(a, b) * b;
}

int x, y, z, k;
llint a[1001];
llint b[1001];
llint c[1001];

int main()
{
    ci >> x >> y >> z >> k;

    rep(i, x) ci >> a[i];
    rep(i, y) ci >> b[i];
    rep(i, z) ci >> c[i];

    vl v;
    
    for(int i = 0; i < x; i++) 
	for(int j = 0; j < y; j++) v.pb(a[i] + b[j]);

    sort(v.begin(), v.end(), greater<llint>());

    priority_queue<llint> que;

    for(int i = 0; i < v.size() && i < k; i++) 
	for(int j = 0; j < z; j++) que.push(v[i] + c[j]);
    
    for(int i = 0; i < k; i++) {
	co << que.top() << en;
	que.pop();
    }
    
    return 0;
}


Measured memory_bytes: 42852
#define R(i,n)for(int i=0;i<=n;i++)
s;main(a,b,c,x){scanf("%d%d%d%d",&a,&b,&c,&x);R(i,a)R(j,b)R(k,c)if(x==(500*i+100*j+50*k))s++;printf("%d",s);}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define maxn 500100
#define ll long long
int a[maxn];
int d[maxn];
ll dp[maxn];
int n,m;
int dis[maxn];
int main()
{
    while(~scanf("%d%d",&n,&m))
    {
        for(int i=1;i<=n;++i) scanf("%d",&a[i]);
        dp[n+1]=1;
        for(int i=n;i>=1;--i)
        {
            if(a[i]/2>=dp[i+1]) dp[i]=dp[i+1];
            else dp[i]=dp[i+1]+a[i];
        }
        dis[0]=m;
        for(int i=1;i<=n;++i)
            dis[i]=min(dis[i-1],abs(dis[i-1]-a[i]));
        int q;
        scanf("%d",&q);
        while(q--)
        {
            int x;
            scanf("%d",&x);
            if(dis[x-1]>=dp[x+1]) puts("YES");
            else puts("NO");
        }
    }
    return 0;
}


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

signed main(){
  int n;cin>>n;
  int ans=0;
  vector<int> v(n);
  for(int i=0;i<n;i++)cin>>v[i];
  for(int i=0;i<n-1;i++){
    int a=min(v[i],v[i+1]);
    if((v[i]-a)&1)a--;
    if(a<0)a=0;
    ans+=a;
    v[i]-=a;v[i+1]-=a;
    ans+=v[i]/2;
  }
  ans+=v[n-1]/2;
  cout<<ans<<endl;
}



Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<string>

using namespace std;

int main() {
	int H, W;

	cin >> H >> W;

	vector<string> a(H);


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

	for (int i = 0; i < W+2; i++)
	{
		cout << "#";
	}

	cout << "\n";
	for (int i = 0; i < H; i++)
	{
		cout << a[i] << endl;
	}

	for (int i = 0; i < W + 2; i++)
	{
		cout << "#";
	}


	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int i, c = 0;
    char s[3], t[3];
    scanf("%s",s);
    scanf("%s",t);
    for(i=0;i<3;i++)
    {
        if(s[i]==t[i])
        c++;
    }
    printf("%d",c);
    return 0;
}

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

int main()
{
    int n,l,i,sum=0;
    cin>>n>>l;
    vector<int> v;
    for(i=1;i<=n;i++){
        v.push_back(l+i-1);
        sum+=(l+i-1);
    }
    int minn=1e9,id;
    for(i=0;i<n;i++){
        int x=sum-v[i];
        if(abs(x-sum)<minn){  
            minn=abs(x-sum);
            id=i;
            
        }
    }
    cout<<sum-v[id];
    
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)

const int inf = ( 1 << 28);

int dp[20001][256];
int solve(int n,int m,int *cbook,int *in){
  rep(i,n+1)rep(j,256)dp[i][j]=inf;
  dp[0][128]=0;

  rep(i,n){
    rep(j,256){
      rep(k,m){
	int next=j+cbook[k];
	if (next<0)next=0;
	else if (next>255)next=255;
	dp[i+1][next]=min(dp[i+1][next],dp[i][j]+(next-in[i])*(next-in[i]));
      }
    }
  }
  
  int ans = inf;
  rep(i,256)ans=min(ans,dp[n][i]);
  return ans;
}


main(){
  int n,m;
  int in[20000],cbook[200];
  while(scanf("%d%d",&n,&m) && n){
    rep(i,m)scanf("%d",&cbook[i]);
    rep(i,n)scanf("%d",&in[i]);
    cout << solve(n,m,cbook,in) << endl;
  }
}

Measured memory_bytes: 20000
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <cmath>
using namespace std;


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

    int ans = 0;

    map<string, int> m;

    for(int i = 0; i < n; i++)
    {
        string temp;
        cin >> temp;

        if(m[temp] == 0)
        {
            ans++;
            m[temp]++;
        }


    }


    cout << ans;



    return 0;

}


Measured memory_bytes: 19096
#include<bits/stdc++.h>
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define lli long long int
#define rep(i,n) for(lli i=0; i<n; i++)
#define loop(i, j, n) for(lli i=j; i<n; i++)
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) < (b) ? (a) : (b))
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
//Function
lli combi(lli n, lli r)
{
	if(r==0 || r==n) return 1;
	else return combi(n-1,r) + combi(n-1,r-1);
}
lli sigma1(lli n){return n*(n+1)/2;}
lli sigma2(lli s, lli n){return sigma1(n) - sigma1(s -1);}
using namespace std;
// }}} End Header

lli body(lli a, lli b){
	return (a-b)*(a-b);
}
int main()
{
	ios::sync_with_stdio(false); cin.tie(nullptr);
	int a, b, c, x, y, cost, cost1, cost2, ans;
	cin >> a >> b >> c >> x >> y;
	int k = Max(x, y);
	cost = a*x + b*y;
	cost1 = 2*c*k;
	if(x > y) cost2 = 2*c*y + (x-y)*a;
	else cost2 = 2*c*x + (y-x)*b;
	ans = Min(cost, cost1);
	ans = Min(ans, cost2);
	cout << ans << endl;
 	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdbool.h>

inline static int gl(void){
    int x = 0;
    for(;;){
        unsigned int c = getchar_unlocked() - 48;
        if(c < 10){
            x = x*10 + c;
        }else{
            break;
        }
    }
    return x;
}

typedef struct{
    int y;
    int x;
} pos_t;

typedef struct{
    int fy;
    int fx;
    int ty;
    int tx;
} move_t;

char a[512*512];
move_t out[512*512];


inline static int s(int y, int x, int w){
    if(y%2==0){
        return y*w+x;
    }else{
        return y*w+(w-1-x);
    }
}

inline static pos_t xy(int n, int w){
    int q = n/w;
    int r = n%w;
    pos_t t;
    t.y = q+1;
    if(q%2==0){
        t.x = r+1;
    }else{
        t.x = w-r;
    }
    return t;
}

int main(void){
    int h=gl(), w=gl();
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            int t=getchar_unlocked()-48;
            a[s(i,j,w)] = t;
            getchar_unlocked();
        }
    }
    bool haveCoin = false;
    int count = 0;
    int pos = 0;
    for(int i=0; i<h*w-1; i++){
        if(a[i]%2==1){
            haveCoin = !haveCoin;
        }
        if(haveCoin){
            const pos_t p=xy(i, w);
            const pos_t q=xy(i+1, w);
            out[pos].fy=p.y;
            out[pos].fx=p.x;
            out[pos].ty=q.y;
            out[pos].tx=q.x;
            pos++;
            count++;
        }
    }
    printf("%d\n", count);
    for(int i=0; i<count; i++){
        printf("%d %d %d %d\n", out[i].fy, out[i].fx, out[i].ty, out[i].tx);
    }
    return 0;
}


Measured memory_bytes: 6144
#include <iostream>
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define pii std::pair<int,int>
#define pli std::pair<ll,int>
#define pil std::pair<int,ll>
#define psi std::pair<string,int>
#define pll std::pair<ll,ll>
#define pci std::pair<char,int>
#define sll(x) scanf("%lld",&x)
#define prll(x) printf("%lld ",x)
#define pri(x) printf("%d ",x)
#define si(x) scanf("%d",&x)
#define pb push_back
#define vll std::vector<ll>
#define vpi std::vector<std::pair<int,int>>
#define vi std::vector<int>
#define vvi std::vector<std::vector<int>>
#define vvpil std::vector<std::vector<std::pair<int,ll>>>
#define vlpii std::vector<std::list<pii>>
#define vlpil std::vector<std::list<pil>>
#define li std::list<int>
#define lpil std::list<pil>
#define Endl printf("\n")
#define vli vector<list<int>>
#define vvll vector<vector<ll>>
#define mp make_pair
#define ma 100000000
#define mod 1000000007
const ll  INF=10000000000000;
using namespace std;
ll dp[25][(1 << 21 ) + 1] ;
void add(ll& a , ll b){
    a += b ;
    a %= mod ;
}
void sub(ll& a , ll b){
    a -= b ;
    if(a<0) a += mod ;
}
int main()
{
    int n ;
    int a[25][25] ;
    cin >> n ;
    for(int i = 1 ; i <= n; i++) for(int j = 1 ; j <= n ; j++ ) cin >> a[i][j] ;
    memset(dp , 0 , sizeof dp ) ;
    for(int i = 0 ; i < 22 ; i++) dp[i][0] = 1 ;
    for(int k = 1 ; k < (1 << n) ; k++){
        int i = __builtin_popcount(k ) ;
        for(int j = 1 ; j <= n  && (1 << (j - 1 )) <= k; j++){
            if(a[i][j]){
                add( dp[i][k] , dp[i-1][-(1 << (j - 1)) + k] ) ;
            }
        }
    }
    cout << dp[n][(1 << (n)) - 1]  << endl;


    return 0;
}


Measured memory_bytes: 409856
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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 ll mod=1e9+7;

int main(){
    ll d;
    cin >> d;
    vector<pll> c;
    rep(i,26){
        ll t;
        cin >> t;
        c.push_back(make_pair(t,i+1));
    }
    vector<vector<pll>> s(d);
    rep(i,d){
        rep(j,26){
            ll v;
            cin >> v;
            s[i].push_back(make_pair(v,j+1));
        }
        sort(s[i].rbegin(),s[i].rend());
    }
    vector<ll> ans(d),used(26);
    ll tot=d;
    ll cnt=0;
    sort(c.rbegin(),c.rend());
    while(tot){
        rep(i,26){
            ans[tot-1]=c[i].se;
            tot--;
            cnt++;
            if(tot==0) break;
        }
        if(cnt==26){
            for(ll i=d-27;i>=0;i--){
                ans[i]=s[i][0].se;
                tot--;
            }
            break;
        }
    }
    rep(i,d){
        cout << ans[i] << endl;
    }
    return 0;
} 


Measured memory_bytes: 3856
#include <string>
#include <iostream>
#include <stdio.h>
#include <vector>

using namespace std;

int main() {
  ios::sync_with_stdio(false);

  int n;
  cin >> n;

  vector<int> v;
  int last_num, tmp;
  for (int i = 0; i < n; i++) {
    cin >> tmp;

    if (i == 0) {
      last_num = tmp;
      v.push_back(tmp);
      continue;
    }

    if (last_num != tmp) {
      v.push_back(tmp);
      last_num = tmp;
    }
  }

  for (int i = 0; i < v.size(); i++) {
    if (i) {
      cout << " ";
    }
    cout << v[i];
  }
  cout << endl;
}




Measured memory_bytes: 3440
<?php
  declare(strict_types=1);

  fscanf(STDIN, "%i %i %i", $r, $g, $b);
  if ((int)($r.$g.$b) % 4 === 0)
  {
      echo "YES", PHP_EOL;
  }
  else
  {
      echo "NO", PHP_EOL;
  }


Measured memory_bytes: 4856
/*{{{*/
#include<bits/stdc++.h>

typedef long long ll;

#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define FORR(i,a,b) for(ll i=b-1;i>=a;i--)

#define vl vector<ll>
#define pll pair<ll,ll>

#define DEBUG(x) cout<<#x<<": "<<x<<endl

using namespace std;
/*}}}*/

int main() {
  ll a;
  string b;
  cin >> a >> b;
  ll BASE = 100;
  ll bl = 0;
  bl += (ll)(b[0]-'0')*100;
  bl += (ll)(b[2]-'0')*10;
  bl += (ll)(b[3]-'0')*1;
  cout << a*bl/100 << endl;
  return 0;
}

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

using namespace std;

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

	char a, b;
	cin >> a >> b;
	if (b == 'H') {
		cout << a << '\n';
	} else {
		cout << (a == 'H' ? 'D' : 'H') << '\n';
	}

	return 0;
}



Measured memory_bytes: 256
my $input_string = <STDIN>;

my $N = 0;
chomp($input_string);
$N = $input_string;

my @array = ();
my $a_i = 0;

while(@array < $N){
	$a_i = <STDIN>;
	chomp($a_i);
	push(@array, $a_i);
}

my $limit = @array;
my $loop = 0;
my $i=0;

while($loop < $N){
	
	my $aaa = $array[$i];
	$i = $aaa - 1;
	$loop++;
	
	if($aaa == 2){
		print "$loop";
		exit;
	}
}

if($loop == $N){
	print "-1";
}

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

int main(){
    int N;
    cin >> N;
    vector<int> A(N,0);
    REP(i,N){
        cin >> A[i];}
    int o = 0;
    REP(i,N){
        o += A[i]%2;}
    cout << (o%2==0?"YES":"NO") << endl;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
using namespace std;
long long f(long long x){
    if(x <= 0 || x %4 == 3)return 0;
    long long y=0;
    for(long long i=x-x%4;i<=x;i++){
        y ^= i;
    }
    return y;
}
int main(void){
    long long a, b;
    cin >> a >> b;
    cout << (f(a-1) ^ f(b)) << endl;
}


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

int main(void){
    int n, l=10000, f[l];
    string s;
    fill(f,f+l,0);

    cin>>n;
    rep(i,n){
        string t; cin>>t;
        s+=t;
    }

    rep(i,n) rep(j,4) if(s[i]) f[stoi(s.substr(i,j+1))]=1;
    rep(i,l) if(!f[i]){
        cout<<i<<endl;
        break;    
    }
}



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

#define for_(i,a,b) for(int i=(a);i<(b);++i)

int main() {
	int sum;
	
	while (cin >> sum, sum) {
		for_(i,0,9) {
			int a;
			cin >> a;
			sum -= a;
		}
		
		cout << sum << endl;
	}
}

Measured memory_bytes: 3072
#include <bits/stdc++.h>
//#define DEBUG
#define REP( i , nn ) for(int i = 0 ; i < (int) nn; i++)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
template <class T>
void print_vect(std::vector<T> v){
    for(int i = 0 ; i < v .size(); i++) cout << v[i] << " ";
    cout << endl;
}


void solve(){
    int n;
    cin >> n;
    map<string, int> mp;
    for(int i = 0 ; i < n ; i++){
        string s;
        cin >> s;
        mp[s]++;
    }
    int maxVote = 0;
    vector<string> ans;
    for(auto it = mp.begin() ; it!= mp.end() ;it++){
        int v = (*it).second;
        if( v > maxVote){
            maxVote = v;
            ans.clear();
            ans.push_back((*it).first);
        }else if ( v == maxVote){
            ans.push_back((*it).first);
        }
    }
    for( int i = 0 ; i < ans.size() ; i++){
        cout << ans[i] << "\n";
    }
} 

int main()
{
    //making data IO Fast
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    /****************************/

    #ifdef DEBUG
    int TEST_CASES = 2;
    while(TEST_CASES--){
    #endif // DEBBUG

    solve();

    #ifdef DEBUG
    }
    #endif // DEBUG
    
    return 0;
}

//Thanks to CSES problemset
// I am trained with this kind of problem

Measured memory_bytes: 27152
n, x, m = list(map(int, input().split()))

r = [0] * (m)

r[x] = 1
a = x

t = 0
u = 0

s = [0, x]

for i in range(2, m+2):

    a = (a ** 2) % m
    s.append(s[-1] + a)

    if r[a] == 0:
        r[a] = i
    else:
        t = i - r[a]
        u = r[a]
        break

if u >= n:
    print(s[n])

else:
    #print(s, t, u)
    p = (n - (u-1)) // t
    q = (n - (u-1)) % t

    ans = s[u-1+ q] + p * (s[u+t] - s[u])

    print(ans)

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

set<int> st[1 << 17];
int c[1 << 17];

string s;
void solve() {
	cin >> s;
	int n; n = s.length();
	int dle = n / 2 - 1, dri = (n + 1) / 2;
	int d = n / 2;
	int q; cin >> q;
	rep(i, q) {
		int l, r; cin >> l >> r; l--; r--;
		if (n % 2 && d == l)l++;
		else if (n % 2 && d == r)r--;
		if (l > r)continue;
		if (l <= dle&&dri <= r) {
			int le = dle - l;
			int ri = r - dri;
			int ma = max(le, ri);
			int mi = min(le, ri);
			if (dle - ma <= dle - mi - 1) {
				st[dle - ma].insert(dle - mi -1);
			}
		}
		else if (l >= dri) {
			int le = l - dri, ri = r - dri;
			st[dle - ri].insert(dle - le);
		}
		else {
			st[l].insert(r);
		}
	}
	int cur = 0;
	rep(i, d) {
		//cout << i << endl;
		cur += c[i]; cur = (cur % 26 + 26) % 26;
		//cout << c[i] << endl;
		int dif = s[n - 1 - i] - s[i];
		if (dif < 0)dif += 26;
		//cout << dif << endl;
		if (st[i].empty()) {
			if (dif != cur) {
				cout << "NO" << endl; return;
			}
			continue;
		}
		int ad = dif - cur;
		if (ad < 0)ad += 26;
		int memo = -1;
		for (auto itr = st[i].begin(); itr != st[i].end(); itr++) {
			int z = *itr;
			if (memo < 0) {
				cur += ad; if (cur >= 26)cur -= 26;
				c[z + 1] -= ad;
				//cout << z << endl;
				memo = z;
			}
			else {
				st[memo + 1].insert(z);
				memo = z;
			}
		}
	}
	cout << "YES" << endl;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	solve();
	//stop
	return 0;
}

Measured memory_bytes: 26240
# coding: utf-8
# Your code here!
def is_unique2(seq):
    seen = []
    unique_list = [x for x in seq if x not in seen and not seen.append(x)]
    return len(seq) == len(unique_list)

n=int(input())

line=[]

for i in range(n):
    line.append(list(input()))
    
#print(line)
flag=is_unique2(line)
#print(flag)

for i in range(n-1):
    if line[i][-1]!=line[i+1][0]:
        flag=False  #outならfalse

#print(flag)

if flag:
    print("Yes")
else:
    print("No")

              
              
              

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include<iostream>
using namespace std;
int main(){
	int k,s,z;
	int ans;
	cin>>k>>s;
	for(int x=0;x<=k;x++)
	{
		for(int y=0;y<=k;y++){
			z=s-(x+y);
			if(z>=0 && z<=k && x+y+z==s){
				ans++;
			}
		}
		}
		cout<<ans;
		
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize ("Ofast")
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace __gnu_pbds;
using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<long long,long long> ii; 	
typedef complex<long double> com;

const ll mod = 1e9+7;

int main(){
	ios_base::sync_with_stdio(false);
	ll a,b;
	cin >> a >> b;
	cout << a*b << endl;
}

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

int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if(a+b>c+d) cout << "Left" << endl;
    else if(a+b==c+d) cout << "Balanced" << endl;
    else cout << "Right" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define llu unsigned long long
#define ld double
#define llu unsigned long long
#define rep(i,x,y)  for(int i=int(x);i<int(y);++i)
#define For(i,x,y)  for(int i=int(x);i<=int(y);++i)
#define FOr(i,x,y)  for(int i=int(x);i>=int(y);--i)
#define pi acos(-1) 
#define mk make_pair
#define pa pair<ll,ll>
#define lf else if
#define IL inline
#define max(x,y)    ((x)<(y)?(y):(x))
#define min(x,y)    ((x)<(y)?(x):(y))
#define sqr(x)      ((x)*(x))
#define Mul(x,y)    ((x)=1LL*(x)*(y)%mod)
#define Add(x,y)    ((x)=((x)+(y))%mod)
#define Max(x,y)    ((x)=((x)<(y)?(y):(x)))
#define Min(x,y)    ((x)=((x)>(y)?(y):(x)))
#define E(x)        return writeln(x),0
#define LL			(long long)
#define p(x)        printf("~%lld~\n",LL(x))
#define pp(x,y)     printf("~~%lld %lld~~\n",LL(x),LL(y))
#define ppp(x,y,z)  printf("~~~%lld %lld %lld~~~\n",LL(x),LL(y),LL(z))
#define pppp(a,b,c,d)	printf("~~~%lld %lld %lld %lld\n",LL(a),LL(b),LL(c),LL(d))
#define f_in(x)     freopen(x".in","r",stdin)
#define f_out(x)    freopen(x".out","w",stdout)
#define open(x)     f_in(x),f_out(x)
#define fi first
#define se second
#define GuYue		puts("\nGuYueNa________________________________________________________________________________")
typedef complex<double> E;
namespace SHENZHEBEI{
#ifdef LOCAL
    struct _{_(){freopen("cf.in","r",stdin);}}_; 
#endif 
#define NEG 1
    static const int GYN=2333333;
    char SZB[GYN],*S=SZB,*T=SZB;
    inline char gc(){   if (S==T){  T=(S=SZB)+fread(SZB,1,GYN,stdin); if (S==T) return '\n';  }   return *S++;    }
#if NEG
    inline ll read(){    ll x=0,g=1; char ch=gc();   for (;!isdigit(ch);ch=gc()) if (ch=='-') g=-1;  for (;isdigit(ch);ch=gc())  x=x*10-48+ch;   return x*g; }
    inline void write(ll x){    if (x<0) putchar('-'),x=-x;  if (x>=10)   write(x/10);    putchar(x%10+'0');  }
#else
    inline ll read(){    ll x=0; char ch=gc();   for (;!isdigit(ch);ch=gc());    for (;isdigit(ch);ch=gc())  x=x*10-48+ch;   return x;   }
    inline void write(ll x){    if (x>=10)   write(x/10);    putchar(x%10+'0');  }
#endif
    inline char readchar(){ char ch=gc();   for(;isspace(ch);ch=gc());  return ch;  }
    inline ll readstr(char *s){ char ch=gc();   int cur=0;  for(;isspace(ch);ch=gc());      for(;!isspace(ch);ch=gc())  s[cur++]=ch;    s[cur]='\0';    return cur; }
	void Print(long long *a,int s,int t){For(i,s,t)printf("%lld ",a[i]);}
	void Print(int *a,int s,int t){For(i,s,t)printf("%d ",a[i]);}
	void Print(char *a,int s,int t){For(i,s,t)putchar(a[i]);}
	void writeln(ll x){write(x);puts("");}
}using namespace SHENZHEBEI;
const ll N=310;
ll answ,n,ans[N];char s[N][N],t[N][N];
int main(){
	n=read();
	For(i,1,n)readstr(s[i]+1);
	rep(i,0,n)ans[i]=1;
	For(i,1,n)For(j,1,n){
		rep(k,0,n){
			ll x=i+k,y=j-k+n+n;
			for(;x>n;x-=n);
			for(;y>n;y-=n);
			ans[(i-j+k+n*10)%n]&=s[i][j]==s[x][y];
		}
	}
	rep(i,0,n)answ+=ans[i]*n;
	writeln(answ);
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a.at(i);
  }
  sort(a.begin(), a.end());
  cout << a.at(N/2) - a.at(N/2 - 1) << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <numeric>
#include <cmath>
#include <limits>
#include <stdio.h>
#include <iomanip>
#include <cstdlib>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
ll Max(ll(a), ll(b), ll(c)) {
	return max(max(a, b), c);
}
ll Min(ll(a), ll(b), ll(c)) {
	return min(min(a, b), c);
}





int main() {

	ll a, b, x;
	cin >> a >> b >> x;
	ll an;
	if (a == 0) {
		an = b / x + 1;
	}
	else {
		an = (b / x - (a - 1) / x);
	}
	cout << an << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
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 int MOD = 1000000007;
const int INF = 1e9;

const int mod = 1000000007;
const int inf = 1e9;
#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};

const int mxN = 103;
vector<int> adj[mxN];

int main(){
    int n;
    cin >> n;
    for(int i = 0; i < n; i++) {
        int v, k;
        cin >> v >> k;
        for(int j = 0; j < k; j++) {
            int a;
            cin >> a;
            a--;
            adj[i].push_back(a);
        }
    }

    vector<int> dis(n, INF);
    dis[0] = 0;
    queue<int> Q;
    Q.push(0);

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

        for(auto e: adj[p]) {
            if(dis[e] == INF) {
                dis[e] = dis[p] + 1;
                Q.push(e);
            }
        }
    }

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


Measured memory_bytes: 3120
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define ll unsigned long long
using namespace std;
int main(){
    ll A,B,C;
    cin>>A>>B;
    C=max(A,B);
    for(;;){
        if(C%min(A,B)==0){
            cout<<C<<endl;
            return 0;
        } else {
            C+=max(A,B);
        }
    }
}

Measured memory_bytes: 256
/*
   Author: Shivam Shukla
   Problem URL: 
*/
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pair<ll,ll> > vpll;
 
const int MOD=1e9+7;
const int MAX=1e5+5;
const double PI= acos(-1.0);
const long double EPS=1e-10;
const int64_t INF=1e18+10;
 
#define fastio() ios_base::sync_with_stdio(false);cin.tie(0), cout.tie(0)
#define trace(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vi vector<int>
#define vl vector<ll>
#define vs vector<str>
#define vc(x) vector<x>
#define mapll map<ll,ll>
#define mapib map<int,bool>
#define mapiv map<int,vector>
#define mapsi map<string,int>
#define repa(i,n) for(ll i=0;i<n;i++)
#define dowa(i,n) for(ll i=n;i>=0;i--)
#define reps(i,j,k,s) for(ll i=j;i<k;i+=s)
#define downs(i,j,k,s) for(ll i=j;i>=k;i-=s)
#define trv(i,x) for(auto i:x)
#define pb push_back
#define sz(x) (int)x.size()
#define ff first
#define ss second
#define str string 
#define dub double
#define pqmax priority_queue<ll>
#define pqmin priority_queue<ll,vl,greater<ll> >
 
template<typename t> t lcm(t a, t b) {return (a*b)/__gcd(a,b);}
template<typename t> t gcd(t a, t b) {return __gcd(a,b);}
template<typename t> t mul_mod(t a, t b, t m){t res=((a%m)*(b%m)%m); return res;}
template<typename t> t add_mod(t a, t b, t m){t res=((a%m)+(b%m))%m; return res;}
template<typename t> t pow(t a,t b,t m) {t res=1;while(b){if(b&1) res=mul_mod(res,a,m);a=mul_mod(a,a,m), b>>=1;} return res%m;}
template<typename t> vc(t) num_vec(t num) {t res; while (num) res.pb(num%10), num/=10; return res;}
template<typename t> t vec_num(t vec) {t res=0; ll mul=1; repa(i,sz(vec)) res=vec[i]*mul, mul*=10; return res;}
 

int32_t main(int argc,char** argv){
	fastio();
	auto tstart= clock();   
    
    /* Code Starts Here */
    ll n,m,s=0;cin>>n;
    vi a(n); repa(i,n) cin>>a[i], s+=a[i];
    
    cin>>m;
    repa(i,m){
    	int p,t;cin>>p>>t;
    	cout<<(s-a[p-1]+t)<<endl;
    }
    /* Code Ends Here */

    cerr<<setprecision(2)<<fixed<<"Time elapsed: "<<(double)(clock() - tstart)/CLOCKS_PER_SEC<<endl; 
    return 0; 
}

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

ans = n

person = []
have = []

for i in range(k):
  person.append(int(input()))
  have.append(input().split())

import itertools
have = list(itertools.chain.from_iterable(have))
sunuke = (list(range(1, n+1)))

have = list(map(int, have))

for j in range(len(have)):
  if have[j] in sunuke:
    sunuke.remove(have[j])

print(len(sunuke))

Measured memory_bytes: 9408
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  long long n,y;
  cin >> n >> y;
  for(int i=n;i>=0;i--){
    if(10000*i>y){
      continue;
    }
    for(int j=0;j<=n-i;j++){
      int k=n-i-j;
      if(10000*i+5000*j+1000*k==y){
        cout << i << " " << j << " " << k << endl;
        return 0;
      }
    }
  }
  cout << "-1 -1 -1" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
using namespace std;
int main()
 {  ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
	//int t; 
     //   cin>>t;
      //  while(t--){
        ll n,k;
        cin>>n>>k;
        
        ll a[n];
        for(int i=0;i<n;i++){
            cin>>a[i];
        }
        if(k<n){
            sort(a,a+n);
            ull s =0;
            for(int i=0;i<n-k;i++) s+= a[i];
            cout<<s<<"\n";
        }
        else cout<<"0\n";
	//}return 0;
}

Measured memory_bytes: 1792
#include <vector>
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <numeric>

using namespace std;
typedef long long li;
typedef pair <li, li> pi;
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)

const li mod = 1e9 + 7;

li doit(vector<li> vs) {
    const li n = vs.size();
    li ans = 0;
    rep(i, n) {
        li appear = (i + 1) * (n - i) % mod;
        ans += vs[i] * appear;
        ans %= mod;
    }
    return ans;
}

vector<li> d(vector<li> vs) {
    const li n = vs.size();
    vector<li> ans(n - 1);
    rep(i, n - 1) {
        ans[i] = vs[i + 1] - vs[i];
    }
    return ans;
}

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

    vector<li> xs(n), ys(m);
    rep(i, n) {
        cin >> xs[i];
    }
    rep(i, m) {
        cin >> ys[i];
    }

    cout << doit(d(xs)) * doit(d(ys)) % mod << endl;
    return 0;
}


Measured memory_bytes: 6272
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
vector<long long> a(100),b(100),c(100),d(100);
long long e[101],f[101],g[101],h[101];
    

int main(){
    long long m,n,w,x,y,v;
    long long ans=0;
    cin >> n >> w;
    cin >> x >> v;
    a.push_back(v);
    for(int i=0;i<n-1;i++){
        cin >> y >> v;
        if(y==x){
            a.push_back(v);
        }else if(y==x+1){
            b.push_back(v);
        }else if(y==x+2){
            c.push_back(v);
        }else if(y==x+3){
            d.push_back(v);
        }
    }

    sort(a.rbegin(),a.rend());
    sort(b.rbegin(),b.rend());
    sort(c.rbegin(),c.rend());
    sort(d.rbegin(),d.rend());

    e[0] = 0;
    f[0] = 0;
    g[0] = 0;
    h[0] = 0;
    for(int i=0;i<n;i++){
        e[i+1] = e[i]+a[i];
        f[i+1] = f[i]+b[i];
        g[i+1] = g[i]+c[i];
        h[i+1] = h[i]+d[i];
    }
    for(long long i=0;i<=n;i++){
        for(long long j=0;j<=n-i;j++){
            for(long long k=0;k<=n-i-j;k++){
                for(long long l=0;l<=n-i-j-k;l++){
                    if((i*x+j*(x+1)+k*(x+2)+l*(x+3))<=w){
                        ans = max(ans,e[i]+f[j]+g[k]+h[l]);
                    }
                }
            }
        }
    }
    cout << ans << endl;
}

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

#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//以降 cin の入力元が 'input.txt' になる
//std::ifstream in("input.txt");
//std::cin.rdbuf(in.rdbuf());

signed main()
{
    gearup;
    string s; cin >> s;
    if(s[0] == '9' || s[1] == '9')out("Yes");
    else out("No");
}


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

bool vis[10];

int main()
{
  int x;
  for(int i=0;i<4;i++)
    cin>>x,vis[x]=true;
  
  if(vis[1] && vis[4] && vis[7] && vis[9])
    cout<<"YES\n";
  else
    cout<<"NO\n";
}


Measured memory_bytes: 256
N, K = map(int, input().split())
mod = 1000000007

ans = 0
for i in range(K, N + 2):
    max_candidate = ((2 * N + 1 - i) * i * (1/2)) % mod
    min_candidate = ((i - 1) * i * (1/2)) % mod
    ans = ans + (max_candidate - min_candidate + 1) % mod
print(int(ans % mod))

Measured memory_bytes: 9204
//QWsin
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define rep(i,x,y) for(int i=x;i<=y;++i)
#define out(i,u) for(int i=first[u];i!=-1;i=nxt[i])
#define repvc(i,vc) for(int i=0,Sz=vc.size();i<Sz;++i)
using namespace std;
inline int read()
{
	char ch=getchar();int ret=0,f=1;
	while(ch<'0' || ch>'9') {if(ch=='-')f=-1;ch=getchar();}
	for(;ch>='0' && ch<='9';ch=getchar()) ret=ret*10+ch-'0';
	return ret*f;
}

inline void print(string name,int *arr,int len){
	rep(i,1,len) printf("%s[%d]=%d\n",name.c_str(),i,arr[i]);puts("");
}
inline void print(string name,int a){
	printf("%s=%d\n",name.c_str(),a);puts("");
}

typedef long long ll;
const int INF=1<<30;
const int MOD=1e9+7;

const int maxn=100000+10;
char s[maxn];

ll dp[maxn][13];

int main()
{
	scanf("%s",s+1);
	int n=strlen(s+1);
	dp[0][0]=1;
	rep(i,0,n-1)
	{
		rep(j,0,12) if(dp[i][j])
		{
			dp[i][j]%=MOD;
			if(s[i+1]!='?')
			{
				int c=s[i+1]-'0';
				dp[i+1][(j*10+c)%13]+=dp[i][j];
			}
			else
			{
				rep(c,0,9)
					dp[i+1][(j*10+c)%13]+=dp[i][j];
			}
		}
	}
	cout<<dp[n][5]%MOD<<endl;
	return 0;
}


Measured memory_bytes: 10496
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
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;}
typedef pair<ll,ll> P;
typedef pair<ll,ll> Pll;
//小数点以下　cout << fixed << setprecision(10) << num << endl;
//桁数はlog10(mid)でやれ　log(mid)/log(10)はWA
//long*long<0で判定するな
//開区間と閉区間
//アルファベットが何番目かは x=s[i]-'a'
//bfsはmain()内で　rep(i,h)rep(j,w)rep(i,4)でバグ
//切り上げ：(a+(b-1))/b
//32bit以上は 1ull<<j
// map 初期値0 for(auto itr=mp.begin();itr!=mp.end();++itr) itr->fi itr->se で全探索
// for(auto u:mp) u.fi u.se も可能
//n個のgcd,lcmは一つずつみて更新していく
//大きな数を扱うときは素因数分解した形で持っておく
// (l/a[i]) = l*powmod(a[i],MOD-2)%MOD;
//auto itr=lower_bound(ALL(a),key) a[itr-a.begin()]

int main(){
    int n,x; cin >> n >> x;
    if(x==1||x==2*n-1){
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    if(n==2){
        cout << 1 << endl;
        cout << 2 << endl;
        cout << 3 << endl;
        return 0;
    }
    vector<int> ans(2*n-1,0);
    int j=1;
    if(x+2<=2*n-1){
        if(n-2>=0){
            ans[n-2]=x+1;
            ans[n-1]=x;
            ans[n]=x-1;
            ans[n+1]=x+2;
            rep(i,2*n-1){
                if(j==x-1) j+=4;
                if(ans[i]==0){
                    ans[i]=j;
                    j++;
                }
            }
        }else{
            ans[n-1]=x+1;
            ans[n]=x;
            ans[n+1]=x-1;
            ans[n+2]=x+2;
            rep(i,2*n-1){
                if(j==x-1) j+=4;
                if(ans[i]==0){
                    ans[i]=j;
                    j++;
                }
            }
        }
    }else{
       if(n-2>=0){
            ans[n-2]=x-2;
            ans[n-1]=x;
            ans[n]=x+1;
            ans[n+1]=x-1;
            rep(i,2*n-1){
                if(j==x-2) j+=4;
                if(ans[i]==0){
                    ans[i]=j;
                    j++;
                }
            }
        }else{
            ans[n-1]=x-2;
            ans[n]=x;
            ans[n+1]=x+1;
            ans[n+2]=x-1;
            rep(i,2*n-1){
                if(j==x-2) j+=4;
                if(ans[i]==0){
                    ans[i]=j;
                    j++;
                }
            }
        }
    }
    rep(i,2*n-1) cout << ans[i] << endl;
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
#define pb push_back
#define mk make_pair
#define fi first
#define se second
using namespace std;
typedef pair<int, int> pii;
typedef long long LL;
using namespace std;

int main() {
    int x; cin>>x;
    if(x==7||x==5||x==3) cout<<"YES\n";
    else cout<<"NO\n";
    return 0;
}


Measured memory_bytes: 384
#include<stdio.h>

 int main(void)
 {
 char str[100];
 int i;
 int count = 0;

 scanf("%s", str);

 for (i = 0; str[i] != '\0'; i++){
 count++;
 }

 for (i=count - 1; i>= 0; i--){
 printf("%c", str[i]);
 }
 printf("\n");

 return 0;

 }

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

int main() {
	ios::sync_with_stdio(0), cin.tie(0);
	string s;
	cin >> s;
	int n = int(s.size());
	if (n % 2 == 1) {
		cout << "No" << '\n';
		exit(0);
	}
	for (int i = 0; i < n; i += 2) {
		if (s[i] == 'h' && s[i+1] == 'i') {
			// good
		} else {
			cout << "No" << '\n';
			exit(0);
		}
	}
	cout << "Yes" << '\n';
}


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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(m);
  for (int i = 0; i < m; i++) {
    cin >> a.at(i);
  }
  sort(a.begin(), a.end());
  int ans = 0;
  int hw = 0;
  for (int i = 0; i < m; i++) {
    hw += a.at(i);
    if (hw > n) {
      cout << -1;
      return 0;
    }
  }
  cout << n - hw;
  return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll cnt(ll n){
    if(n==1) return 1;
    else
        return 2 * cnt(n / 2) + 1;
}
int main() {
    ll h;
    cin >> h;

    cout << cnt(h) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
  int n;
  cin>>n;
  double a[n];
  for(int i=0;i<n;i++)
  {
    cin>>a[i];
  }
  sort(a,a+n);
  double ans=a[0];
  for(int i=1;i<n;i++)
  {
    ans+=a[i];
    ans/=2;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int max = Math.max(a, b);
        int min = Math.min(a, b);
        System.out.println(max != min ? 2 * max - 1: 2 * max);
    }
}


Measured memory_bytes: 23124
N=list(input())
N_num=len(N)
max_num=0
min_num=0


for i in range(N_num):
        if N[i] == "A":
                min_num=i
                break

N.reverse()
for i in range(N_num):
        if N[i] == "Z":
                max_num=i
                break

print(N_num-max_num-min_num)


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

using namespace std;

void scan() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

#define ll long long
#define fir first
#define sec second

const ll maxn = 1e6 + 7;
ll a[maxn], b[maxn];

ll n, k;

bool cmp(ll a, ll b) {
    return a > b;
}

bool judge(ll x) {
    ll sum = 0;
    for (ll i = 0; i < n; i++) {
        ll tmp = x / b[i];
        if (a[i] >= tmp)
            sum += a[i] - tmp;
//        cout << sum << ' ';
    }
//    cout << sum << endl;
    return k >= sum;
}

int solve(int T) {


    cin >> n >> k;
    for (ll i = 0; i < n; i++) cin >> a[i];
    for (ll i = 0; i < n; i++) cin >> b[i];
    sort(a, a + n);
    sort(b, b + n, cmp);
    ll l = 0, r = 1e16;
    while (l < r) {
        ll mid = (l + r) / 2;
//        cout << mid << endl;
        if (judge(mid)) r = mid;

        else l = mid + 1;
    }
    cout << l << endl;
    return 0;
}


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

    int T = 1;
//    cin >> T;
    for (int i = 1; i <= T; i++) solve(i);
    return 0;
}

Measured memory_bytes: 5888
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
	int N;
	cin >> N;
	map<int, int> OddNums, EvenNums;
	for (int i = 0; i < N; i++) {
		int v;
		cin >> v;
		(i % 2 == 0 ? EvenNums : OddNums)[v]++;
	}
	int ans=100001;
	vector<pair<int, int>> Odds, Evens;
	for (auto& p : OddNums) Odds.push_back({ p.second, p.first });
	for (auto& p : EvenNums) Evens.push_back({ p.second, p.first });
	sort(Odds.begin(), Odds.end(), greater<pair<int, int>>());
	sort(Evens.begin(), Evens.end(), greater<pair<int, int>>());
	if (Odds[0].second != Evens[0].second) ans = N - Odds[0].first - Evens[0].first;
	else {
		if (Odds.size() > 1) ans = N - Odds[1].first - Evens[0].first;
		if (Evens.size() > 1) ans = min(ans, N - Odds[0].first - Evens[1].first);
		if (Odds.size() == 1 && Evens.size() == 1) ans = min(N - Evens[0].first, N - Odds[0].first);
	}
	cout << ans << endl;

}

Measured memory_bytes: 6136
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e6+10;
typedef long long ll;
bool used[maxn];
int mu[maxn];
vector<int> prime;
ll f[maxn];
int low[maxn];
void sieve(int size){
    //f:multiplicative function;
    mu[1] = 1;
    f[1] = 1;
    for (int i=2;i<=size;i++){
        if (!used[i]){
            prime.push_back(i);
            mu[i] = -1;
            //f:TODO
            low[i] = i;
        }
        for (int j = 0;j < prime.size();j++){
            ll nxt = 1ll * i * prime[j];
            if (nxt > size)break;
            used[nxt] = 1;
            if (i % prime[j]){
                low[nxt] = prime[j];
                mu[nxt] = -mu[i];
                //f: mod or not?
                f[nxt] = f[i] * f[prime[j]];
            }else{
                low[nxt] = prime[j] * low[i];
                mu[nxt] = 0;
                if (low[nxt] != nxt){
                    //mod or not?
                    f[nxt] = 1ll * f[low[nxt]] * f[nxt/low[nxt]];
                }else{
                    // i = prime[j] ^ k
                    //f:TODO
                }
                break;
            }
        }
    }
}

int main(){
    sieve(1e6);
    ll n,p;
    cin>>n>>p;
    ll ans = 1;
    for (int i=0;i<prime.size();i++){
        ll t = prime[i];
        int cnt = 0;
        while (p % t == 0){
            cnt ++;
            p /= t;
            if (cnt == n){
                cnt = 0;
                ans *= t;
            }
        }
    }
    if (p!= 1 && n == 1)ans *= p;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 17532
N = int(input())

a = [0 for _ in range(N + 1)]

for i in range(1, N + 1):
    temp = i
    while(temp <= N):
        a[temp] += 1
        temp += i
        
ans = 0
for i in range(1, N + 1):
    ans += i * a[i]
print(ans)

Measured memory_bytes: 224840
#include<iostream>
#include<vector>
#include<queue>
using namespace std;
int main () {
  int H, W;
  cin >> H >> W;
  vector<vector<int>>num(H, vector<int>(W));
  vector<vector<char>>map(H, vector<char>(W));
  vector<vector<bool>>reach(H, vector<bool>(W, false));
  queue<int>qx;
  queue<int>qy;
  queue<int>qn;
  for (int i = 0; i < H; i ++) {
    for (int j = 0; j < W; j ++) {
      cin >> map[i][j];
      if (map[i][j] == '#') {
        qx.push(i);
        qy.push(j);
        qn.push(0);
        reach[i][j] = true;
        num[i][j] = 0;
      }
    }
  }
  int x[] = {0, 1, 0, -1};
  int y[] = {1, 0, -1, 0};
  while(!qx.empty()) {
    int bx = qx.front();
    int by = qy.front();
    int bn = qn.front();
    qx.pop();
    qy.pop();
    qn.pop();
    for (int i = 0; i < 4; i ++) {
      int ax = bx + x[i];
      int ay = by + y[i];
      int an = bn + 1;
      if (ax >= H || ax < 0 || ay >= W || ay < 0 || reach[ax][ay]) continue;
      num[ax][ay] = an;
      reach[ax][ay] = true;
      qx.push(ax);
      qy.push(ay);
      qn.push(an);
    }
  }
  int ans = 0;
  for (int i = 0; i < H; i ++) {
    for (int j = 0; j < W; j ++) {
      if (ans < num[i][j]) ans = num[i][j];
    }
  }
  cout << ans << endl;
}
  
  



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

const int INF = 1e9;

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(m), b(m);
  vector<int> to(m, 0);
  for (int i = 0; i < m; i++) {
    cin >> a[i] >> b[i];
    for (int j = 0; j < b[i]; j++) {
      int c;
      cin >> c, c--;
      to[i] |= 1 << c;
    }
  }
  vector<int> dp(1 << n, INF);
  dp[0] = 0;
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < (1 << n); j++) {
      int nj = j | to[i];
      dp[nj] = min(dp[nj], dp[j] + a[i]);
    }
  }
  if (dp[(1 << n) - 1] == INF) {
    cout << -1 << endl;
  } else {
    cout << dp[(1 << n) - 1] << endl;
  }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int n, m, q;
int a[55], b[55], c[55], d[55];
int A[10] = {};
int dfs(int *A, int j)
{
    if (j == n)
    {
        int ans = 0;
        for (int i = 0; i < q; i++)
        {
            if (A[b[i]] - A[a[i]] == c[i])
            {
                ans += d[i];
            }
        }
        return ans;
    }
    int max = 0;
    for (int i = A[j - 1]; i <= m; i++)
    {
        A[j] = i;
        int t = dfs(A, j + 1);
        max = (max > t) ? max : t;
    }
    return max;
}
int main()
{
    scanf("%d %d %d", &n, &m, &q);
    for (int i = 0; i < q; i++)
    {
        scanf("%d %d %d %d", &a[i], &b[i], &c[i], &d[i]);
        a[i]--;
        b[i]--;
    }
    A[0] = 1;
    printf("%ld", dfs(A, 1));
    return 0;
}

Measured memory_bytes: 1736