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

typedef long long int ll;

bool com(pair <ll , ll> p1 , pair <ll ,ll> p2){
    if(p1.second < p2.second){
        return true;
    }
    if(p1.second == p2.second){
        return(p1.first <= p2.first);
    }
    return false;
}

int main(){
    int n; cin >> n;
    ll x , y , tot = 0;
    ll cur[n+5] = {0} , dead[n+5] = {0};
    vector <pair <ll ,ll> > v;
    for(int i = 1; i <= n; i++){
        cin >> x >> y;
        v.push_back({x , y});
    }
    sort(v.begin() , v.end() , com);
    for(int i = 0; i < n; i++){
        tot += v[i].first;
        if(tot > v[i].second){
            cout << "No\n"; return 0;
        }
    }
    cout << "Yes\n";
}

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

void main()
{
    auto S = readln.chomp;
    auto len = S.length;
    if (len%2 == 1) {
        writeln("No");
        return;
    }

    foreach (i; 0..len/2) {
        auto c = S[len-i-1];
        switch (S[i]) {
            case 'b':
                if (c != 'd') goto default;
                break;
            case 'd':
                if (c != 'b') goto default;
                break;
            case 'p':
                if (c != 'q') goto default;
                break;
            case 'q':
                if (c != 'p') goto default;
                break;
            default:
                writeln("No");
                return;
        }
    }
    writeln("Yes");
}

Measured memory_bytes: 508
import sys
import bisect
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())

N, M = tuple(li())

categories = [ tuple(li()) for _ in range(N) ]
categories.sort()

total_cost = [(0, 0)]
for A, B in categories:
    total_cost.append((B + total_cost[-1][0], A * B + total_cost[-1][1]))
    idx = bisect.bisect_right( total_cost, (M, 0) )
total = total_cost[idx][1] + (M - total_cost[idx][0]) * categories[idx - 1][0]
print(total)


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


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


  int n;
  cin >> n;
  vector<pair<int,int> > x(n);
  vector<int > pre_x(n);
  rep(i,n){
    cin >> x[i].first;
    x[i].second = i;
    pre_x[i] = x[i].first;
  }
  sort(x.begin(),x.end());
  int mid_s = x[n/2-1].first;
  int mid_l = x[n/2].first;
  rep(i,n){
    if(pre_x[i]<=mid_s) cout << mid_l << endl;
    else cout << mid_s << endl;

  }
  
  return 0;
    

}


Measured memory_bytes: 4608
from operator import itemgetter
class BIT:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)

    def sum(self, i):
        s = 0
        i += 1
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s

    def add(self, i, x):
        i += 1
        while i <= self.size:
            self.tree[i] += x
            i += i & -i

N = int(input())
xy = [list(map(int,input().split())) for _ in range(N)]
xy.sort(key=itemgetter(1))
for i in range(N):
    xy[i][1] = i
xy.sort(key=itemgetter(0))
y = [xy[i][1] for i in range(N)]

mod = 998244353
p2 = [1]*(N+1)
for i in range(N):
    p2[i+1] = p2[i]*2%mod

bit1 = BIT(N)
bit2 = BIT(N)

for i in range(N):
    bit2.add(i,1)

ans = 0

for i in range(N):
    bit1.add(y[i],1)
    bit2.add(y[i],-1)
    n1 = bit1.sum(N-1)-bit1.sum(y[i])
    n2 = bit1.sum(y[i]-1)
    n3 = bit2.sum(N-1)-bit2.sum(y[i])
    n4 = bit2.sum(y[i]-1)
    ans += 1
    ans += (p2[n1]-1)+(p2[n2]-1)+(p2[n3]-1)+(p2[n4]-1)
    ans += (p2[n1]-1)*(p2[n2]-1)+(p2[n3]-1)*(p2[n4]-1)+(p2[n1]-1)*(p2[n3]-1)+(p2[n2]-1)*(p2[n4]-1)+2*(p2[n1]-1)*(p2[n4]-1)+2*(p2[n2]-1)*(p2[n3]-1)
    ans += 2*((p2[n1]-1)*(p2[n2]-1)*(p2[n3]-1)+(p2[n1]-1)*(p2[n2]-1)*(p2[n4]-1)+(p2[n1]-1)*(p2[n3]-1)*(p2[n4]-1)+(p2[n2]-1)*(p2[n3]-1)*(p2[n4]-1))
    ans += 2*(p2[n1]-1)*(p2[n2]-1)*(p2[n3]-1)*(p2[n4]-1)
    ans %= mod
print(ans)


Measured memory_bytes: 109784
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;


void main()
{
  auto n = readln.chomp.to!int;
  auto k = readln.chomp.to!int;
  auto x = readln.chomp.to!int;
  auto y = readln.chomp.to!int;
  writeln(min(n,k)*x+max(0,n-k)*y);
}


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

long long d[110][110];
const long long INF = (long long)1e10;

void solve(long long N, long long M, vector<long long> a, vector<long long> b, vector<long long> c){
	for(int i = 0; i <= N; ++i) for(int j = 0; j <= N; ++j) {
		d[i][j] = INF;
		if(i == j) d[i][j] = 0;
	}
	for(int i = 0; i < M; ++i) {
		d[a[i]][b[i]] = d[b[i]][a[i]] = c[i];
	}
	for(int k = 1; k <= N; k++) for(int i = 1; i <= N; ++i) for(int j = 1; j <= N; ++j) {
		d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
	}
	long long res = 0;
	for(int k = 0; k < M; ++k) {
		int f = 1;
		for(int i = 1; i <= N; ++i) for(int j = 0; j <= N; ++j) {
			if (d[i][j] == d[i][a[k]] + c[k] + d[b[k]][j]
					|| d[i][j] == d[i][b[k]] + c[k] + d[a[k]][j]) {
				f = 0;
			}
		}
		res += f;
	}
	cout << res << endl;
}

int main(){	
	long long M;
	long long N;
	scanf("%lld",&N);
	scanf("%lld",&M);
	vector<long long> a(M-1+1);
	vector<long long> b(M-1+1);
	vector<long long> c(M-1+1);
	for(int i = 0 ; i <= M-1 ; i++){
		scanf("%lld",&a[i]);
		scanf("%lld",&b[i]);
		scanf("%lld",&c[i]);
	}
	solve(N, M, a, b, c);
	return 0;
}



Measured memory_bytes: 384
#include <stdio.h>
#include <string.h>
int main(void){
	int i;
	char str[100];

	scanf("%[^\n]",str);
	for(i=0;i<(int)strlen(str);i++)
		str[i] = toupper(str[i]);
	printf("%s\n",str);
	return 0;
}

Measured memory_bytes: 524
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();

		ArrayList<Integer> hyoukouDAO = new ArrayList<>();
		Map<Integer, Boolean> goodTen = new HashMap<>();

		for(int i = 0; i < N; i++) {
			hyoukouDAO.add(sc.nextInt());
			goodTen.put(i, true);
		}

		for(int i = 0; i < M; i++) {
			int A = sc.nextInt();
			int B = sc.nextInt();

			int Ahyoukou = hyoukouDAO.get(A-1);
			int Bhyoukou = hyoukouDAO.get(B-1);

			//System.out.println(Ahyoukou + " " + Bhyoukou);

			if(Ahyoukou > Bhyoukou) {
				//Aの方がいい展望台
				goodTen.put(B-1, false);
			}else if(Ahyoukou < Bhyoukou) {
				goodTen.put(A-1, false);
			}else {
				goodTen.put(A-1, false);
				goodTen.put(B-1, false);
			}
		}

		int answer = 0;

		for(int i = 0; i < goodTen.size(); i++) {
			if(goodTen.get(i)) {
				answer ++ ;
			}
		}

		System.out.println(answer);

	}

}


Measured memory_bytes: 61064
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int n,m;
char T[52],W[52],tmp[52];
char ans[52];
bool ok=false;
inline bool cmp(char *a,char *b) {
	for (int i=1;i<=n;++i) {
		if (a[i]<b[i]) return 0;
		if (a[i]>b[i]) return 1;
	}
	return 0;
}
inline bool cck(int st,int ed) {
	for (int i=st;i<=ed;++i)
		if (T[i]^W[i-st+1]&&T[i]^'?') return false;
	return true;
}
int main() {
	scanf("%s%s",T+1,W+1);
	n=strlen(T+1),m=strlen(W+1);
	for (int i=1;i<=n;++i) ans[i]='z';
	for (int i=1,st,ed;i<=n-m+1;++i) {
		st=i,ed=i+m-1;
		if (cck(st,ed)) {
			ok=true;
			for (int j=1;j<=n;++j) tmp[j]=T[j];
			for (int j=st;j<=ed;++j) T[j]=W[j-st+1];
			for (int j=1;j<=n;++j) T[j]=(T[j]^'?')?T[j]:'a';
			if (cmp(ans,T))
				for (int j=1;j<=n;++j) ans[j]=T[j];
			for (int j=1;j<=n;++j) T[j]=tmp[j];
		}
	}
	if (ok) {
		for (int i=1;i<=n;++i) printf("%c",(ans[i]^'?')?ans[i]:'a');
		puts("");
	}
	else puts("UNRESTORABLE");
	return 0;
}

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

const int INF = 1 << 29;
const long long int Mod = 1000000007;
using ll = long long int;
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(ll i = 0; i < (ll)N; ++i)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)



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

	cout << (x == 0 ? 1 : 0) << endl;
}

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

int main() {
  int n; cin >> n;
  int k; cin >> k; int q; cin >> q;
  vector<int> a(q);
  rep(i, q) {
    cin >> a[i];
  }
  vector<int> b(n);
  rep(i, q) {
    b[a[i] - 1]++;
  }
  rep(i, n) {
    if (q - b[i] >= k) cout << "No" << endl;
    else cout << "Yes" << endl;
  } 
}


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

#define rep(i,n) for(int (i)=0;(i)<(n);++(i))
#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define ALL(obj) (obj).begin(),(obj).end()
#define space <<" "<<
using namespace std;

int main(){
    int n;
    int x;
    cin>>n;
    FOR(i,1,n+1){
    x=i;
    if(i%3 ==0){
    cout<<" "<<i;
    }else{
    while(x!=0){
    if(x%10==3){
    cout<<" "<<i;
    break;
    }
    x/=10;
    }
    }

    }
    cout<<endl;
}





Measured memory_bytes: 3088
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

const int P = 998244353;
typedef unsigned long long ull;
typedef __uint128_t L;
struct FastMod {
	ull b, m;
	FastMod(ull b) : b(b), m(ull((L(1) << 64) / b)) {}
	ull reduce(ull a) {
		ull q = (ull)((L(m) * a) >> 64);
		ull r = a - q * b; // can be proven that 0 <= r < 2*b
		return r >= b ? r - b : r;
	}
};
FastMod F(P);
int upd(int x){return x + (x >> 31 & P);}
int dp[403][403][2] , pw[2][403][403] , N , h[403] , cnt;

int DP(int l , int r){
	if(l > r) return 0;
	int id = ++cnt , val = 1e9 , num = 0;
	for(int j = l ; j <= r ; ++j) val = min(val , h[j]);
	int pre = l - 1 , sz = 0; dp[id][0][0] = 1;
	for(int j = l ; j <= r + 1 ; ++j)
		if(j == r + 1 || val == h[j]){
			++num; int t = DP(pre + 1 , j - 1);
			if(t){
				static int tmp[403][2]; memset(tmp , 0 , sizeof(tmp));
				for(int p = 0 ; p <= sz ; ++p)
					for(int q = 0 ; q < j - pre ; ++q)
						for(int x = 0 ; x < 2 ; ++x)
							for(int y = 0 ; y < 2 ; ++y)
								tmp[p + q][x | y] = F.reduce(tmp[p + q][x | y] + 1ll * dp[id][p][x] * dp[t][q][y]);
				memcpy(dp[id] , tmp , sizeof(dp[id])); sz += j - pre - 1;
			}
			pre = j;
		}
	--num;
	for(int i = 1 ; i <= num ; ++i){
		static int tmp[403][2]; memcpy(tmp , dp[id] , sizeof(tmp));
		for(int j = 0 ; j <= r - l + 1 ; ++j){
			tmp[j + 1][0] = upd(tmp[j + 1][0] - dp[id][j][0]);
			tmp[j + 1][1] = upd(tmp[j + 1][1] + dp[id][j][0] - P);
		}
		memcpy(dp[id] , tmp , sizeof(dp[id]));
	}
	int len = val - max(h[l - 1] , h[r + 1]);
	for(int i = 0 ; i <= r - l + 1 ; ++i){
		dp[id][i][0] = F.reduce(1ll * dp[id][i][0] * pw[0][r - l + 1 - i][len]);
		dp[id][i][1] = F.reduce(1ll * dp[id][i][1] * pw[1][r - l + 1 - i][len]);
	}
	return id;
}

int main(){
	scanf("%d" , &N); for(int i = 1 ; i <= N ; ++i) scanf("%d" , h + i);
	for(int i = 0 ; i <= N ; ++i) pw[0][i][0] = pw[0][0][i] = 1;
	for(int j = 1 ; j <= N ; ++j){
		pw[0][j][1] = upd(pw[0][j - 1][1] + pw[0][j - 1][1] - P); pw[1][j][1] = pw[0][j][1] - 1;
		for(int k = 2 ; k <= N ; ++k){
			pw[0][j][k] = F.reduce(1ll * pw[0][j][k - 1] * pw[0][j][1]);
			pw[1][j][k] = F.reduce(1ll * pw[1][j][k - 1] * pw[1][j][1]);
		}
	}
	int t = DP(1 , N); int sum = 0;
	for(int i = 0 ; i <= N ; ++i) for(int j = 0 ; j <= 1 ; ++j) sum = upd(sum + dp[t][i][j] - P);
	printf("%d\n" , sum); return 0;
}


Measured memory_bytes: 2816
n = gets.chomp.to_i
arr = gets.chomp.split(" ").map(&:to_i)

# abs(a_i - (b + i)) = abs((a_i - i) - b)
# 先に (a_i - i) を計算
(0..n-1).each do |i|
  arr[i] -= i + 1
end

# 真ん中の数字が最適っぽい(予想)
arr.sort_by!{|a| a}
b = arr[n / 2]

# 残った部分を計算
result = 0
arr.each do |a|
  result += (a - b).abs
end

puts result


Measured memory_bytes: 35964
#include "bits/stdc++.h"
using namespace std;

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < n; i++)
#define Rep(i, n) for(int i = 1; i < n; i++)
#define In(vec) rep(i, n) cin>>vec[i];
#define ANS(s) cout << s << endl
#define inc(a, b) cin >> a >> b;

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vii;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
int round_int(int a, int b) { return (a + (b - 1)) / b; }


// 4,8方向に探索する際に用いる配列
//int dx[4] = { 0,  0, 1, -1 };
//int dy[4] = { 1, -1, 0,  0 };
int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };

constexpr auto MAX = 100010;

// ────────────────────────────────────────────────────

int main() {
	string b;
	cin >> b;

	int a[4];
	rep(i, 4) {
		a[i] = (int)(b[i] - '0');
	}


	for (int i = 0; i < (1 << 3); i++) {
		int ans = a[0];
		string s;

		for (int j = 0; j < 3; j++) {
			if ((i >> j) & 1) {
				ans += a[j + 1];
				s.push_back('+');
			}
			else {
				ans -= a[j + 1];
				s.push_back('-');
			}
		}

		if (ans == 7) {
			rep(j, 3) {
				cout << a[j] << s[j];
			}
			cout << a[3] << "=7" << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

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

		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		
		double[] money = new double[N];
		String[] type = new String[N];
		for (int i = 0; i < N; i++) {
			money[i] = scan.nextDouble();
			type[i] = scan.next();
		}
		
		double sum = 0;
		for (int i = 0; i < N; i++) {
			if (type[i].equals("JPY")) {
				sum += money[i];
			} else {
				sum += money[i] * 380000;
			}
		}
		
		System.out.println(sum);
		
		scan.close();
	}
}

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

int main() {
  string Ans = "No";  // 回答：

  string S; cin >> S; // 入力文字列

  if (S.at(2)==S.at(3) && S.at(4)== S.at(5) ){
    Ans = "Yes";
  }

  cout << Ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
const ll zero = 0;
const ll INF = 3000000000000000000; //10^18
const int inINF = 1000000000; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;

int main(){
    ll N;
    cin >> N;
    ll A, preA;
    cin >> A;
    if(A != zero){
        printf("-1\n");
        return 0;
    }
    preA = zero;
    ll ans = 0;
    for (ll i = 1; i < N; i++) {
        cin >> A;
        if (A == preA + 1) {
            ans++;
        }
        else if (A > preA + 1) {
            printf("-1\n");
            return 0;
        }
        else{
            ans += A;
        }
        preA = A;
    }

    printf("%lld\n", ans);


}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

void solve()
{
	double xa1, ya1, xa2, ya2, xb1, yb1, xb2, yb2;
	while(cin >> xa1 >> ya1 >> xa2 >> ya2 >> xb1 >> yb1 >> xb2 >> yb2)
	{
		if(xb2 < xa1 || xa2 < xb1 || yb1 > ya2 || yb2 < ya1)
		{
			cout << "NO" << endl;
		}
		else
		{
			cout << "YES" << endl;
		}
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define dump(x) cout << (x) << endl
typedef long long ll;
typedef pair<int, int> P;


int main() {
  int n, m;
  cin >> n >> m;
  vector<P> v(m);
  REP(i, m) {
    cin >> v[i].second >> v[i].first;
  }
  sort(v.begin(), v.end());
  int cnt = 1;
  int p = v[0].first;
  FOR(i, 1, m) {
    if (p <= v[i].second) {
      cnt++;
      p = v[i].first;
    }
  }
  dump(cnt);
  return 0;
}


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

using namespace std;

int schedule[1024];

bool check(int a, int b) {
    for (int i = a; i < b; i++) {
        if (schedule[i] != 0) return false;
    }
    return true;
}

int main() {
    int a, b;
    int N;
    cin >> a >> b;
    cin >> N;
    for (int i = 0; i < N; i++) {
        int s, f;
        cin >> s >> f;
        schedule[s]++;
        schedule[f]--;
    }

    for (int i = 1; i < 1024; i++) {
        schedule[i] += schedule[i-1];
    }
    puts(check(a, b) ? "0" : "1");

    return 0;
}





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


int main(){
    int n;
    cin >> n;
    vector<bool> plist(n+1,true);
    plist[0]=false;
    int e=(int)sqrt(n);
    for(int i=2;i<=n;i++){
        if(!plist[i])continue;
        for(int j=2;i*j<=n;j++){
            plist[i*j]=false;
        }
    }
    vector<long> list(n+1,0);
    for(int i=2;i<=n;i++){
        for(int j=2;j<=n;j++){
            if(plist[j]){
                for(int k=i;k%j==0;k/=j){
                    list[j]++;
                }
            }
        }
    }
    long ans=1;
    for(int i=2;i<=n;i++){
        if(plist[i]!=0){
            ans=(ans*(list[i]+1))%(long)(1e9+7);
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
	int n;
	cin >> n;
	vector<int> A(n), a(10001);
	for (int& i : A) {
		cin >> i;
		++a[i];
	}
	for (int i = 0, j = 0; i < n; ++i) {
		while (!a[j]) ++j;
		--a[j];
		A[i] = j;
	}
	for (int i = 0; i < n - 1; ++i) cout << A[i] << ' ';
	cout << A.back() << endl;
}


Measured memory_bytes: 10656
// https://atcoder.jp/contests/abc163/tasks/abc163_d
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define is_in(i, s) (s.find(i) != s.end())
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef pair<int,int> P;
#define M 1000000007

#define MAX_N 200005


ll mpow(ll x, ll n){ //x^n(mod M) ←普通にpow(x,n)では溢れてしまうため，随時mod計算
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % M;
        x = x*x % M;
        n = n >> 1; // n = n/2
    }
    return ans;
}
ll mdev(ll a,ll b){
	return a * mpow(b,M-2) % M;
}
ll msub(ll a,ll b){
	if(a<b){
		a+=M;
		return msub(a,b);
	}
	return (a-b)%M;
}

ll sum(ll n){
	// 0,1,...,nの和
	if(n<0) return 0;
	ll tmp = n*(n+1)%M;
	return mdev(tmp,2);
}

int main() {
	ll n,k;
	cin >> n >> k;
	ll ans = 0;
	ll nsum = sum(n);
	for(int i=k;i<=n+1;i++){
		ans = (ans + msub(msub(nsum,sum(n-i)),sum(i-1))+1)%M;
	}
	cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <algorithm> 
#include <cstdlib>
#include <map>
#include <queue>
#include <vector>
#include <stack>
using namespace std;
int main(){
    int count=0;
    string s;
    cin >> s;
    cout << s[0] << s.size()-2 << s[s.size()-1] << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){

  int N;
  int answer=0;
  
  scanf("%d",&N);

  int V[N];
  int C[N];
  int sa[N];

  int i;
  
  for(i=0; i<N; i++){
    scanf("%d",&V[i]);
  }

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

  for(i=0; i<N; i++){
    sa[i] = V[i]-C[i];
  }
  
  for(i=0; i<N; i++){
    if(sa[i]>=0){
      answer += sa[i];
    }
  }

  printf("%d\n",answer);
  
  return 0;

}


Measured memory_bytes: 128
W,H,N=map(int,input().split())
XYA=[list(map(int,input().split())) for i in range(N)]

X=[0,W]
Y=[0,H]

for i in range(N):
    if XYA[i][2]==1:
        X[0]=max(X[0],XYA[i][0])
    elif XYA[i][2]==2:
        X[1]=min(X[1],XYA[i][0])
    elif XYA[i][2]==3:
        Y[0]=max(Y[0],XYA[i][1])
    else:
        Y[1]=min(Y[1],XYA[i][1])

if X[1]-X[0]<=0 or Y[1]-Y[0]<=0:
    print(0)
else:
    print((X[1]-X[0])*(Y[1]-Y[0]))


Measured memory_bytes: 38256
n,m=map(int,input().split())
l=[0 for i in range(n+1)]
for i in range(m):
  a,b=map(int,input().split())
  l[a-1]+=1
  l[b]-=1
s=0
c=0
for i in l:
  s+=i
  if s==m:
    c+=1
print(c)

Measured memory_bytes: 4136
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define int ll
#define all(x) x.begin(), x.end()
#define x first
#define y second
#define mp make_pair
#define mt make_tuple

const int N = 1e6 + 10;
int n;
int a[N];
int d[N];

signed main() {
#ifdef LC
	assert(freopen("input.txt", "r", stdin));
#endif
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	fill_n(d, N, -1);
	for (int i = 0; i < n; ++i) {
		int l = -1, r = N - 1;
		while (r - l > 1) {
			int m = (l + r) / 2;
			if (d[m] >= a[i]) {
				l = m;
			} else {
				r = m;
			}
			assert(0 <= r && r < N);
		}
		d[r] = a[i];
	}
	cout << (int)(find(d, d + N, -1) - d) << endl;
	return 0;
}



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

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

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

	int n;
	ll x;
	cin >> n >> x;
	ll a[n], b[n];
	int idx = 0;
	rep(i, 0, n) {
		cin >> a[i];
		b[i] = a[i];
	}

	ll rsl = 1e18;
	rep(k, 0, n) {
		ll tmp = 0;
		rep(i, 0, n) {
			b[i] = min(b[i], a[(i - k + n) % n]);
			tmp += b[i];
		}
		tmp += k * x;
		rsl = min(rsl, tmp);
	}

	cout << rsl << endl;

}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        long x = sc.nextLong();

        System.out.println(solve(x));

        sc.close();
    }

    static long solve(long x) {
        return x / 11 * 2 + (x % 11 == 0 ? 0 : (x % 11 <= 6 ? 1 : 2));
    }
}

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

int main() {
    int H, W;
    std::cin >> H >> W;

    char c[H][W];
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            std::cin >> c[i][j];
        }
    }

    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            if (c[i][j] == '#') {
                std::cout << c[i][j];
            } else {
                int cnt = 0;
                if (0 < i     && 0 < j &&     c[i-1][j-1] == '#') ++cnt;
                if (0 < i     &&              c[i-1][j]   == '#') ++cnt;
                if (0 < i     && j < (W-1) && c[i-1][j+1] == '#') ++cnt;
                if (0 < j     &&              c[i][j-1]   == '#') ++cnt;
                if (j < (W-1) &&              c[i][j+1]   == '#') ++cnt;
                if (i < (H-1) && 0 < j &&     c[i+1][j-1] == '#') ++cnt;
                if (i < (H-1) &&              c[i+1][j]   == '#') ++cnt;
                if (i < (H-1) && j < (W-1) && c[i+1][j+1] == '#') ++cnt;

                std::cout << cnt;
            }
        }
        std::cout << std::endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
// memo  fixed  setprecision(20);
using vvll = vector<vector<ll>>;
ll mod =1e9+7;
/*"itob" int to "N"base */           template<typename TypeInt> string itob(const TypeInt v, int base){static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";string ret;static numeric_limits<TypeInt> t;TypeInt n = v;if (t.is_signed) {if (v < 0) n *= -1;}while (n >= base) {ret += table[n%base];n /= base;}ret += table[n];if (t.is_signed) {if (v < 0 && base == 10) ret += '-';}reverse(ret.begin(), ret.end());return ret;}
/*"chmin" a = MAX*/                  template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
/*"chmax" a = MIN*/                  template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/*"ctoi"  char to int*/              int ctoi(char c) {return c-'0';}
/*"gcd"   MAX Euclidean */           ll gcd(ll a,ll b){if(b==0)return a; return gcd(b,a%b);}
    /*"lcm"   MIN*/                      ll lcm(ll a,ll b){ll g = gcd(a,b);return a/g*b;}
/*"primecheck"If prime,return true.*/bool primecheck(ll n){if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}
ll modpow(ll a,ll n, ll mod){ll res = 1;while(n>0){if (n%2==1){res = res * a % mod;}a = a * a % mod;n/=2;}return res;}

int main() {
    int n,d;
    cin >> n >> d;
    ll x[n][d];
    for(int i=0;i<n;i++){
        for(int j=0;j<d;j++){
            cin >> x[i][j];
        }
    }
    ll ans =0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            ll che = 0;
            for(int k=0;k<d;k++){
                che +=pow(abs(x[i][k]-x[j][k]),2);
            }
            ll check = pow(che,0.5);
            double now = pow(che,0.5);
            if(check==now)ans++;
        }
    }
    cout << ans <<endl;
}
    



Measured memory_bytes: 4032
#include<bits/stdc++.h> 
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp> 
#define mod 1000000007
#define mod2 998244353
#define int long long
#define endl "\n"
#define p_b push_back
#define m_p make_pair
#define fastIO ios_base::sync_with_stdio(false),cin.tie(NULL)
using namespace std;
using namespace __gnu_pbds;
template <class T> 
using _ost = tree<
		T, 
		null_type, 
		less<T>, 
		rb_tree_tag, 
        tree_order_statistics_node_update>;

// char alphabet[26] = {'a','b','c','d','e','f','g','h','i',
//        'j','k','l','m','n','o','p','q','r','s','t','u','v',
//        'w','x','y','z'};


int32_t main(){
 	fastIO;
 	string a[]={"ARC","ABC"};
 	string s;cin>>s;
 	if(s==a[0])
 		cout<<a[1];
 	else
 		cout<<a[0];
}		



Measured memory_bytes: 3656
#include <stdio.h>
#include <string.h>

void pri(int a, int b, char x[]){
    int i;
    for(i = 0; i < b - a + 1; i++){
    printf("%c",x[ a + i ]);    
    }

printf("\n");
}
void rev(int a, int b, char x[]){
 char z[1100];
 int i;
 strcpy(z,x);
 for(i = 0; i < b - a + 1; i++){
  z[a + i] = x[b - i];
 }
 strcpy(x,z);
}
void rep(int a, int b, char x[], char p[]){
 int i;
 
 for(i = 0; i < b - a + 1; i++){
  x[a + i] = p[i];
 }
}

void func(char x[], char y[]){

int a, b;
char p[1024];

if(strcmp(x ,"print") == 0){
scanf("%d %d",&a,&b);
pri(a,b,y);
}

if(strcmp(x,"reverse") == 0){
scanf("%d %d",&a,&b);
rev(a,b,y);
}

if(strcmp(x,"replace") == 0){
scanf("%d %d %s",&a,&b,p);
rep(a,b,y,p);
}

}

int main(void)
{
 char c[1024];

char f[10];

 int n;

scanf("%s",c);

scanf("%d",&n);

while(n-- > 0){

scanf("%s",f);

func(f,c);

}

 return 0;
}

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

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

    if (a > b) rep(i, a) cout << b;
    else rep(i, b) cout << a;

    cout << endl;
    return 0;
}

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

using ull = unsigned long long;

const ull MOD = 1000000007;

int main(void) {
    ull N;
    cin >> N;
    vector<ull> T(N, 0);
    vector<ull> A(N, 0);
    vector<bool> B(N, false);
    int t_index = -1, a_index = -1;

    for(int i = 0; i < N; i++) {
        cin >> T[i];
    }
    for(int i = 0; i < N; i++) {
        cin >> A[i];
    }

    ull t_mx = 0;
    for(int i = 0; i < N; i++) {
        if(t_mx < T[i]) {
            t_mx = T[i];
            t_index = i;
            B[i] = true;
        }
    }
    ull a_mx = 0;
    for(int i = N-1; i >=0; i--) {
        if(a_mx < A[i]) {
            a_mx = A[i];
            a_index = i;
            B[i] = true;
        }
    }

    if(t_mx != a_mx || t_index > a_index) {
        cout << 0;
        return 0;
    }

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

    ull ans = 1;
    for(int i=0;i<N;i++) {
        if(!B[i]) {
            ans = (ans * min(T[i], A[i])) % MOD;
        }
    }
    cout << ans;

    return 0;
}

Measured memory_bytes: 1792
n, m = [int(item) for item in input().split()]

k = []
list = [0] * m
for i in range(n):
  line = [int(item) for item in input().split()]
  for item in range(m):
    if (item+1) in line[1:]:
      list[item] += 1

num = 0
for item in list:
  if item == n:
    num+=1

print(num)

Measured memory_bytes: 3060
#include<stdio.h>
#include<math.h>
#define INFINITY 100000000000000000;

int A[500000],sum=0;
void mergeSort(int,int);

int main(){
  int n,i;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  
  mergeSort(0,n);
  for(i=0;i<n-1;i++){
    printf("%d ",A[i]);
  }
  printf("%d\n",A[i]);
  printf("%d\n",sum);

  return 0;
}

void merge(int left,int mid, int right){
  int i,j,k,n1,n2;
  n1=mid-left;
  n2=right-mid;
  int L[n1+1],R[n2+1];
  for(i=0;i<n1;i++)L[i]=A[left+i];
  for(i=0;i<n2;i++)R[i]=A[mid+i];
  L[n1]=INFINITY;
  R[n2]=INFINITY;
  i=0;
  j=0;
  for(k=left;k<right;k++){
    sum+=1;
    if(L[i]<=R[j]){
      A[k]=L[i];
      i=i+1;
    }
    else{
      A[k]=R[j];
      j=j+1;
    }
  }
}

void mergeSort(left,right){
  int mid;
  if(left+1<right){
    mid=(left+right)/2;
    mergeSort(left,mid);
    mergeSort(mid,right);
    merge(left,mid,right);
  }
}

Measured memory_bytes: 4500
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
//typedef vector<unsigned int>vec;
typedef vector<ll>vec;
typedef vector<vec> mat;
typedef vector<vector<int>> Graph;

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
//const ll MOD = 998244353;
const double PI = acos(-1.0);
const double EPS = 1e-10;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> six, nine;
    for(int i=1;i<=N;i*=6) six.push_back(i);
    for(int i=1;i<=N;i*=9) nine.push_back(i);

    vector<int> dp(N+1, INF);
    dp[0] = 0;
    for(int i=1;i<=N;i++){
        REP(j, six.size()){
            if(i - six[j] >= 0) chmin(dp[i], dp[i-six[j]] + 1);
        }
        REP(j, nine.size()){
            if(i - nine[j] >= 0) chmin(dp[i], dp[i-nine[j]] + 1);
        }
    }
    cout << dp[N] << endl;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll A, B, C;
    cin >> A >> B >> C;
    ll le = 4 * A * B;
    ll ri = (C - A - B) * (C - A - B);
    if (C - A - B < 1) {
        cout << "No" << '\n';
        return;
    }
    if (le < ri) {
        cout << "Yes" << '\n';
    } else {
        cout << "No" << '\n';
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include <cmath>
#include <limits>
#include<set>
#include <iomanip>
#include <queue>
#include <map>
#include <string>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
const long long INF=(1LL<<62);
const double inf=pow(10,10);
double pi=3.141592653589793;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const ll MOD = 1000000007;
void init(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
}
int MAX = 100000+10;
long long fac[100010], finv[100010], inv[100010];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < 100010; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
	init();
	ll N;cin>>N;
	vector<ll>a(N);
	ll sum1=0;
	ll sum2=0;
	for(int i=0;i<N;i++){
		cin>>a[i];
		sum1+=a[i];
	}
	ll ans=INF;
	for(int i=0;i<N-1;i++){
		sum2+=a[i];
		ll sum3=sum1-sum2;
		ans=min(ans,abs(sum3-sum2));
	}
	cout<<ans<<endl;
}



Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <tuple>
#include <queue>
#include <bitset>
#include <unordered_map>
#include <tuple>
#include <utility>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <set>
#include <sys/time.h>

using namespace std;

void solve(long long N, long long Q, vector<long long> S, vector<long long> T, vector<long long> X, vector<long long> D){
  for (int i = 0; i < N; i++) {
    S[i] -= X[i];
    T[i] -= X[i];
  }

  vector<pair<long long, long long>> st(N);
  vector<pair<long long, long long>> en(N);

  for (int i = 0; i < N; i++) {
    st[i] = make_pair(S[i], X[i]);
    en[i] = make_pair(T[i], X[i]);
  }

  sort(st.begin(), st.end());
  sort(en.begin(), en.end());

  multiset<long long> v;

  long long d;
  int sti = 0;
  int eni = 0;

  for (int i = 0; i < Q; i++) {
    d = D[i];
    while (sti < N && d >= st[sti].first) {
      v.insert(st[sti].second);
      sti++;
    }
    while (eni < N && d >= en[eni].first) {
      v.erase(v.find(en[eni].second));
      eni++;
    }
    if (v.empty()) {
      std::cout << -1 << std::endl;
    } else {
      std::cout << *(v.begin()) << std::endl;
    }
  }

}

int main(){
  long long N;
  long long Q;
  scanf("%lld",&N);
  vector<long long> X(N);
  vector<long long> T(N);
  vector<long long> S(N);
  scanf("%lld",&Q);
  vector<long long> D(Q);
  for(int i = 0 ; i < N ; i++){
    scanf("%lld",&S[i]);
    scanf("%lld",&T[i]);
    scanf("%lld",&X[i]);
  }
  for(int i = 0 ; i < Q ; i++){
    scanf("%lld",&D[i]);
  }
  solve(N, Q, S, T, X, D);
  return 0;
}


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

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

    for(int h=1; h<=n; h++) {
        int count = 0;
        for(int i=1; i<=100; i++) {
            if(i * i >= h) break;

            for(int j=i; j<=100; j++) {
                for(int k=j; k<=100; k++) {
                    int x = (i*i)+(j*j)+(k*k)+(i*j)+(j*k)+(k*i);
                    if(x == h) {
                        if(i == j && j==k && k==i) {
                            count++;
                        } else if(i!=j && j!=k & k!=i){
                            count += 6;
                        } else {
                            count += 3;
                        }
                    }
                }
            }
        }
        cout << count << endl;
    }
}

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

int main() {
  int n,W; cin>>n>>W;
  vector<int> v(n),w(n);
  rep(i, n) cin>>v[i]>>w[i];

  vector<vector<int>> dp(n+1, vector<int>(W+1, 0));
  rep(i, n) {
    rep(j, W+1) {
      if (j-w[i]>=0) dp[i+1][j]=max(dp[i][j], dp[i][j-w[i]]+v[i]);
      else dp[i+1][j]=dp[i][j];
    }
  }
  cout<<dp[n][W]<<endl;
}



Measured memory_bytes: 6836
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

int main(void){
	string s;

	cin >> s;

	int id = 0, a = 0, b = 0, c = 0;
	for (int i = 0; i < s.size(); i++){
		if (s[i] == 'a')
			a++;
		else if (s[i] == 'b')
			b++;
		else
			c++;
	}

	if (s.size() == 1){
		cout << "YES";
	}
	else if (s.size() == 2){
		if (s[0] == s[1])
			cout << "NO";
		else
			cout << "YES";
	}
	else {
		if (abs(a-b) < 2 && abs(b-c) < 2 && abs(c-a) < 2)
			cout << "YES";
		else
			cout << "NO";
	}
	cout << endl;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <stdbool.h>
#include <math.h>
#include <time.h>
#define ll long long
#define min(a, b) ((a) > (b) ? (b) : (a))
#define max(a, b) ((a) > (b) ? (a) : (b))
#define miin(a, b, c) min((a), min((b), (c)))
#define maax(a, b, c) max((a), max((b), (c)))
#define mod 1000000007

int n, m, a[333333], i = 2;

int nyaa(int x)
{
    int res = 1;
    while (x--)
        res *= 2;
    return res;
}

main()
{
    scanf("%d", &n);
    m = nyaa(n);
    for (int i = 0; i < m; i++)
    {
        scanf("%d", &a[i]);
    }
    while (n--)
    {
        for (int j = 0; j < m; j += i)
        {
            a[j] = (a[j] - a[i / 2 + j] ? abs(a[j] - a[i / 2 + j]) : a[j]);
        }
        i *= 2;
    }
    printf("%d\n", a[0]);
    return 0;
}

Measured memory_bytes: 1152
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using static System.Console;
using static System.Math;
class Program
{

    void Solve()
    {
        var N = io.Int;
        var S = io.String;
        var p = S.Substring(0, N / 2);
        var s = S.Substring(N / 2);
        WriteLine(
            p == s
                ? "Yes"
                : "No"
            ) ;
    }

    SimpleIO io = new SimpleIO();
    public static void Main(string[] args) => new Program().Stream();
    private void Stream()
    {
        //var exStdIn = new System.IO.StreamReader("stdin.txt");
        //SetIn(exStdIn);
        Solve();
        io.Flush();
    }
}

class SimpleIO
{
    string[] _nextBuffer;
    int _bufferCnt;
    char[] cs = new char[] { ' ', '"', ',' };
    StreamWriter sw = new StreamWriter(OpenStandardOutput())
    {
#if DEBUG
        AutoFlush = true
#else
        AutoFlush = false
#endif
    };
    public SimpleIO()
    {
        _nextBuffer = new string[0];
        _bufferCnt = 0;
        SetOut(sw);
    }
    string Next()
    {
        if (_bufferCnt < _nextBuffer.Length) return _nextBuffer[_bufferCnt++];
        var st = ReadLine();
        while (st == string.Empty) st = ReadLine();
        _nextBuffer = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        _bufferCnt = 0;
        return _nextBuffer[_bufferCnt++];
    }
    public string String => Next();
    public char Char => char.Parse(String);
    public int Int => int.Parse(String);
    public long Long => long.Parse(String);
    public double Double => double.Parse(String);
    public void Flush() => Out.Flush();
}

Measured memory_bytes: 11092
#include<stdio.h>
int count=0;
void selectionSort(int*,int);
int main(){
  int n,a[100],i;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  selectionSort(a,n);
  for(i=0;i<n;i++){
    printf("%d",a[i]);
    if(i!=n-1)printf(" ");
  }
  printf("\n%d\n",count);
  return 0;

}
void selectionSort(int* A,int N){
  int i,j,minj,x;// N個の要素を含む0-オリジンの配列A
  for(i=0;i<=N-1;i++){
    minj = i;
    for( j=i;j<=N-1;j++){
      if (A[j] < A[minj]){
	minj = j;
      }
    }
    if(minj!=i){
	x=A[i];
	A[i]=A[minj];
	A[minj]=x;
	count++;
    }
  }
}



Measured memory_bytes: 2128
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = 1; i <= (int)(n); i++)
#define drep(i, n) for(int i = (n)-1; i >= 0; i--)
#define ALL(x) (x).begin(), (x).end()
#define dup(x,y) (((x)+(y)-1)/(y))
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

// Mod int
const int mod = 1000000007;
// const int mod = 998244353;
struct mint {
  ll x;
  mint():x(0){}
  mint(ll x):x((x%mod+mod)%mod){}
  // mint(ll x):x(x){}
  mint& fix() { x = (x%mod+mod)%mod; return *this;}
  mint operator-() const { return mint(0) - *this;}
  mint& operator+=(const mint& a){ if((x+=a.x)>=mod) x-=mod; return *this;}
  mint& operator-=(const mint& a){ if((x+=mod-a.x)>=mod) x-=mod; return *this;}
  mint& operator*=(const mint& a){ (x*=a.x)%=mod; return *this;}
  mint operator+(const mint& a)const{ return mint(*this) += a;}
  mint operator-(const mint& a)const{ return mint(*this) -= a;}
  mint operator*(const mint& a)const{ return mint(*this) *= a;}
  bool operator<(const mint& a)const{ return x < a.x;}
  bool operator==(const mint& a)const{ return x == a.x;}
};
istream& operator>>(istream&i,mint&a){i>>a.x;return i;}
ostream& operator<<(ostream&o,const mint&a){o<<a.x;return o;}
//



int main() {
  int n, m;
  cin >> n >> m;
  vector<string> a(n), b(m);
  rep(i, n) cin >> a[i];
  rep(i, m) cin >> b[i];
  rep(i, n-m+1) rep(j, n-m+1) {
    bool ok = true;
    rep(k, m) rep(l, m) {
      if (b[k][l] != a[i+k][j+l]) ok = false;
    }
    if (ok) {
      cout << "Yes\n";
      return 0;
    }
  }
  cout << "No\n";
}

Measured memory_bytes: 3624
#include <iostream>

using namespace std;

string s;
int64_t result = 0;

void recur(size_t pos, int64_t cur, int64_t acc) {
  if (pos == s.size()) {
    result += acc + cur;
  } else {
    auto val = s[pos] - '0';
    recur(pos + 1, cur * 10 + val, acc);
    recur(pos + 1, val, acc + cur);
  }
}

int main() {
  cin >> s;
  recur(1, s[0] - '0', 0);
  cout << result << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char str[100002];
char str2[100002];
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin>>str;
	reverse_copy(str,str+strlen(str),str2);
	if(!strcmp(str,str2))
	{
		cout<<"Yes\n";
		return 0;
	}
	for(int i=0,lon=strlen(str);i<lon;i++)
		if(str2[i]=='b'&&str[i]!='d')
		{
			cout<<"No\n";
			return 0;
		}
		else if(str2[i]=='d'&&str[i]!='b')
		{
			cout<<"No\n";
			return 0;
		}
		else if(str2[i]=='p'&&str[i]!='q')
		{
			cout<<"No\n";
			return 0;
		}
		else if(str2[i]=='q'&&str[i]!='p')
		{
			cout<<"No\n";
			return 0;
		}
	cout<<"Yes\n";
	return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

    static int mod = 998244353;

    static int max = 4 * 100000 + 2;

    static long[] fact = new long[max];
    static long[] modinv = new long[max];
    static long[] factinv = new long[max];

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = Integer.parseInt(scan.next());
        int m = Integer.parseInt(scan.next());
        int k = Integer.parseInt(scan.next());
        scan.close();

        initCombi();

        long ans = 0;
        for (int i = 0; i <= k; i++) {
            ans += (m * combi(n - 1, i) % mod) * modPow(m - 1, n - 1 - i) % mod;
            ans %= mod;
        }

        System.out.println(ans);
    }

    private static void initCombi() {
        fact[0] = 1;
        fact[1] = 1;
        modinv[1] = 1;
        factinv[0] = 1;
        factinv[1] = 1;

        for (int i = 2; i < max; i++) {
            fact[i] = fact[i - 1] * i % mod;
            modinv[i] = mod - modinv[mod % i] * (mod / i) % mod;
            factinv[i] = factinv[i - 1] * modinv[i] % mod;
        }
    }

    private static long combi(int n, int k) {
        return fact[n] * (factinv[k] * factinv[n - k] % mod) % mod;
    }

    private static long modPow(long a, long b) {
        if (b == 0) {
            return 1;
        }

        if (b % 2 == 0) {
            return modPow(a * a % mod, b / 2);
        } else {
            return modPow(a * a % mod, (b - 1) / 2) * a % mod;
        }
    }
}


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

int main() {
	bool cards[4][14];
int n, rank;
char suit;

for(int s=0;s<4; s++)
for(int r=1; r<=13; r++)
cards[s][r]=0;
cin>>n; 
for(int i=0; i<n; i++){
cin>>suit>>rank;
if(suit=='S') cards[0][rank]=1;
if(suit=='H') cards[1][rank]=1;
if(suit=='C') cards[2][rank]=1;
if(suit=='D') cards[3][rank]=1;

}
for(int s=0; s<4; s++){
for(int r=1; r<=13; r++){
if(cards[s][r]) continue;
if(s==0) suit='S';
if(s==1) suit='H';
if(s==2) suit='C';
if(s==3) suit='D';
cout<<suit<<" "<<r<<endl;

}
}


	return 0;
}

Measured memory_bytes: 1160
H, W = map(int, input().split())
 
a = [input() for i in range(H)]
 
a = [i for i in zip(*a)]
a = [i for i in a if "#" in i]
 
a = [i for i in zip(*a)]
a = [i for i in a if "#" in i]
 
for i in a:
    print("".join(i))

Measured memory_bytes: 3188
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main()
{
	int a, b, k, i;
	scanf("%d %d %d", &a, &b, &k);
	int x1 = a + k - 1, x2 = b - k + 1;
	for(i = a; i <= a + k - 1 && i < b - k + 1; ++i)
		printf("%d\n", i);
	int j = i >= b - k + 1 ? i: b - k + 1;
	for(; j <= b; ++j)
		printf("%d\n", j);
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
 
#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,n) for (int i = 0; i < n; i++)
#define forr(i,a,b) for (int i = a; i <= b; i++)
#define all(v) v.begin(), v.end()
#define pb(x) push_back(x)
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;

const int MX = 5005, mod = 1000000007;
int n, a, b, mem[MX][MX][2], mem2[MX][MX];

ll pot (ll b, int p) {
	ll res = 1;
	while (p) {
		if (p & 1) (res *= b) %= mod;
		(b *= b) %= mod;
		p /= 2;
	}
	return res;
}

void sum (int &a, int b) {
	a += b;
	if (a >= mod) a -= mod;
}

int dp (int i, int j, int f);

int dp2 (int i, int j) {
	if (i < 0) return 0;

	int &res = mem2[i][j];
	if (res != -1) return res;
	res = 0;

	sum(res, dp(i, j, 1));
	sum(res, dp2(i - 1, j + 1));

	return res;
}

int dp (int i, int j, int f) {
	if (f == 0 && j >= a) return 0;
	if (f == 1 && j >= b) return 0;
	if (!i) return 1;

	int &res = mem[i][j][f];
	if (res != -1) return res;
	res = 0;

	sum(res, dp(i - 1, j + 1, f));
	sum(res, dp(i - 1, 1, f ^ 1));

	if (i == n || (j && f)) {
		sum(res, dp2(i - a - 1, j + a + 1));

		if (j && f && i >= a)
			sum(res, dp(0, j + i, f));
	}

	return res;
}

int main () {
	ios_base::sync_with_stdio(0); cin.tie(0);
	memset(mem, -1, sizeof(mem));
	memset(mem2, -1, sizeof(mem2));

	cin >> n >> a >> b;
	if (a > b) swap(a, b);
	cout << MOD(pot(2, n) - dp(n, 0, 0), mod) << endl;

	return 0;
}


Measured memory_bytes: 297660
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int W = sc.nextInt();
		int h = sc.nextInt();
		int w = sc.nextInt();

		if (h >= 0) {
			H = H - h;
		}
		if (w >= 0) {
			W = W - w;
		}
      	if (H < 0) {
			H = 0;
		}
		if (W < 0) {
			W = 0;
		}
      
		System.out.println(H * W);

	}

}


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

int main() {
	int cnt;
	while (scanf("%d", &cnt), cnt) {
		rep(i, 9) {
			int a; cin >> a;
			cnt -= a;
		}
		cout << cnt << endl;
	}
	return 0;
}

Measured memory_bytes: 1244