akhauriyash/Code-Regression huggingface dataset:
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define INF 10e16
#define MOD 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
char dir[4]={'u','l','d','r'};
ll cmp1(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}

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

//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    int a,b;cin>>a>>b;
    string s;cin>>s;
    int n=s.length();
    int cnt=0;
    for(int i=0;i<a;i++){
        if(s[i]-'0'>9||s[i]-'0'<0){
            cout<<"No"<<endl;
            return 0;
        }
    }
    if(s[a]!='-'){
        cout<<"No"<<endl;
        return 0;
    }
    for(int i=a+1;i<a+b+1;i++){
        if(s[i]-'0'>9||s[i]-'0'<0){
            cout<<"No"<<endl;
            return 0;
        }
    }

        cout<<"Yes"<<endl;
   
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <math.h>

using namespace std;

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

	long long int ans = 0;
	for (int i = 0; i < pow(2, S.length() - 1); i++)
	{
		int previ = 0;
		for (int j = 0; j < S.length() - 1; j++)
		{
			if (((i >> j) & 1) == 1)
			{
				string sub = S.substr(previ, j + 1 - previ);
				ans += stoi(sub);
				previ = j + 1;
			}
		}
		string sub = S.substr(previ, S.length());
		ans += stoll(sub);
	}
	cout << ans << endl;

	return 0;
}

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

long long gcd(long long a,long long b)
{
	long long r=max(abs(a),abs(b));
	long long l=min(abs(a),abs(b));
	if (l==0LL)
	{
		return r;
	}
	return gcd(l,r%l);
}

int main(int argc, char const *argv[])
{
	int t;
	cin>>t;
	long long a,b,c,d;
	for (int i = 0; i < t; ++i)
	{
		cin>>a>>b>>c>>d;
		if (a<b||d<b)
		{
			cout<<"No\n";
			continue;
		}
		if (c>=b-1)
		{
			cout<<"Yes\n";
			continue;
		}
		if (b-gcd(b,d)+a%gcd(b,d)<=c)
		{
			cout<<"Yes\n";
		}
		else
		{
			cout<<"No\n";
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int n,i;
    int money=100000;
    scanf("%d",&n); 
    for(i=0;i<n;i++){  
    money=money*1.05;
    if(money%1000>0){
    money=money/1000;
    money+=1;
    money*=1000;
    }
    }
    printf("%d\n",money);
    
    return 0;
}


Measured memory_bytes: 2028
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
'''
#Pythonを用いる場合
#numpy 1.18.0, scipy 1.4.1, scikit-learn 0.22, numba 0.47.0, networkx 2.4
 
import numpy as np
from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson
from scipy.sparse import csr_matrix
'''
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？


x,y=mii()

for i in range(26):
    for j in range(51):
        if i+j==x and i*4+j*2==y:
            print("Yes")
            exit()
print("No")






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

int main()
{
    vector<int> a(5);
    rep(i, 5) cin >> a[i];
    sort(a.begin(), a.end());
    int mx = a[4], mn = a[0];
    int k;
    cin >> k;
    if (abs(mx - mn) <= k)
    {
        cout << "Yay!" << endl;
    }
    else
        cout << ":(" << endl;
    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
using namespace std;
int main() {
    char c;
    for(int i=0;i<3;i++) {
        cin >>c;
        if(c=='1') cout << "9";
        else if(c=='9') cout << "1";
        else cout << c;
    }
    cout << endl;
}

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

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

    int x, a;
    cin >> x >> a;

    if(x < a){
        cout << 0 << endl;
    }else{
        cout << 10 << endl;
    }

    return 0;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
#include <typeinfo>
#include <cxxabi.h>
#ifdef LOCAL
#include "dbgtoki.hpp"
#define DUMP(i) dump((string)TOSTRING(i), demangle(typeid(i).name()), __LINE__ , i) 
#else
#define DUMP(i)
#endif

using namespace std;
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#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(s) (s).begin(), (s).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()) , v.end());
#define dis distance
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define pub push_back
#define sec second
#define fir first

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector <int> > vvi;
const int EPS = 1e-9;
const int MOD = 1e9+7;
const int INF = (1 << 30);

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,x;
	cin >> n >> x;
	vi A(n);
	REP(i,n)cin >> A[i];
	int sum = 0;
	ll ans = 0;
	REP(i,n){
		DUMP(i);
		sum += A[i];
		if(sum > x){
			DUMP(sum - x);
			ans += sum - x;
			A[i] -= sum - x;
			sum = x;
		}
		if(i > 0)sum -= A[i-1];
		DUMP(sum);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	input := scanIntNum()
	fmt.Println(destroy(input))
}

func scanIntNum() (num int) {
	sc.Scan()

	num, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return num
}

func destroy(n int) int {
	if n == 1 {
		return 1
	}
	return destroy(n/2)*2 + 1
}

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

#define M 1000000007
#define pb emplace_back
#define f first
#define s second
#define rep(i, st, ed) for(ll i=st; i<ed; ++i)
#define repn(i, st, ed) for(ll i=st; i<=ed; ++i)
#define repb(i, ed, st) for(ll i=ed; i>=st; --i)
#define all(v) v.begin(),v.end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define PI acosl(-1.0)

typedef long long ll;
typedef unsigned long long int llt;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef vector<ll> vec;
typedef vector<pll> vecp;
typedef map<ll, ll> mpll;


const int N = 1e5 + 10;
const ll INF = 1LL << 60;

template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}

template <typename A, typename B>
string to_string(pair<A, B> p);
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
 
string to_string(const string& s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << to_string(H) << endl;
  debug_out(T...);
}
#define LOCAL 3
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:" << endl, debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif


void solve()
{
	ll a, b, n;
	cin>>a>>b>>n;
	ll mm = max(a, b);
	ll k = n / mm;
	if(n%mm != 0) k++;
	cout<<k<<endl;
}


int main()
{
	ll Tests = 1;
    //cin>>Tests;
    while(Tests--)
    {
    	solve();
    }
    return 0;
}

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

void solve() {
	int k, a, b; cin >> k >> a >> b;
	for (int i = a; i <= b; i++) {
		if (i % k == 0) {
			cout << "OK\n";
			return;
		}
	}
	cout << "NG\n";

	//cout << "Case #" << t + 1 << ": " << count << endl;
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(nullptr);
	/*int t; cin >> t;
	for (int i = 0; i < t; i++) {
		solve();
	}*/

	solve();

    return 0;
}

Measured memory_bytes: 3652
#pragma warning(disable:4786)
#pragma warning(disable:4996)
#include<list>
#include<bitset>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<functional>
#include<string>
#include<cstring>
#include<cstdlib>
#include<queue>
#include<utility>
#include<fstream>
#include<sstream>
#include<cmath>
#include<stack>
#include<assert.h>
using namespace std;

#define MEM(a, b) memset(a, (b), sizeof(a))
#define CLR(a) memset(a, 0, sizeof(a))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define ABS(X) ( (X) > 0 ? (X) : ( -(X) ) )
#define S(X) ( (X) * (X) )
#define SZ(V) (int )V.size()
#define FORN(i, n) for(i = 0; i < n; i++)
#define FORAB(i, a, b) for(i = a; i <= b; i++)
#define ALL(V) V.begin(), V.end()
#define IN(A, B, C)  ((B) <= (A) && (A) <= (C))

typedef pair<int,int> PII;
typedef pair<double, double> PDD;
typedef vector<int> VI;
typedef vector<PII > VP;

#define AIN(A, B, C) assert(IN(A, B, C))

//typedef int LL;
typedef long long int LL;
//typedef __int64 LL;

char A[2003], B[2003];
int L[2003], R[2003];
int len;

int solve(VP V, int l, int r) {
	if (SZ(V) == 0) return l + r;
	int ret = 1000000;
	int sz = SZ(V);

	for (int xx = 0; xx < 2; xx++) {
		sort(ALL(V));
		{
			VI Z;
			for (int i = 0; i < sz; i++) {
				Z.push_back(V[i].second);
			}
			for (int i = sz - 2; i >= 0; i--) {
				Z[i] = MAX(Z[i], Z[i + 1]);
			}

			int jl = 0;
			for (int il = l; il <= len; il++) {
				while (jl < sz && V[jl].first <= il) jl++;
				int rr = (jl == sz ? 0 : Z[jl]);
				if (l > 0) {
					int cand = 2 * rr + il + ABS(il - l) + sz;
					ret = MIN(ret, cand);
				}
				else if (r > 0) {
					int cand = 2 * il + rr + ABS(rr - r) + sz;
					ret = MIN(ret, cand);
				}
				else {
					int cand = 2 * (rr + il) + sz;
					ret = MIN(ret, cand);
				}
			}
		}

		for (int i = 0; i < sz; i++) {
			swap(V[i].first, V[i].second);
		}
		swap(l, r);
	}
	return ret;
}

int main()
{
	scanf("%s %s", A, B);
	int cntA = 0, cntB = 0;
	len = strlen(A);
	for (int i = 0; i < len; i++) {
		cntA += A[i] - '0';
		cntB += B[i] - '0';
	}

	if (cntB == 0) {
		if (cntA == 0) {
			printf("0\n");
		}
		else {
			printf("-1\n");
		}
		return 0;
	}

	for (int i = 0; i < len; i++) {
		for (int j = 0; j < len; j++) {
			int k = (i - j + len) % len;
			if (B[k] == '1') {
				L[i] = j;
				break;
			}
		}
		for (int j = 0; j < len; j++) {
			int k = (i + j + len) % len;
			if (B[k] == '1') {
				R[i] = j;
				break;
			}
		}
	}

	int ans = 1000000;
	for (int j = 0; j < len; j++) {
		VP V;
		for (int i = 0; i < len; i++) {
			int k = (i + j) % len;
			if (A[i] != B[k]) {
				V.push_back(PII(L[i], R[i]));
			}
		}
		int now = solve(V, 0, j);
		//printf("1 j=%d now=%d\n", j, now);
		ans = MIN(ans, now);
		if (j != 0) {
			int now = solve(V, len - j, 0);
			//printf("2 j=%d now=%d\n", j, now);
			ans = MIN(ans, now);
		}
	}
	printf("%d\n", ans);
	return 0;
}


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


int main(){

 long long int N,M,K;
  scanf("%lld",&K);
  scanf("%lld %lld",&N,&M);
long long int i;

for(i=N;i<=M;i++){
  if(i%K == 0){
    printf("OK");
    return(0);
  }
}

printf("NG");


/*
  char A[];
  scanf("%s",A);
  */

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








 return(0);
 }


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

int main(void)
{
    long long int n,i,num=0,pre=0,sum=1,x,mod=1000000007;
    scanf("%lld",&n);
    long long int *number=(long long int*)malloc(sizeof(long long int)*200001);
    for(i=0;i<n+1;i++) number[i]=0;
    for(i=0;i<n;i++)
    {
        scanf("%lld",&num);
        if(pre==num) continue;
        sum+=number[num];
        number[num]=sum;
        sum%=mod;
        pre=num;
    }
    printf("%lld\n",sum);
    free(number);
    return 0;
}




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

int main() {
  int a, b, x;
  cin >> a >> b;
  x = a * b;
  if(x % 2 == 0) {
    cout << "Even" << endl;
  }
  else {
    cout << "Odd" << endl;
  }
}

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

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,int> plli;
typedef pair<int,pii> pipii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;
 
#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n);i>=0;i--)
#define rrep2(i,a,b) for (int i=(a);i>b;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
 
const int mod = 1e9 + 7;
const ll INF = 1<<30;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
 
int n,k;
int ldp[5005][5005];
int rdp[5005][5005];
 
int main(){
    scanf("%d%d",&n,&k);
    vi a(n);
    rep(i,n) scanf("%d",&a[i]);
    rep(i,n){
        ldp[i][0]=1;rdp[i][0]=1;
        if (a[i]<k) ldp[i][a[i]]=1;
        if (a[n-1-i]<k) rdp[i][a[n-1-i]]=1;
    }
    rep2(i,1,n)rep(j,k){
            if (j-a[i]>=0) ldp[i][j]=ldp[i-1][j-a[i]]||ldp[i-1][j];
            else ldp[i][j]|=ldp[i-1][j];
            if (j-a[n-1-i]>=0) rdp[i][j]=rdp[i-1][j-a[n-1-i]]||rdp[i-1][j];
            else rdp[i][j]|=rdp[i-1][j];
    }
    rep(i,n)rep2(j,1,k){
        rdp[i][j]+=rdp[i][j-1];
    }
    int cnt=0;
    int lnum=0;
    rep(i,n){
        if (k-a[i]<=0){
            cnt+=1;
            continue;
        }
        rep(j,k){
            if (i==0) lnum=0;
            else if (i==n-1){
                if (ldp[i-1][j] && a[i]+j>=k){
                    cnt+=1;
                    break;
                }
                continue;
            }
            else{
                if (ldp[i-1][j]) lnum=j;
                else continue;
            }
            if (k-a[i]-lnum<=0){
                cnt+=1;
                break;
            }
            if (rdp[n-2-i][k-1-lnum]-rdp[n-2-i][k-a[i]-lnum-1]){
                cnt+=1;
                break;
            }
        }
    }
    cout << n-cnt << endl;
    return 0;
}

Measured memory_bytes: 195840
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;

bool isprime(ll x){
    for(int i=2; i*i<=x; i++){
        if(x%i==0)return false;
    }
    return true;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll x;cin>>x;
    while(!isprime(x))x++;
    cout<<x<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <random>
#include <algorithm>
#include <chrono>
#include <map>
#define tNow chrono::duration_cast<msec>(chrono::system_clock::now().time_since_epoch())
#define INF (1 << 30)
using namespace std;

typedef chrono::milliseconds msec;

int d, lastVal = -INF, bestVal = -INF, times = 0, groups = 0, updates = 0, positiveUpdates = 0;
vector<int> c(27), cur, ans;
vector< vector<int> > s;

int calc() {
    int sum = 0;
    vector<int> last(27, 0);
    for (int i = 1; i <= d; ++i) {
        sum += s.at(i).at(cur.at(i));
        last.at(cur.at(i)) = i;
        for (int j = 1; j <= 26; ++j) sum -= c.at(j) * (i - last.at(j));
    }
    return sum;
}

void update(int curVal) {
    lastVal = curVal;
    if (bestVal < curVal) {
        bestVal = curVal;
        ans = cur;
        ++positiveUpdates;
    }
    ++updates;
}

int main() {
    random_device r;
    msec st = tNow;
    msec lm = st + chrono::milliseconds(1980);
    cin >> d;
    s = vector< vector<int> >(d + 1, vector<int>(27));
    cur.resize(d + 1);
    for (int i = 1; i <= 26; ++i) cin >> c.at(i);
    for (int i = 1; i <= d; ++i) for (int j = 1; j <= 26; ++j) cin >> s.at(i).at(j);
    mt19937 m(r());
    for (int i = 1; i <= d; ++i) cur.at(i) = m() % 26 + 1;
    update(calc());
    // cur = {0, 1, 17, 13, 14, 13};
    // update(calc());
    // cout << bestVal << endl;
    // for (int i = 1; i <= d; ++i) cout << ans.at(i) << endl;

    while (tNow < lm) {
        ++groups;
        mt19937 m(r());
        for (int i = 0; i < 100; ++i) {
            int changeAt = m() % d + 1, changeTo = m() % 26 + 1, changedFrom = cur.at(changeAt);
            if (changedFrom == changeTo) continue;
            cur.at(changeAt) = changeTo;
            int curVal = calc();
            if (m() % max(1, (lastVal - curVal) / 5) == 0) update(curVal);
            else cur.at(changeAt) = changedFrom;
            ++times;
        }
    }

    for (int i = 1; i <= d; ++i) cout << ans.at(i) << endl;
    msec ed = tNow;
    #ifdef ___DEBUG
    cout << "Best Value: " << bestVal << endl;
    cout << "Best Score: " << max(bestVal + 1000000, 0) << endl;
    cout << "Tried: " << times << "times, " << groups << "groups\n";
    cout << "Updated: " << updates << "times\n";
    cout << (ed - st).count() << "ms\n";
    #endif
    return 0;
}


Measured memory_bytes: 3676
from array import array

def readinput():
    n=int(input())
    a=array('L',list(map(int,input().split())))
    return n,a

count=0
def merge(a,left,mid,right):
    INFTY=10**9+1
    global count
    n1=mid-left
    n2=right-mid
    #L=[a[left+i] for i in range(n1)]
    L=a[left:mid]
    L.append(INFTY)

    #R=[a[mid+i] for i in range(n2)]
    R=a[mid:right]
    R.append(INFTY)

    i=0;j=0
    for k in range(left,right):
        if(L[i]<=R[j]):
            a[k]=L[i]
            i+=1
        else:
            a[k]=R[j]
            j+=1
        count+=1
   

def mergeSort(a,left,right):
    if(left+1<right):
        mid=(left+right)//2
        mergeSort(a,left,mid)
        mergeSort(a,mid,right)
        merge(a,left,mid,right)
    return

def main(n,a):
    global count
    mergeSort(a,0,n)
    return a,count

if __name__=='__main__':
    n,a=readinput()
    a,count=main(n,a)
    print(' '.join(map(str,a)))
    print(count)


Measured memory_bytes: 65832
using System;
class Program{
  static void Main(string[] args){
    string[] tmp = Console.ReadLine().Split(' ');
    int a = int.Parse(tmp[0]);
    int b = int.Parse(tmp[1]);
    int c = int.Parse(tmp[2]);
    if(a==b&&b==c){
      Console.WriteLine("Yes");
    }else{
      Console.WriteLine("No");
    }
  }
}

Measured memory_bytes: 13140
#include<stdio.h>
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<string>
#include<math.h>
using namespace std;

const int MAX = 100;

int main(){
    int N;
    int L[MAX];
    int ans = 0;
    
    cin >> N;
    for(int i = 0;i < N;i++){
        cin >> L[i];
    }

    for(int i = 0;i < N;i++){
        for(int j = i + 1;j < N;j++){
            for(int k = j + 1;k < N;k++){
                if(L[i] == L[j] || L[j] == L[k] || L[k] == L[i]){
                    continue;
                }
                int l = L[i];
                int m = L[j];
                int s = L[k];

                if(s > m){
                    swap(s,m);
                }
                if(m > l){
                    swap(m,l);
                }
                if(s + m > l){
                    ans++;
                }
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3132
#include<algorithm>
#include<cassert>
#include<cmath>
#include<cstdio>
#include<iostream>
#include<map>
#include<numeric>
#include<stack>
#include<string>
#include<deque>
#include<queue>
#include<vector>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const ll mod = 1e9+7;
const double PI = acos(-1);  // PI = 3.141593...

int main() {
    int n;
    cin >> n;
    cout << n*n*n << endl;
    
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  int count = n;
  unsigned long int a,b;
  unsigned long int v[n];
  for (size_t i = 0; i < count; i++) {
    cin >> v[i];
  }
  sort(v, v+n, greater<int>());
  for (int i = 1; i < count; i++) {
    if (i == count - 1) {
      a = v[0];
      b = v[i];
    } else if (v[i] <= v[0]/2) {
      a = v[0];
      if (v[0]/2 - v[i] < v[i-1] - v[0]/2) b = v[i];
      else b = v[i-1];
      break;
    }
  }
  cout << a << ' ' << b << endl;
}


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

int main() {
  int x, y;
  cin >> x >> y;
  if (y % 4 != 0 && y % 2 != 0) {
    cout << "No" << endl;
  }
  else {
    if (y >= 2*x && y <= 4*x) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
  }
}

Measured memory_bytes: 3476
use std::io;
use std::str::FromStr;

fn read_line() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s
}

macro_rules! from_line {
    ($($a:ident : $t:ty),+) => {
        $(let $a: $t;)+
        {
            let _line = read_line();
            let mut _it = _line.trim().split_whitespace();
            $($a = _it.next().unwrap().parse().unwrap();)+
                assert!(_it.next().is_none());
        }
    };
}

fn main() {

    from_line!(n: i32, m: i32);

    let mut a = Vec::<Vec<i64>>::with_capacity(m as usize);
    let mut b = Vec::<i64>::with_capacity(m as usize);
//    let mut c = Vec::<i64>::with_capacity(m as usize);
    let mut c = Vec::new();

    for i in 0..n {
        let stdin = io::stdin();
        let mut buf = String::new();
        stdin.read_line(&mut buf).ok();
        let mut it = buf.split_whitespace().map(|n| usize::from_str(n).unwrap());

        let mut v: Vec<i64> = buf.split_whitespace()
            .map(|n| i64::from_str(n).unwrap())
            .collect();
        a.push(v);
    }

    for i in 0..m {
        let stdin = io::stdin();
        let mut buf = String::new();
        stdin.read_line(&mut buf).ok();
        let mut it = buf.split_whitespace().map(|n| usize::from_str(n).unwrap());

        b.push(it.next().unwrap() as i64);
    }

    for i in 0..n {
        c.push(0);
    }

    for i in 0..n {
        for j in 0..m {
            c[i as usize] += a[i as usize][j as usize] * b[j as usize];
        }
    }

    for i in 0..n {
        println!("{}", c[i as usize]);
    }
}



Measured memory_bytes: 5048
function Main(s){
  s = s.split("\n");
  var n = +s[0];
  var a = s[1].split(" ").map(a=>+a);
  var b = [];
  b[n-1] = a.reduce((a,z,i)=>{b[i-1]=a;return a+z;});
  var ans = 9e9;
  for(var i = 2; i < n - 1; i++){
    var sl = b[i-1] / 2, sr = (b[n-1] + b[i-1]) / 2;
    var l = lower_bound(b,1,i-1,sl);
    var r = lower_bound(b,i+1,n-1,sr);
    var m = [b[l-1],b[i-1]-b[l-1],b[r-1]-b[i-1],b[n-1]-b[r-1]];
    ans = Math.min(ans, Math.max(...m) - Math.min(...m));
    if(i - l > 1){
      m = [b[l],b[i-1]-b[l],b[r-1]-b[i-1],b[n-1]-b[r-1]];
      ans = Math.min(ans, Math.max(...m) - Math.min(...m));
      if(n - r > 1){
        m = [b[l],b[i-1]-b[l],b[r]-b[i-1],b[n-1]-b[r]];
        ans = Math.min(ans, Math.max(...m) - Math.min(...m));
      }
    }
    if(n - r > 1){
      m = [b[l-1],b[i-1]-b[l-1],b[r]-b[i-1],b[n-1]-b[r]];
      ans = Math.min(ans, Math.max(...m) - Math.min(...m));
    }
  }
  console.log(ans);
}
function lower_bound(d,a,b,e){for(var c;1<b-a;)d[c=0|(a+b)/2]<e?a=c:b=c;return d[a]<e?b:a};
Main(require("fs").readFileSync("/dev/stdin","utf8"));


Measured memory_bytes: 39048
N, Q = gets.split.map(&:to_i)
S = gets.chomp!
Ary = readlines.map(&:chomp!).map { |e| e.split.map(&:to_i) }
ruisekiwa = [0]
S.each_char.with_index do |char, i|
  if char == 'A' && S[i + 1] == 'C'
    ruisekiwa << ruisekiwa.last + 1
  else
    ruisekiwa << ruisekiwa.last
  end
end

Ary.each do |line|
  l = line[0] - 1
  r = line[1] - 1

  puts ruisekiwa[r] - ruisekiwa[l]
end


Measured memory_bytes: 18996
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  ll N, K;
  cin>>N>>K;
  ll A[N];
  for(int i=0;i<N;++i) cin>>A[i];
  int l=1, r=1e9, m;
  int num;
  while(l<r) {
    m = (l+r)/2;
    num = 0;
    for(int i=0;i<N;++i) {
      if(A[i]%m==0) num += A[i]/m-1;
      else num += A[i]/m;
    }
    if(num<=K) r = m;
    else l = m+1;
  }
  cout<<l<<endl;
}



Measured memory_bytes: 5200
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<int> h;
    for(int i = 0;i < n;i++)
    {
        int x;
        cin >> x;
        h.push_back(x);
    }
    int count = 0;
    for(int i = n - 1;i >= 0;i--)
    {
        int max = 0;
        for(int j = 0;j < i;j++)
        {
            if(h[j] > max)
            {
                max = h[j];
            }
        }
        if(h[i] >= max)
        {
            count++;
        }
    }
    cout << count;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <cmath>
#include <stack>


int main (void){

	int n;

	std::cin >> n;

	std::vector<int> v(n);

	for (size_t i = 0; i < n; i++)
	{
		std::cin >> v[i];
	}

	std::sort(v.begin(), v.end());
	std::reverse(v.begin(), v.end());

	int alice_score = 0, bob_score = 0;

	for (size_t i = 0; i < n; i++)
	{
		if (i % 2 == 0) {
			alice_score += v[i];
		}
		else {
			bob_score += v[i];
		}
	}

	std::cout << alice_score - bob_score << std::endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mo 1000000007
using namespace std;
int fac[3010],nifac[3010],sum[3010],l[3010],r[3010],f[3010][3010];
bool bo[3010];
int getmi(int a,int x)
{
	int ans=1;
	while (x)
	{
		if (x&1) ans=(long long)ans*a%mo;
		a=(long long)a*a%mo;
		x>>=1;
	}
	return ans;
}
int C(int n,int m)
{
	if ((m>n)||(n<0)||(m<0)) return 0;
	return (long long)fac[n]*nifac[m]%mo*nifac[n-m]%mo;
}
int main()
{
	//freopen("in.txt","r",stdin);
	int n,m;scanf("%d%d\n",&n,&m);
	fac[0]=nifac[0]=1;
	for (int i=1;i<=n;i++) {fac[i]=(long long)fac[i-1]*i%mo;nifac[i]=getmi(fac[i],mo-2);}
	for (int i=1;i<=n;i++)
	{
		char ch=getchar();
		sum[i]=(ch=='1');
	}
	for (int i=1;i<=m;i++) scanf("%d%d",&l[i],&r[i]);
	bo[1]=true;int ed=1;
	for (int i=2;i<=m;i++)
	{
		if (l[i]==l[ed]) {if (r[i]>=r[ed]) {bo[ed]=false;bo[i]=true;ed=i;}continue;}
		if (r[i]>r[ed]) {bo[i]=true;ed=i;}
	}
	int top=0;
	for (int i=1;i<=m;i++) if (bo[i])
	{
		top++;
		l[top]=l[i];r[top]=r[i];
	}
	for (int i=1;i<=top;i++) 
	l[top+1]=r[top]+1;
	f[0][0]=1;
	for (int i=1;i<=top;i++) for (int j=r[i-1]+1;j<l[i];j++) sum[j]=0;
	for (int i=1;i<=n;i++) sum[i]+=sum[i-1];
	
	for (int i=1;i<=top;i++)
	for (int j=max(0,sum[r[i]]-max(0,(r[i]-l[i+1]+1)));j<=sum[r[i]];j++)
	{
		//if (l[i]<=r[i-1])
		//{
			for (int k=max(0,l[i]-min(l[i+1],r[i]+1)+j);k<=min(sum[r[i-1]],j);k++)
				f[i][j]=(f[i][j]+(long long)f[i-1][k]*C(min(l[i+1],r[i]+1)-l[i],j-k))%mo;
		//}
		//else f[i][j]=f[i-1][sum[r[i-1]]];
		//cerr<<i<<' '<<j<<' '<<f[i][j]<<endl;
	}
	int ans=0;
	for (int i=0;i<=sum[r[top]];i++) ans=(ans+f[top][i])%mo;
	cout<<ans<<endl;
}

Measured memory_bytes: 15360
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define PI 3.14159265358979323

//int calc1(float a,float b,float c,float d,float e,float f,float *x,float *y);
//void quick(int *,long long,long long);
int comp(char *a,char *b);

int main(){
	
	char a[1000][35];
	char b[35];
	int  c[1000];
	int  max1,max2,max3,n,i,j,flag;

	n=0;
	max1=-1,max2=-1,max3=-1;
	while(scanf("%s",b)!=EOF){
		/*if(b[0]=='.')
			break;*/
		flag=0;
		for(i=0;i<n;i++)
			if(comp(a[i],b)==0){
				flag=1;
				break;
			}
		if(flag==1){
			c[i]++;
			if(max1==-1){
				max1=i;
			}else if(c[i]>c[max1])
				max1=i;
		}else{
			for(j=0;b[j]!='\0';j++)
				a[n][j]=b[j];
			a[i][j]='\0';
			c[n]=1;
			if(j>max3){
				max2=n;
				max3=j;
			}
			n++;
		}
	}
	printf("%s %s\n",a[max1],a[max2]);
	return 0;
}

/*int calc1(float a,float b,float c,float d,float e,float f,float *x,float *y){

	if(a*e-b*d==0)
		return 0;
	*x=(c*e-b*f)/(a*e-b*d);
	*y=(a*f-d*c)/(a*e-b*d);
	return 1;
}*/

int comp(char *a,char *b){

	int i=0;
	while(1){
		if(a[i]=='\0'&&b[i]=='\0')
			return 0;
		if(a[i]=='\0')
			return -1;
		if(b[i]=='\0')
			return +1;
		if(a[i]>b[i])
			return 1;
		else if(a[i]<b[i])
			return -1;
		if(i>100000)
			return -2;
		i++;
	}
}

Measured memory_bytes: 544
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60


def main():
    H, W = map(int, readline().split())
    S = [readline().strip() for _ in range(H)]

    L = [[0] * W for _ in range(H)]
    R = [[0] * W for _ in range(H)]
    U = [[0] * W for _ in range(H)]
    D = [[0] * W for _ in range(H)]

    for i in range(H):
        c = 0
        for j in range(W):
            if S[i][j] == '#':
                c = 0
            else:
                L[i][j] = c
                c += 1
        c = 0
        for j in range(W - 1, -1, -1):
            if S[i][j] == '#':
                c = 0
            else:
                R[i][j] = c
                c += 1

    for j in range(W):
        c = 0
        for i in range(H):
            if S[i][j] == '#':
                c = 0
            else:
                U[i][j] = c
                c += 1
        c = 0
        for i in range(H - 1, -1, -1):
            if S[i][j] == '#':
                c = 0
            else:
                D[i][j] = c
                c += 1

    ans = 0
    for i in range(H):
        for j in range(W):
            if S[i][j] == '.' and ans < L[i][j] + R[i][j] + U[i][j] + D[i][j] + 1:
                ans = L[i][j] + R[i][j] + U[i][j] + D[i][j] + 1

    print(ans)
    return


if __name__ == '__main__':
    main()


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

using namespace std;

int main(int argc, const char * argv[])
{
  int answer = 0, answersub = 0;
  int N = 0, K = 0;
  std::cin >> N >> K;

  std::vector<int> h(N);
  for (int i = 0; i < N; i++) {std::cin >> h[i];}

  sort(h.begin(), h.end(), greater<int>());

  answer = h[0];
  for (int i = 0; i < N-K+1; i++) {
    answersub = h[i] - h[i + K - 1];
    if (answersub < answer) answer = answersub;
  }

  std::cout << answer << '\n';

  return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
int main(void){
 int h,w,i,j;
 scanf("%d%d",&h,&w);
 char c[h][w+1];
 for(i=0;i<h;i++){
  scanf("%s",c[i]);
 }
 int s[h+2][w+2];
 for(i=0;i<h+2;i++){
  for(j=0;j<w+2;j++){
   s[i][j]=0;
  }
 }
 for(i=0;i<h;i++){
  for(j=0;j<w;j++){
   if(c[i][j]=='#'){
    s[i][j]++;
    s[i][j+1]++;
    s[i][j+2]++;
    s[i+1][j]++;
    s[i+1][j+1]+=10;
    s[i+1][j+2]++;
    s[i+2][j]++;
    s[i+2][j+1]++;
    s[i+2][j+2]++;
   }
  }
 }
 for(i=1;i<h+1;i++){
  for(j=1;j<w+1;j++){
   if(s[i][j]>=10) printf("#");
   else printf("%d",s[i][j]);
  }
  putchar('\n');
 }
 return 0;
}

Measured memory_bytes: 128
#include<map>
#include<set>
#include<cmath>
#include<regex>
#include<queue>
#include<stack>
#include<bitset>
#include<vector>
#include<cstdio>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<unordered_map>
#include<unordered_set>

#pragma warning(disable:4996)
using namespace std;

constexpr long long MOD = 1000000007;
constexpr int MAXN = 1005;

int N;
int sum[MAXN];
bool flag[MAXN];

bool isPrim(int x) {
	for (int i = 2; i <= (int)sqrt(x * 1.0); ++i) {
		if (x % i == 0) {
			return false;
		}
	}
	return true;
}

int main() {
	for (int i = 1; i <= N; ++i) {
		flag[i] = isPrim(i);
	}
	scanf("%d", &N);
	for (int i = 2; i <= N; ++i) {
		if (isPrim(i)) {
			int j = N;
			while (j) {
				sum[i] += j / i;
				j /= i;
			}
		}
	}
	long long tempAns = 1;
	for (int i = 2; i <= N; ++i) {
		tempAns = tempAns * (sum[i] + 1) % MOD;
	}
	printf("%lld\n", tempAns);
	return 0;
}

Measured memory_bytes: 256
a, b, c, d, e, f = map(int, input().split())

water = [0 for _ in range(f+1)]
sugure = [0 for _ in range(f+1)]
i = 0
while 100 * a * i <= f:
    j = 0
    while 100 * a * i + 100 * b * j <= f:
        water[100 * a * i + 100 * b * j] = 1
        j += 1
    i += 1
i = 0
while c * i <= f:
    j = 0
    while c * i + d * j <= f:
        sugure[c * i + d * j] = 1
        j += 1
    i += 1

ans = []
for i in range(1, f+1):
    if water[i]:
        j = 0
        tmp = 0
        i_ans = [0, 0, 0]
        while 100 * j / (i + j) <= e * 100 / (100 + e) and j <= f and i + j <= f:
            if sugure[j]:
                i_ans = [100 * j / (i + j), i, j]
            j += 1
        ans.append(i_ans)
ans.sort(reverse=True)
ans = ans[0]
print(ans[1]+ans[2], ans[2])

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

#define FOR(i, a, b) for(int i = a; i < b; i ++)
#define FORS(i, a, b, c) for(int i = a; i < b; i += c)
#define FORN(i, a, b) for(int i = a; i <= b; i ++)
#define FORD(i, a, b) for(int i = a-1; i >= b; i --)
#define FORE(i, b) for(auto &i:b)
#define REP(i, b) FOR(i, 0, b)
#define REPN(i, b) FORN(i, 0, b)
#define SQ(i) (i*i)
#define ALL(a) a.begin(), a.end()
#define ALLA(a,n) a, a+n
#define SORT(a) sort(ALL(a))
#define SORTA(a, n) sort(ALLA(a, n))
#define REV(a) reverse(ALL(a))
#define REVA(a, n) reverse(ALLA(a, n))
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define IN(a, b) (a.find(b) != a.end())
#define BACK(a) a.back(); a.RB()
#define QBACK(a) a.top(); a.pop()
#define PRINT(a) FORE(i, a) cout << i << " "; cout << endl

#define PB  push_back
#define RB  pop_back
#define RF  pop_front
#define INS insert
#define F   first
#define S   second
#define UM  unordered_map
#define US  unordered_set
#define PQ  priority_queue

#define IO ios_base::sync_with_stdio(false); cin.tie(NULL)

typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<ll,ll> pll;
typedef queue<int> qi;
typedef queue<double> qd;
typedef queue<ll> qll;
typedef US<int> si;
typedef US<double> sd;
typedef US<ll> sll;
typedef vector<vi> mi;
typedef vector<vd> md;
typedef vector<vll> mll;
typedef vector<pi> vpi;
typedef vector<pd> vpd;
typedef vector<pll> vpll;


int main(){
  IO; int N, K; cin >> N >> K;
  vi H(N); REP(i, N) cin >> H[i];
  vi dp(N); dp[0] = 0;
  FOR(i, 1, N){
    dp[i] = dp[i-1] + abs(H[i] - H[i-1]);
    FOR(j, max(0, i-K), i) MIN(dp[i], dp[j] + abs(H[i]-H[j]));
  }
  cout << dp[N-1] << endl;
}


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

typedef long  long ll;
#define FF first
#define SS second
#define INF 2000000000


int main(){
    ll h;
    cin >> h;
    ll ans = floor(log(h)/log(2));
    cout << setprecision(15) << pow(2, ans) - 1 + pow(2, ans);
}


Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let (N, M): (usize, usize) = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap()
        )
    };
    let (L, R, C): (Vec<usize>, Vec<usize>, Vec<i64>) = {
        let (mut L, mut R, mut C) = (vec![], vec![], vec![]);
        for _ in 0..M {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            L.push(iter.next().unwrap().parse().unwrap());
            R.push(iter.next().unwrap().parse().unwrap());
            C.push(iter.next().unwrap().parse().unwrap());
        }
        (L, R, C)
    };

    let G = {
        let mut G = vec![std::collections::HashMap::new(); N + 1];
        let mut E = (0..M).collect::<Vec<_>>();
        E.sort_by_key(|&i| C[i]);
        E.reverse();
        for &i in &E { G[L[i]].insert(R[i], C[i]); }
        for i in 1..N { G[i + 1].insert(i, 0); }
        G
    };

    const INF: i64 = 1_000_000_000_000_000;
    let mut dp = vec![INF; N + 1];
    let mut q = std::collections::BinaryHeap::new();
    q.push((0, 1));
    while let Some((dist, i)) = q.pop() {
        let dist = -dist;
        if dist < dp[i] {
            dp[i] = dist;
            for (&j, &w) in &G[i] { q.push((-(dist + w), j)); }
        }
    }
    let ans = if dp[N] < INF { dp[N] } else { -1 };

    println!("{}", ans);
}


Measured memory_bytes: 88316
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<string>
#include<ctime>

using namespace std;
typedef long long ll;
const int Max = 1e6 + 5;

int main(){
	int n, m, i, j, t, k, p, q, ans, flag;
	while(~scanf("%d %d", &n, &m)){
		t = k = p = flag = -1;
		for(i = 0; i <= 2000; i++){
			for(j = 0; j <= 2000; j++){
				q = m - 10000 * i - 5000 * j;
				if(q >= 0){
					if(i + j + (q / 1000) == n) { flag = 1; t = i; k = j; p = q / 1000; break; }

				}
			}
			if(flag == 1) break;
		}
		printf("%d %d %d\n", t, k, p);
	}
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
///#include<bits/stdc++.h>
using namespace std;
#include <iostream>
/// Info.
///****************************************************************************************************************************************///
/// Coder               : BAHAA El_DEEN OSAMA SAYED.
/// Problem name        : Q - Addition and Subtraction Easy
/// Method              : brute force
/// Date                : 19/2/2020
///****************************************************************************************************************************************///



#define rep(i,x1,x2)      for(int i=x1; i<=x2 ;++i)
#define rep0(i,x)         for(int i=0; i<x ;i++)
#define all(v)           ((v.begin()),((v.end())
#define mm(v,d)          memset(v,d,sizeof(v))
#define MP               make_pair
#define SZ(v)            ((int) ( (v).size() ) )
#define ull              unsigned long long
#define ll               long long
#define pi               3.1415926536
#define oo               1e9
#define OO               1e18
#define Fx(n)            fixed<<setprecision(n)
#define FasterIO           std::ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define RE0              return 0
#define RE1              return 1
#define mp(a,b)          make_pair(a,b)
#define X                first
#define Y                second
#define pii              pair(int a, int b)
#define RE               return
//#define LD               long double

const  int  N   = (int) 1e5+10;
const  int  M   = (int) 1e3+4;
const  int  INF = (int) 0x3f3f3f3f;
const double ESP = 1e77;
const ll MOD=1e9+7;


ll a,b(0);
string s;

int main()
{

cin>>a>>s>>b;
(s=="-")?cout<<a-b : cout << a+b;


RE0;}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
N = int(input())
f = [list(map(int, input().split())) for _ in range(N)]
p = [list(map(int, input().split())) for _ in range(N)]
dp = [0] * (pow(2, 10))
for i in range(pow(2, 10)):
  for j in range(N):
    c = 0
    for k in range(10):
      if f[j][k]:
        if i & (1 << k):
          c += 1
    dp[i] += p[j][c]
res = -float("inf")
for i in range(1, pow(2, 10)):
  res = max(res, dp[i])
print(res)

Measured memory_bytes: 42092
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    final String s = scanner.nextLine();
    final int n = Integer.parseInt(s);
    final String s2 = scanner.nextLine();

    final String[] split = s2.split("");
   
    int a = 0;
    for (int i = 0; i <= n - 3; i++) {
      if (split[i].equals("A")
          && split[i+1].equals("B")
          && split[i+2].equals(("C"))) {
        a++;
      }
    }
    System.out.println(a);
  }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define ll long long
#define fort(i,n) for (int i = 1; i <= n; ++i)
#define pi pair<int,int>
#define pl pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define sz size()
#define er erase
#define fr first
#define sc second
#define rc(x) return cout << x, 0
using namespace std;

int a,b,v[5],ans1,ans2;

int32_t main()
{
    ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
    fort (i,3)
    {
        cin >> a >> b;
        ++v[a], ++v[b];
    }
    fort (i,4)
        if (v[i]==1) ++ans1;
        else if (v[i]==2) ++ans2;
    if (ans1==2&&ans2==2) rc("YES");
    cout << "NO";
}


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

using LL = long long;
enum {W, V};
using P = tuple<LL, LL>;

int main() {
  LL N, D;
  cin >> N >> D;

  vector<LL> X(N), Y(N);
  for(auto i = 0; i < N; ++i) cin >> X[i] >> Y[i];

  vector<P> former, latter;
  function<void(int,int,P,vector<P>&)> dfs = [&](int l, int r, P p, vector<P>& c) {
    if(l == r) {
      c.emplace_back(p);
    } else {
      dfs(l + 1, r, p, c);
      dfs(l + 1, r, P(get<W>(p) - X[l], get<V>(p) - Y[l]), c);
      dfs(l + 1, r, P(get<W>(p) + X[l], get<V>(p) + Y[l]), c);
    }
  };
  dfs(0, N / 2, P(0, 0), former);
  dfs(N / 2, N, P(0, 0), latter);
  sort(begin(former), end(former));
  sort(begin(latter), end(latter));

  LL ans = 0;
  for(auto* p: {&former, &latter}) for(auto i: *p) if(abs(get<W>(i)) <= D) ans = max(ans, abs(get<V>(i)));

  multiset<LL> S;
  int l, r;
  l = r = upper_bound(begin(former), end(former), -get<W>(latter[0]) + D, [](auto v, auto i) {return v < get<W>(i);}) - begin(former);
  for(auto p: latter) {
    while(l && -get<W>(p) - D <= get<W>(former[l - 1])) S.insert(get<V>(former[--l]));
    while(r && -get<W>(p) + D <  get<W>(former[r - 1])) S.erase( get<V>(former[--r]));
    if(!S.empty()) ans = max(ans, abs(get<V>(p) + *begin(S)));
  }

  cout << ans << endl;
}

Measured memory_bytes: 517684
#include <bits/stdc++.h>
using namespace std;
using ll = long long; using P = pair<int,int>;
using vl = vector<ll>; using vvl = vector<vl>;
#define mp make_pair
#define pb push_back
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,n) for (int i=(n-1);i >= 0;i--)
#define all(v) v.begin(),v.end()
#define sz(v) (int)((v).size())
#define MAX(v) *max_element(all(v))
#define MIN(v) *min_element(all(v))
#define Sort(v) sort(all(v))
#define Rev(v) reverse(all(v))
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);in(name)
#define vv(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define VV(type,name,h,w) vector<vector<type>>name(h,vector<type>(w));in(name)
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cout << H << " ";
    debug_out(T...);
}
#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
    for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
    return os;
}
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
template<class T>bool chmax(T &a, const T &b) {if(a<b){a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) {if(b<a){a=b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll mod = 1000000007;
const int dx[8] = {1,0,-1,0,1,1,-1,-1}; const int dy[8] = {0,1,0,-1,1,1,-1,-1};

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    int n,k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    bool can = true;
    int left = 0, right = k-1;
    for(int i = 0;i < n-k;i++){
        if(a[left] < a[right+1]) cout << "Yes" << endl;
        else cout << "No" << endl;
        left++; right++;
    }
}

Measured memory_bytes: 3952
n = int(input())
l = list(map(int, input().split(" ")))
sep = round(n/2)
dif = sum(l[0:sep]) - sum(l[sep:n])

for i in range(sep):
    if dif > 0:
        sep -= 1
    else: sep += 1
    nx = sum(l[0:sep]) - sum(l[sep:n])
    if abs(nx) < abs(dif):
        dif = nx
    else: break
print(abs(dif))





Measured memory_bytes: 3060
using System;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            char[] s = Console.ReadLine().ToCharArray();
            char[] t = Console.ReadLine().ToCharArray();
            int res = 0;
            for (int i = 0; i < s.Length; i++)
            {
                if (s[i] == t[i])
                {
                    res++;
                }
            }

            Console.WriteLine(res);
        }
    }
}


Measured memory_bytes: 11092