akhauriyash/Code-Regression huggingface dataset:
from itertools import permutations
import sys
input = sys.stdin.readline
 

def main():
 
    input = sys.stdin.readline
 
    n = int(input())
    p = tuple(map(int, input().split()))
    q = tuple(map(int, input().split()))
 
    L = list(permutations(list(range(1, n + 1))))
    print(abs(L.index(p) - L.index(q)))
 
 
if __name__ == "__main__":
    main()

Measured memory_bytes: 70176
r=[*$<];a,b,c=r[0,8].sort_by{|t|t.split[1].to_f},r[8,8].sort_by{|t|t.split[1].to_f},r[16,8].sort_by{|t|t.split[1].to_f};puts a[0,2],b[0,2],c[0,2];*u=*a[2,6],*b[2,6],*c[2,6];
puts u.sort_by{|t|t.split[1].to_f}[0,2]


Measured memory_bytes: 6860
a, b, c = map(int, input().split())
cnt = 0
if a % 2 != 0 or b % 2 != 0 or c % 2 != 0:
  print(0)
  exit()
if a == b and b == c:
  print(-1)
  exit()
while cnt >= 0:
  if a % 2 != 0 or b % 2 != 0 or c % 2 != 0:
    print(cnt)
    exit()
  else:
    a1 = (b + c) // 2
    b1 = (a + c) // 2
    c1 = (a + b) // 2
    a = a1
    b = b1
    c = c1
    cnt += 1
print(cnt)

Measured memory_bytes: 3064
n, q = gets.chomp.split(" ").map{|s| s.to_i}

avs = (0...n).map{|a| [a, 0]}
avcache = {}

max_a, max_v = avs[0]

q.times.each do
  a, v = gets.chomp.split(" ").map{|s| s.to_i}
  a -= 1

  av_a = avs[a]
  v_a = (av_a[1] += v)

  if v > 0
    avcache[a] = av_a if avcache[a].nil?
    if max_v < v_a || (max_v == v_a && max_a > a)
      max_v = v_a
      max_a = a
    end
  else
    avcache.delete(a) if v_a <= 0
    if max_a == a
      if avcache.empty?
        max_a, max_v = avs[0]
      else
        max_a, max_v =
          avcache.values.max do |a, b|
            vcmp = a[1] <=> b[1]
            (vcmp != 0) ? vcmp : (b[0] <=> a[0])
          end
      end
    end
  end

  #p avs
  puts [max_a + 1, max_v].join(" ")
end

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

uint_fast32_t N, M, a[101010], A;

constexpr uint_fast32_t z = static_cast<uint_fast32_t>('0'), n = static_cast<uint_fast32_t>('9');
template<class T>
void uread(T& x){
    do{
        x = static_cast<T>(fgetc(stdin));
    }while(z > x || x > n);
    x -= z;
    T c = static_cast<T>(fgetc(stdin));
    while(z <= c && c <= n){
        x = x * 10 + c - z;
        c = static_cast<T>(fgetc(stdin));
    }
}

int main(){
    scanf("%u%u", &N, &M);
    for(int i = N; i; --i){
        uread(a[i]);
        a[i] += a[i + 1];
        a[i] %= M;
    }
    sort(a, a + N + 1);
    for(int i = 1, j = 0; i <= N; ++i){
        if(a[i] != a[i - 1])j = -1;
        A += ++j;
    }
    cout << A << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<stack>
#include<iostream>
#include<string>
#include<cstdlib>

using namespace std;

int main(void)
{
	stack<int>st;

	string str;

	int b,c,d,e,f,g;

	while(cin >> str){
		if(str[0] == '+'){
			 b = st.top();
             st.pop();
			 c = st.top();
			 st.pop();
			 st.push(b+c);
		}else if(str[0] == '-'){
			 d = st.top();
             st.pop();
			 e = st.top();
			 st.pop();
			 st.push(e-d);
		}else if(str[0] == '*'){
			 f = st.top();
             st.pop();
			 g = st.top();
			 st.pop();
			 st.push(f*g);
		}else{
		st.push(atoi(str.c_str()));
		}
	}

	cout << st.top() << endl;


	return 0;
} 

Measured memory_bytes: 1196
def check(num):
  if num > 1:
    for i in range(2,num):
      if (num % i) == 0:
        return False
        break
    else:
      return True
  else:
    return False

a = int(input())
for i in range(a,100500):
  if check(i):
    print(i)
    break


Measured memory_bytes: 2940
<?php
    $N = intval(trim(fgets(STDIN)));
    
    $AC=0;
    $RE=0;
    $WA=0;
    $TLE=0;
    
    for($i=0;$i<$N;$i++){
        $ans = trim(fgets(STDIN));
        
        if($ans == "AC"){
            $AC++;
        }elseif($ans == "TLE"){
            $TLE++;
        }elseif($ans == "WA"){
            $WA++;
        }elseif($ans == "RE"){
            $RE++;
        }
        
    }
    
    echo "AC x ".$AC."\n";
    echo "WA x ".$WA."\n";
    echo "TLE x ".$TLE."\n";
    echo "RE x ".$RE."\n";
?>

Measured memory_bytes: 16228
#include <iostream>
#include <vector>
#include <unordered_set>
#include <numeric>

using namespace std;


class Solution{

private:
    int H, W;

public:
    vector<long long> freq(int H, int W, const unordered_set<long long>& set){

        this->H = H, this->W = W;

        vector<unordered_set<long long>> res(10);
        for(long long black: set){
            long long x = black / W, y = black % W;
            for(int d1 = 0; d1 <= 2; d1 ++)
                for(int d2 = 0; d2 <= 2; d2 ++)
                    if(in_area(x + d1 - 2, y + d2 - 2) && in_area(x + d1, y + d2)){

                        int cnt = 0;
                        for(int i = x + d1 - 2; i <= x + d1; i ++)
                            for(int j = y + d2 - 2; j <= y + d2; j ++)
                                cnt += set.count((long long)i * W + j);
                        res[cnt].insert((long long)(x + d1 - 2) * W +(y + d2 - 2));
                    }
        }

        vector<long long> ret(10, 0ll);
        for(int i = 1; i < 10; i ++) ret[i] = res[i].size();
        ret[0] = (long long)(H - 2) * (W - 2) - accumulate(ret.begin() + 1, ret.end(), 0ll);
        return ret;
    }

private:
    bool in_area(int x, int y){
        return x >= 0 && x < H && y >= 0 && y < W;
    }
};

int main() {

    int H, W, N;
    scanf("%d%d%d", &H, &W, &N);

    unordered_set<long long> set;
    long long a, b;
    while(N --){
        scanf("%lld%lld", &a, &b);
        a --, b --;
        set.insert(a * W + b);
    }

    vector<long long> res = Solution().freq(H, W, set);
    for(long long e: res) printf("%lld\n", e);

    return 0;
}


Measured memory_bytes: 47760
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string s;
    cin>>s;
    int n=s.size()-2;
    for(int i=n/2;i>=0;i--){
        if(s.substr(0,i)==s.substr(i,i)){cout<<i*2<<endl; return 0;}
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
const int maxn=2e3+5;
typedef long long ll;
ll dp[maxn][maxn];
int n;
pair<int,int> a[maxn];
inline bool cmp1(pair<int,int> a1,pair<int,int> b1){
	return a1.first>b1.first;
}
int main(){
	cin>>n;
	for (int i=1;i<=n;i++){
		scanf("%d",&a[i].first);
		a[i].second=i;
	}
	sort(a+1,a+n+1,cmp1);
	memset(dp,0xf3,sizeof(dp));
	dp[0][0]=0;
	ll ans=-1e14;
	for (int len=1;len<=n;len++){
		for (int l=0;l<=len;l++){
			int r=len-l;
			int ot=n-r+1;
			if (l) dp[l][r]=max(dp[l][r],dp[l-1][r]+1ll*(a[len].second-l)*a[len].first);
			if (r) dp[l][r]=max(dp[l][r],dp[l][r-1]+1ll*(ot-a[len].second)*a[len].first);
			if (len==n) ans=max(ans,dp[l][r]);
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 35192
#include<iostream>
#include<cstdio>
#include<vector>


int main() {
	int w, n;
	std::cin >> w >> n;
	std::vector<int> vl(w+1);
	for (int i = 1; i < w+1; i++) {
		vl[i] = i;
	}
	for (int j = 0; j < n; j++) {
		int a, b, c;
		std::scanf("%d,%d", &a, &b);
		c = vl[a];
		vl[a] = vl[b];
		vl[b] = c;
	}
	for (int i = 1; i < w + 1; i++) {
		std::cout << vl[i] << std::endl;
	}
}

Measured memory_bytes: 3140
N,M = map(int,input().split())

A = []
B = []
C = []

for i in range(M):
    a,b,c = map(int,input().split())
    a -= 1
    b -= 1
    A.append(a)
    B.append(b)
    C.append(c)
inf = 10**18
dist = [[inf]*N for i in range(N)]

for i in range(N):
    for j in range(N):
        if i == j:
            dist[i][j] = 0

for i in range(M):
    dist[A[i]][B[i]] = C[i]
    dist[B[i]][A[i]] = C[i]

for k in range(N):
    for i in range(N):
        for j in range(N):
            dist[i][j] = min(dist[i][j],dist[i][k] + dist[k][j])
ans = 0
for i in range(M):
    if C[i] > dist[A[i]][B[i]]:
        ans += 1

print(ans)





Measured memory_bytes: 73328
import itertools
n = int(input())
temp = []
for i in range(n):
    x, y = map(int, input().split())   
    temp.append([x,y])

def distance(x1, y1, x2, y2):
    return (abs(x1-x2)**2 + abs(y1-y2)**2)**0.5

T = list(itertools.permutations(temp))

ans = 0
cnt = 0
for i in T:
    t = 0
    for j in range(1, len(i)):
        t += distance(i[j-1][0], i[j-1][1], i[j][0], i[j][1])
    cnt += 1
    ans += t
print(ans/cnt)

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

int main(void){

    int N, Q; cin>>N>>Q;
    string S; cin>>S;

    vector<int> a(N, 0);
    int sum=0;
    for (int i = 0; i < N-1; ++i) {
        if(S[i]=='A' && S[i+1]=='C'){
            sum++;
        }
        a[i] = sum;
    }

    for (int i = 0; i < Q; ++i) {
        int L, R; cin>>L>>R;
        cout<<a[R-2]-a[L-2]<<endl;
    }


    return 0;
}

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

int main() {
    double n,d;
    cin>>n>>d;
    double ans = ceil(n/(2*d+1));
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int x , y, i, j;
	while(1){
		scanf("%d %d", &x, &y);
		for(i = 0; i < x; i++){
			for(j = 0; j < y; j++){
				if(i % 2 == 0){
					if( j % 2 == 0){
						putchar('#');
					}
					if(j % 2 == 1){
						putchar('.');
					}
				}
				if(i % 2 == 1){
					if(j % 2 == 0){
						putchar('.');
					}
					if(j % 2 == 1){
						putchar('#');
					}
				}
				
				if(j == y-1){
					putchar('\n');
				}
			}
		}
		if(x == 0 && y==0){
			break;
		}
		putchar('\n');
	}
	
	
	return 0;
}

Measured memory_bytes: 572
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <map>
#include <algorithm>
#include <queue>

using namespace std;

const int INF = 200*100 + 100;

struct Dict {
    map<string,int> dict;
    int id;

    Dict() : id(0) {}

    int get(const string &str) {
        if(dict.count(str)) return dict[str];
        return dict[str] = id++;
    }

    int size() const { return id; }
};

bool dfs(int pos, int val, const vector<vector<pair<int,int> > > &graph, vector<int> &dist) {
    if(dist[pos] != INF) return dist[pos] == val;
    dist[pos] = val;
    const vector<pair<int,int> > &edges = graph[pos];
    for(vector<pair<int,int> >::const_iterator it = edges.begin(); it != edges.end(); ++it) {
        int nc = val + it->second;
        if(!dfs(it->first, nc, graph, dist)) return false;
    }
    return true;
}

vector<vector<pair<int,int> > > v(200);
vector<int> dist(200);
vector<unsigned char> visited(200);

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    while(true) {
        int N;
        cin >> N;
        if(!N) break;
        cin.ignore();
        for(int i = 0; i < 2*N; ++i) {
            v[i].clear();
        }
        Dict dict;
        for(int i = 0; i < N; ++i) {
            string line;
            getline(cin, line);
            for(string::iterator it = line.begin(); it != line.end(); ++it) {
                if(*it == '=' || *it == '^') *it = ' ';
            }
            istringstream is(line);
            string unit_left, unit_right;
            int ord;
            int tmp;
            is >> tmp >> unit_left >> tmp >> ord >> unit_right;
            //sscanf(line.c_str(), "%*d %s = %*d^%d %s ", unit_left, &ord, unit_right);
            const int id_left = dict.get(string(unit_left));
            const int id_right = dict.get(string(unit_right));
            v[id_left].push_back(make_pair(id_right, ord));
            v[id_right].push_back(make_pair(id_left, -ord));
        }

        const int M = dict.size();
        bool ok = true;
        fill(dist.begin(), dist.end(), INF);
        for(int i = 0; i < M; ++i) {
            if(dist[i] == INF) {
                if(!dfs(i, 0, v, dist)) {
                    ok = false;
                    break;
                }
            }
        }

        if(!ok) {
            cout << "No" << endl;
        } else {
            cout << "Yes" << endl;
        }
    }
    return 0;
}

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

using namespace std;

#define FOR0(i, a, b, s) for (int i = a; s > 0 ? i < b : i > b; i += s)
#define FOR1(n) FOR0(i, 0, n, 1)
#define FOR2(i, n) FOR0(i, 0, n, 1)
#define FOR3(i, a, b) FOR0(i, a, b, 1)
#define FOR4(i, a, b, s) FOR0(i, a, b, s)
#define GET5(_1, _2, _3, _4, _5, ...) _5
#define FOR(...) GET5(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  FOR(n) cin >> a[i];
  FOR(i, k, n) {
    if (a[i - k] < a[i])
      cout << "Yes" << '\n';
    else
      cout << "No" << '\n';
  }
  return 0;
}

Measured memory_bytes: 3988
#include <iostream>

using namespace std;

int main(void)
{
    int N = 0; cin >> N;

    string s; cin >> s;

    int count = 1;

    for(auto ptr = s.begin() + 1; ptr != s.end(); ++ptr) {
        if(*ptr != *(ptr - 1)) {
            count++;
        }
    }

    cout << count << endl;

    return 0;
}


Measured memory_bytes: 512
import collections
n = int(input())
aa = list(map(int, input().split()))
ca = collections.Counter(aa)
la = sorted([a for a in ca.items()], key = lambda x:x[0], reverse=True)

list1 = []
list2 = []

for a in la:
  if a[1] > 1:
    list1.append(a)
  if a[1] >3:
    list2.append(a)
    
if len(list1) > 1:    
    xr = list1[0][0] * list1[1][0]
else:
  xr = 0
    
if len(list2) > 0:
  xs = list2[0][0] * list2[0][0]
else:
  xs = 0
  
ans = max(xr, xs)

print(ans)

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

int main() {
    string S;
    cin >> S;
    bool a = true;
    for(int i=0;i<S.size();i+=2){
        if(S.at(i)!='R'&&S.at(i)!='U'&&S.at(i)!='D'){
            a=false;
            break;
        }
    }    
    for(int i=1;i<S.size();i+=2){
        if(S.at(i)!='L'&&S.at(i)!='U'&&S.at(i)!='D'){
            a=false;
            break;
        }        
    }  
    if(a==true) cout << "Yes" << endl;
    else cout << "No" <<endl;  
    
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>

using namespace std;

int main(int argc, const char *argv[]) {
  int n;
  cin >> n;

  vector<int> p(n), q(n);
  for (int i = 0; i < n; i++) {
    cin >> p[i];
  }

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

  vector<int> perm(n);
  iota(perm.begin(), perm.end(), 1);
  int i = 0, p_order, q_order;
  do {
    bool eq_p = equal(perm.begin(), perm.end(), p.begin());
    bool eq_q = equal(perm.begin(), perm.end(), q.begin());
    if (eq_p) {
      p_order = i;
    }
    if (eq_q) {
      q_order = i;
    }

    i++;
  } while (next_permutation(perm.begin(), perm.end()));

  cout << abs(p_order - q_order) << "\n";
  return 0;
}

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

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

  double ans = 0.0;
  for (double n : v) ans += 1.0 / n;
  cout << fixed << setprecision(10) << 1.0 / ans << endl;
}


Measured memory_bytes: 256
import math
a, b, c = map(int, input().split())
l = []; d = int(math.sqrt(c)); e = 0
for i in range(1, d + 1):
	if i * i == c: l += [i]
	elif c % i == 0: l += [i, c // i]
for x in l:
	if a <= x <= b: e += 1
print(e)

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

/*構造体の宣言
key : 0以上の整数値
*next : struct node型のアドレスを記憶するポインタ変数
*prev : struct node型のアドレスを記憶するポインタ変数
*/
struct node{
  unsigned int key;
  struct node *next;
  struct node *prev;
};

typedef struct node* NodePointer; //struct node* 型と同じ意味を持つ, NodePointer型を定義

NodePointer nil; //新たなnodeのアドレスを記憶するポインタ変数

/*双方向リストの要素の探索
リストを一周するかkeyを見つけるまでループを回す*/
NodePointer listSearch(int key){
	NodePointer cur = nil->next; //番兵の次の要素からたどる
	while(cur != nil && cur->key != key){
		cur = cur->next;
	} //curのnextだけを変更しているのでリスト自体には何の影響もない
	return cur;
}

/*双方向リストの初期化を行う関数
番兵を生成し, prevとnextを番兵につなげて空のリストを生成*/
void init(){
  nil = malloc(sizeof(struct node)); //nodeのサイズだけメモリを確保する
  nil->next = nil; //nillが指すnodeのメンバであるポインタ変数nextにnillを入れる
  nil->prev = nil; //nillが指すnodeのメンバであるポインタ変数prevにnillを入れる
}

void printList(){
  NodePointer cur = nil->next;
  int isf = 1;
  while(1){
    if ( cur == nil ) break;
    if ( isf == 0)  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}

/*双方向リストの要素の削除
引数のtのnextのprevとprevのnextを繋いで要素を削除する*/
void deleteNode(NodePointer t){
  if(t == nil) return; //nillが番兵の場合処理しない
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t); //メモリ割り当ての解放
}

/*リストの最初を削除する*/
void deleteFirst(){
  NodePointer t = nil->next;
  if ( t == nil ) return;
  deleteNode(t);
}

/*リストの最後を削除する*/
void deleteLast(){
  NodePointer t = nil->prev;
  if ( t == nil ) return;
  deleteNode(t);
}

/*指定したkeyのリストを削除する*/
void delete(int key){
  NodePointer t = listSearch(key);
  deleteNode(t);
}

/*双方向リストへの要素の挿入
先にnillのnextのnextとprevを変更してから, nillのnextとprevを変更*/
void insert(int key){
  NodePointer x; //新たなnodeのアドレスを記憶するポインタ変数
  x = malloc(sizeof(struct node)); //nodeのサイズだけメモリを確保する
  x->key = key; //xが指すnodeのメンバkeyに引数のkeyを代入する
  x->next = nil->next; //xのnextをnillのnextにする
  nil->next->prev = x; //nillのnextのprevをxにする
  nil->next = x; //nillのnextをxにする
  x->prev = nil; //xのprevをnillにする
}

int main(){
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ){
    scanf("%s%d", com, &key);
    if ( com[0] == 'i' ) {insert(key); np++; size++;}
    else if ( com[0] == 'd' ) {
      if (strlen(com) > 6){
	if ( com[6] == 'F' ) deleteFirst();
	else if ( com[6] == 'L' ) deleteLast();
      } else {
	delete(key); nd++; 
      }
      size--;
    }
  }

  printList();
  return 0;
}


Measured memory_bytes: 32960
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("YES")
#define p_no() p("NO")

template < typename T >
void vprint(T &V){
	for(auto v : V){
    	cout << v << " ";
	}
	cout << endl;
}

int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, 1, 0, -1};

const ll mod = 1e9 + 7;
const ll inf = 1e18;

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

    // input
    ll A, B, C;
    cin >> A >> B >> C;

    vector<ll> D;
    D.push_back(A);
    D.push_back(B);
    D.push_back(C);

    sort(ALL(D));

    if(D[2]%2==0){
        p(0);
    }else{
        p(D[0]*D[1]);
    }
    
    return 0;
}

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

typedef long long int ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;

#define endl '\n'
#define ff first
#define ss second
#define sz(v) (int)v.size()
#define int long long
#define pb push_back
#define f(i,l,r) for(ll i=l;i<=r;i++)
#define rf(i,r,l) for(ll i=r;i>=l;i--)
#define Max 5000001
#define inf 2147483647
#define llinf 9223372036854775807
#define all(v) v.begin(),v.end()
#define bp(n) __builtin_popcountll(n)
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)

#define d0(a) cout<<a<<' ';
#define d1(a) cout<<a<<endl;
#define d2(a,b) cout<<a<<' '<<b<<endl;
#define d3(a,b,c) cout<<a<<' '<<b<<' '<<c<<endl;
#define d4(a,b,c,d) cout<<a<<' '<<b<<' '<<c<<' '<<d<<endl;
#define d5(a,b,c,d,e) cout<<a<<' '<<b<<' '<<c<<' '<<d<<' '<<e<<endl;
#define d6(a,b,c,d,e,f) cout<<a<<' '<<b<<' '<<c<<' '<<d<<' '<<e<<' '<<f<<endl;

const ll N=1e5+5,mod=1e9+7,bit=61;



signed main()
{
    fast;

    ll t=1;
    //cin>>t;
    while(t--)
    {
        string s,s1;
        cin>>s>>s1;
        ll n=s.length();
        string m=s1.substr(0,n);
        if(m==s)
        {
            cout<<"Yes\n";
        }
        else
        {
            d1("No");
        }
    }
    return 0;
}


















Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
long long n;
vector<int> ok;
long long a[4],b[4];
long long dp[6000],pd[26000000];
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n>>a[1]>>a[2]>>a[3];
	cin>>b[1]>>b[2]>>b[3];
	if(a[1]<b[1])
		ok.push_back(1);
	if(a[2]<b[2])
		ok.push_back(2);
	if(a[3]<b[3])
		ok.push_back(3);
	long long v=0;
	memset(dp,-1,sizeof(dp));
	dp[n]=0;
	for(int i=n;i>=1;i--){
		if(dp[i]==-1)
			continue;
		for(int j=0;j<ok.size();j++){
			if(i>=a[ok[j]]){
				dp[i-a[ok[j]]]=max(dp[i-a[ok[j]]],dp[i]+b[ok[j]]);
			}
		}
		v=max(v,dp[i]+i);
	}
	v=max(v,dp[0]);
	ok.clear();
	if(a[1]>b[1])
		ok.push_back(1);
	if(a[2]>b[2])
		ok.push_back(2);
	if(a[3]>b[3])
		ok.push_back(3);
	n=v;
	memset(pd,-1,sizeof(pd));
	pd[n]=0;
	for(int i=n;i>=1;i--){
		if(pd[i]==-1)
			continue;
		for(int j=0;j<ok.size();j++){
			if(i>=b[ok[j]]){
				pd[i-b[ok[j]]]=max(pd[i-b[ok[j]]],pd[i]+a[ok[j]]);
			}
		}
		v=max(v,pd[i]+i);
	}
	v=max(v,pd[0]);
	cout<<v<<endl;
	return 0;
}


Measured memory_bytes: 203392
def main():
    A, B, C, D = map(int, input().split())
    for i in range(500):
        if i % 2 == 0:
            C -= B
        else:
            A -= D
        if (A < 1) or (C < 1):
            if i % 2 == 0:
                print('Yes')
            else:
                print('No')
            exit()


if __name__ == '__main__':
    main()


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

int main() {
	long double h, w, x, y;
	cin >> w >> h >> x >> y;
	
	if(x == w/2 && y == h/2) cout << (h*w)/2 << " " << 1;
	else cout << (h*w)/2 << " " << 0;
	// your code goes here
	return 0;
}

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

using namespace std;

int main()
{ int x; int y;int z;int temp;
cin >>x; cin >> y;

if (y >x){
        temp = y;
        y= x;
        x = temp;



}
z = y;
if (x>=y){
    for(int i =1 ;i<x;i++){

        z= z*10;

        z= z+y;

    }
    cout << z<<endl;
}

return 0;
}


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

int N;
int x[10], y[10];

int main(){

    
    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;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.stream.LongStream;
import java.util.Arrays;
class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        long[] x = new long[N];
        long[] s = new long[N];
        for(int i=0;i<N;++i){
            x[i] = scan.nextLong();
            s[i] = scan.nextLong();
        }
        long[] dp = new long[N];
        Arrays.fill(dp, Long.MIN_VALUE);
        dp[0] = s[0];
        long ans = dp[0];
        for(int i=1;i<N;++i){
            dp[i] = Math.max(s[i], s[i]+dp[i-1] - (x[i] - x[i-1]));
            ans = Math.max(ans, dp[i]);
        }
        System.out.println(ans);

    }
}

Measured memory_bytes: 114388
#define _CRT_SECURE_NO_WARNINGS
#define MaxSize 16777215
#include <stdio.h>
#include <stdlib.h>


void insert(char *D, char s[]) {
	int i = -1;
	char c;
	int p = -1;
	while (c = s[++i]) {
		switch (c) {
		case 'A':
			p *= 4;
			p += 4;
			break;
		case 'C':
			p *= 4;
			p += 5;
			break;
		case 'G':
			p *= 4;
			p += 6;
			break;
		case 'T':
			p *= 4;
			p += 7;
			break;
		}
	}
	D[p] = 'Y';
}

int find(char *D, char s[]) {
	int i = -1;
	char c;
	int p = -1;
	while (c = s[++i]) {
		switch (c) {
		case 'A':
			p *= 4;
			p += 4;
			break;
		case 'C':
			p *= 4;
			p += 5;
			break;
		case 'G':
			p *= 4;
			p += 6;
			break;
		case 'T':
			p *= 4;
			p += 7;
			break;
		}
	}
	return D[p] == 'Y';
}

int main() {
	char *D = (char *)malloc(sizeof(char) * MaxSize);
	int i;
	for (i = 0; i < MaxSize; ++i) {
		D[i] = 'N';
	}

	char com[7];
	char s[13];
	int n;
	scanf("%d", &n);
	for (i = 0; i < n; ++i) {
		scanf("%s%s", com, s);
		if (com[0] == 'i') {
			insert(D, s);
		}
		else {
			if (find(D, s)) {
				printf("yes\n");
			}
			else {
				printf("no\n");
			}
		}
	}


	free(D);

	return 0;
}

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



int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
	string x,y;
  cin >> x >> y;
  if(x==y) cout << "=" << endl;
  else if(x>y) cout << ">" << endl;
  else cout << "<" << endl;

  return 0;
    

}

Measured memory_bytes: 256
tap = input()
ans = 'Yes'
for i in range(1,len(tap)+1):
  if i%2 == 0:
    if tap[i-1] == 'R':
      ans = 'No'
      break
  else:
    if tap[i-1] == 'L':
      ans = 'No'
      break
print(ans)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((long long)(x).size())
#define g(a, b) __gcd((a), (b))
#define l(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
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; }
template<class T, class U>T rem(T a, U b) { return a - b*floor(a/b); }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;



int main()
{
        ll N, M;
        cin >> N >> M;


        vll X(M);
        rep(i, 0, M) cin >> X[i];
        sort(all(X));

        if (M <= N) {
                cout << 0 << endl;
                return 0;
        }

        vll diff(M-1);

        rep(i, 0, M-1) {
                diff[i] = X[i+1] - X[i];
        }
        sort(all(diff));


        ll ans = accumulate(diff.begin(), diff.begin() + len(diff) - N + 1, 0LL);
        cout << ans << endl;
}


Measured memory_bytes: 4532
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007



int main() {

  int N;
  cin >> N;

  vector<int> a(N);
  for(int i = 0;i < N;i++) cin >> a.at(i);

  int num = 1,sum = 0;
  for(int i = 0;i < N;i++) {
    if(a.at(i) == num) {
      sum++;
      num++;
    }
  }

  if(sum == 0) cout << -1 << endl;
  else cout << N - sum << endl;

}


Measured memory_bytes: 1152
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] H;
		H = new int[N];
		int sum = 1;
		for(int n = 0; n < N; n++) {
			H[n] = sc.nextInt();
			int max = H[0];
			for(int index = 0; index < H.length; index++) {
				max = Math.max(max, H[index]);
			}
			if(n != 0) {
				if(H[n] >= H[n - 1] && H[n] >= max) {
					sum ++;
				}
			}
		}
		sc.close();
		System.out.print(sum);
	}
}

Measured memory_bytes: 21840
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int i,j,n,m,t,p=0,a[102];
    scanf("%d",&n);

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

    for(i=0; i<n-1; i++)
    {
        m=i;
        for(j=i+1; j<n; j++)
        {
            if(a[j]<a[m])
            {
                m=j;
            }
        }
        if(a[i]!=a[m])
        {
            swap(a[i],a[m]);
            p++;

        }
    }

    for(i=0; i<n-1; i++)
    {
        printf("%d ",a[i]);
    }
    printf("%d\n",a[n-1]);
    printf("%d\n",p);
    return 0;
}

Measured memory_bytes: 3212
import sys
n,y=map(int,input().split())
for i in range(n+1):
    for j in range(n+1-i):
        cul=10000*i+5000*j
        if cul>y:
            break
        if cul+1000*(n-i-j)==y:
            print(i,j,n-i-j)
            sys.exit()
print(-1,-1,-1)

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

int main()
{long long x,y,sum=0;
cin>>x>>y;
vector<long long>m;
for(int i=0;i<x;i++)
{
long long z;
cin>>z;
m.push_back(z);
}
if(x<=y){cout<<0;}
else{
sort(m.begin(),m.end());
while(y--)
 {m.pop_back();}
for(int i=0;i<m.size();i++)
{
    sum=sum+m[i];
}
cout<<sum;
}
    return 0;
}

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  vector<int> p(n);
  for (int i = 0; i < n; i++) {
    cin >> p[i];
  }
  sort(p.begin(), p.end());
  int ans = 0;
  for (int i = 0; i < k; i++) {
    ans += p[i];
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 3660
#include <stdio.h>

int main(){
  int n = 0;
  char a[5];
  scanf("%c%c%c%c", &a[0], &a[1], &a[2], &a[3]);
  int j = 0;

  for(int i = 0; i < 4; i++){
  if(a[j] == '+'){
    n++;
  } else if(a[j] == '-'){
    n--;
  }
  j++;
}

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


Measured memory_bytes: 128
len = 1000000
p = Array.new(len,1)
p[0] = 0
i = 1
m = Math.sqrt(len).to_i
loop do
  i += 1
  i += 1 while p[i-1] == 0 && i < m
  j = i
  p[j-1] = 0 while (j += i) <= len
  break if i == m
end

(1..(len-1)).each do |i|
  p[i] += p[i-1]
end

begin
  while (n = STDIN.readline.chomp.to_i)
    puts p[n-1]
  end
rescue
  exit
end

Measured memory_bytes: 13904
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(10)

using namespace std;

typedef pair<int, int> P;
int N, M;
int A[10];

string dp[10005];

map<int, int> mp = {
        {1, 2},
        {2, 5},
        {3, 5},
        {4, 4},
        {5, 5},
        {6, 6},
        {7, 3},
        {8, 7},
        {9, 6},
};

string solve(int n) {
    if (dp[n] != "") return dp[n];
    if (n == 0) return "";

    string res = "";
    REP(i, M) {
        int a = A[i];
        if (n - mp[a] < 0) continue;
        string r = solve(n - mp[a]);
        if (r == "0") {
            continue;
        }

        char r0 = r[0];

        string tmp;
        if (a >= r[0] - '0') {
            tmp = to_string(a) + r;
        }
        else {
            tmp = r + to_string(a);
        }

        if (tmp.size() >= res.size()) {
            res = tmp;
        }

    }

    if (res.empty()) res = "0";

    dp[n] = res;
    return res;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    cin >> N >> M;
    REP(i, M) cin >> A[i];
    sort(A, A + M);

    string ans = solve(N);
    cout << ans << endl;
}


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

string rot1(string s)
{
    string t = s;
    int n = s.size();
    for(int i=0;i<n;++i)
        t[(i+1)%n] = s[i];
    return t;   
}

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

    string s,t;
    cin>>s>>t;
    bool flg = 0;
    for(int i=0;i<=s.size()+1;++i)
    {
        if(s==t)
            flg=1;
        s = rot1(s);
    }
    if(flg)
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}   

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <cstring>
#define rep(i,j,k) for(int i=(j);i<(k);i++)
using namespace std;
int data[3][100005];
int rdata[100005],flag[100005];
int _abs(int a)
{
    return a>0?a:-a;
}
int dfs(int a)
{
    flag[a]=1;
    int nex=rdata[a];
    if(flag[nex])return 1;
    else return 1+dfs(nex);
}
int main()
{
    int n;
    scanf("%d",&n);
    rep(j,0,3)rep(i,1,n+1)scanf("%d",&data[j][i]);
    rep(i,1,n+1)
    {
        if(data[1][i]%3!=2)
        {
            puts("No");
            return 0;
        }
        rdata[i]=(data[1][i]+1)/3;
    }
    rep(i,1,n+1)if((data[0][i]+2)/3!=rdata[i]||(data[2][i]+2)/3!=rdata[i])
    {
        puts("No");
        return 0;
    }
    rep(i,1,n+1)if(rdata[i]%2!=i%2)
    {
        puts("No");
        return 0;
    }
    long long cnt[2]={0,0},nxd[2]={0,0};
    rep(i,1,n+1)if(data[0][i]%3==0)cnt[i%2]++;
    rep(i,1,n+1)if(!flag[rdata[i]])nxd[i%2]+=(dfs(rdata[i])%2)^1;
    if(cnt[0]%2==nxd[1]%2&&cnt[1]%2==nxd[0]%2)puts("Yes");
    else puts("No");
    return 0;
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define mod 1000000007
#define MAX 1000000000000000
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(i=(ll)a;i<(ll)b;i++)
#define revrep(i,a,b) for(i=(ll)a;i>=(ll)b;i--)
#define ii pair<ll,ll>
#define MP make_pair
#define pb push_back
#define f first
#define se second
#define ll long long int
#define vi vector<ll>
ll modexp(ll a,ll b){ ll res = 1; while(b > 0){  if(b & 1) res = (res * a)%mod;  a = (a * a)%mod;  b/=2;  }  return res; }
#define rs resize
typedef tree< ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update > OST;
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

const ll N = 52;
string s;
int main()
{
    std::ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin>>s;
    if(s == "Sunny") s = "Cloudy";
    else{
        if(s == "Cloudy") s = "Rainy";
        else
            s = "Sunny";
    }
    cout<<s;
    return 0;
}

Measured memory_bytes: 256
#Educational DP Contest
#A-Frog1

n = int(input())
#n,m = map(int,input().split())
lst1 = list(map(int,input().split()))

#dp table
dp = [0]*n


#process1
dp[1] = abs(lst1[1]-lst1[0])

for i in range(2,n):
    bb,b = abs(lst1[i]-lst1[i-2]),abs(lst1[i]-lst1[i-1])
    dp[i] = min(dp[i-2]+bb,dp[i-1]+b)

#output process
print(dp[-1])


Measured memory_bytes: 52592
#pragma GCC optimize("O3,inline,unroll-loops")
#include <iostream>
#include <algorithm>
#include <cstdio>
#define N 200020
using namespace std;

int a[N];

int main(void)
{
    int n;
    int i, v;

    scanf("%d", &n);
    for(i = v = 0; i < n; i ++)
    {
        scanf("%d", &a[i]);
        v ^= a[i];
    }
    for(i = 0; i < n; i ++)
        printf("%d%c", v ^ a[i], " \n"[i == n - 1]);

    return 0;
}


Measured memory_bytes: 4604
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <list>
#include <numeric>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;

int a, b, c, n;
string s;



int main()
{
cin>>a>>b>>c;
  if(a==b&&b==c)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
	
}


Measured memory_bytes: 256
s=list(input())
s=[int(i) for i in s]
s=[s[0]*10+s[1],s[2]*10+s[3]]
if (s[0]==0 and s[1]==0) or (s[0]>12 and s[1]==0):
  print("NA")
elif (s[0]<=12 and s[0]!=0) and (s[1]<=12 and s[1]!=0):
  print("AMBIGUOUS")
elif (s[0]<=12 and s[0]!=0):
  print("MMYY")
elif (s[1]<=12 and s[1]!=0):
  print("YYMM")
else:
  print("NA")

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <tuple>
#include <queue>
#include <set>
#include <math.h>
#include <array>
#include <list>
#include <set>
const int MOD=1000000007;
using namespace std;
typedef long long ll;
typedef tuple<ll,int,int> tup;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> p;
typedef vector<p> vp;
const int INF=1e9;
int main(int argc,char const* argv[])
{
  int n;
  cin >> n;
  vector<ll>a(n);
  int ans=0;
  for(int i=0;i<n;i++)
    {
      ll tmp;
      cin >> tmp;
      while(tmp%2==0)
	{
	  ans++;
	  tmp/=2;
	}
    }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 384
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2")

#include <bits/stdc++.h>
#define whlie while
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repr(i,N) for(int i = (N) - 1; i >= 0; i--)
#define rep1(i,N) for(int i = 1; i <= (N) ; i++)
#define repr1(i,N) for(int i = (N) ; i > 0 ; i--)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define vrep(v,it) for(auto it = v.begin(); it != v.end(); it++)
#define vrepr(v,it) for(auto it = v.rbegin(); it != v.rend(); it++)
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
using namespace std; void solve();
using ll = long long; using vl = vector<ll>;
using vi = vector<int>; using vvi = vector< vector<int> >;
constexpr int inf = 1001001001;
constexpr ll infLL = (1LL << 61) - 1;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(7);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cerr << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,N) do { cerr << #v << " = "; array_out(v , N);cout << endl;} while(0)
#else
  #define trc(...)
  #define trca(...)
  int main(){solve();}
#endif
using P = pair<ll,ll>; using vp = vector<P>;
constexpr int MOD = /**/ 1000000007; //*/ 998244353;
////////////////

void solve(){
  inl(N); ins(S);
  if(N % 2 == 0 && S.substr(0 , N / 2) == S.substr(N / 2 , N / 2)) out("Yes");
  else out("No");

}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <tuple>
#include <cstring>
#include <map>
#include <iomanip>
#include <ctime>
#include <complex>
#include <cassert>
#include <climits>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define _ << " " <<
#define all(X) (X).begin(), (X).end()
#define len(X) (X).size()
#define Pii pair<int, int>
#define Pll pair<ll, ll>
#define Tiii tuple<int, int, int>
#define Tlll tuple<ll, ll, ll>

ll dp[305][305][305];

int main() {
    ll n, k;
    cin >> n >> k;
    vector<ll> h(n), v;
    map<ll, ll> mp;
    for (int i = 0; i < n; i++) {
        cin >> h[i];
        v.push_back(h[i]);
    }
    v.push_back(0);
    sort(all(v));
    v.erase(unique(all(v)), v.end());
    for (int i = 0; i < v.size(); i++) {
        mp[v[i]] = i;
    }

    ll INF = 2e18;
    for (int i = 0; i <= 300; i++) {
        for (int j = 0; j <= 300; j++) {
            for (int p = 0; p <= 300; p++) dp[p][i][j] = INF;
        }
    }
    dp[0][0][0] = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            for (int p = 0; p < v.size(); p++) {
                dp[i + 1][j][p] = min(dp[i + 1][j][p], dp[i][j][p]);
                if (mp[h[i]] > p) {
                    dp[i + 1][j + 1][mp[h[i]]] = min(dp[i + 1][j + 1][mp[h[i]]], dp[i][j][p] + h[i] - v[p]);
                }
                else {
                    dp[i + 1][j + 1][mp[h[i]]] = min(dp[i + 1][j + 1][mp[h[i]]], dp[i][j][p]);
                }
            }
        }
    }

    ll ans = INF;
    for (int i = 0; i < v.size(); i++) {
        ans = min(ans, dp[n][n - k][i]);
    }
    cout << ans << endl;

    /*
    for (int i = 0; i <= n; i++) {
        cout << i << endl;
        for (int j = 0; j <= n; j++) {
            for (int p = 0; p < v.size(); p++) cout << dp[i][j][p] << " ";
            cout << endl;
        }
    }*/

    


}


Measured memory_bytes: 219392
N, M = map(int, input().split())
stores = [list(map(int, input().split())) for _ in range(N)]

stores.sort()
total = 0
i = 0
while True:
    if total >= M:
        i -= 1
        break
    total += stores[i][1]
    i += 1

ac = 0
k_count = 0
j = 0
while not j > i:
    if j == i:
        ac += stores[j][0] * (M-k_count)
    else:
        ac += stores[j][0] * stores[j][1]
    k_count += stores[j][1]
    j += 1

print(ac)


Measured memory_bytes: 27880
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int main(){
  double dot[5][2],vec[4][2],edge[4],ang[4],all;
  for(;;){
    if(scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf",&dot[0][0],&dot[0][1],&dot[1][0],&dot[1][1],&dot[2][0],&dot[2][1],&dot[3][0],&dot[3][1]) == EOF){break;}
    dot[4][0] = dot[0][0];
    dot[4][1] = dot[0][1];
    for(int i=0; i<4; i++){
      vec[i][0] = dot[i+1][0]-dot[i][0];
      vec[i][1] = dot[i+1][1]-dot[i][1];
      edge[i] = sqrt(vec[i][0]*vec[i][0]+vec[i][1]*vec[i][1]);
    }
    ang[0] = acos(-(vec[0][0]*vec[3][0]+vec[0][1]*vec[3][1])/(edge[0]*edge[3]));
    ang[1] = acos(-(vec[1][0]*vec[0][0]+vec[1][1]*vec[0][1])/(edge[1]*edge[0]));
    ang[2] = acos(-(vec[2][0]*vec[1][0]+vec[2][1]*vec[1][1])/(edge[2]*edge[1]));
    ang[3] = acos(-(vec[3][0]*vec[2][0]+vec[3][1]*vec[2][1])/(edge[3]*edge[2]));
    all = ang[0]+ang[1]+ang[2]+ang[3];
    if(all < 6.283){cout <<"NO"<<endl;}
    else{cout <<"YES"<<endl;}
  }
  return 0;
}

Measured memory_bytes: 1268
from collections import Counter
n, k = map(int, input().split())
ps = [input() for _ in range(n)]
heads = Counter((p[0] for p in ps))
ans = 0
while len(heads) >= k:
    ans += 1
    for h, c in heads.most_common()[:k]:
        if c==1:
            heads.pop(h)
        else:
            heads[h] -= 1
print(ans)

Measured memory_bytes: 4084
#include<stdio.h>
#define it register int
#define ct const int
#define il inline
typedef long long ll;
ll Max(ll p,ll q){return p>q?p:q;}
#define P 1000000007
il int ksm(it x,it L){
	it ans=1;while(L) L&1?ans=(0ll+ans)*x%P:0,x=(0ll+x)*x%P,L>>=1;
	return ans;
}
int main(){
	int n;scanf("%d",&n);
	if(n<=1) return puts("0"),0;
	printf("%d\n",(ksm(10,n)-2*ksm(9,n)%P+ksm(8,n)+P)%P);
  	return 0;
}
 

Measured memory_bytes: 1728
A,B,C,X,Y=map(int,input().split())
ans=[]
ans.append(max([X,Y])*2*C)
ans.append(A*X+B*Y)
t=min([X,Y])*2*C
if X>=Y:
  t+=(X-Y)*A
else:
  t+=(Y-X)*B
ans.append(t)
print(min(ans))

Measured memory_bytes: 3064
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto nk = readln.split.to!(int[]);
    auto N = nk[0];
    auto K = nk[1];
    int[26] ps;
    foreach (_; 0..N) {
        ++ps[readln.chomp[0] - 'A'];
    }
    int solve() {
        int r;
        for (;;) {
            sort!"a > b"(ps[]);
            foreach (i; 0..K) {
                if (ps[i] == 0) return r;
                --ps[i];
            }
            ++r;
        }
    }
    writeln(solve());
}

Measured memory_bytes: 380
#include <bits/stdc++.h>
#define inf 1000000005
#define mod 1000000007
#define eps 1e-10
#define rep(i,n) for(int i = 0; i < (n); ++i) 
#define rrep(i,n) for(int i = 1; i <= (n); ++i) 
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define each(a,b) for(auto& (a): (b)) 
#define all(v) (v).begin(),(v).end() 
#define sz(v) (int)(v).size() 
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define mx(x,y) x=max(x,y) 
#define mn(x,y) x=min(x,y)
#define rev(v) reverse((v).begin(),(v).end());
#define so(v) sort((v).begin(), (v).end());
#define yn {puts("Yes");}else{puts("No");}
#define fi first
#define se second
#define pb push_back

using namespace std;

using ll = long long;
using P = pair<int,int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vd = vector<double>;
using vp = vector<P>;
using vs = vector<string>; 

int main() {
    unsigned long long h;
  	ll ct,t;
    cin >> h;
  	ct=0;
    vl k;
    k.pb(1) ;
    rep(i, 100) {
        t = k.at(i);
        k.pb(2*t);
    }
    t = 0;
    while (h >= 1) {
        ct = ct + k.at(t);
        t++;
        h = h / 2;
    }
    cout << ct << endl;
    return 0;
}


Measured memory_bytes: 3580
#正負で分割
#dpの作り方はARCの方の人のロジックを参考にした。
def 解():
    iN,iA =[int(x) for x in input().split()]
    aX = [int(x) - iA for x in input().split()]
    aPlus = [x for x in aX if 0 < x ]
    aMinus = [-1 * x for x in aX if x < 0  ]
    iLenPlus = len(aPlus)
    iLenMinus = len(aMinus)
    iLen0 = iN - iLenPlus - iLenMinus

    iCZero = 2**iLen0  #sum(k=1..N){nCk} = 2^n -1 #1は組み合わせ0の場合
    iRet = 0
    iUlim = min(sum(aPlus) , sum(aMinus))
    if 0 < iUlim:
        dp1 = {0:1}
        for iX in aPlus:
            for k,v in dp1.copy().items():
                n = k+iX
                if n <= iUlim:
                    dp1[n] = dp1.get(n,0)+v
        dp2 = {0:1}
        for iX in aMinus:
            for k,v in dp2.copy().items():
                n = k+iX
                if n <= iUlim:
                    dp2[n] = dp2.get(n,0)+v
        for i in range(1,iUlim+1):
            if i in dp1 and i in dp2:
                iRet += dp1[i] * dp2[i]
    print((iRet+1)*iCZero  -1) #組み合わせ0の場合を引く
解()


Measured memory_bytes: 3188