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

using namespace std;

#define ll long long
#define pb push_back
#define mp make_pair
#define fst first
#define snd second

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

    string ans = "";
    for(int i = 0; i < n; i++)
    {
        ans += s[i];
        ans += t[i];
    }

    cout << ans;

    return 0;
}


Measured memory_bytes: 256
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#include <bitset>
#include <stack>
 
using namespace std;
 
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define repl(i,s,n) for(int i=s; i<=n; ++i)
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define ktya(x) sort(all(x))
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 1e18
#define INFLL 1000000000000000007LL
#define SIZE 200105
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mind(a,b) (a>b?b:a)
#define maxd(a,b) (a>b?a:b)

typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
ll MOD = 1000000007;
//ll MOD=998244353;
typedef ll Weight;
struct Edge {
	int src, dst;
	Weight weight;
};
bool operator < (const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
	e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
int calc_wa(int x){
	int ret=0;
	while(x){
		ret+=(x%10);
		x/=10;
	}
	return ret;
}

int main(){
	int N;
	cin>>N;
	int mi=100000;
	for(int i=1;i<=N-1;i++){
		mi=min(calc_wa(i)+calc_wa(N-i),mi);
	}
	cout<<mi<<endl;
}


Measured memory_bytes: 256
N = int(input())
p = list(map(int, input().split()))
ans_list = [i for i in range(1, N+1)]
check = 0
for i in range(N):
    if p[i] == ans_list[i]:
        pass
    else:
        check += 1
if check <= 2:
    print('YES')
else:
    print("NO")

Measured memory_bytes: 3060
module Mod = struct
  module type S = sig val modulo : int end
  module Make (S : S) = struct open S
    let modulo = modulo
    let (+) a b = (a + b) mod modulo
    let (-) a b = (a - b + modulo) mod modulo
    let ( * ) a b = (a * b) mod modulo
    let rec ( ** ) a n =
      if n = 0 then 1
      else if n mod 2 = 1 then a * a**(n-1)
      else let t = a ** (n/2) in t * t
    let inv a = a ** (modulo-2)
    let (/) a b = a * inv b
  end
end
module M = Mod.Make(struct let modulo = 1000000007 end)

let fact = begin
  let a = Array.make 4020 1 in
  for i = 1 to 4000 do a.(i) <- M.(i * a.(i-1)) done;
  a
end

let comb n k = if n < max 0 k then 0 else M.(fact.(n) / fact.(k) / fact.(n-k))

let () =
  Scanf.scanf "%d %d" @@ fun n k ->
  for i = 1 to k do
    Printf.printf "%d\n" @@
    M.(comb (k-i+i-1) (i-1) * comb (n-k-i+1+i) (i))
  done


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

int main() {
  int n;
  int R[200000];
  cin >> n;
  rep(i, n) cin >> R[i];
  int maxm = R[1] - R[0];
  int minm = R[0];
  for (int i = 1; i < n; i++) {
    maxm = max(maxm, R[i] - minm);
    // iを増やしてく過程で、それ以前のR[i]の最小値を保持する
    minm = min(minm, R[i]);
  }
  cout << maxm << endl;
}


Measured memory_bytes: 3868
import sys
from bisect import *
from collections import *
from copy import deepcopy
from heapq import *
from itertools import *
from math import *
from operator import *
from pprint import *

sys.setrecursionlimit(10**8)

input = sys.stdin.readline

def main():
    """ main """
    N,K,Q = map(int, input().split())
    res = [0]*N
    for _ in range(Q):
        a = int(input())
        a -= 1
        res[a] += 1
    for x in res:
        if 0 < (K-Q+x): print('Yes')
        else: print('No')

if __name__ == '__main__':
    main()

Measured memory_bytes: 5340
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=1000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};

ll a[100001];
int main() {

	int n;
	cin>>n;

	ll t=0;
	rep(i,n){
		cin>>a[i];
		if(a[i]%2==1)t++;
	}
	if(t%2==0)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;

	return 0;

}


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

using namespace std;

#define ll long long int 

ll maxl=1e9+1;

int main()
{
	ll n;
	cin>>n;
	ll ans[n+1]={0};
	for(int i=0,a;i<n-1;i++)
	{
		cin>>a;
		ans[a]++;
	}
	for(int i=1;i<=n;i++)
	{
		cout<<ans[i]<<"\n";	
	}
}

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

#define  int        long long int
 #define    sp(x)                 setprecision(x)
#define    bp(x)           __builtin_popcount(x)
 #define  ld         long double
 #define  f(i,j,n)            for(int i = j; i <= n; i++)
#define  r(i,n,j)       for(int i = n; i >= j; i--)
 #define  all(container)       container.begin() , container.end()
#define  sz(container)   (int)container.size()
 #define  ff             first
#define  ss             second
 #define  pii      pair <int , int>
#define  sp(x)       setprecision(x)
 #define  endl    "\n"
#define  mod  1000000007
 #define  pb    push_back
#define  mp    make_pair
 #define  T     int ttt; cin >> ttt; while(ttt--)
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);

int power(int x, int y, int p)  
{  
    int res = 1;    
    x = x % p; 
    if (x == 0) return 0; 
    while (y > 0)  
    {     
        if (y & 1)  
            res = (res*x) % p;  
        y = y>>1; 
        x = (x*x) % p;  
    }  
    return res; 
}

int32_t main()
{
    fast
    int a;
    cin>>a;
    cout<<a+ a*a + a*a*a;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e9
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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;

int a[3],b[3];
int v[5];
signed main(){
    cin>>a[0]>>b[0]>>a[1]>>b[1]>>a[2]>>b[2];
    for (int i = 0; i < 3; i++)
    {
        v[a[i]]++;
        v[b[i]]++;
    }
    int cnt_1=0;
    int cnt_2=0;
    for (int i = 1; i <= 4; i++)
    {
        if(v[i]==1) cnt_1++;
        if(v[i]==2) cnt_2++;
    }
    if(cnt_1==2 && cnt_2==2) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    
    
 
   
    return 0;
}

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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repp(i, n, m) for(int (i) = (n); (i) < (m); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define ldou long double
#define fi first
#define se second
#define setpre(x) std::cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define outs(x) cout << (x) << " "
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ std::cout << " [LOGGER] " << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , "; logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 300005;

/* ...o(^-^)o... */

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

    if(n%3){
        rep(i, n){
            if(a[i] != 0){
                out("No"); return 0;
            }
        }
        out("Yes"); return 0;
    }

    map<lint, int> mp;
    rep(i, n) mp[a[i]]++;
    if(mp.size() > 3){
        out("No"); return 0;
    }
    if(mp.size() == 2){
        P p = *mp.begin();
        P q = *(++mp.begin());
        if(p.se > q.se) swap(p, q);
        if(p.se!=n/3 || q.se!=2*n/3 || p.fi!=0){
            out("No"); return 0;
        }
        out("Yes"); return 0;
    }
    if(mp.size() == 1){
        P p = *mp.begin();
        if(p.fi != 0){
            out("No"); return 0;
        }
        out("Yes"); return 0;
    }

    auto itr = mp.begin();
    P p = *itr; itr++;
    P q = *itr; itr++;
    P r = *itr;
    if(p.se!=n/3 || q.se!=n/3 || r.se!=n/3){
        out("No"); return 0;
    }
    if(p.fi != (q.fi^r.fi)){
        out("No"); return 0;
    }
    out("Yes");
}

Measured memory_bytes: 5632
#include <cstdlib>
#include <iostream>
#include <string>
#include <time.h>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
using namespace std;

#define huge 1000000007

int main(void) {

	long int N = 0, A=0, B = 0;
	cin >> N >> A;
	int res = 0;
	if (N - A > 0)
		res = N - A;
	else
		res = 0;

	cout << res << endl;
	return 0;


}

Measured memory_bytes: 256
program main
  implicit none
  integer :: n, i
  real(8) :: x, res
  character(3) :: u
  read (*, *) n
  res = 0.0
  do i = 1, n
    read (*, *) x, u
    if (u == "BTC") x = x * 380000
    res = res + x
  end do
  write (*, *) res
end program main


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  int n, i, j, v, u, k;
  int A[101][101];

  scanf("%d", &n);

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

  
  for(i=1; i<=n; i++){
    scanf("%d", &u);
    scanf("%d", &k);
    for(j=1; j<=k; j++){
      scanf("%d", &v);
      A[i][v] = 1;
    }
  }
  
  for(i=1; i<=n; i++){
    for(j=1; j<=n; j++){
      if(j != 1){
	printf(" ");
      }
      printf("%d", A[i][j]);
    }
    printf("\n");
  }
  
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m=1,i;
    cin>>n;
    int a[n],b[n]={0};
    for(i=0; i<n-1; i++)
    {
        cin>>a[i];
    }
    sort(a,a+(n-1));
    for(i=0; i<n-2; i++)
    {
        if(a[i]==a[i+1])
        {
            m++;
        }
        else
        {
            b[a[i]-1] = m;
            m=1;
        }
    }
    if(a[n-3]==a[n-2])
    {
        b[a[n-2]-1] = m;
    }
    else
    {
        b[a[n-2]-1] = 1;
    }
    for(i=0; i<n; i++)
    {
        cout<<b[i]<<endl;
    }
}


Measured memory_bytes: 5192
#include <cmath>
#include <iostream>
#include <map>
#include <string>
#include <vector>
#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;
  ll d;
  cin >> n >> d;
  ll x, y;
  int ans = 0;
  rep(i, n) {
    cin >> x >> y;
    if (x * x + y * y <= d * d) ++ans;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define do long double
using namespace std;
//桁
int kt(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }
signed main(){
  int a;
  cin>>a;
  cout<<(a+1)/2-1<<endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast","inline")
#include <bits/stdc++.h>
#define clr(x) memset(x,0,sizeof x)
#define For(i,a,b) for (int i=(a);i<=(b);i++)
#define Fod(i,b,a) for (int i=(b);i>=(a);i--)
#define fi first
#define se second
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define outval(x) cerr<<#x" = "<<x<<endl
#define outtag(x) cerr<<"---------------"#x"---------------"<<endl
#define outarr(a,L,R) cerr<<#a"["<<L<<".."<<R<<"] = ";\
						For(_x,L,R)cerr<<a[_x]<<" ";cerr<<endl;
using namespace std;
typedef long long LL;
typedef vector <int> vi;
LL read(){
	LL x=0,f=0;
	char ch=getchar();
	while (!isdigit(ch))
		f|=ch=='-',ch=getchar();
	while (isdigit(ch))
		x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return f?-x:x;
}
const int N=100005;
int n,m;
int a[N];
int fa[N];
int getf(int x){
	return fa[x]==x?x:fa[x]=getf(fa[x]);
}
vector <int> v[N];
vector <int> va,vb;
int main(){
	n=read(),m=read();
	For(i,1,n)
		a[i]=read();
	if (m==n-1)
		return puts("0"),0;
	For(i,1,n)
		fa[i]=i;
	For(i,1,m){
		int x=read()+1,y=read()+1;
		x=getf(x),y=getf(y);
		fa[x]=y;
	}
	For(i,1,n)
		v[getf(i)].pb(a[i]);
	For(i,1,n){
		if (v[i].empty())
			continue;
		sort(v[i].begin(),v[i].end());
		reverse(v[i].begin(),v[i].end());
		vb.pb(v[i].back());
		v[i].pop_back();
		while (!v[i].empty())
			va.pb(v[i].back()),v[i].pop_back();
	}
	sort(va.begin(),va.end());
	int cnt=(int)vb.size()-2;
	if (va.size()<cnt)
		return puts("Impossible"),0;
	LL ans=0;
	For(i,0,(int)vb.size()-1)
		ans+=vb[i];
	For(i,0,cnt-1)
		ans+=va[i];
	cout<<ans<<endl;
	return 0;
}


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

using namespace std;

int main() {
  int n;
  cin >> n;
  long long res = n;
  for (int i = 0; i < n - 1; i++) {
    int x, y;
    cin >> x >> y;
    if (x > y) swap(x, y);
    res -= (long long) x * (n - y + 1);
    res += (long long) (i + 1) * (n - i);
  }
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
 
int main(){
    int A,B;
    int cnt;
    cin >> A >> B;
    
    for (int i=0; i<400; i++){
        if ((1+(A-1)*i)>=B){
            cnt=i;
            break;
        } 
    }
    cout << cnt;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int n;
  int a[200];
  int st,sum=0;
    cin >> n;
  for(int i=0;i<n*2;i++){
    cin >> a[i];
  }
  for(int i=0;i<n*2;i++){
      for(int j=1;j<n*2;j++){
	if(a[j-1]<a[j]){
	  st=a[j-1];
	  a[j-1]=a[j];
	  a[j]=st;
	}
      }
  }
  for(int i=1;i<n*2;i+=2){
    sum+=a[i];
  }
  cout << sum << endl;
  return 0;
}


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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

int main()
{
    ll N, D; cin >> N >> D;
    ll D2 = D*D;

    ll ans = 0;
    rep(i,N){
        ll X, Y; cin >> X >> Y;
        if(X*X+Y*Y <= D2){
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3612
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <bitset>
#include <vector>
#include <queue>

using namespace std;

typedef long long ll;
#define FOR(i,a,b)   for(ll i = (a); i < (b); i++ )
#define REP(i, n)    FOR(i,0,n)
typedef pair< ll, ll >   cp2;
typedef pair< ll, cp2 >   cp3;
#define fi first
#define se second
#define sec  se.fi
#define thr  se.se
const ll mod = 1000000007;
//              123456789


///////////////////////////////////////////////
//
//
///////////////////////////////////////////////

////////////////////////////////////////////////
////////////////////////////////////////////////

int N;
string S[2];
string B;
bool J;
ll ans;

int main(){
	
	cin>>N;
	cin>>S[0]>>S[1];
	
	REP( i, N ){
		if( !i ){
			if( S[0][i] == S[1][i] ){
				ans = 1;
				J = false;
			}
			else{
				ans = 2;
				J = true;
				i++;
			}
			continue;
		}
		if( S[0][i] == S[1][i] ){
			if( !J ){
				(ans *= 2)%=mod;
			}
			J = false;
		}
		else{
			if( J ){
				(ans *= 3)%=mod;
			}
			else{
				(ans *= 2)%=mod;
			}
			J = true;
			i++;
		}
		//cout<<ans<<endl;
	}
	
	(ans*=3)%=mod;
	
	cout<<ans<<endl;
	
	return 0;
	
}

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

#define REP(i, N) for(int i = 0; i< N; i++)
using namespace std;

int fact(int n){
    int kekka = 1;
    REP(i,n ){
        kekka *= (i + 1);
    }
    return kekka;
}

int main(int argc, const char * argv[]) {
    int N, M;
    cin >> N >> M;
    int a[28];
    int b[28];
    REP(i, M){
        cin >>a[i] >> b[i];
    }
    int route[5040][8];
    REP(i, fact(N - 1)){
        route[i][0] = 1;
        int katamari = i ;
        vector<int> katamarisuuji;
        REP(j, N-1){
            katamarisuuji.push_back(j + 2);
        }
        REP(j, N - 2){
            int sanshou =(katamari) / fact(N - j - 2);
           // printf("%d,%d\n",sanshou,katamari);
            route[i][j + 1] = katamarisuuji[sanshou];
            katamarisuuji.erase(katamarisuuji.begin() + sanshou);
            katamari -=sanshou* fact(N - j - 2);
           // printf("%d", route[i][j + 1]);
        }
        route[i][N - 1] = katamarisuuji[0];
       // printf("\n");
    }
    int houhou = 0;
    int mitigaaru = 0;
    REP(i, fact(N - 1)){
        REP(j, N - 1){
            mitigaaru = 0;
            REP(k, M){
              //  printf("%d,%d\n", route[i][j], route[i][j+1]);
                if((route[i][j] == a[k] && route[i][j + 1] == b[k]) || (route[i][j] == b[k] && route[i][j + 1] == a[k])){
                    mitigaaru = 1;
                   // printf("aru\n");
                    break;
                }
            }
            if(mitigaaru == 0) {break;}
        }
        if(mitigaaru == 1) houhou++;
    }
    cout << houhou << endl;
}


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

bool comp(tuple<int, string, int> a,  tuple<int, string, int> b){
  
  if(std::get<1>(a) == std::get<1>(b)){
 	 return std::get<2>(a) > std::get<2>(b);
  }
  else{
    return std::get<1>(a) < std::get<1>(b);
  }
}

int main(){
  int N;
  cin >> N;
  vector<tuple<int, string, int>> scores(N);
  int score;
  string town;
  for(int i = 0; i < N; i++){
    cin >> town >> score;
    auto data = make_tuple(i + 1, town, score);
    scores.at(i) = data;
  }
  
  sort(scores.begin(), scores.end(),comp );
  
  for(int i = 0; i < N; i++){
    cout << get<0>(scores.at(i))<< endl;
  }
  
}


Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>

int main() {
  size_t N;
  scanf("%zu", &N);

  std::vector<unsigned> a(N), b(N);
  for (size_t i=0; i<N; ++i)
    scanf("%u", &a[i]);

  for (size_t i=0; i<N; ++i)
    scanf("%u", &b[i]);

  unsigned res=0;
  for (unsigned i=(1<<28); i; i>>=1) {
    std::sort(a.begin(), a.end(), std::greater<>());
    std::sort(b.begin(), b.end());

    size_t i1=0, i2=0, i3=0;
    unsigned cur=0;
    for (size_t j=0; j<N; ++j) {
      while (i1 < N && a[j] + b[i1] < 1*i) ++i1;
      while (i2 < N && a[j] + b[i2] < 2*i) ++i2;
      while (i3 < N && a[j] + b[i3] < 3*i) ++i3;
      cur += (i2-i1) + (N-i3);
    }
    if (cur & 1)
      res |= i;

    for (size_t j=0; j<N; ++j) {
      a[j] &= i-1;
      b[j] &= i-1;
    }
  }

  printf("%u\n", res);
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>

int main()
{
    int a, b;
    char op;
    std::vector<int> answers;
    while(scanf("%d %c %d", &a, &op, &b)) {
        if (op == '?') {
            break;
        }

        switch (op) {
        case '+':
        {
            answers.push_back(a + b);
            break;
        }
        case '-':
        {
            answers.push_back(a - b);
            break;
        }
        case '*':
        {
            answers.push_back(a * b);
            break;
        }
        case '/':
        {
            answers.push_back(a / b);
            break;
        }
        default:
        {
            break;
        }
        }
    }

    for (int r : answers) {
        std::cout << r << std::endl;
    }


    return 0;

}


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

using namespace std;
typedef long long ll;

int main () {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
	string s, t; cin >> s >> t;
  	cout << (t.substr(0, (int)(s.size())) == s ? "Yes" : "No") << endl;
  	return 0;
}


Measured memory_bytes: 3600
#include <iostream>
using namespace std;
typedef long long Int;

int main() {
    char _;
    Int n = 0, m = 0, s = 0, x, y;
    while (cin >> x >> _ >> y) {
        s += x*y;
        n += y;
        m += 1;
    }
    cout << s << endl;
    cout << (Int)((double)n/m+0.5) << endl;
    return 0;
}

Measured memory_bytes: 0
def calc(arr, flag)
  (1...arr.size).each{|i| arr[i] += arr[i-1] }
  if flag
    arr.each{ |v| $list[v].nil? ? $list[v] = 1 : $list[v] += 1 }
  else arr.each{ |v| $list[v].nil? ? next : ($list[v].class == Array ? $list[v][1] += 1 : $list[v] = [$list[v], 1]) }
  end
end
loop do
  $n, $m = gets.split.map(&:to_i)
  break if $n == 0
  $list = {}
  l = $n.times.map{ gets.to_i }
  k = $m.times.map{ gets.to_i }
  (0...$n).each{|i| calc(l[i..-1], true) }
  (0...$m).each{|i| calc(k[i..-1], false) }
  p $list.reduce(0){ |s, v| s += (v[1].class == Array ? v[1][0]*v[1][1] : 0) }
end

Measured memory_bytes: 86932
import sys
input = sys.stdin.readline

def main():
    N = int(input())
    h = list(map(int,input().split()))
    dp = [0 for _ in range(N)]
    dp[0] = 0
    dp[1] = abs(h[1]-h[0])
    cost = h
    for i in range(1,N-1):
        dp[i+1] = min(dp[i]+abs(cost[i+1]-cost[i]),\
            dp[i-1]+abs(cost[i+1]-cost[i-1]))
    print(dp[-1])

if __name__ == "__main__":
    main()

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

num = list(range(1, n+1))
num2 = list(range(1, n+1))
count = [0]*n

judge = 0

while True:
    for a in range(0, n):
        if num[a] % 2 == 0:
            judge += 1
            num[a] /= 2
            count[a] += 1
    if judge == 0:
        break
    judge = 0

mx = max(count)

for a in range(0, n):
    if count[a] == mx:
        ans = num2[a]
        break

print(ans)


Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <cmath>

#define	MOD 1000000007;
#define PI 3.14159265358979323846;

using namespace std;
typedef long long ll;
#define	MAX_NODE 8;

#define WHITE 0;
#define GRAY 1;
#define BLACK 2;

int P[9][9];

int N;
int totalCount = 0;
void dfs(int nodeID, int nodeCount, int color[])
{
	//cout << nodeID << endl;
	color[nodeID] = 2;
	if (nodeCount == N)
	{
		totalCount++;
	}

	for (int i = 1; i <= N; i++)
	{
		if (P[nodeID][i] == 1 && color[i] == 0)
		{
			dfs(i, ++nodeCount, color);
			color[i] = 0;
			nodeCount--;
		}
	}
}

int main()
{
	int  M;
	cin >> N >> M;
	int color[9];
	for (int i = 1; i <= N; i++)
	{
		color[i] = 0;
	}

	for (int i = 0; i < M; i++)
	{
		int n, m;
		cin >> n >> m;
		P[n][m] = 1;
		P[m][n] = 1;
	}

	dfs(1, 1, color);
	cout << totalCount << endl;
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using u64 = uint_fast64_t;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007;
//constexpr long long MOD = 998244353;
template<class T1, class T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return true;} return false; }
template<class T1, class T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return true;} return false; }
inline int popcount(int x) {return __builtin_popcount(x);}
inline int popcount(long long x) {return __builtin_popcountll(x);}
void print() { cout << "\n"; }
template<class T, class... Args>
void print(const T &x, const Args &... args) {
    cout << x << " ";
    print(args...);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////

struct UnionFind {
    int N;
    vector<int> node;

    UnionFind(){}
    UnionFind(int N) : N(N), node(N,-1) {}

    void init(int x) {
        node.assign(x,-1);
        N = x;
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (node[x] > node[y]) swap(x,y);
        node[x] += node[y];
        node[y] = x;
        N--;
        return true; 
    }

    bool same(int x, int y) {return root(x) == root(y);}

    int root(int x) {
        if (node[x] < 0) return x;
        return node[x] = root(node[x]);
    }

    int size(int x) {return -node[root(x)];}

    int count() const {return N;}
};

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N,H,W; cin >> N >> H >> W;
    vector<int> R(N),C(N),A(N);
    rep(i,N) {
        cin >> R[i] >> C[i] >> A[i];
        --R[i];
        --C[i];
    }

    vector<int> idx(N);
    iota(all(idx),0);
    sort(all(idx),[&](int i, int j){return A[i] > A[j];});
    UnionFind uf(H+W);
    vector<int> edge(H+W);
    ll ans = 0;
    rep(i,N) {
        int u = idx[i];
        if (uf.same(R[u],H+C[u])) {
            int r = uf.root(R[u]);
            if (edge[r] < uf.size(r)) {
                ans += A[u];
                edge[r]++;
            }
        } else {
            int r = uf.root(R[u]);
            int c = uf.root(H+C[u]);
            if (edge[r] == uf.size(r) and edge[c] == uf.size(c)) continue;
            uf.merge(r,c);
            ans += A[u];
            if (uf.root(r)==r) {
                edge[r] += edge[c]+1;
            } else {
                edge[c] += edge[r]+1;
            }
        }
    }

    cout << ans << ln;
}


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

int main(){
long long int n, a, b;    
    cin >> n >> a >> b;
    if(n % (a + b) > a ){
        cout << a + (n /(a + b))* a << endl; 
    }
    else{
        cout << n % (a + b) + (n /(a + b))* a << endl; 
    }
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int zettaiti(int x) {
	if (x < 0) return -x;
	else return x;
}

int main() {
	int a[5], min=0, sum=0;
	bool flg = true;

	cin >>a[0] >> a[1] >> a[2] >> a[3] >> a[4];


	for (int i = 0; i < 5; i++) { 
		if (a[i] % 10 != 0) {
			sum = i;
			break;
		}
	}

	for (int i = 0; i < 5; i++) {
		if(a[i]%10!=0) if ((a[i] % 10) < (a[min] % 10)) min = i;
	}

	for (int i = 0; i < 5; i++) {
		if (i != min) {
			sum += (a[i]/10) * 10;
			if(a[i] % 10!=0)sum += 10;
		}
	}

	sum += a[min];

	cout << sum;

	
}

Measured memory_bytes: 256
let [| N; M; C |] = stdin.ReadLine().Split() |> Array.map int
let B = stdin.ReadLine().Split() |> Array.map int

let rec solver r i =
    if i = N then r
    else
        let A = stdin.ReadLine().Split() |> Array.map int

        let s =
            Array.zip A B
            |> Array.map (fun x -> (fst x) * (snd x))
            |> Array.sum
        if s + C > 0 then solver (r + 1) (i + 1)
        else solver r (i + 1)

solver 0 0 |> stdout.WriteLine


Measured memory_bytes: 13268
using System;

namespace Circle
{
    class Class1
    {
        public static void Main()
        {
            double r = double.Parse(Console.ReadLine());
            double s = Math.PI * Math.Pow(r, 2);
            double l = Math.PI * 2 * r;
            Console.WriteLine("{0} {1}", s, l);
        }
    }
}



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

const double inf = 1e40;

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

    static int limit[40010];
    for (int i = 0; i < 40010; i++) limit[i] = (1 << 28);

    int sum = 0;
    for (int i = 0; i < N; i++) {
        for (int j = sum; j <= sum + t[i] * 2; j++) {
            limit[j] = min(limit[j], v[i] * 2);
        }
        sum += t[i] * 2;
    }

    static double dp[40010][300];
    for (int i = 0; i < 40010; i++) for (int j = 0; j < 300; j++) dp[i][j] = -inf;
    dp[0][0] = 0;
    for (int i = 0; i < sum; i++) { // 時間
        // cerr << "limit[" << i + 1 << "] " << limit[i + 1] << endl;

        for (int j = 0; j <= limit[i]; j++) {
            if (dp[i][j] < 0) continue;
            for (int k = -1; k <= 1; k++) {
                if (j + k < 0 or j + k > limit[i + 1]) continue;
                dp[i + 1][j + k] = max(dp[i + 1][j + k], dp[i][j] + 0.5 * double(2 * j + k) / 2.0);
            }
        }
    }
    cout << fixed << setprecision(10) << dp[sum][0] / 2 << endl;

    return 0;
}

Measured memory_bytes: 94208
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<vector>
#include<set>
#include<queue>
#include<cstdlib>
#include<algorithm>

using namespace std;
#define pb push_back
#define mp make_pair
#define ls(x) (x << 1)
#define rs(x) (x<<1|1)
#define SZ(x) (int)(x).size()

typedef long long LL;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<LL, LL> pll;

const double eps = 1e-10;
const double PI = acos(-1.0);
//const double PI = 3.14159265358979323846264338327950288419716939937510
int dcmp(const double &x) { if (fabs(x) < eps) return 0; return x < 0 ? -1 : 1; }
const int MOD = 1e9 + 7;
const int INF = 2e9;
const double INF_d = 1e64;

template<class T>
T qmod(T a, T b){ T ret = 1; while (b){ if (b & 1) ret *= a; b >>= 1; a *= a; } return ret; }
template<class T>
T gcd(T a, T b){ return !b ? a : gcd(b, a % b); }
template<class T>
T ex_gcd(T a, T b, T &x, T &y){
    if (!b){ x = 1, y = 0; return a; }
    T t, ret;
    ret = ex_gcd(b, a % b, x, y);
    t = x, x = y, y = t - a / b * y;
    return ret;
}
template<class T>
T inv(T t, T p){ return t == 1 ? 1 : (p - p / t) * inv(p % t, p) % p; }
// head

const int N = 1e6 + 7;
int n, L, a[N];
vector<int> res;

void solve(){
    deque<int> dq; while (!dq.empty()) dq.pop_back();
    for (int i = 0; i < n; i++){
        while (SZ(dq) && a[dq.back()] >= a[i]){
            dq.pop_back();
        }
        dq.push_back(i);
        int cpr = dq.back() - dq.front();
        while (cpr >= L){
            dq.pop_front(); cpr--;
        }
        if (i >= L - 1){
            res.pb(a[dq.front()]);
        }
    }
    for (int i = 0; i < SZ(res); i++){
        if (i) printf(" ");
        printf("%d", res[i]);
    }
    puts("");
}

int main(){
    scanf("%d%d", &n, &L);
    for (int i = 0; i < n; i++) scanf("%d", &a[i]);
    solve();
    return 0;
}




Measured memory_bytes: 10980
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    string x;
    cin >> x;
    vector<int> cnt;
    cnt.push_back(1);
    for (int i = 1; i < x.length(); i++) {
        if (x[i] == x[i - 1]) cnt.at(cnt.size() - 1)++;
        else {
            cnt.push_back(1);
        }
    }

    int ans = x.length();
    int s = 1;
    if (x[0] == 'T') s = 2;
    for (; s < cnt.size(); s += 2) {
        ans -= 2 * min(cnt.at(s - 1), cnt.at(s));
        if (cnt.at(s - 1) > cnt.at(s) && s + 1 < cnt.size()) {
            cnt.at(s + 1) += cnt.at(s - 1) - cnt.at(s);
        }
    }

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

Measured memory_bytes: 1024
#include<set>
#include<map>
#include<ctime>
#include<queue>
#include<cmath>
#include<climits>
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
#define LL long long
using namespace std;
int read(){
    int f=1,x=0;char s=getchar();   
    while(s<'0'||s>'9'){if(s=='-')f=-1;s=getchar();}  
    while(s>='0'&&s<='9'){x=x*10+s-'0';s=getchar();}
    return x*f;
}
#define MAXV 2000
#define MAXN 200000
#define INF 0x3f3f3f3f
#define Mod int(1e9+7)
LL fac[4*MAXV+5],inv[4*MAXV+5];
LL f[2*MAXV+5][2*MAXV+5],a[MAXN+5],b[MAXN+5];
LL Pow(LL x,LL y){
	LL ret=1;
	while(y){
		if(y&1) ret=ret*x%Mod;
		x=x*x%Mod;
		y>>=1;
	}
	return ret;
}
inline LL C(int n,int m){return fac[n]*inv[m]%Mod*inv[n-m]%Mod;}
int main(){
	int n=read();
	for(int i=1;i<=n;i++){
		a[i]=read(),b[i]=read();
		f[2001-a[i]][2001-b[i]]++;
	}
	for(int i=1;i<=4001;i++)
		for(int j=1;j<=4001;j++)
			f[i][j]=(f[i][j]+f[i-1][j]+f[i][j-1])%Mod;
	fac[0]=1;
	for(int i=1;i<=4*MAXV+2;i++)
		fac[i]=fac[i-1]*i%Mod;
	inv[4*MAXV+2]=Pow(fac[4*MAXV+2],Mod-2);
	for(int i=4*MAXV+1;i>=0;i--)
		inv[i]=inv[i+1]*(i+1)%Mod;
	LL ans=0;
	for(int i=1;i<=n;i++)
		ans=(ans+f[2001+a[i]][2001+b[i]])%Mod;
	for(int i=1;i<=n;i++)
		ans=((ans-C((a[i]+b[i])<<1,a[i]<<1))%Mod+Mod)%Mod;
	printf("%lld\n",ans*Pow(2,Mod-2)%Mod);
	return 0;
}

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

max = 0
next = 0
a = []
for i in range(n):
    temp = int(input())
    a.append(temp)
    if max < temp:
        next = max
        max = temp
    elif next < temp:
        next = temp

#print(a)
#print(max,next)

for i in a:
    if i == max:
        print(next)
    else:
        print(max)

Measured memory_bytes: 68952
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE OverloadedLists #-}

module Main where

import qualified Data.Text as T
import qualified Data.Text.IO as T
import Data.List

main :: IO ()
main = do
  input <- T.getLine
  putStrLn $ solve input

solve :: T.Text -> String
solve target = if target `elem` (map T.pack . permutations $ "abc")
  then "Yes"
  else "No"


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

int main()
{
	//freopen("in.txt","r",stdin);
	int n;
	cin>>n;
	int cnt=0;
	for(int i=1;i<=n;i++)
	{
		int temp;
		cin>>temp;
		if(i&1)
			if(temp&1)
				cnt++;

	}
	cout<<cnt<<endl;
	return 0;
}

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

int main(){
  int A,B,C,X;
  cin >> A >> B >> C >> X;
  int counter = 0;
  for(int i=0;i<=A;i++){
    for(int j=0;j<=B;j++){
      for(int k=0;k<=C;k++){
        if(500*i+100*j+50*k == X){
          counter ++;
        }
      }
    }
  }
  cout << counter << endl;
}


Measured memory_bytes: 256
/**
*	  Name: Ajay
*	  Institute: IIITH 
*/

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <deque>
#include <vector>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <ctime>
#include <string.h>
#define ll long long
#define inf 0x7fffffff
#define mod 1000000007
#define pb push_back
#define ppi pair<int,int>
#define vi vector<int>
#define vvi vector<vector<int>>
#define vii vector<ppi>
#define vll vector<ll>
#define mp make_pair
#define fi first
#define se second
using namespace std;

void fastio()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
}
void input()
{
  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  #endif
}
const int N=200005;

vi g[N];
int counter[N];
int lazy[N];
int vis[N];
void dfs(int u,int sum,int p)
{
	vis[u]=1;
	sum+=lazy[u];
	counter[u]+=sum;
	for(int v:g[u])
	{
		if(v==p) continue;
		if(!vis[v])
			dfs(v,sum,u);
	}
}

int main()
{      
  fastio();
  int n,q,a,b,p,x,i,j;
  cin>>n>>q;
  for(i=0;i<n-1;i++)
  {
  	cin>>a>>b;
  	g[a].pb(b);
  	g[b].pb(a);
  }
  for(i=0;i<q;i++)
  {
  	cin>>p>>x;
  	lazy[p]+=x;
  }
  dfs(1,0,-1);
  for(i=1;i<=n;i++)
  	cout<<counter[i]<<" ";
  return 0;
}

Measured memory_bytes: 24832
S = input()

X= ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i',
    'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r',
    's', 't', 'u', 'v', 'w', 'x', 'y', 'z']

ans = ''
for x in X:
    if x not in S:
        ans = x
        break

if ans == '':
    ans = 'None'
print(ans)

Measured memory_bytes: 3316
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0, -1, 1, 0 };
const ll dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
///////////////////////////////////////

int main() {
	ll w, h, x, y;
	cin >> w >> h >> x >> y;
	double ans = (double)(w)* h / 2;
	if (x*2==w && y*2==h) {
		cout << fixed << setprecision(10) << ans << " " << 1 << endl;
	}
	else {
		cout << fixed << setprecision(10) << ans << " " << 0 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue = BinaryHeap!(Array!long, "a<b");
// dfmt on

void main()
{
    long N = lread();
    auto S = sread();
    if (N & 1)
    {
        writeln("No");
        return;
    }
    if (S[0 .. $ / 2] == S[$ / 2 .. $])
    {
        writeln("Yes");
        return;
    }
    writeln("No");
}


Measured memory_bytes: 256
from collections import deque
n,x,y = map(int,input().split())
next = [[] for i in range(n)]
next[0].append(1)
next[n-1].append(n-2)
next[x-1].append(y-1)
next[y-1].append(x-1)
for i in range(1,n-1):
  next[i].append(i-1)
  next[i].append(i+1)

ans = [0] *(n-1)

for j in range(n):
  mark = ['inf']*(n)
  que = deque([j])
  mark[j] = 0
 
  while que:
    q = que.popleft()
    for k in next[q]:
      if mark[k] == 'inf':
        mark[k] = mark[q] + 1
        que.append(k)
  
  for l in range(0,n):
    if mark[l] != 0:
      ans[mark[l]-1] += 1

for x in ans:
  print(x//2)
      

Measured memory_bytes: 78708
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    int N, K;
    cin >> N >> K;
    double sum = 0;
    for (int i = 1; i <= N; i++) {
        double P;
        if (i >= K) P = 1.0L/N; else {
            double l = ceil(log2((double)K/i));
            P = 1.0/N * pow(1.0L/2, ceil(l));
        }
        sum += P; 
    }
    cout << fixed << setprecision(12);
    cout << sum << endl;
}


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

int main(){
    long long n,m;
    cin>>n>>m;
    priority_queue<pair<long long ,long long > > pq; 
    for(int i=0;i<n;i++){
        int a,b;
        cin>>a>>b;
        pq.push(make_pair(-a,b));
    }
    long long ans = 0;
    while(m>0){
        long long price = -pq.top().first;
        long long count = pq.top().second;
        if(count>=m){
            ans += price * m;
            m = 0;
        }else{
            m -= count;
            ans += price * count;
        }
        pq.pop();
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 2420
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>

using namespace std;
typedef long long ll;

int gcd(int x, int y) {
  if (x < y) swap(x, y);
  while (y > 0) {
    int r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//for(int i = ; i < ; i++){}

int main(){
    int n;
    cin>>n;
    int a[n];
    long max = 0;
    ll min = 1000000000;
    for(int i = 0; i<n; i++){
        cin>>a[i];
        if(a[i]<min) min=a[i];
        if(a[i]>max) max = a[i];
    }
    cout<<max-min<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<queue>
using namespace std;
const int N=1e5+10;
int n,m,head[N],cnt,deg[N],A,B,dis[N],ans;queue<int>q;
struct edge{int nxt,to;}ed[N];
inline void addedge(int x,int y){ed[++cnt].to=y;ed[cnt].nxt=head[x];head[x]=cnt;}
inline void topsort(){
	for(register int i=1;i<=n;i++)if(!deg[i])q.push(i);
	while(!q.empty()){
		int u=q.front();q.pop();
		for(register int i=head[u];i;i=ed[i].nxt){
			int v=ed[i].to;
			dis[v]=max(dis[v],dis[u]+1);ans=max(ans,dis[v]);
			if(--deg[v]==0)q.push(v);
		}
	}
}
int main(){
	scanf("%d%d",&n,&m);
	for(register int i=1;i<=m;i++)
		scanf("%d%d",&A,&B),addedge(A,B),deg[B]++;
	topsort();
	printf("%d\n",ans);
	return 0;
}

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

int getSign(int i){
    if(i>0){
        return 1;
    }else if (i<0){
        return -1;
    }else{
        return 0;
    }
}

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i=0;i<N;i++){
  	cin >> A[i];
  }
  int pre=A[0];
  int sign0=0;
  int sign1;
  int cnt=1;
  for (int i=1;i<N;i++){
  sign1=getSign(A[i]-pre);
    if(sign0*sign1<0){
    cnt++;
  sign0=0;
  }else{
  if(sign0==0 and sign1 !=0)sign0=sign1;  
    }
  pre=A[i];  
  }
 cout <<cnt <<endl;
  return 0;
  
}


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

#define endl "\n"
#define ll long long int

const int MAX = 1000001;

int factor[MAX] = {0};

void generatePrimeFactors()
{
    factor[1] = 1;
    for (int i = 2; i < MAX; i++)
        factor[i] = i;
    for (int i = 4; i < MAX; i += 2)
        factor[i] = 2;
    for (int i = 3; i * i < MAX; i++)
    {
        if (factor[i] == i)
        {
            for (int j = i * i; j < MAX; j += i)
            {
                if (factor[j] == j)
                    factor[j] = i;
            }
        }
    }
}
int calculateNoOFactors(int n)
{
    if (n == 1)
        return 1;

    int ans = 1;
    int dup = factor[n];

    int c = 1;

    int j = n / factor[n];

    while (j != 1)
    {
        if (factor[j] == dup)
            c += 1;

        else
        {
            dup = factor[j];
            ans = ans * (c + 1);
            c = 1;
        }

        j = j / factor[j];
    }

    ans = ans * (c + 1);

    return ans;
}

void solve(ll caseNo)
{
    generatePrimeFactors();
    int n;
    cin >> n;

    int cnt = 0;
    for(int i=1;i<n;i++)
    {
        int rem = n - i;
        int fact_cnt = calculateNoOFactors(rem);
        cnt += fact_cnt;
    }
    cout << cnt << endl;
}

int main()
{

    ll cases;
    cases = 1;
    for (ll i = 1; i <= cases; i++)
    {
        solve(i);
    }
    return 0;
}

Measured memory_bytes: 7560
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define Rep(i, r, n) for (ll i = r; i < n; i++)
#define pb push_back
#define MOD 1000000007
#define INF 1000000000000
#define EPS 0.00000000001
typedef long long ll;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    //---------------------------------------------
    int a,b;
    cin>>a>>b;
    cout<<(a-1)*(b-1)<<endl;
    
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;

int main() {
    ll n;
    cin >> n;
    
    vl a(n);
    rep(i, n) {
        cin >> a[i];
    }

    deque<ll> d;
    rep(i, n) {
        ll p = lower_bound(d.begin(), d.end(), a[i]) - d.begin();
        if(p == 0) {
            d.push_front(a[i]);
        }
        else {
            d[p-1] = a[i];
        }
    }

    out(d.size());
    re0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()
#define pb push_back

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;
}
constexpr int mod = 1e9+7;
constexpr int inf = 3e18;

int mod_pow(int x,int y,int m=mod){
	int res=1;
	while(y>0){
		if(y&1)(res*=x)%=m;
		(x*=x)%=m;
		y>>=1;
	}
	return res;
}
vector<int>perm,inv;
void init_perm(){
	int x=1e6+1;perm.resize(x);inv.resize(x);
	perm[0]=1;
	REP(i,x+1)perm[i]=perm[i-1]*i%mod;
	inv[x]=mod_pow(perm[x],mod-2);
	for(int i=x-1;i>=0;i--){
		inv[i]=inv[i+1]*(i+1)%mod;
	}
}
int nCk(int x,int y){
	if(x<y)return 0;
	return perm[x]*inv[x-y]%mod*inv[y]%mod;
}
int H,W,N;
vector<P>v;
int dp[3005][2];
signed main(){
	init_perm();
	cin>>H>>W>>N;
	v.resize(N);
	rep(i,N)cin>>v[i].first>>v[i].second;
	v.pb({1,1});v.pb({H,W});
	sort(all(v));
	dp[0][0]=1;
	rep(i,len(v)){
		for(int j=i+1;j<len(v);j++){
			int difX=v[j].first-v[i].first;
			int difY=v[j].second-v[i].second;
			if(difX>=0&&difY>=0){
				rep(k,2)(dp[j][k^1]+=dp[i][k]*nCk(difX+difY,difX)%mod)%=mod;
			}
		}
	}
	cout<<(dp[N+1][1]-dp[N+1][0]+mod)%mod<<endl;
}


Measured memory_bytes: 19092
N=int(input())
ls=[[0]*9 for _ in range(9)]
for i in range(1,N+1):
  a=i
  while a//10!=0:
    a//=10
  b=i%10
  if b!=0:
    ls[a-1][b-1]+=1 
ans=0    
for i in range(1,10):
  for j in range(1,10):
    ans+=ls[i-1][j-1]*ls[j-1][i-1]
print(ans)

Measured memory_bytes: 3064