akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;

int main(){
    string N;  cin >> N;
    ll ans = 0;
    int up = 0;
    for(int i=N.length()-1; i>=0; i--){
        int d = (N[i] - '0') + up;
        if(d%10 <= 4){
            ans += d%10;
            if(d >= 10) up = 1;
            else up = 0;
        }else if(d%10 >= 6){
            ans += 10 - d%10;
            up = 1;
        }else{
            if(i==0 || N[i-1] - '0' <= 4){
                ans += 5;
                up = 0;
            }else{
                ans += 5;
                up = 1;
            }
        }
    }
    cout << ans + up << endl;
}


Measured memory_bytes: 1412
from collections import Counter

def solve():
    N, M = map(int, input().split())
    *A, = map(int, input().split())
    *B, = map(int, input().split())
    c = Counter()
    MOD = 10**9+7

    used = set()

    for i in range(N):
        for j in range(M):
            if A[i]==B[j]:
                if A[i] in used:
                    print(0)
                    return
                else:
                    used.add(A[i])
            c[min(A[i], B[j])] += 1

    cd = 0
    ans = 1
    bef = 0
    for i, j in sorted(c.items()):
        cd += (i - bef)
        if i in used:
            # print(cd, j)
            cd -= 1
            for k in range(j-1):
                ans *= (cd-k)
                ans %= MOD
            cd -= j-1
        else:
            # print(cd, j)
            ans *= j
            cd -= 1
            for k in range(j-1):
                ans *= (cd-k)
                ans %= MOD
            cd -= j-1
        bef = i
    print(ans%MOD)

solve()

Measured memory_bytes: 3700
N,K = map(int,input().split())
R,S,P = map(int,input().split())
T = list(input())

score = 0
for i in range(N):
  if i >= K and T[i] == T[i-K]:
    T[i] = 'x'
  elif T[i] == 'r':
    score += P
  elif T[i] == 's':
    score += R
  elif T[i] == 'p':
    score += S
print(score)

Measured memory_bytes: 4084
import java.io.*;
import java.util.*;
 
public class Main {
    private static boolean debug = false;
    private static boolean elapsed = false;
 
    private void solve(Scanner sc, PrintWriter out) {
        int N = sc.nextInt();
        int[] p = new int[N];
        for (int i = 0; i < N; ++i) {
            p[i] = sc.nextInt() - 1;
        }
 
        int[] r = new int[N];
        for (int i = 0; i < N; ++i) {
            r[p[i]] = i + 1;
        }
        int[] a = new int[N];
        int[] b = new int[N];
        for (int i = 0; i < N; ++i) {
            a[i] = N * (i + 1);
            b[i] = N * (N - i - 1) + r[i];
        }
//      for (int i = 0; i < N - 1; ++i) {
//          while (a[p[i]] + b[p[i]] >= a[p[i + 1]] + b[p[i + 1]]) {
//              for (int j = p[i + 1]; j < N; ++j) {
//                  ++a[j];
//              }
//              for (int j = p[i + 1]; j >= 0; --j) {
//                  ++b[j];
//              }
//          }
//      }
        for (int i = 0; i < N; ++i) {
            if (i > 0) {
                out.print(" ");
            }
            out.print(a[i]);
        }
        out.println();
        for (int i = 0; i < N; ++i) {
            if (i > 0) {
                out.print(" ");
            }
            out.print(b[i]);
        }
        out.println();
    }
    /*
     * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9
     * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18
     */
    public static void main(String[] args) {
        long S = System.currentTimeMillis();
 
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        new Main().solve(sc, out);
        out.flush();
 
        long G = System.currentTimeMillis();
        if (elapsed) {
            System.err.println((G - S) + "ms");
        }
    }
}

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

#define    ll     long long int

int main( )
{
    ll n, m, s;
    cin >> n >> m;
    if (n > m) swap(n, m);
    if (n == 1) {
        if (m == 1) {
            cout << "1\n";
            return 0;
        }
        cout << max(m - 2, 0LL) << '\n';
    }
    else {
        cout << ((n * m) - (2 * (n - 1) + 2 * (m - 1))) << '\n';
    }
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <string>

using namespace std;

#define LL long long

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

LL mod(LL x, LL md) {
	return ((x % md) + md) % md;
}

class Mint {
public:
	static LL md;
	LL x;
	Mint(LL _x) {
		x = mod(_x, md);
	}
	Mint(const Mint &y) {
		x = mod(y.x, md);
	}
};

void MintMyExgcd(LL a, LL b, LL &x, LL &y) {
	// solve equation ax + by = 1 (mod m)
	LL md = Mint::md;
	if (b == 0) {
		y = 0;
		x = 1;
		return ;
	}
	MintMyExgcd(b, a % b, x, y);
	LL t = y;
	y = mod(x - (a / b) * y, md);
	x = t;
}

LL MintNY(LL x) {
	if (x == 0) {
		return 1;
	}
	LL md = Mint::md;
	LL a, b;
	MintMyExgcd(x, md, a, b);
	while (a < 0) {
		a += md;
	}
	return a;
}

/* LL gcd(LL a, LL b) {
	if (b == 0) {
		return a;
	}
	return gcd(b, a % b);
} */

Mint operator+(Mint a, Mint b) {
	return Mint(mod(a.x + b.x, Mint::md));
}
Mint operator-(Mint a, Mint b) {
	return Mint(mod(a.x - b.x, Mint::md));
}
Mint operator*(Mint a, Mint b) {
	return Mint(mod(a.x * b.x, Mint::md));
}
Mint operator/(Mint a, Mint b) {
	Mint c = Mint(MintNY(b.x));
	return Mint(mod(a.x * c.x, Mint::md));
}

Mint operator-(Mint a) {
	return Mint(-a.x);
}
bool operator==(Mint a, Mint b) {
	return a.x == b.x;
}
bool operator!=(Mint a, Mint b) {
	return a.x != b.x;
}
bool operator>(Mint a, Mint b) {
	return a.x > b.x;
}
bool operator<(Mint a, Mint b) {
	return a.x < b.x;
}
bool operator>=(Mint a, Mint b) {
	return a.x >= b.x;
}
bool operator<=(Mint a, Mint b) {
	return a.x <= b.x;
}

void operator+=(Mint &a, Mint b) {
	a = a + b;
}
void operator-=(Mint &a, Mint b) {
	a = a - b;
}
void operator*=(Mint &a, Mint b) {
	a = a * b;
}
void operator/=(Mint &a, Mint b) {
	a = a / b;
}

ostream& operator<<(ostream &out, Mint a) {
	out << a.x;
	return out;
}

istream& operator>>(istream &in, Mint &a) {
	in >> a.x;
	return in;
}

Mint factorial(LL n) {
	if (n == 0) {
		return Mint(1);
	}
	Mint res = 1;
	for (LL i = 1; i <= n; ++i) {
		res *= i;
	}
	return res;
}
Mint multiRange(LL s, LL t) {
	Mint res = 1;
	for (LL i = s; i <= t; ++i) {
		res *= i;
	}
	return res;
}

Mint getC(LL n, LL k) {
	if (n - k < k) {
		return getC(n, n - k);
	}
	return multiRange(n - k + 1, n) / factorial(k);
}

Mint getA(LL n, LL k) {
	return multiRange(n - k + 1, n);
}

Mint countNonNegativeDivision(LL n, LL k) {
	return getC(n + k - 1, k - 1);
}
Mint countPositiveDivision(LL n, LL k) {
	if (n < k) {
		return 0;
	}
	if (k <= 0) {
		return 0;
	}
	return getC(n - 1, k - 1);
}
Mint quickMod(Mint a, LL b) {
	Mint res = 1;
	while (b > 0) {
		if (b % 2) {
			res *= a;
		}
		a *= a;
		b /= 2;
	}
	return res;
}

LL Mint::md = 1000000007;

int n, m;
int *a;
int main() {
	cin >> n >> m;
	a = new int[m];
	for (int i = 0; i < m; ++i) {
		scanf("%d", &a[i]);
		n -= a[i];
	}
	if (n < 0) {
		n = -1;
	}
	cout << n << endl;
	return 0;
}

Measured memory_bytes: 3764
#include "bits/stdc++.h"
#define rep(i,a,n) for(int i = (a);i < (n);i++)
typedef unsigned long long ull;
typedef long long ll;
using namespace std;

int main(){
	int a,b;
	cin >> a >> b;
	cout << abs(a-b) << endl;
	
	return 0;
}


Measured memory_bytes: 3108
while True:
    n, x = [int(_) for _ in input().split()]
    if n == x == 0:
        break
        
    count = 0
    for i in range(1, n + 1 - 2):
        for j in range(i + 1, n + 1 -1):
            for k in range(j + 1, n + 1):
                if i + j + k  == x:
                    count += 1

    print(count)
    



Measured memory_bytes: 5604
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1LL << 30;
int MOD = 1e9+7;
main(){
    string S;
    cin >> S;
    if(S.find("AC") != -1)cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int a,b,c,num;
	scanf("%d%d%d",&a,&b,&c);
	int ab = a+b;
	int ac = a+c;
	int bc = b+c;
	num = ab;
	if(num>ac){
		num = ac;
	}
	if(num>bc){
		num = bc;
	}
	printf("%d\n",num);
}

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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

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<typename T>
void print1(T begin, T end) {
  while (begin != end) {
    cout << (*begin) << " ";
    *begin++;
  }
  cout << endl;
}

template<typename T>
void print2(T Array, int height, int width) {
  for (int i = 0; i < height; i++) {
    for (int j = 0; j < width; j++) {
      cout << " " << Array[i][j];
    }
    cout << endl;
  }
}

void print() { std::cerr << endl; }
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  std::cerr << head << " ";
  print(std::forward<Tail>(tail)...);
}

template<class T>
void Add(T &a, const T &b, const T &mod=1e9+7) {
  int val = ((a % mod) + (b % mod)) % mod;
  if (val < 0) { val += mod; }
  a = val;
}

// ------------------------------------------------------------------------------------------

const int INF = 1e18;

// idx, (未処理, 偶数左, 奇数, 偶数右)
const int VARI = 5;
int dp[200010][VARI];

signed main() {
  int N;
  cin >> N;
  vec<int> v(N);
  rep (i, N) {
    cin >> v[i];
  }

  const int one = 0; // 左のゼロ区間
  const int two = 1; // 右のゼロ区間
  const int three = 2; // 左の偶数区間
  const int four = 3; // 右の偶数区間
  const int five = 4; // 奇数区間

  // 初期化
  fill(dp[0], dp[N+1], INF);
  dp[0][one] = 0;

  // DP
  rep (i, N) {
    // 未処理左
    chmin(dp[i+1][one], dp[i][one] + v[i]);

    // 偶数左
    int cost1 = (v[i] == 0 ? 2 : (v[i] % 2));
    chmin(dp[i+1][two], min(dp[i][two], dp[i][one]) + cost1);

    // 偶数右
    int cost2 = (v[i] == 0 ? 2 : (v[i] % 2));
    chmin(dp[i+1][four], min(dp[i][three], dp[i][four]) + cost2);

    // 奇数
    int cost3 = 1 - (v[i] % 2);
    int mi = min({dp[i][two], dp[i][three], dp[i][one]});
    chmin(dp[i+1][three], mi + cost3);

    // 未処理右
    int mi2 = min({dp[i][two], dp[i][four], dp[i][three], dp[i][five]});
    chmin(dp[i+1][five], mi2 + v[i]);
  }

  int ans = INF;
  rep (i, VARI) {
    chmin(ans, dp[N][i]);
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 9600
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define inf 20021225
#define ll long long
#define mdn 1000000007
using namespace std;
 
int f[4100][4100],inv2;
int fac[8100],inv[8100];
int n,a[200010],b[200010];
 
int ksm(int bs,int mi)
{
	int ans=1;
	while(mi)
	{
		if(mi&1)	ans=(ll)ans*bs%mdn;
		bs=(ll)bs*bs%mdn; mi>>=1;
	}
	return ans;
}
 
int C(int x,int y)
{
	if(x<y)	return 0;
	return (ll) fac[x] * inv[x-y] %mdn *inv[y]%mdn;
}
bool vis[4100][4100];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)	scanf("%d%d",&a[i],&b[i]),f[2001-a[i]][2001-b[i]]+=1;
	fac[0]=inv[0]=1; inv2=ksm(2,mdn-2);
	for(int i=1;i<=8001;i++)	fac[i]=(ll)fac[i-1]*i%mdn;
	inv[8001]=ksm(fac[8001],mdn-2);
	for(int i=8000;i;i--)	inv[i]=(ll)inv[i+1]*(i+1)%mdn;
	for(int i=1;i<=4001;i++)
		for(int j=1;j<=4001;j++)
			f[i][j]+=f[i-1][j]+f[i][j-1],f[i][j]%=mdn;
	int mns=0,add=0;
	for(int i=1;i<=n;i++)
		mns = ((ll)mns + C(2*(a[i]+b[i]),2*a[i]))%mdn , add = ((ll)add + f[2001+a[i]][2001+b[i]])%mdn;
	//printf("%d %d %d\n",a[i],b[i],f[2001+a[i]][2001+b[i]]);
	add -= mns; if(add<0)	add+=mdn;
	//printf("%d\n",mns);
	printf("%d\n",(ll)add*inv2%mdn);
	return 0;
}


Measured memory_bytes: 65920
#pragma GCC optimize("O3")
#include<bits/stdc++.h>

using namespace std;

typedef long long lll;
#define int lll
typedef long double ld;

typedef pair<int,int> pii;
#define x first
#define y second

const int N=1e5+100;

int p[N],r[N];

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

    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>p[i],
        r[p[i]]=i;
    multiset<int,greater<int>> s{0,0,n+1,n+1};
    int ans=0;
    for(int val=n;val>=1;val--)
    {
        int pos=r[val];
        int l=*prev(s.lower_bound(pos));
        int ll=*prev(s.lower_bound(pos),2);
        int r=*s.lower_bound(pos);
        int rr=*next(s.lower_bound(pos));
        int cnt1=(l-ll)*(r-pos);
        int cnt2=(rr-r)*(pos-l);
        ans+=val*(cnt1+cnt2);
        s.insert(pos);
    }
    cout<<ans;
}


Measured memory_bytes: 6528
import java.util.Scanner;

public class Main {
	int a, b;
	String op = "";
	
	public static void main(String[] args) {
		new Main().run();
	}
	
	void run() {
		Scanner sc = new Scanner(System.in);
		while(!op.equals("?")) {
			a = sc.nextInt();
			op = sc.next();
			b = sc.nextInt();
			if(!op.equals("?"))System.out.println(calc(a, op, b));
		}
		sc.close();
	}
	
	int calc(int a, String op, int b) {
		if(op.equals("+")) return a + b;
		if(op.equals("-")) return a - b;
		if(op.equals("*")) return a * b;
		if(op.equals("/")) return a / b;
		return 0;
	}
}



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

int K;
string S;

int main()
{
    cin >> K;
    cin >> S;

    if (S.length() <= K)
    {
        cout << S << endl;
    }
    else
    {
        cout << S.substr(0,K)+"..." << endl;
    }
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define modulo (M)
#define mod(mod_x) (((long long)mod_x)%modulo)
int cnt = 0;
long long M;

int beki(int a,int b){
	int x = 1;
	while(b!=0){
		if(b&1){
			x=mod(x*a);
		}
		a=mod(a*a);
		b>>=1;
	}
	return x;
}

struct matrix{
	vector<vector<long long>> value;
	
	matrix(int height,int width){
		value.resize(height,vector<long long>(width,0));
		if(height==width){
			for(int i=0;i<get_width();i++){
				value[i][i] = 1;
			}
		}
	}
	
	void resize(int height,int width){
		value.resize(height,vector<long long>(width,0));
		for(int i=0;i<get_width();i++){
			value[i][i] = 1;
		}
	}
	
	void set_value(vector<vector<long long>> &V){
		value = V;
	}
	
	void set_value(initializer_list<long long> list){
		auto it = list.begin();
		for(int i=0;i<get_height();i++){
			for(int j=0;j<get_width();j++){
				value[i][j]=*it;
				if(i!=get_height()-1||j!=get_width()-1)it++;
			}
		}
	}
	
	int get_width(){
		return value[0].size();
	}
	
	int get_height(){
		return value.size();
	}
	
	void print(){
		for(int i=0;i<get_height();i++){
			for(int j=0;j<get_width();j++){
				if(j!=0)cout<<' ';
				cout<<value[i][j];
			}
			cout<<endl;
		}
	}
	
};

matrix matrix_multiple(matrix &A,matrix &B){
	cnt++;
	matrix R(A.get_height(),B.get_width());
	int multi_cnt;
	if(A.get_width()!=B.get_height()){
		assert(false);
	}
	else multi_cnt = A.get_width();
	
	for(int i=0;i<R.get_height();i++){
		for(int j=0;j<R.get_width();j++){
			R.value[i][j]=0;
			for(int k=0;k<multi_cnt;k++){
				
				R.value[i][j] = mod(R.value[i][j] + mod(A.value[i][k] * B.value[k][j]));
	
			}
		}
	}
	return R;
	
}

matrix matrix_beki(matrix A,long long cnt){
	if(A.get_width()!=A.get_height())assert(0);
	matrix R(A.get_width(),A.get_width());
	while(cnt!=0){
		if(cnt&1){
			R=matrix_multiple(R,A);
		}
		A=matrix_multiple(A,A);
		cnt>>=1;
	}
	return R;
}



int main(){
	
	long long L,A,B;
	cin>>L>>A>>B>>M;
	
	vector<long long> maxi(18,0);
	long long x = 10;
	for(int i=0;i<18;i++){
		long long ok = -1;
		long long ng = L;
		while(abs(ok-ng)>1){
			long long mid = (ok+ng)/2;
			long long a = A+B*(mid);
			if(a<x){
				ok = mid;
			}
			else{
				ng = mid;
			}
		}
		maxi[i] = ok+1;
		for(int j=i-1;j>=0;j--){
			maxi[i]-=maxi[j];
		}
		x*=10;
	}
	A=mod(A);
	B=mod(B);
	matrix ans(3,3);
	for(int i=0;i<18;i++){
		matrix X(3,3);
		X.set_value({
			beki(10,i+1),0,0,
			1,1,0,
			0,B,1
		});
		X=matrix_beki(X,maxi[i]);
		ans = matrix_multiple(ans,X);
		//ans.print();
	}
	
	matrix ans2(1,3);
	ans2.set_value({0,A,1});
	ans2 = matrix_multiple(ans2,ans);
	cout<<ans2.value[0][0]<<endl;

		
	
	return 0;
}

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

int sx, sy, tx, ty;
string ans = "", X[] = {"L", "R"}, Y[] = {"D", "U"};

int main()
{
    cin >> sx >> sy >> tx >> ty;
    bool x = sx < tx, y = sy < ty;
    for (int i = 0; i < 2; i++, x = !x, y = !y)
    {
        for (int j = 0; j < abs(sx - tx); j++)
            ans = ans + X[x];
        for (int j = 0; j < abs(sy - ty); j++)
            ans = ans + Y[y];
    }
    for (int i = 0; i < 2; i++, x = !x, y = !y)
    {

        ans = ans + X[!x];
        for (int j = 0; j < abs(sy - ty) + 1; j++)
            ans = ans + Y[y];
        for (int j = 0; j < abs(sx - tx) + 1; j++)
            ans = ans + X[x];
        ans = ans + Y[!y];
    }
    cout << ans << endl;
}

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

int main() {

  int W, H, x, y, r;
  cin >> W >> H >> x >> y >> r;

  if (x + r <= W && y + r <= H && 0 <= x - r && 0 <= y - r) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;

}


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

using namespace std;

const int N = 1e4;

int a[N];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, x;
  cin >> n >> x;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int d = 0, ans = 1;
  for (int i = 1; i <= n; i++) {
    d = d + a[i - 1];
    if (d > x) break;
    ans++;
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 256
#include<iostream> 
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cmath> 
#include<algorithm>
#include<vector>
#define ll long long 
using namespace std;
const int maxn=500010, inf=1e9;
int n;
int a[maxn];
char s[maxn];
vector<int>v[maxn];

template<typename T>
inline void read(T &k)
{
	int f=1; k=0; char c=getchar();
	while(c<'0' || c>'9') c=='-'&&(f=-1), c=getchar();
	while(c<='9' && c>='0') k=k*10+c-'0', c=getchar();
	k*=f;
}

int main()
{
	scanf("%s", s+1);
	int n=strlen(s+1);
	for(int i=1;i<=n;i++) a[i]=s[i]-'0';
	if(a[1]==0 || a[n]==1) return puts("-1"), 0;
	for(int i=1;i<=n;i++)
	if(a[i] && !a[n-i]) return puts("-1"), 0;
	int pre=0;
	for(int i=1;i<=n;i++)
	if(a[i])
	{
		while(pre+1<i)
		{
			pre++;
			v[i].push_back(pre);
		}
	}
	while(pre+1<n)
	{
		pre++;
		v[n].push_back(pre);
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=0;j<v[i].size();j++) printf("%d %d\n", i, v[i][j]);
	}
}

Measured memory_bytes: 17152
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var s = Console.ReadLine();

            if (n % 2 != 0)
            {
                Console.WriteLine("No");
                return;
            }

            if (s.Substring(0,(n/2)) == s.Substring(n / 2))
            {
                Console.WriteLine("Yes");                
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define pb push_back
#define int long long
#define all(x) (x).begin(), (x).end()
using namespace std;

const int N = 3e5 + 5;

struct cell {
    int k, l, r;
};

struct forset {

    bool operator ()(const cell &a, const cell &b) const {
        return a.l - a.r < b.l - b.r;
    }
};

int n;
vector<cell> a, b, c;

bool cmp1(cell a, cell b) {
    return a.k < b.k;
}


signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t;
    cin >> t;
    while (t--) {
    a.clear();
    b.clear();
    c.clear();
    int ans = 0;

    cin >> n;
    for (int i = 1; i <= n; i++) {
        int k, l, r;
        cin >> k >> l >> r;
        if (r >= l)
            c.pb({k, l, r});
        else
            a.pb({k, l, r});
    }
    sort(c.begin(), c.end(), cmp1);
    sort(a.begin(), a.end(), cmp1);
    int cur = 0;
    multiset<cell, forset> q;
    for (int i = 1; i <= n; i++) {
        while (cur < a.size() && a[cur].k <= i)
            cur++, q.insert(a[cur - 1]);
        if (q.size() > i) {
            while (q.size() != i) {
                b.pb(*q.begin());
                q.erase(q.begin());
            }
        }
    }
    sort(b.begin(), b.end(), cmp1);
    vector<cell> all;
    for (auto x: q)
        all.pb(x);
    sort(all.begin(), all.end(), cmp1);
    for (auto x: b)
        all.pb(x);
    b.clear();
    q.clear();
    cur = c.size() - 1;
    while (cur >= 0 && c[cur].k == n)
        cur--, b.pb(c[cur + 1]);
    //reverse(all(c));
    for (int i = n; i >= 1; i--) {
        while (cur >= 0 && c[cur].k == i - 1)
            cur--, q.insert(c[cur + 1]);
        while (q.size() > n - i + 1) {
            auto it = q.end();
            it--;
            b.pb(*it);
            q.erase(it);
        }
    }
   // cout << cur << ' '  << c.size() <<  ' ' << q.size() <<  ' ' << b.size() << endl;
    for (auto x: b)
        all.pb(x);
    b.clear();
    for (auto x: q)
        b.pb(x);
    sort(b.begin(), b.end(), cmp1);
    for (auto x: b)
        all.pb(x);
    //cout << ans << endl;
    //for (auto x: all)
    //    cout << x.k <<' ' << x.l << ' ' << x.r << endl;
    for (int i = 0; i < all.size(); i++)
        if (all[i].k >= i + 1)
            ans += all[i].l;
        else
            ans += all[i].r;
    cout << ans << "\n";
    }
    return 0;
}


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

 int all(int n){
    int sum = 0;
    while(n > 0){
      sum += n % 10;
      n /= 10;
    }
    return sum;
  }

int main(){
  int N, A, B;
  cin >> N >> A >> B;
  
  int count = 0;
  for(int i = 1; i <= N; i++){
    int sumsum = all(i);
    if(all(i) >= A && all(i) <= B){
      count += i;
    }
  }
  
  cout << count << endl;
}


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

using namespace std;

typedef vector<int> VI;
#define ALL(a) (a).begin(),(a).end()
#define PB push_back
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define IN(v) int v;cin>>v;
#define OUT(v) cout<<v<<endl


int main() {
  IN(N);

  VI A(N), dp;
  cin >> A[0];
  dp.PB(-A[0]);

  REP(i, N-1) {
    IN(a);
    A.PB(a);
    auto it = upper_bound(ALL(dp), -a);
    if (it == dp.end())
        dp.PB(-a);
    else
        *it = -a;
  }
  OUT(dp.size());

  return 0;
}


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

using namespace std;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	long long n, d, x, y, br = 0;
	cin >> n >> d;
	for(long long i = 0; i < n; ++i){
		cin >> x >> y;
		if(sqrt(x * x + y * y) <= d) ++br;
	}
	cout << br;

	return 0;
}



Measured memory_bytes: 3684
#include<iostream>
#include<vector>
#include<algorithm>
#include<stdio.h>
using namespace std;
int main() {
	int a, b, c, d, e, f;
	string A;
	cin >> a >> b >> c >> d >> e >> f;
	if (e-a > f) {
		A = ":(";
	}
	else {
		A = "Yay!";
	}
	cout << A << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

main(){
	int h, w, i, j;
	while(1){
		scanf("%d%d",&h,&w);
		
		if(h<3&&w<3)break;
		
		for(i=0;i<h;i++){
			for(j=0;j<w;j++){
				if(i==0||i+1==h||j==0||j+1==w)printf("#");
				else printf(".");
			}
			printf("\n");
		}
		
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 572
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5;
int a[N],b[N];
int main()
{
    int n,r=0;
    cin>>n;
    for(int i=0; i<n; i++)cin>>a[i];
    for(int i=0; i<n; i++)cin>>b[i];
    if(n&1)
    {
        for(int i=0; i<n; i++)r^=a[i]^b[i];
    }
    for(int i=1<<29; i; i>>=1)
    {
        for(int j=0; j<n; j++)a[j]&=i-1;
        sort(a,a+n);
        for(int j=0; j<n; j++)
        {
            int t=lower_bound(a,a+n,i-(b[j]&(i-1)))-a;
            if((t&1)!=(n&1))r^=i;
        }
    }
    cout<<r;
    return 0;
}

Measured memory_bytes: 1792
print([1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51][int(input())-1])

Measured memory_bytes: 38256
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main(void){
	int n;

	cin >> n;
	while(n--){
		int len,big;
		string val[2];
		bool crr=false;

		for(int j=0;j<2;j++){
			cin >> val[j];
			reverse(val[j].begin(),val[j].end());
		}

		big=val[0].size()>=val[1].size()?0:1;
		val[1-big].append((len=val[big].size())-val[1-big].size(),'0');

		if(len<=80){
			for(int j=0;j<len;j++){
				val[0][j]+=val[1][j]+crr-0x60;
				crr=val[0][j]/10;
				val[0][j]%=10;
				val[0][j]+=0x30;
			}

			if(crr){
				val[0].append(1,'1');
				len++;
			}
		}

		if(len<=80)
			reverse(val[0].begin(),val[0].end());
		else
			val[0]="overflow";

		cout << val[0] << endl;
	}

	return 0;
}

Measured memory_bytes: 1212
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<string>


long long  INF=1000000000000000000;
long long mod=1000000007;
using namespace std;


int main(){
string s,t;
cin>>s;
cin>>t;
long long ans=0;
for(int i=0;i<s.size();i++){
    if(s[i]==t[i]){
        ans++;
    }
}
cout<<ans<<endl;
 return 0;
}

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

int main()
{
	int n;
	cin >> n;
	vector<string> s(n);
	for(int i =0;i<n;i++)
	cin >> s[i];
	for(int i = 0;i<n-1;i++)
	{
		if(s[i].back()!=s[i+1].front())
		{
			cout<<"No"<<endl;
			return 0;
		}
	}
	sort(s.begin(),s.begin()+n);
	for(int i =0 ;i<n-1;i++)
	{
		if(s[i]==s[i+1])
		{
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
	

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define MAX 100005
#define NIL -1
struct Node { int p, r, l; };

Node T[MAX];
int n, D[MAX];
void print(int u) {
	int i, c;
	cout << "node " << u << ": ";
	cout << "parent = " << T[u].p << ", ";
	cout << "depth = " << D[u] << ", ";
	if (T[u].p == NIL)cout << "root, ";
	else if (T[u].l == NIL)cout << "leaf, ";
	else cout << "internal node, ";
	cout << "[";
	for (i = 0, c = T[u].l; c != NIL; i++, c = T[c].r) {
		if (i)cout << ", ";
		cout << c;
	}
	cout << "]" << endl;
}
void rec(int u, int p) {
	D[u] = p;
	if (T[u].r != NIL)rec(T[u].r, p);
	if (T[u].l != NIL)rec(T[u].l, p + 1);
}

int main() {
	int i, j, d, v, c, l, r;
	cin >> n;
	for (i = 0; i < n; i++)T[i].p = T[i].l = T[i].r = NIL;
	for (i = 0; i < n; i++) {
		cin >> v >> d;
		for (j = 0; j < d; j++) {
			cin >> c;
			if (j == 0)T[v].l = c;
			else T[l].r = c;
			l = c;
			T[c].p = v;
		}
	}
	for (i = 0; i < n; i++) {
		if (T[i].p == NIL)r = i;
	}
	rec(r, 0);
	for (i = 0; i < n; i++)print(i);
	return 0;
}

Measured memory_bytes: 7744
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
template <typename T> using posteriority_queue = priority_queue<T, vector<T>, greater<T> >;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
template <typename T> void unique(vector<T> &a) { a.erase(unique(ALL(a)), a.end()); }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  string n; int k; cin >> n >> k;
  int m = n.length();
  vector<vector<vector<ll> > > dp(m + 1, vector<vector<ll> >(k + 1, vector<ll>(2, 0)));
  dp[0][0][false] = 1;
  REP(x, m) REP(y, k + 1) {
    dp[x + 1][y][true] += dp[x][y][true];
    dp[x + 1][y][n[x] - '0' > 0] += dp[x][y][false];
    if (y + 1 <= k) {
      FOR(i, 1, 10) {
        dp[x + 1][y + 1][true] += dp[x][y][true];
        if (i <= n[x] - '0') dp[x + 1][y + 1][n[x] - '0' > i] += dp[x][y][false];
      }
    }
  }
  cout << dp[m][k][true] + dp[m][k][false] << '\n';
  return 0;
}


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

using namespace std;

typedef long long LL;

#define N 120
#define M 520

const LL mod=1000000007;
LL n,m,ans,a[N],f[N][N][M];

void upd(LL &x,LL y){x=(x+y)%mod;}

int main(){
	scanf("%lld%lld",&n,&m);
	for (LL i=1;i<=n;++i){
		scanf("%lld",a+i);
	}
	sort(a+1,a+n+1,greater<LL>());
	f[1][1][a[1]]=1;
	for (LL i=2;i<=n;++i)
		for (LL j=0;j<=i;++j)
			for (LL k=0;k<=m;++k)
				if (f[i-1][j][k]){
					upd(f[i][j][k],f[i-1][j][k]*(k-(a[i]-1)*j));
					if (k+a[i]<=m) upd(f[i][j+1][k+a[i]],f[i-1][j][k]*(j+1));
					for (LL l=1;l<a[i]&&k+l<=m;++l) upd(f[i][j][k+l],f[i-1][j][k]*2*j);
					if (j>1) for (LL l=0;l<a[i]&&k+l<=m;++l) upd(f[i][j-1][k+l],f[i-1][j][k]*(j-1)*(a[i]-l-1));
				}
	for (LL i=1;i<=n;++i) upd(ans,f[n][i][m]);
	printf("%lld\n",ans);
	
	return 0;
}
			

Measured memory_bytes: 49408
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int N;
int P[1001],X[1001];
vint ko[1001];
pint costmin[1001];
bool solve(int from){
	costmin[from]=mp(X[from],0);
	int konum=ko[from].size();
	if(konum==0) return 1;
	//printf("from:%d\n",from+1);
	rep(i,konum){
		int to=ko[from][i];
		if(solve(to)==0){
			//printf("solve(%d)=0\n",to+1);
			return 0;
		}
		else{
			//printf("solve(%d)=1\n",to+1);
		}
	}
	vector<vint > knap(konum+1,vint(X[from]+1,-INF));//knap[i][w]:i番目の子まで読んだ時に、自分と同じ色の子孫の重みの総和がwである時の自分と同じ色で塗った直接の子の重みの総和最大値
	int sum=0;
	knap[0][0]=0;
	rep(i,konum){
		int to=ko[from][i];
		rep(w,X[from]+1){
			if(w>=costmin[to].first&&knap[i][w-costmin[to].first]>=0) knap[i+1][w]=max(knap[i+1][w],knap[i][w-costmin[to].first]+costmin[to].first);
			if(w>=costmin[to].second&&knap[i][w-costmin[to].second]>=0) knap[i+1][w]=max(knap[i+1][w],knap[i][w-costmin[to].second]);
			//printf("from:%d i:%d to:%d costmin:(%d,%d) w:%d knap:%d X[from]:%d\n",from+1,i,to+1,costmin[to].first,costmin[to].second,w,knap[i+1][w],X[from]);
		}
		sum+=costmin[to].first;
	}
	int choosemax=0,canchoosewmax=-1;
	bool canchoose=0;
	rep(w,X[from]+1){
		if(knap[konum][w]>=0){
			canchoose=1;
			canchoosewmax=w;
		}
	}
	if(canchoose) choosemax=knap[konum][canchoosewmax];
	//printf("from:%d choosemax:%d canchoose:%d\n",from+1,choosemax,canchoose);
	if(canchoose==0){
		return 0;
	}
	else{
		costmin[from].second=sum-choosemax;
	}
	//printf("costmin[%d]:(%d,%d)\n",from+1,costmin[from].first,costmin[from].second);
	return 1;
}
int main(){
	scan(N);
	P[0]=-1;
	rep1(i,N-1){
		scan(P[i]);
		P[i]--;
		ko[P[i]].push_back(i);
	}
	rep(i,N){
		scan(X[i]);
	}
	if(solve(0)) prin("POSSIBLE");
	else prin("IMPOSSIBLE");
	return 0;
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
#define INF 2000000000
#define MOD 1000000007
#define EPS (1e-10)

using namespace std;

int main(int argc, char *argv[]) {

	//int D = 365;
	int D; cin >> D;

	vector<int> c(26,0);
	vector<vector<int>> s(D,vector<int>(26,0));
	vector<int> t(D,0);

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

	for (int i = 0; i < D; i++) {
		for (int j = 0; j < 26; j++) {
			cin >> s[i][j];	
		}
	}

	vector<int> MAX(D,0);
	for (int i = 0; i < D; i++) {
		int ans =0;
		int idx = 0;
		for (int j = 0; j < 26; j++) {
			if (MAX[i] < s[i][j]) {
				MAX[i] = s[i][j];	
				t[i] = j+1;	
			}
		}
	}

	int ANSER = 0;
	vector<int> last(26,0);
	for (int i = 0; i < D; i++) {
		ANSER += s[i][t[i]-1];	
		last[t[i]-1] = i+1;
		for (int j = 0; j < 26; j++) {
			ANSER -= c[j] * ((i+1) - last[j]) ;
		}
	}

	int cnt = 100000;
	while(cnt > 0) {
		vector<int> last(26,0);
		int d = (rand() % 365);
		int q = (rand() % 26) + 1;
		int old = t[d];
		t[d] = q;
		int ans = 0;
		for (int i = 0; i < D; i++) {
			ans += s[i][t[i]-1];	
			last[t[i]-1] = i+1;
			for (int j = 0; j < 26; j++) {
				ans -=	c[j] * ((i+1) - last[j]) ;
			}
		}
		if (ans < ANSER) {
			t[d] = old;	
		}else {
			ANSER = ans;
		}
		//cout << ANSER << endl;
		cnt--;
	}

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



	return 0;
}


Measured memory_bytes: 3700
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
int main(){
    int n;
    set<string> A;
    string s;
    cin>>n;
    rep(i,n) cin>>s,A.insert(s);
    cout<<A.size()<<"\n";
}

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

using namespace std;

int main()
{
    int arr[3] ;
    for(int i = 0 ; i < 3 ; ++i)
        cin>>arr[i] ;
    sort(arr , arr + 3) ;
    int ans = 0 ;
    for(int i =1 ; i < 3 ; ++i)
        ans += arr[i] - arr[i-1] ;
    cout<<ans<<endl;
    return 0 ;
}


Measured memory_bytes: 256
N,K = map(int,input().split())
p = list(map(int,input().split()))

S = sum(p[:K])
S_MAX = S

for i in range(N-K):
    S += p[K+i] - p[i]
    if S_MAX < S:
        S_MAX = S

E = (S_MAX + K)/2

print(E)


Measured memory_bytes: 25060
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
using namespace std;
using LL = long long;

int main(void)
{
	LL h, w, a, b;
	cin >> h >> w >> a >> b;
	LL x = h / a;
	LL y = w / b;
	LL ans = x * a * y * b;
	ans = h * w - ans;
	cout << ans << endl;
	return 0;
}



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

#define ll long long

#define pii pair < int, int >
#define pll pair < ll, ll >

#define vi vector < int >
#define vs vector < string >

#define pb push_back

using namespace std;

const int N = 2e5 + 5;
const int maxn = 1e6 + 5;

bool chk[maxn], vis[maxn];
int cnt[maxn];

int main()
{
    int n;

    cin >> n;

    vi a;

    for(int i = 0; i < n; i++){
        int x;

        cin >> x;

        a.pb(x);
        cnt[x]++;
    }

    sort(a.begin(), a.end());

    int mx = a.back();
    int b[mx + 5];

    memset(b, 0, sizeof(b));

    for(int i = 0; i < n; i++){
        for(int j = a[i]; j <= mx; j += a[i]) b[j]++;
    }

    int ans = 0;

    for(int i = 0; i < n; i++){
        if(b[a[i]] == 1) ans++;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 11908
#include <bits/stdc++.h>
#define sz(arr) (int)arr.size()
#define all(arr) arr.begin(), arr.end()

using namespace std;
typedef long long ll;

void _cin() {}
template <class Head, class... Tail>
void _cin(Head&& head, Tail&&... tail) {
  cin >> head;
  _cin(forward<Tail>(tail)...);
}

#define Cin(T, ...) \
  T __VA_ARGS__;    \
  _cin(__VA_ARGS__)

int main() {
  Cin(int, n, a, b);

  int ans = 0;
  for (int i = 1; i <= n; ++i) {
    string s = to_string(i);
    int sum = 0;
    for (auto e : s) {
      sum += e - '0';
    }
    if (a <= sum && sum <= b) ans += i;
  }

  cout << ans << endl;

  return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;

const int N = 1e5+100, SQ=512, M=3, MOD = 998244353; 

int add(ll a, int b){
    return (a + b + 2LL*MOD) % MOD;
}
 
int mul(ll a, int b){
    return (a * b) % MOD;
}

void sadd(int &a, int b){
    a = add(a, b);
}

void smul(int &a, int b){
    a = mul(a, b);
}

int bp(int a, int b){
    if(b == 0)
        return 1;
    int x = bp(a, b/2);
    smul(x, x);
    return b&1 ? mul(x, a) : x;
}

vector<int> g[M][N];
int n, m[M], gr[M][N], cnt[M][SQ], res[SQ];

void calc(vector<int> g[], int gr[]){
	memset(gr, 0, N * sizeof gr[0]);
	for(int v=n-1 ; v>=0 ; v--){
		set<int> st;
		for(auto u : g[v])
			st.insert(gr[u]);
		int mex=0;
		while(st.count(mex))
			mex ++;
		gr[v] = mex;
	}
}

void merge(int a[], int b[], int res[]){
	memset(res, 0, SQ*sizeof res[0]);
	for(int i=0 ; i<SQ ; i++)
		for(int j=0 ; j<SQ ; j++)
			sadd(res[i^j], mul(a[i], b[j]));
}

signed main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	cin >> n;
	for(int i=0 ; i<M ; i++){
		cin >> m[i];
		for(int j=0 ; j<m[i] ; j++){
			int v, u;cin >> v >> u;v --;u --;
			if(v>u)
				swap(v, u);
			g[i][v].push_back(u);
		}
		calc(g[i], gr[i]);
		for(int j=0 ; j<n ; j++)
			sadd(cnt[i][ gr[i][j] ], bp(10, 18*(j+1)));
	}
	merge(cnt[0], cnt[1], res);
	for(int i=0 ; i<SQ ; i++)
		cnt[1][i] = res[i];
	merge(cnt[1], cnt[2], res);
	cout << res[0] << "\n";
}

























Measured memory_bytes: 13824
/*
  mail: mleautomaton@foxmail.com
  author: MLEAutoMaton
  This Code is made by MLEAutoMaton
*/
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define ll long long
#define re register
#define file(a) freopen(a".in","r",stdin);freopen(a".out","w",stdout)
inline int gi(){
	int f=1,sum=0;char ch=getchar();
	while(ch>'9' || ch<'0'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9'){sum=(sum<<3)+(sum<<1)+ch-'0';ch=getchar();}
	return f*sum;
}
int n,d;
int main(){
	n=gi();d=gi();
	printf("%d\n",n/(2*d+1)+(n%(2*d+1)?1:0));
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<cmath>
#include<string>

#define ls (t<<1)
#define rs ((t<<1)+1)
#define mid ((l+r)>>1)
#define fi first
#define se second
#define mk make_pair
#define pb push_back

#define N 100005
#define M 200005
#define seed 23333
#define Mo 998244353

using namespace std;
int i,j,m,n,p,k,a[N],Q[N],l,r,x;
long long ans=(long long)1e16;
void ins(int x)
{
		while (l<=r&&a[Q[r]]>=a[x]) --r;
		Q[++r]=x; 
}
long long work(int x)
{
		int i;
		l=1,r=0;
		long long ans=0;
		for (i=1;i<=n;++i) ins(i);
		for (i=n+1;i<=2*n;++i)
		{
				ins(i);
				while (Q[l]<i-x) ++l;
				ans+=a[Q[l]];
		}
		return ans;
}
int main()
{
	scanf("%d%d",&n,&x);
	for (i=1;i<=n;++i) scanf("%d",&a[i]),a[i+n]=a[i];
	for (i=0;i<n;++i) 
	ans=min(ans,work(i)+1ll*i*x);
	cout<<ans<<endl; 	 
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cstdint>
#include <bitset>

void flip_recurse(std::vector<std::uint64_t>& result, std::uint64_t current, int from, int to) {
    for (int x = from - to; x > to; --x) {
        if (from % x == to) {
            result.push_back(current | (1ULL << x));
        } else if (from % x >= to * 2) {
            flip_recurse(result, current | (1ULL << x), from % x, to);
        }
    }
}

std::vector<std::uint64_t> flip_list(int from, int to) {
    std::vector<std::uint64_t> result;
    flip_recurse(result, 0, from, to);
    std::sort(result.begin(), result.end());
    for (auto it = result.begin(); it != result.end();) {
        bool elim = false;
        for (auto it2 = result.begin(); it2 != it; ++it2) {
            if (((*it2) & (~*it)) == 0) {
                elim = true;
                break;
            }
        }
        if (elim) {
            it = result.erase(it);
        } else {
            ++it;
        }
    }
    return result;
}

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

    int N;
    std::cin >> N;
    std::vector<int> a(N);
    std::vector<int> b(N);
    for (auto& i : a) {
        std::cin >> i;
    }
    for (auto& i : b) {
        std::cin >> i;
    }
    std::vector<std::vector<std::uint64_t>> flips;
    for (int i = 0; i < N; ++i) {
        if (a[i] == b[i]) {
            continue;
        }
        auto flip = flip_list(a[i], b[i]);
        if (flip.empty()) {
            std::cout << "-1\n";
            return 0;
        }
        flips.push_back(std::move(flip));
    }
    if (flips.empty()) {
        std::cout << "0\n";
        return 0;
    }
    
    std::uint64_t result = 0;
    for (int bit = 63; bit >= 0; --bit) {
        std::uint64_t mask = 1ULL << bit;
        bool need = false;
        for (auto& f : flips) {
            bool n = std::all_of(f.begin(), f.end(), [&](std::uint64_t val) {
                return (val & mask) != 0;
            });
            if (n) {
                need = true;
                break;
            }
        }
        if (need) {
            result |= mask;
            for (auto& f : flips) {
                for (auto& f2 : f) {
                    f2 &= ~mask;
                }
            }
        } else {
            for (auto& f : flips) {
                f.erase(std::remove_if(f.begin(), f.end(), [&](std::uint64_t val) {
                    return (val & mask) != 0;
                }), f.end());
            }
        }
    }
    std::cout << result << std::endl;
    
    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<utility>
#include<cmath>
#include<string>
#include<cstring>
#include<map>
#include<queue>
#include<set>
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define prin(arg) std::cout<<arg<<"\n"
#define prin2(arg1,arg2) std::cout<<arg1<<" "<<arg2<<"\n"
#define fill(arg,n) std::memset(arg,n,sizeof(arg))
#define mp(a,b) std::make_pair(a,b)
#define pb push_back
using std::cin;
typedef long long ll;
typedef std::pair<int,int> pi;
typedef std::vector<int> vi;
typedef std::pair<ll,ll> pll;
typedef std::vector<pll> vpll;
typedef std::set<int> si;
typedef std::string str;
const int INF=1e+9;
const ll INFLL=1e+17;
const ll MOD=1e+9+7;
ll H,W,N;
ll a[100010],b[100010];
int main(){
  cin>>H>>W>>N;
  rep(i,N){
    cin>>a[i]>>b[i];
    a[i]--;b[i]--;
  }
  vpll v;//
  rep(i,N){
    for(ll h=-1;h<=1;h++){
      for(ll w=-1;w<=1;w++){
	ll x=a[i]+h,y=b[i]+w;
	if(0<x&&x<H-1&&0<y&&y<W-1){
	  v.pb(mp(x,y));
	}
      }
    }
  }
  ll res[10];
  rep(i,10) res[i]=0;
  if(v.size()==0){
    res[0]=(H-2)*(W-2);
    rep(i,10) prin(res[i]);
  }
  else{
    std::sort(v.begin(),v.end());
    ll cnt=1;
    ll ccnt=0;
    rep(i,v.size()-1){
      if(v[i].first==v[i+1].first&&v[i].second==v[i+1].second) cnt++;
      else{
	res[cnt]++;
	cnt=1;
	ccnt++;
      }
    }
    res[cnt]++;
    ccnt++;
    res[0]=(H-2)*(W-2)-ccnt;
    rep(i,10) prin(res[i]);
  }
  return 0;
}


Measured memory_bytes: 20328
a, b=gets.chomp.split(" ").map(&:to_i);

ab = ""
for i in 0..b-1
 ab = ab + a.to_s
end
ba = ""
for i in 0..a-1
 ba = ba + b.to_s
end

if ab < ba
  puts ab
else
  puts ba
end


Measured memory_bytes: 1788
#include<iostream>
#include <algorithm>
#include<string>
#include <bitset>
#include <vector>
#include <functional>
#include <climits>
#include <iomanip>
using namespace std;
int main()
{

	//int a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, ans = 0;
	long long a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, l = 0, ans = 0;
	//cout << LONG_MAX << endl;
	//string s[1001];
	//long long n, A[1000000000];
	long long n, m;
	cin >> n;
	int z[100000];
	for ( a = 0; a < n; a++)
	{
		cin >> z[a];
	}
	b = 0;
	for ( a = 0; a < n; a++)
	{

		if (b==z[a])
		{
			c++;
			b = 0;
		}
		else
		{
			b = z[a];
		}
	}


	//std::cout << std::fixed;
	//cout << std::setprecision(20) << << endl;
	cout << c << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    string s;
    int k;
    vector<string> t;
    cin >> s >> k;
    for (int i = 1; i <= 5; i++) for (int j = 0; j + i <= s.length(); j++) t.push_back(s.substr(j, i));
    sort(t.begin(), t.end());
    for (int i = 0; i < t.size(); i++) {
        if (i == 0 || t[i] != t[i - 1]) k--;
        if (!k) {
            cout << t[i];
            return 0;
        }
    }
}


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

typedef long long int lli;
typedef long long ll;
typedef long double ld;

int main(){
    int t=1;
    //cin>>t;
    while(t--){
        int n;
        cin>>n;
        int a[n];
        int c=0;
        for(int i=0;i<n;i++){
            cin>>a[i];
        }
        for(int i=0;i<n;i+=2){
            if(a[i]%2!=0)
                c++;
        }
        cout<<c;
    }
    return 0;
}

Measured memory_bytes: 3520
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<string>
#include<vector>
#include<map>  
#include<set>
#include<iterator>
#include<list>
#include<utility>
#include<cstdlib>
#include<queue>
#include<stack>
#include<bitset>
//#include<bits/stdc++.h>
#define PI  2*acos(0.0)
#define pb push_back

       
using namespace std;
using ll = long long;
using lli = long long int;
using ld = long double;



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

float n,x;
ll ans,t;
cin>>n>>x>>t;
ans=ceil(n/x);
cout<<ans*t<<"\n";



	
	return 0;
	
	
	       /***Israil Hosen
	            Computer Science & Engineering
	         University Of Rajshahi.
	         ***/
	
	
	
}

Measured memory_bytes: 3244
#include <iostream>
#include <array>
#include <map>
#include <algorithm>
#include <cmath>
#include <vector>
#include <fstream>
#include <string>
#include <random>
#include <queue>
#include <iomanip>
#include <functional>
#include <climits>
#include <tuple>
#include <unordered_map>
#include <limits>
#include <functional>
#include <cassert>
#include <numeric>
#include <bitset>

#define FOR(x,n) for(int x = 0; x < n; x++)
#define PUT(x) cout << x << endl
#define DPUT(x) printf("%.15lf\n",x)
#define GET(x,y) std::get<x>(y)
#define CHMAX(x,y) x = std::max(x,y)
#define CHMIN(x,y) x = std::min(x,y)

using namespace std;

using ll = long long int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vll = std::vector<ll>;
using vpll = std::vector<pll>;
using vpii = std::vector<pii>;
using vi = std::vector<int>;
using vvi = std::vector<vi>;
using vvpii = std::vector<vpii>;
using vch = std::vector<char>;
using vvch = std::vector<vch>;
using tiii = std::tuple<int, int, int>;

const ll mod197 = 1000000007LL;
const ll INF = 10000000000LL;

const double PI11 = 3.14159265359;

const int dis[5] = { 0,1,0,-1,0 };

const int disD[4] = { 0,1,1,0 };

int main(void)
{

	bitset<6> bit;

	cin >> bit;

	cout << bit.count() << endl;

	return 0;
}


Measured memory_bytes: 256