akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cerr << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cerr<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 500010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = (1 << 30) - 1;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
mt19937 rng; //use it by rng() % mod, shuffle(all(vec), rng)
///////////////////////////////////////////////////////////////////////////////////////////////////

int N;
string S;

void solve() {
	cin >> S;
	N = sz(S);
	int state = 0;
	int cnt = 0;
	ll ans = 0;
	rer(i, N, 0) {
		if(state == 0) {
			if(S[i] == 'A') ans += cnt;
			else if(S[i] == 'B') cnt = 0;
			else if(S[i] == 'C') state = 1;
		}
		else {
			if(S[i] == 'A') {
				state = 0; cnt = 0;
			}
			else if(S[i] == 'B') {
				state = 0; cnt++;
			}
			else if(S[i] == 'C') {
				cnt = 0;
			}
		}
	}
	cout << ans << "\n";
}

uint32_t rd() {
	uint32_t res;
#ifdef __MINGW32__
	asm volatile("rdrand %0" :"=a"(res) ::"cc");
#else
	res = std::random_device()();
#endif
	return res;
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
    cerr << fixed;
	cerr.precision(6);
	rng.seed(rd());
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
	if(!freopen("in.txt", "rt", stdin)) return 1;
#endif	
	solve();
    cerr << "Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}



Measured memory_bytes: 720
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <unordered_map>
#include <cmath>
#include <stack>
#include <set>
#include <map>
#define rep(i,n) for (int i=0; i<n;++i)
#define rep_down(i,n) for (int i=n-1; i>=0;--i)
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;
const int INF = 1000000007;
string S,T;
unordered_map<char, int> M;
unordered_map<char, vector<ll> > N;

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

  cin >> S >> T;
  rep(i, S.size()){
    M[S[i]]++;
    N[S[i]].push_back(i);
  }

  rep(i, T.size()){
    char t = T[i];
    if (M[t]==0){
      cout << -1 << endl;
      return 0;
    }
  }
  ll current = -1ll;
  ll counter = 0ll;
  rep(i, T.size()){
    char c = T[i];
    vector<ll>::iterator it = upper_bound(N[c].begin(), N[c].end(), current);
    if (it == N[c].end()){
      counter++;
      current = N[c][0];
    } else current = *it;
  }
  cout << counter*S.size()+current+1ll << endl;
  return 0;
}

Measured memory_bytes: 1736
#include<bits/stdc++.h>
const int MAXN=200017;
using namespace std;

int a, b, n;
int oc[MAXN];

bool canl(int i)
{
	return i>1&&!oc[i-1];
}
bool canr(int i)
{
	return i<n&&!oc[i+1];
}
void mainp()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
//	freopen("***.in", "r", stdin);
//	freopen("***.out", "w", stdout);

	cin>>n>>a>>b;
	
	oc[a]=1;
	oc[b]=1;
	
	int temp=1;
	while(temp<=100000000)
	{
		if(temp%2==1)
		{
			if(canr(a)) {oc[a]=0; a++; oc[a]=1;}
			else if(canl(a)) {oc[a]=0; a--; oc[a]=1;}
			else
			{
				cout<<"Borys"<<endl;
				return;
			}
		}
		else
		{
			if(canl(b)) {oc[b]=0; b--; oc[b]=1;}
			else if(canr(b)) {oc[b]=0; b++; oc[b]=1;}
			else
			{
				cout<<"Alice"<<endl;
				return;
			}
		}
		
		temp++;
	}
	
	cout<<"Draw"<<endl;
	return;
}

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


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[]args){
        Scanner sc = new Scanner(System.in);
        int W = sc.nextInt();
        int H = sc.nextInt();
        int x = sc.nextInt();
        int y = sc.nextInt();
        int r = sc.nextInt();
        if(x-r < 0 || W < x+r ||  y-r < 0 || H < y+r){
            System.out.println("No");
        }else{
            System.out.println("Yes");
        }
    }
}


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

int main() {
    int n;
    string s;
    cin >> n >> s >> s;
    int b = s[0] == s[1];
    int64_t a = b * 3 + 3;
    for(int i = b + 1; i < n; i++)
        b = s[i] == s[i+1] ? b | 2 : ((a *= b ? b : 2) %= 1000000007, b >> 1);
    cout << a << endl;
    return 0;
}

Measured memory_bytes: 504
# -*- utf-8 -*-

while True:
    try:
        inp = raw_input()
        i = map(int, inp.split())
        a = i[0]
        b = i[1]
    
        s = a + b
    except:
        break
    
    ans = 0
    
    while s >= 1:
        s /= 10
        ans += 1
    
    print ans

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

int main(){
    int n,i,j;
    cin>>n;

    if(n==2){
        int x,y;
        cin>>x>>y;
        if(x==y) cout<<1<<endl;
        else cout<<0<<endl;
        return 0;
    }

    vector<P> v1(101010),v2(101010);
    for(i=0;i<n;i++) {
        int x;
        cin>>x;
        if(i%2==0) v1[x].first++;
        else v2[x].first++;
    }
    for(i=0;i<101010;i++) {
        v1[i].second=i;
        v2[i].second=i;
    }
    sort(v1.begin(),v1.end());
    sort(v2.begin(),v2.end());

    reverse(v1.begin(),v1.end());
    reverse(v2.begin(),v2.end());

    int ans;

    if(v1[0].second!=v2[0].second){
        ans=v1[0].first+v2[0].first;
    }
    else ans=max(v1[0].first+v2[1].first,v1[1].first+v2[0].first);
    
    cout<<n-ans<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>



using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)


















int main(){
    string s;
    cin >> s;
    ll n = s.size();
    ll ans = 0;
    ll dp[100005][2] = {};
    dp[0][1] = 1;
    REP(i, n){
        if(s[i] == '1'){
            dp[i + 1][1] += dp[i][1] * 2;
            dp[i + 1][1] %= MOD;
            dp[i + 1][0] += dp[i][0] * 3;
            dp[i + 1][0] += dp[i][1];
            dp[i + 1][0] %= MOD;
        }
        else{
            dp[i + 1][1] += dp[i][1];
            dp[i + 1][1] %= MOD;
            dp[i + 1][0] += dp[i][0] * 3;
            dp[i + 1][0] %= MOD;
        }
    }
    cout << (dp[n][0] + dp[n][1]) % MOD << endl;
}

Measured memory_bytes: 2048
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <functional>
#include <iostream>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <stack>
#include <string>
#include <vector>
#include <iomanip>
 
using namespace std;
typedef long long ll;
using gra = vector<vector<ll>>;
using gram = vector<unordered_map<ll,ll>>;
 
typedef unsigned long long ull;
 
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; }
 
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template <class T> T dup(T a, T b) { return (a + b - 1) / b; }
template <class T> T modpow(T x, T p, T m) { T a=1; while(p){ if(p%2)a =a*x%m; x = x+x%m; p/=2; } return a; }
// template <class T> void prim(T a) { for(ll i=0;i<a.size();++i) { cout << a[i]; } cout << "\n"; }
//template< typename T >
//T mod_pow(T x, T n, const T &p) {
//  T ret = 1;
//  while(n > 0) {
//    if(n & 1) (ret *= x) %= p;
//    (x *= x) %= p;
//    n >>= 1;
//  }
//  return ret;
//}
/////////////////// 
//

#define mod 1000000007LL
#define INF 10000000000000000LL
 
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep1(i, n) for (ll i = 1; i <= n; ++i)
#define rrep(i, n) for (int i = (n - 1); i >= 0; --i)
#define rrep1(i, n) for (int i = n; i > 0; --i)
 
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
//#define modpow(x, p, m) { ll a=1; while(p){ if(p%2)a =a*x%m; x = x+x%m; p/=2; } return a; }
 
#define m0(h) memset(h, 0, sizeof(h))
#define m1(h) memset(h, 1, sizeof(h))
#define m(h, n) memset(h, (n), sizeof(h))
#define all(n) (n).begin(),(n).end()
#define bit(n) (1LL << (n))
#define pb push_back
#define mp make_pair
 
//#ifdef LOCAL
//
//#define dpri(...) fprintf(stderr, __VA_ARGS__)
//#define pria(g) rep(i,g.size()){ cout << i << "{"; rep(j,g[i].size()) cout << g[i][j] << " "; cout << "}" << "\n"; }
//#else
//#define dpri(...) 42
//#define pria(g) 42
//#endif
//
//
//

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // ---------------------
  // コーディング開始
  // ---------------------
  int a,b;
  cin >> a >> b;
  if((a-1) >= (b-1)*2) pri("YES");
  else pri("NO");
  return 0;
}







Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
ll const INF = 1LL << 60;
ll const MAX_N = 510000;
ll const MOD = 1000000007;

int main() {
    ll H, W, N;
    cin >> H >> W >> N;
    vector<ll> a(N);
    rep(i, N) cin >> a[i];

    vector<vector<ll>> ans(H, vector<ll>(W, 0));

    ll now = 1;
    rep(i, H) {
        if (i % 2 == 0) {
            for (ll j = 0; j < W; j++) {
                ans[i][j] = now;
                a[now - 1]--;
                if (a[now - 1] == 0) {
                    now++;
                }
            }
        } else if (i % 2 == 1) {
            for (ll j = W - 1; j >= 0; j--) {
                ans[i][j] = now;
                a[now - 1]--;
                if (a[now - 1] == 0) {
                    now++;
                }
            }
        }
    }

    rep(i, H) {
        rep(j, W) { cout << ans[i][j] << " "; }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 3676
#!/usr/bin/python3
# -*- coding: utf-8 -*-
n = int(input())
a_list = list(map(int, input().split()))

total = 0
for i in range(1, n):
    if a_list[i - 1] > a_list[i]:
        total += a_list[i - 1] - a_list[i]
        a_list[i] = a_list[i - 1]

print(total)


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

#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(v) reverse((v).begin(),(v).end())
#define ANS(ans) cout<<(ans)<<endl;
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
typedef vector<int> VI;
typedef pair<int, int> P;
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  for (int i = 0; i < (n); ++i)

double d(pair<int,int> p, pair<int,int> n){
    long long s = (p.first-n.first)* (p.first-n.first) + (p.second-n.second)*(p.second-n.second);
    return sqrt(s);
}

int main() {
    int n;
    cin>>n;
    VI list(n);
    REP(i,n){
        list[i]=i;
    }
    vector<pair<int,int>> coordinations(n);
    REP(i,n){
        cin>>coordinations[i].first>>coordinations[i].second;
    }

    double sum=0;
    int num=0;
    do{
        num++;
        double length=0;
        FOR(i,0,n-2){
            length+=d(coordinations[list[i]], coordinations[list[i+1]]);
        }
        sum+=length;
    }while(next_permutation(list.begin(),list.end()));

    cout<<setprecision(10)<<sum/num<<endl;
    return 0;
}


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

namespace AC
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] l = Console.ReadLine().Split((char[])null, StringSplitOptions.RemoveEmptyEntries).Select(s => int.Parse(s)).ToArray();

            Array.Sort(l);
            int count = 0;
            for (int i = 0; i < n - 2; ++i)
            {
                for (int j = i + 1; j < n - 1; ++j)
                {
                    count += LowerBound(l, j, l.Length - j, l[i] + l[j]) - j - 1;
                }
            }
            Console.WriteLine(count);
        }

        static int LowerBound(int[] array, int startIndex, int length, int value)
        {
            while (length > 0)
            {
                int newLength = length >> 1;
                int middleIndex = startIndex + newLength;
                if (array[middleIndex] < value)
                {
                    length -= newLength + 1;
                    startIndex = middleIndex + 1;
                }
                else
                {
                    length = newLength;
                }
            }
            return startIndex;
        }
    }
}


Measured memory_bytes: 13652
#include <iostream>
#include <limits>
using namespace std;
using ll = long long;
using ull = unsigned long long;

static inline bool IsOverflow(ull a, ull b)
{
    return a && b > numeric_limits<ull>::max() / a;
}

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

    bool over = false;
    ull result = 1;
    for (int i = 0; i < n; ++i)
    {
        ull a;
        cin >> a;

        if (a == 0ULL)
        {
            result = 0ULL;
            over = false;
            break;
        }

        if (IsOverflow(result, a))
            over = true;

        result *= a;
        if (result > 1000000000000000000ULL)
            over = true;
    }

    if (over)
        cout << -1 << endl;
    else
        cout << result << endl;

    return 0;
}

Measured memory_bytes: 3660
#include <iostream>
#include<stdio.h>
#include<vector>
#include<string.h>
#include<string>
#include<algorithm>
using namespace std;
long long a[200000]={0};
int erfen(int low,int high,int i)
{
    int mid;
    while(low<=high)
    {
       mid=(low+high)/2;
       if(a[mid]==a[i])
            return 1;
        else if(a[mid]<a[i])
            low=mid+1;
        else
            high=mid-1;
    }
    return 0;
}
int main()
{
    int N,i,low,high,flag;
    scanf("%d",&N);
    for(i=0;i<N;i++)
    {
        scanf("%lld",&a[i]);
    }
    sort(a,a+N);
    for(i=0;i<N;i++)
    {
        low=i+1;
        high=N-1;
        flag=erfen(low,high,i);
        if(flag==1)
        {
            printf("NO\n");
            break;
        }
    }
    if(flag==0)
        printf("YES\n");
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
using namespace std;
vector<int> v;
int main() {
  string s;
  cin >> s;
  vector<bool> vv(26, true);
  for (char i : s) {
    vv[i - 97] = !vv[i - 97];
  }
  for (bool i : vv) {
    if (!i) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    int n;
    const int ac = 0, wa = 1, tle = 2, re = 3;
    cin >> n;
    int counts[4] = {0,0,0,0};
    for (int i=0;i<n;i++)  {
        string s;
        cin >> s;
        switch(s[0]) {
            case 'A':
            counts[ac]++;
            break;
            case 'W':
            counts[wa]++;
            break;
            case 'T':
            counts[tle]++;
            break;
            case 'R':
            counts[re]++;
            break;
        }
    }
    cout << "AC x " << counts[ac] << endl;
    cout << "WA x " << counts[wa] << endl;
    cout << "TLE x " << counts[tle] << endl;
    cout << "RE x " << counts[re] << endl;
}


Measured memory_bytes: 3628
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class MainClass
{
	public const long Giri = 1000000007;
	public const long DpInf = 99999999999;
	public static void Main(string[] args)
	{
		var a = Input().ToInt();
		
		if(a[0] >= 10)
		{
		
		}
		else
		{
			Console.WriteLine(a[1] + 100 * (10 - a[0]));
			return;
		}
		Console.WriteLine(a[1]);
	}
	
	
	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str, int offset = 0)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt() + offset;
		return r;
	 }
}


Measured memory_bytes: 13140
s=input()
n=len(s)
ans="No"
for i in range(n//2):
    if s[i]!=s[-i-1]:
        break
else:
    s_h=s[:n//2]
    s_t=s[n//2+1:]
    for i in range(len(s_h)//2):
        if s_h[i]!=s_h[-i-1]:
            break
        if s_t[i]!=s_t[-i-1]:
            break
    else:
        ans="Yes"
print(ans)

Measured memory_bytes: 3064
// 基本テンプレート

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

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

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

const int MAXN = 1010;
const int MAXX = 5010;
vector<int> G[MAXN];
int N, x[MAXN], dp[MAXN], dp2[MAXN][MAXX];

int solve_dp(vector<int> &a, vector<int> &b, int &lim) {
    int M = a.size();
    repq(i,0,M) repq(j,0,lim) dp2[i][j] = INF;
    dp2[0][0] = 0;
    rep(i,0,M) repq(j,0,lim) {
        if(dp2[i][j] == INF) continue;

        // choose a
        if(j + a[i] <= lim) {
            chmin(dp2[i+1][j+a[i]], dp2[i][j] + b[i]);
        }

        // choose b
        if(j + b[i] <= lim) {
            chmin(dp2[i+1][j+b[i]], dp2[i][j] + a[i]);
        }
    }
    return *min_element(dp2[M], dp2[M]+lim+1);
}

void solve(int p, int par=-1) {
    bool leaf = true;
    vector<int> a, b;
    for(auto to : G[p]) {
        if(to == par) continue;
        leaf = false;
        solve(to, p);
        a.push_back(x[to]);
        b.push_back(dp[to]);
    }
    if(leaf) dp[p] = 0;
    else {
        int val = solve_dp(a, b, x[p]);
        dp[p] = val;
    }
}

signed main() {
    cin >> N;
    rep(i,0,N-1) {
        int p; cin >> p; p--;
        G[p].push_back(i+1);
    }
    rep(i,0,N) {
        cin >> x[i];
        dp[i] = INF;
    }
    
    solve(0);
    cout << (dp[0] == INF ? "IMPOSSIBLE" : "POSSIBLE") << endl;
    return 0;
}

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

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	int ans = 1;
	int sign = 0;
	rep(i, n - 1) {
		if (sign > 0 && a[i] > a[i + 1]) {
			ans++;
			sign = 0;
		}
		else if (sign < 0 && a[i] < a[i + 1]) {
			ans++;
			sign = 0;
		}
		else if (sign == 0) {
			if (a[i] < a[i + 1]) sign = 1;
			if (a[i] > a[i + 1]) sign = -1;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3740
#include <algorithm>
#include <array>
#include <functional>
#include <iostream>
#include <math.h>
#include <vector>
#define ll long long int
#define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, n)

using namespace std;

int main() {
    string s;
    cin >> s;
    if (s[2] == s[3] && s[4] == s[5])
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    static String s;
    static String t;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        s = sc.next();
        t = sc.next();
        char[] cs = s.toCharArray();
        char[] ct = t.toCharArray();


        boolean isMatch = false;
        int point = 0;
        //部分文字列を代入できる場所を探す
        for (int i = cs.length - ct.length; i >= 0 ; i--) {
            isMatch = false;
            for (int j = 0; j < ct.length; j++) {
                if (cs[i + j] != ct[j] && cs[i + j] != '?') {
                    isMatch = false;
                    break;
                } else {
                    isMatch = true;
                    point = i;
                }
            }
            if (isMatch) break;
        }
        if (!isMatch) {
            System.out.println("UNRESTORABLE ");
        } else {
            //部分文字列を代入
            for (int i = 0; i < ct.length; i++) {
                cs[point + i] = ct[i];
            }
            //先頭から順に出力 ?はaに変換する
            for (int i = 0; i < cs.length; i++) {
                if (cs[i] == '?') {
                    System.out.print('a');
                } else {
                    System.out.print(cs[i]);
                }
            }
            System.out.println();
        }
    }
}


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

ll a[100005];

int main(){
    ll n, c;
    cin >> n >> c;
    for(ll i=0;i<n;i++){
        ll s,t,cc;
        cin >> s >> t >> cc;
        a[s]++;
        a[t+1]--;
    }
    ll memo=0;
    for(ll i=1;i<=100000;i++){
        a[i]=a[i - 1]+a[i];
        memo=max(memo,a[i]);
    }
    memo=min(memo,c);
    cout << memo << endl;
}


Measured memory_bytes: 4368
import numpy as np

n, m = map(int, input().split())
a = [int(input()) for _ in range(m)] + [0]
mod = 10 ** 9 + 7

dp = np.zeros(n + 1, dtype=np.int64)
dp[0] = 1
b = a[0]
j = 1
for i in range(1, n + 1):
    if i == b:
        b = a[j]
        j += 1
    else:
        tmp = dp[i - 2] + dp[i - 1]
        if tmp >= mod:
            tmp -= mod
        dp[i] = tmp
print(int(dp[-1]))

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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//main code

int main(int argc, char const* argv[])
{
	int n;
	string s;
	cin >> n >> s;
	int ans = 0;
	for (int i = 1; i < n; i++) {
		VL s1(26,0),s2(26,0);
		int same_char = 0;
		for (int j = 0; j < i; j++) {
			s1[s[j] - 'a']++;
		}
		for (int j = i; j < n; j++) {
			s2[s[j] - 'a']++;
		}
		for (int j = 0; j < 26; j++) {
			if (s1[j] > 0 and s2[j] > 0) {
				same_char++;
			}
		}
		ans = max(ans,same_char);
	}
	cout << ans << endl;
	return 0;
}


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

int a[26];

int main(){
  string s;
  cin >> s;
  for (int i = 0; i < s.size(); i++) {
    a[s[i] - 'a']++;
  }
  for (int i = 0; i < 26; i++) {
    if (a[i] > 1) {
      printf("no\n");
      return 0;
    }
  }
  printf("yes\n");
  return 0;
}


Measured memory_bytes: 256
import sys
#import string
#from collections import defaultdict, deque, Counter
#import bisect
#import heapq
#import math
#from itertools import accumulate
#from itertools import permutations as perm
#from itertools import combinations as comb
#from itertools import combinations_with_replacement as combr
#from fractions import gcd
#import numpy as np

stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
MIN = -10 ** 9
MOD = 10 ** 9 + 7
INF = float("inf")
IINF = 10 ** 18

def solve():
    #n = int(stdin.readline().rstrip())
    n,k = map(int, stdin.readline().rstrip().split())
    H = list(map(int, stdin.readline().rstrip().split()))
    #numbers = [[int(c) for c in l.strip().split()] for l in sys.stdin]
    #word = [stdin.readline().rstrip() for _ in range(n)]
    #number = [[int(c) for c in stdin.readline().rstrip()] for _ in range(n)]
    #zeros = [[0] * w for i in range(h)]
    H.sort()
    if n <= k:
        print(0)
        exit()

    for i in range(k):
        H.pop(-1)

    print(sum(H))

if __name__ == '__main__':
    solve()


Measured memory_bytes: 32076
#include <cstdio>
#include <cstdlib>
#include <cstring>

int top, S[1000];

void push(int x){
	S[++top] = x;
}

int pop(){
	top--;
	return S[top + 1];
}

int main(){
	int a, b;
	top = 0;
	char s[100];

	while(scanf("%s", s) != EOF){
		if (s[0] == '+'){
			a = pop();
			b = pop();
			push(a + b);
		}
		else if (s[0] == '-'){
			b = pop();
			a = pop();
			push(a - b);
		}
		else if (s[0] == '*'){
			a = pop();
			b = pop();
			push(a * b);
		}
		else {
			push(atoi(s));
		}
	}

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

	return 0;
}

Measured memory_bytes: 984
#include<iostream>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<cmath>

using namespace std;

int main(){
  int N,T,A;
  cin>>N>>T>>A;
  double min;
  int minnum;
  vector<double> H(N);
  for (int i=0;i<N;i++) cin>>H.at(i);
  for (int i=0;i<N;i++){
    H.at(i)=abs((T-H.at(i)*0.006)-A);
  }
  min=H.at(0);
  minnum=0;
  for (int i=0;i<N;i++){
    if (min>H.at(i)){
      min=H.at(i);
      minnum=i;
    }
  }
  cout<<minnum+1<<endl;
  return 0;
}


Measured memory_bytes: 256
array = []

for i in range(2):
    val = input().split()
    array.append(val)

n = int(array[0][0])
k = int(array[0][1])
h = sorted([int(s) for s in array[1]], reverse=True)

if k >= n:
    print(0)
elif k == 0:
    print(sum(h))
else:
    del h[0:k]
    print(sum(h))


Measured memory_bytes: 28300
n = int(input())
min_count = n
for i in range(n+1):
    m = i
    result = 0
    while m > 0:
        result += m % 6
        m //= 6
    m = n-i
    while m > 0:
        result += m %9
        m //= 9
    min_count = min(result, min_count)
print(min_count)

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

typedef long long ll;
typedef long double ld;

int main(){
    ios_base::sync_with_stdio(false), cin.tie(0);
    cout.precision(10);
    cout << fixed;

    int n, m;
    cin >> n >> m;
    cout << n*(n-1)/2 + m*(m-1)/2;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <bitset>

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 1000000007; //998244353;

template<class _T> static void get(_T& a) {
	std::cin >> a;
}
template<class _T> static void get(_T& a, _T& b) {
	std::cin >> a >> b;
}
template<class _T> static void get(_T& a, _T& b, _T& c) {
	std::cin >> a >> b >> c;
}
template <class _T> static _T tp_abs(_T a) {
	if (a < (_T)0) {
		a *= (_T)-1;
	}
	return a;
}

static void exec();

int main()
{
	exec();
	fflush(stdout);
	return 0;
}


static void exec()
{
	int N;
	get(N);
	std::vector<LLONG> hi(N);
	for (int i = 0; i < N; i++) {
		get(hi[i]);
	}

	LLONG max = 0;
	for (int i = 0; i < N; i++) {
		max = std::max(max, hi[i]);

		if (max - hi[i] > 1) {
			printf("No\n");
			return;
		}
	}
	printf("Yes\n");
}


Measured memory_bytes: 4052
import java.util.*;
import java.io.*;
class Main{
	public static void main(String[]args){
		Scanner in=new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out, true);
		long x = Math.abs(in.nextLong());
		long k = in.nextLong();
		long d = in.nextLong();

		long step = Math.min(k, x/d);
		k = k - step;
		long pos = x - (step * d);
		if(k == 0){
			out.println(Math.abs(pos));
		}
		else{
			if(k % 2 == 0)
				out.println(pos);
			else
				out.println(Math.abs(pos - d));
		}
	}
}


Measured memory_bytes: 35776
#include <iostream>
using namespace std;
using ll = long long;

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

  int Q; cin >> Q;
  for (int i = 0; i < Q; i++) {
    ll A, B; cin >> A >> B;
    if (A > B) swap(A, B);
    ll AB = A * B;
    ll x = 1, r = B;
    while (x < r) {
      ll mid = (x + r) / 2;
      if (mid * mid < AB) x = mid + 1;
      else r = mid;
    }
    if (A != B) x--;
    if (x * (x + 1) >= AB) cout << 2 * x - 2 << "\n";
    else cout << 2 * x - 1 << "\n";
  }
}

Measured memory_bytes: 256
//#define _USE_MATH_DEFINES
#include <iostream>
//#include <stdio.h>
//#include <iomanip>
#include <vector>
//#include <string>
//#include <algorithm>
//#include <functional>
//#include <cmath>

using namespace std;


long money(long m,int n){
	//5%?????? + 1000??????????????????
	const int u = 1000;

	if (n <= 0){
		return m;
	}
	else{
		m = m * 1.05;
		m = (m + u - 1) / u * u;
		n--;
		money(m, n);
	}
	
}


int main(){

	int n;
	long m = 100000;

	cin >> n;

	m = money(m, n);


	cout << m << endl;


	return 0;
}

Measured memory_bytes: 1160
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			while(sc.hasNext()) {
				String s = sc.nextLine();
				if(s.equals("END OF INPUT"))
					break;
				String[] str = s.split(" ");
				
				for(String a:str) {	
					System.out.print(a.length());
				}
				System.out.println();
			}
		}
	}
}



Measured memory_bytes: 26348
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
    long long n;
    cin >> n;
    
    long long res = 1;
    for(int i = 1; i <= n; i++) {
        res *= i;
        res %= ((long long)1e9 + 7);
    }
    
    cout << res << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define rSort(v) sort(v.rbegin(), v.rend())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

/* Macros reg. ends here */

const ll INF = 1LL << 50;

int main() {
  // ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll n;
  cin >> n;

  vll as(n + 1);
  rep(i, n) cin >> as[i + 1];

  rrepLRE(i, n, 1) {
    for (ll j = 2 * i; j <= n; j += i) {
      as[i] ^= as[j];
    }
  }
  vll bs;
  repLRE(i, 1, n) if (as[i]) bs.push_back(i);

  cout << bs.size() << endl;
  rep(i, (ll)bs.size()) cout << bs[i] << ((i == (ll)bs.size()-1) ? "\n" : " "); 

  return 0;
}


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

int main() {
    int l, r, d;
    cin >> l >> r >> d;
    int cnt = 0;
    for (int i = l; i <= r; i++) {
        if (i % d == 0) cnt++;
    }
    cout << cnt << endl;
}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
	for(auto &e:u) fill_v<T>(e,v...);
}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int64 N, K, S;
	cin >> N >> K >> S;
	vector<int64> A(N, 0);
	REP(i, K) A[i] = S;
	FOR(i, K, N) {
	  A[i] = (S == 1e9 ? 1 : 1e9);
	}
	REP(i, N) {
	  cout << A[i] << " ";
	}
	cout << endl;
}


Measured memory_bytes: 2176
def metric(student,point)
  return (student[0] - point[0]).abs + (student[1] - point[1]).abs
end
n,m = gets.chomp.split(' ').map(&:to_i)
students = []
points = []
n.times do
  students.push(gets.chomp.split(' ').map(&:to_i))
end
m.times do
  points.push(gets.chomp.split(' ').map(&:to_i))
end
students.each do |student|
  min = 10**10
  min_idx = 100
  points.each_with_index do |point,idx|
    metric = metric(student,point)
    if metric < min
      min = metric
      min_idx = idx + 1
    end
  end
  puts min_idx
end

Measured memory_bytes: 14268
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    H, W = map(int, rl().split())
    s = [list(input()) for _ in range(H)]
    
    dp = [[0] * W for _ in range(H)]
    dp[0][0] = s[0][0] == '#'
    for i in range(1, W):
        dp[0][i] = dp[0][i - 1] + (s[0][i - 1] == '.' and s[0][i] == '#')
    for i in range(1, H):
        dp[i][0] = dp[i - 1][0] + (s[i - 1][0] == '.' and s[i][0] == '#')
    
    for i in range(1, H):
        for j in range(1, W):
            dy = s[i - 1][j] == '.' and s[i][j] == '#'
            dx = s[i][j - 1] == '.' and s[i][j] == '#'
            dp[i][j] = min(dp[i - 1][j] + dy, dp[i][j - 1] + dx)
    print(dp[-1][-1])


if __name__ == '__main__':
    solve()


Measured memory_bytes: 42736
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
int main()
{
	long long a,b;
	char str;
	while(cin>>a)
	{
		cin>>str>>b;
		if(str=='+')
		cout<<a+b<<endl;
		else
		cout<<a-b<<endl;	
	}
	return 0;
}


Measured memory_bytes: 256
n = int(input())
from collections import defaultdict
loc2score = defaultdict(lambda : [])
score2idx = defaultdict(lambda : 0)
for i in range(n):
    loc, score = input().split()
    loc2score[loc].append(int(score))
    score2idx[int(score)] = i

for key in sorted(loc2score.keys()):
    scores = sorted(loc2score[key], reverse=True)
    for i in range(len(scores)):
        print(score2idx[scores[i]]+1)

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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

int main()
{
    ll N, M;
    cin >> N >> M;
    ll S = std::min(N, M / 2);
    M -= 2LL * S;
    S += M / 4LL;
    cout << S << endl;
    return 0;
}

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

using namespace std;

//vector string deque break continue
#define forn(i, s, f) for (int i = (int)s; i < (int)f; i++)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define fs first
#define sc second
#define pf push_front
#define pb push_back
#define pop_f pop_front
#define pop_b pop_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()

template <typename T> istream& operator>>(istream& in, vector <T>& a) {for (auto& i : a) in >> i; return in;}
template <typename T> ostream& operator<<(ostream& out, vector <T>& a)  {for (auto& i : a) out << i << " "; return out;}
template <typename T, typename U> void chkmin(T& a, U b) {if (a > b) a = b;}
template <typename T, typename U> void chkmax(T& a, U b) {if (a < b) a = b;}

const int MOD = 1e9 + 7;

int add(int x, int y) {
    x += y;
    if (x >= MOD)
        return x - MOD;
    return x;
}

int sub(int x, int y) {
    x -= y;
    if (x < 0)
        return x + MOD;
    return x;
}

int mul(int x, int y) {
    return (1LL * x * y) % MOD;
}

int bin_pow(int a, int p) {
    if (!p)
        return 1;
    if (p % 2)
        return (1LL * bin_pow(a, p - 1) * a) % MOD;
    int t = bin_pow(a, p / 2);
    return (1LL * t * t) % MOD;
}

int inv(int x) {
    return bin_pow(x, MOD - 2);
}

vector <vector <int>> gr;
vector <int> sz, dp, f;

int C(int a, int b) {
    assert(b - a >= 0);
    return mul(f[b], mul(inv(f[a]), inv(f[b - a])));
}

int dfs(int v, int p = -1) {
    sz[v] = 1;
    dp[v] = 1;
    for (int u : gr[v]) {
        if (u == p)
            continue;
        sz[v] += dfs(u, v);
    }
    int cur = sz[v] - 1;
    for (int u : gr[v]) {
        if (u == p)
            continue;
        dp[v] = mul(dp[v], mul(C(sz[u], cur), dp[u]));
        cur -= sz[u];
    }
    return sz[v];
}

vector <int> ans;

void dfs2(int v, int p = -1) {
    ans[v] = dp[v];
    for (int u : gr[v]) {
        if (u == p)
            continue;
        dp[v] = mul(dp[v], inv(mul(C(sz[u], sz[v] - 1), dp[u])));
        sz[v] -= sz[u];
        sz[u] += sz[v];
        dp[u] = mul(dp[u], mul(C(sz[v], sz[u] - 1), dp[v]));

        dfs2(u, v);

        dp[u] = mul(dp[u], inv(mul(C(sz[v], sz[u] - 1), dp[v])));
        sz[u] -= sz[v];
        sz[v] += sz[u];
        dp[v] = mul(dp[v], mul(C(sz[u], sz[v] - 1), dp[u]));
    }
}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    int n;
    cin >> n;
    gr.resize(n);
    forn (i, 1, n) {
        int v, u;
        cin >> v >> u, --v, --u;
        gr[v].pb(u), gr[u].pb(v);
    }

    f.resize(n + 5);
    f[0] = 1;
    forn (i, 1, sz(f))
        f[i] = mul(f[i - 1], i);;

    sz = dp = vector <int> (n);
    dfs(0);

    ans = vector <int> (n);
    dfs2(0);
    for (int i : ans)
        cout << i << "\n";
    return 0;
}

Measured memory_bytes: 17140
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
typedef pair<int,int>pii;
int n,m,C,a,b,c,d[100001],visit[100001],tg,uu,vv,uv,u,res,ans[100007];
vector<pii>v[100001],dd;
priority_queue<pii,vector<pii>,greater<pii> >q;
signed main()
{
    cin>>n>>m>>C;
    for(int i=1;i<=m;++i)
    {
        cin>>a>>b>>c;
        tg+=c;
        v[a].push_back({c,b});
        v[b].push_back({c,a});
    }
    for(int i=1;i<=n;++i)d[i]=1e16;
    d[1]=0;
    q.push({0,1});
    while(!q.empty())
    {
        u=q.top().se;
        uu=q.top().fi;
        q.pop();
        if(d[u]<uu)continue;
        for(int i=0;i<v[u].size();++i)
        {
            vv=v[u][i].se;
            uv=v[u][i].fi;
            if(d[vv]>d[u]+uv)
            {
                d[vv]=d[u]+uv;
                q.push({d[vv],vv});
            }
        }
    }
    for(int i=1;i<=n;++i)dd.push_back({d[i],i});
    sort(dd.begin(),dd.end());
    res=1e16;
    for(int i=1;i<=n;++i)
    {
        u=dd[i-1].se;
        uu=dd[i-1].fi;
        visit[u]=1;
        ans[i]=ans[i-1];
        for(int j=0;j<v[u].size();++j)
        {
            vv=v[u][j].se;
            uv=v[u][j].fi;
            if(visit[vv]==0)continue;
            ans[i]+=uv;
        }
        if(i!=n&&dd[i].fi==dd[i-1].fi)continue;
        res=min(res,tg-ans[i]+C*uu);
    }
    cout<<res<<endl;
}

Measured memory_bytes: 20280
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mit map<int,int>::iterator
#define sit set<int>::iterator
#define itrm(g,x) for(mit g=x.begin();g!=x.end();g++)
#define itrs(g,x) for(sit g=x.begin();g!=x.end();g++)
#define ltype int
#define rep(i,j,k) for(ltype(i)=(j);(i)<=(k);(i)++)
#define rap(i,j,k) for(ltype(i)=(j);(i)<(k);(i)++)
#define per(i,j,k) for(ltype(i)=(j);(i)>=(k);(i)--)
#define pii pair<int,int>
#define fi first
#define se second
#define mpr make_pair
#define pb push_back
#define fastio ios::sync_with_stdio(false)
const int inf=0x3f3f3f3f,mod=1000000007;
const double pi=3.1415926535897932,eps=1e-6;
int n;string s;
int main(){
    cin>>n>>s;
    if(n&1){puts("No");return 0;}
    if(s.substr(0,n/2)==s.substr(n/2,n/2)) puts("Yes");else puts("No");
    return 0;
}

Measured memory_bytes: 256
/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   main.cpp                                           :+:      :+:    :+:   */
/*                                                    +:+ +:+         +:+     */
/*   By: monoue <marvin@student.42.fr>              +#+  +:+       +#+        */
/*                                                +#+#+#+#+#+   +#+           */
/*   Created: 2020/04/22 12:30:15 by monoue            #+#    #+#             */
/*   Updated: 2020/04/23 06:39:32 by monoue           ###   ########.fr       */
/*                                                                            */
/* ************************************************************************** */

#include <bits/stdc++.h>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/algorithm/string/classification.hpp> // is_any_of
#include <boost/algorithm/string/split.hpp>
#include <boost/algorithm/string/join.hpp>
#include <boost/algorithm/string/replace.hpp>
#include <boost/math/tools/minima.hpp>

const int MOD = 1e9+7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = (n); i >= 0; --i)

namespace adaptor = boost::adaptors;
using namespace std;
using boost::math::tools::brent_find_minima;
using boost::irange;
using boost::algorithm::join;
using boost::algorithm::split;
using boost::algorithm::replace_all;
using boost::multiprecision::cpp_int;
using ll = long long;
using P = pair<int, int>;

// TOP
void	Main()
{
	int n, m;
	cin >> n >> m;
	if (m == 1 || n >= m)
	{
		cout << 0 << endl;
		return ;
	}
	vector<int>	V(m);
	rep(i, m)
		cin >> V.at(i);
	sort(V.begin(), V.end());
	vector<int>	VB(m - 1); // 各点の間隔なので、m でなく m - 1
	// vector<P>	P(m - 1); // 各点の間隔なので、m でなく m - 1
	rep(i, m - 1)
		VB.at(i) = V.at(i + 1) - V.at(i);
	sort(VB.begin(), VB.end(), greater<>());
	int	no_visit;
	no_visit = 0;
	rep(i, n - 1)
		no_visit += VB.at(i);
	cout << (V.at(m - 1) - V.at(0)) - no_visit << endl;
}
// END

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


Measured memory_bytes: 1024
#include <cmath>
    #include <random>
    #include <vector>
    #include <iostream>
    #include <algorithm>
    #include <functional>
    using namespace std;
    mt19937 mt(2007111352);
    int rand_rng(int l, int r) {
    	uniform_int_distribution<int> p(l, r - 1);
    	return p(mt);
    }
    double randouble() {
    	uniform_real_distribution<double> p(0.0, 1.0);
    	return p(mt);
    }
    long long calc(int N, vector<int> X, vector<int> Y, vector<int> P, vector<int> xrail, vector<int> yrail) {
    	long long ans = 0;
    	for (int i = 0; i < N; ++i) {
    		int mindist = (1 << 30);
    		for (int j : xrail) {
    			mindist = min(mindist, abs(X[i] - j));
    		}
    		for (int j : yrail) {
    			mindist = min(mindist, abs(Y[i] - j));
    		}
    		ans += 1LL * mindist * P[i];
    	}
    	return ans;
    }
    int main() {
    	int N;
    	cin >> N;
    	vector<int> X(N), Y(N), P(N);
    	for (int i = 0; i < N; ++i) {
    		cin >> X[i] >> Y[i] >> P[i];
    	}
    	vector<int> xinc, yinc;
    	for (int i = 0; i < N; ++i) {
    		if (X[i] != 0) xinc.push_back(X[i]);
    		if (Y[i] != 0) yinc.push_back(Y[i]);
    	}
    	sort(xinc.begin(), xinc.end()); xinc.erase(unique(xinc.begin(), xinc.end()), xinc.end());
    	sort(yinc.begin(), yinc.end()); yinc.erase(unique(yinc.begin(), yinc.end()), yinc.end());
    	int candx = xinc.size();
    	int candy = yinc.size();
    	vector<long long> ans(N + 1);
    	int limit = min(candx, candy);
    	vector<bool> flag(candx + candy, false);
    	function<long long()> get_score = [&]() {
    		vector<int> xrail = { 0 }, yrail = { 0 };
    		for (int i = 0; i < candx + candy; ++i) {
    			if (flag[i]) {
    				if (i < candx) xrail.push_back(xinc[i]);
    				else yrail.push_back(yinc[i - candx]);
    			}
    		}
    		return calc(N, X, Y, P, xrail, yrail);
    	};
    	ans[0] = get_score();
    	for (int i = 1; i < limit; ++i) {
    		int u = -1;
    		do {
    			u = rand_rng(0, candx + candy);
    		} while (flag[u]);
    		flag[u] = true;
    		// --- hill climbing! --- //
    		long long current_score = get_score();
    		long long best_score = current_score;
    		int repeat = 100000;
    		for (int j = 1; j <= repeat; ++j) {
    			int u1 = -1, u2 = -1;
    			do {
    				u1 = rand_rng(0, candx + candy);
    				u2 = rand_rng(0, candx + candy);
    			} while (!flag[u1] || flag[u2]);
    			flag[u1] = false; // true -> false
    			flag[u2] = true; // false -> true
    			double temperature = double(max(repeat - (j % (repeat / 4)) * 5, 1)) / repeat * ans[i - 1] * 2.0;
    			long long new_score = get_score();
    			if (randouble() < exp((current_score - new_score) / temperature)) {
    				if (best_score > new_score) {
    					cerr << "Repeat #" << j << ": Score " << best_score << " -> " << new_score << endl;
    					best_score = new_score;
    				}
    				current_score = new_score;
    			}
    			else {
    				// revert
    				flag[u1] = true;
    				flag[u2] = false;
    			}
    		}
    		ans[i] = best_score;
    	}
    	for (int i = 0; i <= N; ++i) {
    		cout << ans[i] << endl;
    	}
    	return 0;
    }

Measured memory_bytes: 4220