akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>

int find(std::vector<std::pair<int, std::vector<int>>> const& books, int cost, std::vector<int> const& xs, int x, int depth, int max_depth) {
  /*
  std::cout << "x: ";
  for(auto e: xs) {
    std::cout << e << ", ";
  }
  std::cout << std::endl;
  */
  if(std::all_of(begin(xs), end(xs), [x](int n) { return n >= x; })) {
    return cost;
  }
  // std::cout << "here2: " << depth << std::endl;
  if(depth >= max_depth) return -1;
  std::vector<int> my_xs(xs);
  std::pair<int, std::vector<int>> const& the_book = books[depth];
  for(int i{}; i < xs.size(); ++i) {
    my_xs[i] += the_book.second[i];
  }
  // std::cout << "here3: " << depth << std::endl;
  int res1 = find(books, cost + the_book.first, my_xs, x, depth + 1, max_depth);
  int res2 = find(books, cost + 0             , xs   , x, depth + 1, max_depth);
  // std::cout << "depth: " << depth << " " << res1 << ", " << res2 << std::endl;
  if(res1 == -1) return res2;
  if(res2 == -1) return res1;
  // std::cout << "DDDDDdepth: " << depth << " " << res1 << ", " << res2 << std::endl;

  return std::min(res1, res2);
}

int main(int, char**) {
  int n, m, x;
  std::cin >> n >> m >> x;
  std::vector<std::pair<int, std::vector<int>>> books(n);

  for(int i{}; i < n; ++i) {
    int c;
    std::cin >> c;
    books[i].first = c;
    for(int j{}; j < m; ++j) {
      int a;
      std::cin >> a;
      books[i].second.push_back(a);
    }
  }
  std::sort(begin(books), end(books));
  /*
  for(auto e: books) {
    std::cout << e.first << ": ";
    for(auto e2: e.second) {
      std::cout << e2 << ", ";
    }
    std::cout << std::endl;
  }
  */

  std::vector<int> xs(m);
  auto result = find(books, 0, xs, x, 0, n);

  std::cout << result << std::endl;

  return 0;
}


Measured memory_bytes: 3620
//大文字->小文字 tolower(),逆はtoupper()
//int a = stoi(c); 文字列をintへ
//途中の出力をそのまま残さない
//数値計算 基本はdouble
//map<キー,値> p は辞書。p[キー] = 値
//絶対値 abs()
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

// Nの桁数
ll dig(ll N) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= 10;
	}
	return dig;
}
// x,yの最大公約数
ll gcd(ll x, ll y) {
	ll r;
	while (x%y) {
		r = x % y;
		x = y;
		y = r;
	}
	return y;
}

int main() {
	int K; cin >> K;
	if (K % 2 == 0)cout << K * K / 4 << endl;
	else cout << (K + 1) * (K - 1) / 4 << endl;
}

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

int main()
{
  int64_t a, b, c;
  cin >> a >> b >> c;
  int64_t d = c - a - b;
  bool ans = sqrtl(a * b) * 2 < d;
  cout << (ans ? "Yes": "No") << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int a, b;
	char op;
	while(1){
		//数値2つを演算子を入力
		scanf("%d %c %d", &a, &op, &b);
		//演算子に沿った答えを出力
		if(op == '+'){
			printf("%d\n", a + b);
		}else if(op == '-'){
			printf("%d\n", a - b);
		}else if(op == '*'){
			printf("%d\n", a * b);
		}else if(op == '/'){
			printf("%d\n", a / b);
		}else{
			break;
		}
	}
	return 0;
}

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

using namespace std;

#define MAX 15

const string gesture[MAX] = {
  "Rock","Fire","Scissors","Snake","Human","Tree","Wolf","Sponge",
  "Paper","Air","Water","Dragon","Devil","Lightning","Gun"
};

vector<int> v;
bool ges[MAX];

int solve(){
  int res = -1, N = (int)v.size();

  if(N == 1){
    return res;
  } 

  for(int i = 0 ; i < N ; i++){
    int win = 0, lose = 0;
    for(int j = 0 ; j < MAX ; j++){
      if(v[i] == j || !ges[j]){
	continue;
      }
  

      int cnt = 0, pos = v[i];
      while(true){
	pos++; cnt++;
	if(pos >= MAX){
	  pos = 0;
	}

	if(j == pos){
	  if(cnt > 7){
	    lose++;
	  }else{
	    win++;
	  }
	  break;
	}
      }
    }
    if(win == N-1){
      res = v[i];
      break;
    }
  }

  return res;
}

int main(){
  int n;

  while(cin >> n ,n){
    string str;
    set<string> st;

    v.clear();
    memset(ges,false,sizeof(ges));

    for(int i = 0 ; i < n ; i++){
      cin >> str;
      if(st.count(str)){
	continue;
      }
      for(int j = 0 ; j < MAX ; j++){
	if(gesture[j] == str){
	  v.push_back(j);
	  st.insert(str);
	  ges[j] = true;
	  break;
	}
      }
    }
   
    sort(v.begin(),v.end());
    int ans = solve();

    if(ans == -1){
      cout << "Draw" << endl;
    }else{
      cout << gesture[ans] << endl;
    }
  }

  return 0;
}

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

int main(){
  string N;
  cin >> N;
  int s=0;
  for (int i=0;i<N.size();i++){
    s += N.at(i)-'0';
  }
  if (s%9==0){
    cout << "Yes";
  } else {
    cout << "No";
  }
  cout << endl;
}


Measured memory_bytes: 3680
/* template.cpp(shinobu_menkoi) {{{ */
#include <bits/stdc++.h>
using namespace std;

// clang-format off
#define GET_MACRO(_1, _2, _3, _4, NAME, ...) NAME
#define rep(...) GET_MACRO(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rep1(n) rep2(_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, n) rep4(i, a, n, 1)
#define rep4(i, a, n, s) for (lint i = (a); i < (lint)(n); i += (s))
#define rrep(...) GET_MACRO(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define rrep1(a) rrep2(_, a)
#define rrep2(i, a) rrep3(i, a, 0)
#define rrep3(i, a, n) rrep4(i, a, n, 1)
#define rrep4(i, a, n, s) for (lint i = (a); i >= (lint)(n); i -= (s))
#define each(i, ctn) for (auto &&i : (ctn))

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define all(v) begin(v), end(v)
#define debug(x) cerr << (x) << " (L:" << __LINE__ << ")" << '\n'
#define TEMP_T template <class T>
#define TEMP_TU template <class T, class U>

TEMP_T using vec = vector<T>;
TEMP_T using heap = priority_queue<T>;
TEMP_T using minheap = priority_queue<T, vec<T>, greater<T>>;
using lint = long long;
using ulint = unsigned long long;
using ld = long double;
using vi = vec<int>;
using vvi = vec<vi>;
using vvvi = vec<vvi>;
using pii = pair<int, int>;
using vs = vec<string>;

TEMP_TU ostream &operator<<(ostream &os, const pair<T, U> &p) { return os << p.fi << " " << p.se; }
TEMP_TU istream &operator>>(istream &is, pair<T, U> &p) { return is >> p.fi >> p.se; }

const int INF{1001001001};
const lint LINF{1001001001001001001ll};
const int MOD{(int)1e9 + 7};
const double EPS{1e-9};
const double PI{acos(-1)};
const int dx[]{0, 1, 0, -1, 1, -1, 1, -1}, dy[]{1, 0, -1, 0, 1, -1, -1, 1};

inline bool inside(int y, int x, int h, int w) { return y >= 0 && x >= 0 && y < h && x < w; }
TEMP_T inline bool chmin(T &a, const T &b) { if (a > b) a = b; return a > b; }
TEMP_T inline bool chmax(T &a, const T &b) { if (a < b) a = b; return a < b; }
TEMP_T inline void print(const T &x) { cout << x << '\n'; }
TEMP_T inline void print(const vec<T> &v, string d = "\n") { rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? "\n" : d); }
template <class T = int> inline T in() { T x; cin >> x; return x; }
template <class T = string> vec<T> split(const string &s, char d = ',') {
  vec<T> v; stringstream ss(s); for (string b; getline(ss, b, d); ) {
    stringstream conv(b); T t; conv >> t; v.eb(t); } return v;
}
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(12); } } pre__;
// clang-format on
/* }}} */

signed main() {
  lint n;
  cin >> n;
  lint res = 1;
  rep(i, n) {
    (res *= (i + 1)) %= MOD;
  }
  print(res);
}


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

N,K=map(int,input().split())

ans=0
for n in range(K+1,N+1):
    coff=(n)-(K)
    quan=(N)//n
    ans+=coff*quan
    temp=N-quan*n
    if K!=0:
        temp-=(K-1)
    
    ans+=max(temp,0)
    #print(n,coff,quan,max(temp,0))

print(ans)

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

using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
struct XY{
  int h;
  int w;
};
int H,W;
int a[500][500];
vector<string> outStr;
void output(XY first,XY second,vector<XY> way){
  XY prev = first;
  string out;
  for(int i = 0; i < way.size(); i++){
    out = "" + to_string(prev.h + 1) + " " + to_string(prev.w + 1) + " " + to_string(way[i].h + 1) + " " + to_string(way[i].w + 1);
    outStr.push_back( out );
    prev = way[i];
  }
  out = "" + to_string(prev.h + 1) + " " + to_string(prev.w + 1) + " " + to_string(second.h + 1) + " " + to_string(second.w + 1);
   outStr.push_back(out);
  return ;
}


int main(){
  cin >> H >> W;
  int a[H][W];
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      cin >> a[i][j];

    }
  }

  bool pairNum = false;
  XY first ,second, mid;
  vector<XY> way;
  for(int i = 0; i < H; i++){
    if(i%2 == 0){
      for(int j = 0; j < W; j++){
        if(a[i][j] % 2 == 1){
          if(pairNum){
            second.h = i;
            second.w = j;
            output(first,second,way);
            way.clear();
            pairNum = false;
          }else{
            pairNum = true;
            first.h = i;
            first.w = j;
          }
        }else{
          if(pairNum){
            mid.h = i;
            mid.w = j;
            way.push_back(mid);
          }
        }
      }
    }else{
      for(int j = W-1; j >= 0; j--){
        if(a[i][j] % 2 == 1){
          if(pairNum){
            second.h = i;
            second.w = j;
            output(first,second,way);
            way.clear();
            pairNum = false;
          }else{
            pairNum = true;
            first.h = i;
            first.w = j;
          }
        }else{
          if(pairNum){
            mid.h = i;
            mid.w = j;
            way.push_back(mid);
          }
        }
      }
    }
  }
  cout << outStr.size() << endl;
  for(int i = 0; i < outStr.size(); i++){
    cout << outStr[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 11892
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args) {
		solver();
	}

	public static void solver() {
		FS r = new FS();
		int N = r.nextInt();
		String s = r.next();
		String t = r.next();
		int max  =0;
		for(int i=1; i<=N; i++) {
			if(t.substring(0, i).equals(s.substring(N-i,N))) {
				max = i;
			}
		}
		System.out.println(N*2-max);
	}

	// Read Class
	static class FS {
		private final InputStream in = System.in;
		private final byte[] buffer = new byte[1024];
		private int ptr = 0;
		private int buflen = 0;
		private boolean hasNextByte() {
			if (ptr < buflen) {
				return true;
			} else {
				ptr = 0;
				try {
					buflen = in.read(buffer);
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (buflen <= 0) {
					return false;
				}
			}
			return true;
		}

		private int readByte() { return hasNextByte() ? buffer[ptr++] : -1;}
		private boolean isPrintableChar(int c) {return 33 <= c && c <= 126;}
		private void skipUnprintable() {while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}

		public boolean hasNext() { skipUnprintable(); return hasNextByte();}
		public String next() {
			if (!hasNext()) throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while(isPrintableChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}
		public int nextInt() {
			return (int)nextLong();
		}
		public long nextLong() {
			if (!hasNext()) throw new NoSuchElementException();
			long n = 0;
			boolean minus = false;
			int b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) {
				throw new NumberFormatException();
			}
			while(true) {
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				} else if(b == -1 || !isPrintableChar(b)) {
					return minus ? -n : n;
				} else {
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}
	}
}

Measured memory_bytes: 8148
#include <iostream>

using namespace std;

int main(int argc, char* argv[])
{
    unsigned long long a, b, x; cin >> a >> b >> x;
    unsigned long end = b/x;
    unsigned long start = (a%x == 0) ? a/x : (a+x-1)/x;
    cout << end - start + 1 << endl;
    return 0;
}


Measured memory_bytes: 256
// https://atcoder.jp/contests/abc107/tasks/arc101_a

#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>
using namespace std;

typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOREACH(x, a) for (auto &(x) : (a))
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

// int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

int main() {
    int n, k;
    vector<int> x, y;
    ios::sync_with_stdio(false);
    cin.tie(0);

    cin >> n >> k;
    x.resize(n);

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

    // k本のロウソクに火をつける時間を計算
    for (int i = 0; i <= n - k; i++) {
        // 比較対象の符号が逆の場合
        int a = x[i], b = x[i + k - 1];
        if (signbit(a) != 0 && signbit(b) == 0 ||
            signbit(a) == 0 && signbit(b) != 0) {
            if (abs(a) < abs(b)) {
                y.push_back(2 * abs(a) + abs(b));
            } else {
                y.push_back(abs(a) + 2 * abs(b));
            }
        } else {
            y.push_back(max(abs(a), abs(b)));
        }
    }
    cout << *min_element(ALL(y)) << endl;

    return 0;
}


Measured memory_bytes: 1024
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        h: usize,
        w: usize,
        a: usize,
        b: usize
    }
    for i in 0..h + 1 {
        for j in 0..w + 1 {
            if a * i + (w - a) * (h - i) != b * j + (h - b) * (w - j) {
                continue;
            }
            let mut ans = vec![vec![0; w]; h];
            let mut cr = vec![0; w];
            for k in 0..j {
                cr[k] = b;
            }
            for k in j..w {
                cr[k] = h - b;
            }
            for k in 0..h {
                let mut c = if k < i {a} else {w - a};
                for l in 0..w {
                    if c > 0 && cr[l] > 0 {
                        ans[k][l] = 1;
                        c -= 1;
                        cr[l] -= 1;
                    }
                    if c == 0 {
                        break;
                    }
                }
            }
            for k in 0..h {
                for &x in &ans[k] {
                    print!("{}", x);
                }
                println!("");
            }
            return;
        }
    }
    println!("No");
}


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

void fastStream(){cin.tie(0);std::ios_base::sync_with_stdio(0);}

int A[3];
int main(){

    fastStream();
    for(int i = 0; i < 3; i++) cin >> A[i];
    sort(A, A + 3);
    if(A[0] == A[1] && A[1] == A[2]){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    
    

    return 0;
}


Measured memory_bytes: 256
N=int(input())
pList={}
mod = 10**9+7
def soinsuu(x):
    if x==1:return
    for p in pList:
        if x%p==0:
            pList[p] += 1
            return soinsuu(x//p)
    pList[x] = pList.get(x,0)+1
    return
for n in range(2,N+1):
    soinsuu(n)
ans = 1
for i in pList.values():
    ans = (ans*(i+1))%mod
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <string>
#include <map>
#include <iterator>
#include <set>
#include <queue>
#include <bitset>
#include <cassert>

using namespace std;

struct Edge {
    int to;
    int weight;

    Edge(int to, int weight) : to(to), weight(weight) {}
};

using Graph = vector<vector<Edge>>;
vector<int> colors;
vector<bool> seen;

Graph graph;

void dfs(int v, int c) {
    seen[v] = true;
    colors[v] = c;
    for (auto e : graph[v]) {
        if (seen[e.to]) continue;
        if (e.weight % 2 != 0) dfs(e.to, 1 - c);
        else dfs(e.to, c);
    }
}

int main() {

    int N;
    cin >> N;

    graph.assign(N, vector<Edge>());
    seen.assign(N,false);

    for (int i = 0; i < N - 1; ++i) {
        int u, v, w;
        cin >> u >> v >> w;
        u -= 1;
        v -= 1;
        graph[u].push_back(Edge(v, w));
        graph[v].push_back(Edge(u, w));
    }
    colors.assign(N, 0);

    dfs(0, 1);

    for (int i = 0; i < N; ++i) {
        cout << colors[i] << endl;
    }

}

Measured memory_bytes: 11000
def gcd_base(a, b):
    while b!=0:
        a, b = b, a%b
    return a

def gcd(num_list):
    ans = 0
    for i in num_list:
        ans = gcd_base(ans, i)
    return ans

k = int(input())
ans = 0
for i in range(1, k-1):
    for j in range(i+1, k):
        for l in range(j+1, k+1):
            ans += 6*gcd([i,j,l])
for i in range(1, k):
    for j in range(i+1, k+1):
        ans += 6*gcd_base(i, j)
for i in range(1, k+1):
    ans += i
print(ans)

Measured memory_bytes: 9216
args = input().split(' ')
stack = []
for arg in args:
    if arg.isdecimal():
        stack.append(int(arg))
    elif arg == '+':
        a = stack.pop()
        b = stack.pop()
        stack.append(a + b)
    elif arg == '-':
        a = stack.pop()
        b = stack.pop()
        stack.append(b - a)
    elif arg == '*':
        a = stack.pop()
        b = stack.pop()
        stack.append(a * b)
print(stack.pop())


Measured memory_bytes: 5596
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		String A =scan.next();
		String B =scan.next();
		int a = 0;
		int b = 0;
		int count=0;
		
		if(A.length()>B.length()){
			System.out.println("GREATER");
			System.exit(0);
		}else if (B.length()>A.length()){
			System.out.println("LESS");
			System.exit(0);
		}else if(A.length()==B.length()){
			for(int i =0;i<A.length();i++){
				a= Character.getNumericValue(A.charAt(i));
				b= Character.getNumericValue(B.charAt(i));
				if(a>b){
					System.out.println("GREATER");
					System.exit(0);
				}else if(b>a){
					System.out.println("LESS");
					System.exit(0);
				}else{
					count++;
					if(count==A.length()){
						System.out.println("EQUAL");
					}
				}
			}
		}

	}}


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

int main(void){
    char a[2];
    int cnt=0;
    cin>>a>>a[1];

    for(int i=0;i<2;i++){
        if(a[i]=='H')
            cnt++;
    }
    cout<<(cnt%2==0?"H":"D")<<endl;

    return 0;
}


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

int main(){
  string s;
  string a = "keyence";
  int ans = 0;
  int i, w;
  cin >> s;
  
  w = s.length() - a.length();
  i = 0;
  while(i < a.length()){
    if(a[i] != s[i]){
      s.erase(s.begin() + i, s.begin() + i + w);
      break;
    }
    ++i;
  }
            
  if(a != s){
    cout << "NO" << endl;
  }else{
    cout << "YES" << endl;
  }
  return 0;
}


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

using namespace std;

const int Maxn = 20;
const int Maxm = 100010;
int n;
int a[Maxn] = {0,1,6,9,36,81,216,729,1296,6561,7776,46656,59049};
int f[Maxm];
int main() {
	
	cin >> n;
	
	for(register int i=0; i<=n; i++)
		f[i] = 0x7fffffff / 3;
	
	for(register int i=1; i<=12; i++)	f[a[i]] = 1;
	for(register int i=1; i<=12; i++)
		for(register int j=a[i]; j<=n; j++)
			f[j] = min(f[j],f[j-a[i]]+1);
	
	cout << f[n] << endl;
	
	return 0;
	
}

Measured memory_bytes: 640
import numpy as np

def resolve():
    n, k = map(int, input().split())
    h = np.array(list(map(int, input().split())))

    dp = np.zeros(n, dtype=int)

    for i in range(1, n):
        start = max(0, i - k)
        dp[i] = min(dp[start:i] + np.abs(h[i] - h[start:i]))

    print(dp[n - 1])

resolve()

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

int a[100010];

inline int read(){
    int X=0,w=0; char ch=0;
    while(!isdigit(ch)) {w|=ch=='-';ch=getchar();}
    while(isdigit(ch)) X=(X<<3)+(X<<1)+(ch^48),ch=getchar();
    return w?-X:X;
}

inline void write(int x){
     if(x<0) putchar('-'),x=-x;
     if(x>9) write(x/10);
     putchar(x%10+'0');
}

inline void writeln(int x){
     if(x<0) putchar('-'),x=-x;
     if(x>9) write(x/10);
     putchar(x%10+'0');
     puts("");
}

signed main(){
    int n=read();
    
    for(int i=1;i<=n;i++)
        a[i]=read();
        
    sort(a+1,a+n+1);    
            
    int ans=1LL;
    
    for(int i=1;i<=n;i++){
        if(ans!=0 && 1000000000000000000LL/ans<a[i]){
            cout<<"-1\n";
            return 0;
        }
        ans*=a[i];
    }
        
    cout<<ans<<"\n";
	
	return 0;
}

Measured memory_bytes: 4420
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  string s, t;
  cin >> s >> t;
  int c1[26]{}, c2[26]{};
  vector<int> k[26];
  for (int i = 0; i < s.length(); i++) {
    c1[s[i] - 'a']++;
    k[s[i] - 'a'].push_back(i + 1);
  }
  for (int i = 0; i < t.length(); i++) {
    c2[t[i] - 'a']++;
  }
  for (int i = 0; i < 26; i++) {
    if (c2[i] != 0 && c1[i] == 0) {
      cout << "-1\n";
      return 0;
    }
  }
  ll idx = 1;
  ll l = s.length();
  ll ans = 0;
  for (int i = 0; i < t.length(); i++) {
    int j = t[i] - 'a';
    auto iter = lower_bound(k[j].begin(), k[j].end(), idx);
    int v = iter - k[j].begin();
    //cout << v << "\n";
    if (v == k[j].size()) {
      ans += (l -  idx + 1);
      //cout << i << " "<< idx << " " << ans << "\n";
      idx = 0;
      ans += (ll)(k[j][0] - idx);
      idx = k[j][0] + 1;
      //cout << idx << " " << k[j][0] << " " << ans << "\n";
    } else {
      ans += (ll)(k[j][v] - idx + 1);
      //cout << idx << " " << k[j][v] << " " << ans << "\n";
      idx = k[j][v] + 1;
    }
    
  }
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 1216
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>

using namespace std;
#define int long long

signed main() {
    ios_base::sync_with_stdio(false);
    
    int n;
    cin >> n;
    n += 2;
    vector <int> a(n);
    a[0] = 0;
    a[n - 1] = 0;
    for (int i = 1; i < n - 1; ++i) cin >> a[i];

    int ans = 0;
    for (int i = 0; i < n - 1; ++i) ans += abs(a[i] - a[i + 1]);

    for (int i = 1; i < n - 1; ++i) {
        cout << ans - abs(a[i] - a[i - 1]) - abs(a[i] - a[i + 1]) + abs(a[i - 1] - a[i + 1]) << '\n';
    }

    return 0;
}

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

int main() {
  double a;
  int kisu;
  double kekka;
  
  cin >> a;
  
  kisu = a / 2;
  kisu = a - kisu;
  kekka = kisu / a;
  
  cout << kekka;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <string>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main(){
	int h,a; cin>>h>>a;
	if(h==a) cout << "Yes" << endl;
	else cout << "No" << endl;


  return 0;
}


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

#define iota(i,n,b,s) for(int i=int(b);i!=int((b)+(s)*(n));i+=(s))
#define range(i,n,m) iota(i,(((n)>(m))?((n)-(m)):((m)-(n))),(n),((n)>(m)?-1:1))
#define rep(i,n) iota(i,(n),0,1)
#define loop for(;;)

#define INF (1e9)
#define EPS (1e-9)
#define cons(a,b) (make_pair(a,b))
#define car(a) (a.first)
#define cdr(a) (a.second)
#define cadr(a) (car(cdr(a)))
#define cddr(a) (cdr(cdr(a)))
#define all(a) a.begin(), a.end()
#define trace(var) cerr<<">>> "<<#var<<" = "<<var<<endl;

typedef long long Integer;
typedef double Real;
typedef vector<int> vi;
typedef vector<string> vs;
typedef map<string,int> Dictionary;
const Real PI = acos(-1);

template<class S, class T>
ostream& operator<<(ostream& os, pair<S,T> p) {
  os << '(' << car(p) << ", " << cdr(p) << ')';
  return os;
}

template<class T>
ostream& operator<<(ostream& os, vector<T> v) {
  if (v.size() == 0) {
    os << "(empty)";
    return os;
  }
  os << v[0];
  for (int i=1, len=v.size(); i<len; ++i) os << ' ' << v[i];
  return os;
}

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

vector<int>f(int n){
  vector<int>r;
  for(;n;n/=10)r.push_back(n%10);
  sort(all(r));
  return r;
}

int g(vector<int>r){
  int n=0;
  for(int x:r)n=n*10+x;
  return n;
}

int main() {

  loop {
    int n; cin >> n;
    if (!cin) break;
    cout << (1 + n*-~n/2)<<endl;

  }

  return 0;
}

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

int main(){
	int n;
	string s[50];
	cin >> n;
	for(int i=0; i<n; i++){
		cin >> s[i];
	}
	string ans;
	for(char c='a'; c <='z'; c++){
		int min_n = 60;
		for(int i=0; i<n; i++){
			int cnt=0;
			for(int k=0; k<s[i].length(); k++){
				if(s[i][k]==c)cnt++;
			}
			min_n = min(min_n,cnt);
		}
		for(int p=0; p<min_n; p++){
			ans += c;
		}
	}
	cout << ans << endl;
}




Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <set>
#include <vector>
#include <map>
#include <cstdio>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <cassert>
#include <climits>
#include <numeric>
using namespace std;
typedef long long ll;
#define DEBUG
#ifdef DEBUG
	#define debug printf
#else
	#define debug(...)
#endif
int main(int argc, char const *argv[])
{
	string s;
	cin>>s;
	string cur,prv;
	int ans = 0;
	for(int i = 0;i < s.size(); ++i)
	{
		cur += s[i];
		if(cur != prv)
		{
			prv = cur;
			cur = "";
			ans++;
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
int main(){
	int x,y,a,b,c,d,at=0;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	at=a+b+c+d;
	x=at/60;
	y=at%60;
	printf("%d\n%d\n",x,y);
	return 0;
}



Measured memory_bytes: 2108
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
const double INF=1e9;
using namespace std;
int main(){
  int n,m;
  cin>>n>>m;
  vector<vector<int> >out(n+1);
  rep(i,m+1)out[0].pb(0);
  loop(i,1,n+1){
    int a,b;
    cin>>a>>b;
    loop(j,0,m+1){
      if(j-b>=0)out[i].pb(max(out[i-1][j],out[i-1][j-b]+a));
      else out[i].pb(out[i-1][j]);
    }
  }
  cout<<out[n][m]<<endl;
}

Measured memory_bytes: 5492
#include<bits/stdc++.h>
using namespace std;
int main()
{
long long int i,j,n,m;
cin>>n>>m;
if(n%m==0) cout<<0<<endl;
else
{
   i=n%m;
   j=(m-i);
   cout<<min(i,j)<<endl;
}
return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
#define ll long long int

using namespace std;
int main()
{
	ll n;
	cin >> n;
	ll i,j,k,a[n+1]={0};
	ll x=1,y=1,z=1;
	ll eq;
	for(x=1;x<sqrt(n);x++)
	{
		for(y=1;y<sqrt(n);y++)
		{
			for(z=1;z<sqrt(n);z++)
			{
				eq = pow(x,2) + pow(y,2) + pow(z,2) + x*y + y*z + z*x;
				if(eq<=n)
				{
					a[eq]++;	
				}	
			}
		}
	}
	for(i=1;i<=n;i++)
	{
		cout << a[i] << endl;
	}
}

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

#define ll long long
#define endl '\n'
#define REP(i, a, n) for(int i=a; i<n; ++i)
#define pb push_back
#define sz(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()

typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

const double PI = 3.141592653589793238460;
const ll mod = 1e9 + 7;

void FAST(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}

int main(){
  FAST();

  int n, m, c;
  cin >> n >> m >> c;
  vi b(m);
  REP(i, 0, m)  cin >> b[i];

  int ans = 0;
  REP(i, 0, n){
      int x = 0;
      REP(j, 0, m){
          int a;
          cin >> a;
          x += a * b[j];
      }
      if(x + c > 0)
        ans++;
  }
  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <numeric>
#include <bitset>
using namespace std;
#define lint long long
#define ll long long
#define pq priority_queue
#define mp make_pair
#define vl vector<long long>
long long INF = 1e10;
#define pii pair<long long,long long>
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
/******************************define**********************************/
int N;
vector<int> money = { 1,6,36,216,1296,7776,46656,9,81,729,6561,59049 };
int dp[13][100010];
ll cnt = 0;
/*****************************functions********************************/
void solve() {
	sort(all(money));
	for (int i = 1; i <= N; i++) {
		dp[0][i] = INF;
		cnt++;
	}
	for (int i = 1; i <= 12; i++) {
		for (int j = 0; j <= N; j++) {
			if (j - money[i - 1] >= 0) {
				/*int k = 1;
				int res =dp[i-1][j];
				while (j - k * money[i - 1] >= 0) {
					res = min(res, dp[i - 1][j - k * money[i - 1]] + k);
					k++;
					cnt++;
				}
				dp[i][j] = res;*/
				dp[i][j] = min(dp[i-1][j],dp[i][j - money[i - 1]] + 1);
			}
			else {
				dp[i][j] = dp[i-1][j];
				cnt++;
			}
			//printf("%5d ", dp[i][j]);
		} 
		//cout << endl;
	}
}
/****************************main function*****************************/
int main(void) {

	cin >> N;
	solve();
	cout << dp[12][N] << endl;
	//cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 5376
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.PriorityQueue;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] inputs = br.readLine().split(" ");
		int n = Integer.parseInt(inputs[0]);
		int m = Integer.parseInt(inputs[1]);

		PriorityQueue<Integer> a = new PriorityQueue<>();
		int[][] bc = new int[m][2];

		inputs = br.readLine().split(" ");
		for ( int i = 0; i < n; i++ ) {
			a.add(Integer.parseInt(inputs[i]));
		}

		for ( int i = 0; i < m; i++ ) {
			inputs = br.readLine().split(" ");
			bc[i][0] = Integer.parseInt(inputs[0]);
			bc[i][1] = Integer.parseInt(inputs[1]);
		}
		br.close();

		Arrays.sort(bc, (o1, o2) -> o2[1] - o1[1]);

		for ( int i = 0; i < m; i++ ) {
			while ( !a.isEmpty() && a.peek() < bc[i][1] && 0 < bc[i][0] ) {
				a.poll();
				a.add(bc[i][1]);
				bc[i][0]--;
			}
		}
		
		long ans = 0L;
		for ( Integer i : a ) {
			ans += i;
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 69488
#include<iostream>
using namespace std;
void pr(int a[],int n){
	int first=1;
	for (int i=0;i<n;i++){
		if(first)first=0;else cout<<" ";
		cout<<a[i];
	}
	cout<<endl;
}
int main(){
	int n,a[102];
	cin>>n;
	for(int i=0;i<n;i++)cin>>a[i];
	pr(a,n);
	for(int i=1;i<n;i++){
		int v=a[i],j=i-1;
		while(j>=0&&a[j]>v){
			a[j+1]=a[j];
			j--;
		}
		a[j+1]=v;
		pr(a,n);
	}
	return 0;
}


Measured memory_bytes: 3096
#include<iostream>
int main(){
    int S;
    int hour = 60 * 60;
    int minitue = 60;
    std::cin >> S;
    
    int h = S / hour;
    int m = (S - h * hour) / minitue;
    int s = (S - h * hour - m * minitue);
    
    std::cout << h <<':' << m << ':' << s << std::endl;
    
    return 0;
}


Measured memory_bytes: 3088
#pragma GCC optimize("O3")

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

int main(){
    int64_t n, k;
    static int64_t a[200000];
    scanf("%" SCNd64 "%" SCNd64, &n, &k);
    for(int i=0;i<n;++i) scanf("%" SCNd64, &a[i]);
    sort(a, a+n);

    int64_t l = INT64_MIN / 4, r = INT64_MAX / 4;
    while(r - l > 1){
        int64_t mid = (l + r) / 2;
        int64_t lt = 0, le = 0;
        for(int i=0;i<n;++i){
            if(a[i] >= 0){
                int64_t ok = i, ng = n;
                while(ng - ok > 1){
                    int64_t ch = (ok + ng) / 2;
                    if(a[i] * a[ch] < mid) ok = ch;
                    else ng = ch;
                }
                lt += ok - i;
                ok = i; ng = n;
                while(ng - ok > 1){
                    int64_t ch = (ok + ng) / 2;
                    if(a[i] * a[ch] <= mid) ok = ch;
                    else ng = ch;
                }
                le += ok - i;
            }else{
                int64_t ok = n, ng = i;
                while(ok - ng > 1){
                    int64_t ch = (ok + ng) / 2;
                    if(a[i] * a[ch] < mid) ok = ch;
                    else ng = ch;
                }
                lt += n - ok;
                ok = n; ng = i;
                while(ok - ng > 1){
                    int64_t ch = (ok + ng) / 2;
                    if(a[i] * a[ch] <= mid) ok = ch;
                    else ng = ch;
                }
                le += n - ok;
            }
        }
        if(lt < k && le >= k){ printf("%" PRId64 "\n", mid); return 0; }
        if(le < k) l = mid;
        else r = mid;
    }

    return 0;
}

Measured memory_bytes: 1792
import java.util.Arrays;
import java.util.Scanner;
 
public class Main {
 
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = Integer.valueOf(in.nextLine());
		double[] v = new double[n];
		for(int i = 0; i < n; i++)
			v[i] = Double.valueOf(in.next());

		Arrays.sort(v);
		double sum = v[0];
		for(int i = 1; i < n; i++)
			sum = (sum + v[i]) / 2;
		System.out.println(sum);
		
	}
}

Measured memory_bytes: 22356
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int [][] date = new int [2][2];
        for(int i=0;i<2;i++){
            for(int j=0;j<2;j++){
                date[i][j] = scan.nextInt();
            }
        }
        if(date[0][1]>date[1][1]){
            System.out.println("1");
        }else{
            System.out.println("0");
        }
    }
}

Measured memory_bytes: 22228
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>

using namespace std;

#define gettime printf("\nTime : %0.3lf\n",clock()*1.0/CLOCKS_PER_SEC);
#define PB push_back
#define MP make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repp(i,a,b) for(int i=a;i>=b;i--)
#define Set(x,a) memset(x,a,sizeof(x));

#define vs vector<string>
#define vi vector<int>
#define ll long long
#define ff first
#define ss second
#define pii pair<int,int>

struct comp {
       bool operator() (int a,int b) {
            return a>b;
       }
};

vector<pii> data[100005];
map<int, int> ans;
bool visit[100005] = {};

void solve(int x) {
    visit[x] = true;
    int d = ans[x];
    int n = data[x].size();
    rep (i, 0, n - 1) {
        int a = data[x][i].ff;
        int b = data[x][i].ss;
        if (ans.find(a) == ans.end()) {
            ans[a] = d + b;
        }
        if (!visit[a]) solve(a);
    }
}

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    //std::ios::sync_with_stdio(false);
    int n, m, l, r, d;
    scanf("%d %d", &n, &m);
    rep (i, 1, m) {
        scanf("%d %d %d", &l, &r, &d);
        data[l].PB(MP(r, d));
        data[r].PB(MP(l, d * -1));
    }
    rep (i, 1, n) if (!visit[i]) {
        ans[i] = 0;
        solve(i);
    }
    bool valid = true;
    rep (i, 1, n) {
        int a = data[i].size();
        rep (j, 0, a - 1) {
            if (ans[data[i][j].ff] - ans[i] != data[i][j].ss) {
                valid = false;
                break;
            }
        }
        if (!valid) break;
    }
    if (!valid) printf("No\n");
    else printf("Yes\n");
    return 0;
}


Measured memory_bytes: 19456
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<map>

using namespace std;

int main(){
    long long a,b,n; cin >> a >> b >> n;

    long long ans=0;

    for(long long x=min(b-1,n);x<=min(b-1,n);x++){
        long long ax = a*x;
        //cout << ax << endl;
        long long first;
        first = ax/b;

        long long second=x/b;

        long long result = first - a * second;
        //cout << x << " : " << first << " - " << a << "*" << second << " : " << result << endl;
        if(result>ans)ans=result;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3624
N=int(input())
X=[]
for i,x in enumerate(input().split()):
  X.append((int(x)-1,i+1))
X.sort()
a,b,c,k,l=0,0,0,0,0
ans=[]
for i in range(N*N):
  if b<=N-1:
    x,p=X[b]
    if x==i:
      if a<=b and p!=1:
        print("No")
        exit()
      ans.append(p)
      b+=1
      continue
  if a<=N-1:
    y,q=X[a]
    if q==1:
      a+=1
      if a==N:
        z,r=X[c]
        if c>=b:
          print("No")
          exit()
        if r==N:
          c+=1
          l=0
          z,r=X[c]
        ans.append(r)
        l+=1
        if l==N-r:
          c+=1
          l=0
        continue
      else:
        y,q=X[a]
        k=0
    ans.append(q)
    k+=1
    if k==q-1:
      a+=1
      k=0
  else:
    z,r=X[c]
    if c>=b:
      print("No")
      exit()
    if r==N:
      c+=1
      l=0
      z,r=X[c]
    ans.append(r)
    l+=1
    if l==N-r:
      c+=1
      l=0
  
print("Yes")
print(" ".join(map(str,ans)))

Measured memory_bytes: 85240
def main():
    N = int(input())
    inp = [list(map(int, input().split())) for _ in range(N)]

    for cx in range(0, 101):
        for cy in range(0, 101):
            hmax = 10 ** 10
            flg = False
            ha = 0
            for x, y, h in inp:
                m = abs(x-cx) + abs(y-cy)
                if h == 0:
                    hmax = min(hmax, m)
                else:
                    ht = m + h
                    if ht < 1:
                        break
                    if flg:
                        if ht != ha:
                            flg = False
                            break
                    else:
                        flg = True
                        ha = ht
            
            if flg:
                if ha:
                    if ha <= hmax:
                        print(cx, cy, ha)
                        exit()


if __name__ == "__main__":
    main()

Measured memory_bytes: 42604
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n = ni()
s = ns()

if n % 2:
    ans = "No"

else:
    if s[:n//2] == s[n//2:]:
        ans = "Yes"
    else:
        ans = "No"

print(ans)

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

using namespace std;

namespace {

const int G[14] = {
  1,
  4,
  13,
  40,
  121,
  364,
  1093,
  3280,
  9841,
  29524,
  88573,
  265720,
  797161,
  2391484,
};

int InsertionSort(int* a, int n, int g) {
  int cnt = 0;
  for (int i = g; i < n; ++i) {
    const int v = a[i];
    int j = i - g;
    while (j >= 0 && a[j] > v) {
      a[j + g] = a[j];
      j -= g;
      cnt++;
    }
    a[j + g] = v;
  }
  return cnt;
}

int ShellSort(int* a, int n) {
  int cnt = 0;
  int m = 0;
  for (int i = 0; i < 100; ++i) {
    ++m;
    if (G[i + 1] >= n) {
      break;
    }
  }

  printf("%d\n", m);
  for (int i = m - 1; i >= 0; --i) {
    if (i < m - 1) printf(" ");
    printf("%d", G[i]);
  }
  printf("\n");

  for (int i = 0; i < m; ++i) {
    cnt += InsertionSort(a, n, G[m - i - 1]);
  }

  return cnt;
}

}  // namespace

int main() {
  int n;
  int a[1000000];

  cin >> n;
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
  }
  const int cnt = ShellSort(a, n);
  printf("%d\n", cnt);
  for (int i = 0; i < n; ++i) {
    printf("%d\n", a[i]);
  }
  return 0;
}

Measured memory_bytes: 5136
N = int(input())
words = []
prev = "hogehoge"


def check():
    for i in range(N):
        w = input()
        if (i != 0 and prev[-1] != w[0]) or (w in words):
            return "No"
        prev = w
        words.append(w)
    return "Yes"


print(check())


Measured memory_bytes: 2940
import numpy as np

a, b, x = map(int, input().split())

if x > a * a * b / 2:
    tantheta = (2 * b * a**2 - 2 * x) / (a**3)
else:
    tantheta = a * b**2 / (2 * x)
costheta = 1 / np.sqrt(1 + tantheta**2)
print(np.arccos(costheta) * 180 / np.pi)


Measured memory_bytes: 12428
import numpy as np
N, M = map(int, input().split())
W = [list(map(int, input().split())) for _ in range(N)]
W = np.array(W, dtype=np.int64)
t_max = 0
for i in range(8):
    a = np.array([(-1)**i, (-1)**(i // 2), (-1)**(i // 4)], dtype=np.int64)
    s = np.sum(a * W, axis=1)
    idx = np.argsort(s)[::-1]
    t = np.sum(np.abs(np.sum(W[idx[:M], :], axis=0)))
    if t > t_max:
        t_max = t
print(t_max)


Measured memory_bytes: 18872
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		StringBuilder text = new StringBuilder();
		int count = 1;
		while (true) {
			int num = scan.nextInt();
			if (num == 0) {
				scan.close();
				text.deleteCharAt(text.lastIndexOf("\n"));
				System.out.println(text.toString());
				break;
			} else {
				text.append("Case ").append(count).append(": ").append(num).append("\n");
				count++;
			}
		}
	}

}

Measured memory_bytes: 34092
from collections import Counter

n = 50
comb = [[0] * (n + 1) for _ in range(n + 1)]
for i in range(n + 1):
    for j in range(n + 1):
        if j == 0 or j == i:
            comb[i][j] = 1
        else:
            comb[i][j] = comb[i - 1][j - 1] + comb[i - 1][j]

N, A, B, *X = map(int, open(0).read().split())

ctr = Counter(X)
value = 0
cnt = 0
cand = []
for i, (k, v) in enumerate(sorted(ctr.items(), reverse=True)):
    if i == 0 and A <= v:
        value = k * v
        cnt = v
        cand.append((k, v))
        break

    # Add
    c = min(v, A - cnt)
    value += k * c
    cnt += c
    cand.append((k, c))
    if cnt == A:
        break

# Count combinations
ans = 1
if len(cand) == 1:
    _, n = cand[0]
    ans = 0
    for k in range(A, min(v, B) + 1):
        ans += comb[n][k]
else:
    ans = 1
    for k, c in cand:
        ans *= comb[ctr[k]][c]

print(value / cnt)
print(ans)


Measured memory_bytes: 39664
using System;
class Program
{
	static void Main(string[] args)
	{
		
		string[] input = Console.ReadLine().Split(' ');
		int N = int.Parse(input[0]);
		int M = int.Parse(input[1]);
		if(N==M){
          Console.WriteLine("Yes");
        }
        else{
          Console.WriteLine("No");
        }
	}
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define vc vector<int>
#define um unordered_map<int,int>
#define ll long long 
#define rep(i,a,b) for(__typeof(a) i=a; i<b; i++)
#define si(a) a.size()
#define all(a) a.begin(),a.end()
#define ss(a) a.second
#define ff(a) a.first
#define M 1000000
#define pb push_back
#define repit(i,a) for(auto i=a.begin(); i!=a.end(); i++)
#define take(arr,n) for(int i=0;i<n;i++)cin>>arr[i]
#define out(arr,n) for(int i=0;i<n;i++)cout<<arr[i]<<' '
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
#define reprev(i,b,a) for(__typeof(b) i=b; i>=a; i--)
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
#define doublearray vector<vector<int>>
#define mod 998244353 
using namespace std;
ll max(ll a, ll b){ return a>b?a:b; }
ll min(ll a, ll b){ return a<b?a:b; }
// ll gcd(ll a, ll b){
//     if(b==0) return a;
//     return gcd(b,a%b);
// }
// ll lcm(ll a, ll b){
//     return (a*b)/gcd(a,b);
// }
int main(){
    fastio;
    int a; cin>>a;
    cout<<(a+a*a+a*a*a)<<endl;
    return 0;
}


Measured memory_bytes: 3620
#include<iostream>
#include<cstring>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdio>
#include<cmath>
#define pb(in,tmp) in.push_back(tmp)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) loop(i,0,b)
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
using namespace std;
 
void bom(int x,int y,vector<string>&in){
in[x][y]='0';
loop(i,-3,4)
loop(j,-3,4){
if(i&&j)continue;
if(x+i>=0&&x+i<8&&y+j>=0&&y+j<8&&in[x+i][y+j]=='1')bom(x+i,y+j,in);
}
}
 
int main(){
int n;
cin>>n;
rep(i,n){
vector<string> in(8);
rep(j,8)cin>>in[j];
int x,y;
cin>>x>>y;
if(in[y-1][x-1]=='1')bom(y-1,x-1,in);
cout<<"Data "<<i+1<<":"<<endl;
rep(j,8)cout<<in[j]<<endl;
}
}

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

int main()
{
    string s;
    cin >> s;
    if(s.size() % 2){
        cout << "No" << endl;
        return 0;
    }
    for(int i = 0; i < (int)s.size(); i++){
        if((i % 2 == 0 && s[i] != 'h') || (i % 2 == 1 && s[i] != 'i')){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 256