akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <iostream>
#include <algorithm>
std::vector<long long> solve(int N, std::vector<int> X, std::vector<int> Y, std::vector<int> P) {
	const long long inf = 1LL << 62;
	int mul = 1;
	for (int i = 0; i < N; ++i) {
		mul *= 3;
	}
	std::vector<std::vector<long long> > xsel(1 << N, std::vector<long long>(N));
	std::vector<std::vector<long long> > ysel(1 << N, std::vector<long long>(N));
	for (int i = 0; i < 1 << N; ++i) {
		for (int j = 0; j < N; ++j) {
			xsel[i][j] = std::abs(X[j]);
			ysel[i][j] = std::abs(Y[j]);
			for (int k = 0; k < N; ++k) {
				if ((i >> k) & 1) {
					xsel[i][j] = std::min(xsel[i][j], (long long)std::abs(X[j] - X[k]));
					ysel[i][j] = std::min(ysel[i][j], (long long)std::abs(Y[j] - Y[k]));
				}
			}
		}
	}
	for (int i = 0; i < 1 << N; ++i) {
		for (int j = 0; j < N; ++j) {
			xsel[i][j] *= P[j];
			ysel[i][j] *= P[j];
		}
	}
	std::vector<long long> ans(N + 1, inf);
	for (int i = 0; i < 1 << N; ++i) {
		int cnt = 0;
		for (int j = 0; j < N; ++j) {
			if ((i >> j) & 1) ++cnt;
		}
		for (int j = i; j >= 0; --j) {
			j &= i;
			long long cost = 0;
			for (int k = 0; k < N; ++k) {
				if (!((i >> k) & 1)) {
					cost += std::min({ xsel[j][k], ysel[i - j][k] });
				}
			}
			ans[cnt] = std::min(ans[cnt], cost);
		}
	}
	return ans;
}
int main() {
	int N;
	std::cin >> N;
	std::vector<int> X(N), Y(N), P(N);
	for (int i = 0; i < N; ++i) {
		std::cin >> X[i] >> Y[i] >> P[i];
	}
	std::vector<long long> ans = solve(N, X, Y, P);
	for (int i = 0; i <= N; ++i) {
		std::cout << ans[i] << std::endl;
	}
	return 0;
}

Measured memory_bytes: 13032
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Vector;

//1, 12, 123, 1234
public class Main {
	public static void main(String args[]) {
		Scanner in = new Scanner(System.in);
		String s = in.next();
		String t = in.next();
		int count = 0;
		for (int i = 0; i <s.length(); i++) {
			if (s.charAt(i)!=t.charAt(i)) {
				count++;
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 32564
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順
 
int main() {
  	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
    int N, M;
    scanf ("%d%d",&N ,&M);
    vector<int> PREF(M);
    vector<int> YEAR(M);
    map<int, vector<int>> MAP;
    rep(i,M) {
        scanf ("%d%d", &PREF[i], &YEAR[i]);
        MAP[PREF[i]].push_back(YEAR[i]);
    }
    for (auto &x : MAP) {
        sort(x.second.begin(), x.second.end());
    }
 
    rep(i, M) {
        int P, Y;
        P = PREF[i];
        Y = YEAR[i];
        auto B = MAP[P].begin();
        auto j = lower_bound(B, end(MAP[P]), Y);
        printf("%012ld\n", (ll)P * 1000000 + (int)(j-B)  + 1);
    }
}


Measured memory_bytes: 13184
s = input()
l = len(s)
ans = 0
ls = ['A','C','G','T']

i = 0
while i<=l-1 :
    
    if s[i] in ls :
        
        j = i + 0
        while (j<=l-1) and (s[j] in ls) :
            j += 1
        
        if j-i > ans :
            ans = j-i
        
        i = j + 0

    else :
        i += 1

print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
  ll h;
    cin>>h;
    ll ans=0,count=1;
    while(h>1)
    {
        h=h/2;
        count*=2;
        ans+=count;
    }
    cout<<ans+1<<endl;
}

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

int main(){
  int n;
  cin>>n;
  vector<int64_t> a(n);
  for(int i=0;i<n;++i){
    cin>>a.at(i);
  }
  vector<int> b;
  if(n%2!=0){
    for(int i=n-1;i>=0;i=i-2){
      b.push_back(a.at(i));
    }
    for(int i=1;i<n;i=i+2){
      b.push_back(a.at(i));
    }
  }
  else{
    for(int i=n-1;i>=0;i=i-2){
      b.push_back(a.at(i));
    }
    for(int i=0;i<n;i=i+2){
      b.push_back(a.at(i));
    }
  }

  for(int i=0;i<n;++i){
    cout<<b.at(i)<<" ";
  }
}

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

using namespace std;
int N;
long long int A[100005], B[100005], C[100005];
vector<long long int> SA, SC;

int main(void) {

	cin >> N;
	for (int i = 1; i <= N; i++) {
		cin >> A[i];
	}
	for (int i = 1; i <= N; i++) {
		cin >> B[i];
	}
	for (int i = 1; i <= N; i++) {
		cin >> C[i];
	}

	long long int ans = 0;

	for (int i = 1; i <= N; i++) { SA.push_back(A[i]);
	SC.push_back(C[i]);
	}

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

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

	for (int i = 1; i <= N; i++) {
		//cout << "B[i]= " << B[i] << endl;
		long long int p=lower_bound(SA.begin(), SA.end(), B[i]) - SA.begin();
		long long int q = upper_bound(SC.begin(), SC.end(), B[i]) - SC.begin(); q = N - q;
		//cout << "p= " << p << " q= " << q << endl;
		ans += p*q;
	}

	cout << ans << endl;
	//system("pause");
	return 0;
}

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

#define debug(x) cout <<"DEBUG"<<" "<<#x<<":"<<x<<'\n'

//↓0-indexか1-indexでn回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   //0-index昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) //1-index昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  //0-index降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   //1-index降順
//rep2 -> 第二引数 m から n 回繰り返し ex) m=5 n=3 なら i=5,i=6,i=7 まで
#define rep2(i,m,n) for(int i = ((int)(m)); i < ((int)(n))+((int)(m)); i++)
#define SIZE(x) ((int)((x).size()))
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii; //2次元配列
typedef vector<ll> vll;
typedef vector<string> vs;
using i64 = int_fast64_t;
template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}

/* 円周率は M_PI を使おうね */
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;

/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    //cout << fixed << setprecision(15);

    int a, b; cin >> a >> b;
    int answer = 0;
    if(a==1) answer += 300000;
    if(a==2) answer += 200000;
    if(a==3) answer += 100000;
    if(b==1) answer += 300000;
    if(b==2) answer += 200000;
    if(b==3) answer += 100000;
    if(b==1&&a==1) answer += 400000;
    cout << answer << '\n';
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

ll n,k,q;
vl a;
int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    cin>>n>>k>>q;

    a.resize(q);
    REP(i,q){
        cin>>a[i];
        a[i]--;
    }

    vl sc(n);

    REP(i,q)
        sc[a[i]]++;

    REP(i,n){
        if(k+sc[i]-q > 0)
            cout << "Yes" << endl;
        else
            cout << "No" << endl; 
    }

    return 0;
}

Measured memory_bytes: 2176
#include<stdio.h>

int main()
{
	int a, b;
	scanf("%d %d", &a, &b);
	
	printf("a");
	if(a == b){
		printf(" == ");
	}else if(a > b){
		printf(" > ");
	}else{
		printf(" < ");
	}
	printf("b\n");

	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
ll mod_pow(ll x,ll n,ll mod) {
ll res=1;
  while(n>0) {
if(n&1) {
res=res*x%mod;
}
  x=x*x%mod;
    n>>=1;
  }
  return res;
}
 


int main() {
  ll X,Y;
  cin>>X>>Y;
  if(X>2*Y||Y>2*X) {
    cout<<0<<endl;
    return 0;

  }
  else if((X+Y)%3!=0) {
cout<<0<<endl;
    return 0;
  }
  
  ll A=(X+Y)/3;
  ll B=X-A;
  
  
  ll mod=1000000007;
  ll ans=1;
  for(ll i=0;i<B;i++) {
ans*=(A-i);
    ans%=mod;
  }
  
  for(ll i=2;i<=B;i++) {
ans*=mod_pow(i,mod-2,mod)%mod;
    ans%=mod;
  }
  
  cout<<ans<<endl;
}
    
    

  
  
  
  
  
  
  
  
  
  
  
  

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

int main() {
    int n, m;
    cin >> n >> m;
    vector<long long> a(n);
    vector<long long> b(n);
    for (int i=0; i<n; i++) cin >> a[i] >> b[i];
    vector<long long> c(m);
    vector<long long> d(m);
    for (int i=0; i<m; i++) cin >> c[i] >> d[i];

    vector<long long> ans(n);
    for (int i=0; i<n; i++) {
        long long l = 1000000000;
        for (int j=0; j<m; j++) {
            int dist = abs(a[i] - c[j]) + abs(b[i] - d[j]);
            if (l > dist) {
                ans[i] = j+1;
                l = dist;
            }
        }
        cout << ans[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main()
{
	long long int a, b;
	scanf("%lld %lld",&a, &b);
	if(a>=b||(a<=b&&a>b/2))
	printf("%lld",b/2);
	else
	printf("%lld",a+(b-2*a)/4);
	return 0;	
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin,(obj).end()
#define SORT(list) sort(ALL((list)));
using namespace std;
using ll = long long;
int main(){
    int n;
    cin >> n;
    if(n==1){
        cout <<  "Hello World" << endl;
    }
    else{
        int a,b;
        cin >> a >> b;
        cout << a+b<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>

#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define repp(i, m, n) for(ll i = m, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define clr(ar, val) memset(ar, val, sizeof(ar))
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;
// #define M_PI 3.14159265358979

int main(void)
{
	double a, b, x, ans;
	cin >> a >> b >> x;
	if (x <= 0.5 * a * a * b) {
		// cout << "A" << endl;
		ans = atan((a * b * b) / (2.0 * x)) * 180.0 / M_PI;
	} else { 
		double rest = (a * a * b) - x;
		ans = atan(2.0 * rest / (a * a * a)) * 180.0 / M_PI;
	}
	printf("%.15f\n", ans);
	return 0;
}

Measured memory_bytes: 512
#include<stdio.h>

int main(void)
{

   int n, a, b, to, ta, t;

   scanf("%d%d%d", &n, &a, &b);

   to = n * a;

   ta = b;

   if(to < ta){
      t = to;
   }

   else
      t = ta;


   printf("%d", t);

   return 0;
}


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

int main() {
    int n, k; cin >> n >> k;
    map<char,int> mp;
    int r, s, p; cin >> r >> s >> p;
    mp['r'] = p; mp['s'] = r; mp['p'] = s;
    string t; cin >> t;
    int ans = 0;
    rep(i,k) {
        char now = t[i];
        int len = 0;
        for (int j = i; j < n; j += k) {
            if (t[j] == now) len++;
            else {
                ans += (len+1)/2 * mp[now];
                len = 1;
                now = t[j];
            }
        }
        ans += (len+1)/2 * mp[now];
    }  
    cout << ans << endl;
}

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

int main() {
    int a,b,c,k;cin>>a>>b>>c>>k;
    if(b<=a){
        while(b<=a){
           b*=2;
           --k;
        }
    }
    if(c<=b){
        while(c<=b){
           c*=2;
           --k;
        }
    }    
    if(k>=0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 3620
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <algorithm>
using namespace std;
typedef long long LL;

const int MAXN = 5000;

LL dp[MAXN + 5];
int A[MAXN + 5];

int N, P;

int main()
{
	scanf("%d %d", &N, &P);
	for(int i = 1; i <= N; i++) scanf("%d", &A[i]);
	dp[0] = 1;
	for(int i = 1; i <= N; i++){
		int x = A[i];
		for(int j = MAXN; j >= x; j--){
			if(j >= x) dp[j] += dp[j - x];
		}
	}
	LL sum = 0;
	for(int i = 0; i <= MAXN; i++){
		if(i % 2 == P) sum += dp[i];
	}
	printf("%lld\n", sum);
}

Measured memory_bytes: 256
import java.util.Scanner

object Main extends App  {
  val sc = new Scanner(System.in)

  val n = sc.nextInt

  val vl = List.fill(n)(sc.nextInt)
  val cl = List.fill(n)(sc.nextInt)

  val reg = s"%0${n}d"

  val res =
    (0 to (Math.pow(2,n) -1 ).toInt).foldLeft(0){case (max,k) =>
//      println(s"k.toBinaryString = ${k.toBinaryString}")
      val kBin =
        if(n < 20) reg.format(k.toBinaryString.toLong)
        else k.toBinaryString

      val sum = kBin.zipWithIndex.map{case (ch,i) => if(ch == '1') vl(i) - cl(i) else 0}.sum
      Math.max(max,sum)
    }

  println(res)
}


Measured memory_bytes: 117880
#include "bits/stdc++.h"
using namespace std;
typedef long long lint;
#define rep(i,n) for(int i=0;i<n;++i)
#define MAXN 100010
#define MAXM 1100000
#define all(v) v.begin(),v.end()
#define inf 2147483647
#define linf 1152921504606846976

string next(int n,string s){//000=>001=>002=>003=>010(gyaku)
	++s[0];
	rep(i,n){
		if(s[i]>='4'){
			if(i==n-1)return "unko";
			++s[i+1],s[i]='0';
		}
	}
	return s;
}

int main(){

	lint n,a[3];cin>>n>>a[0]>>a[1]>>a[2];
	vector<lint> l(n);rep(i,n)cin>>l[i];
	int ans=inf;
	for(string b="00000000";"unko"!=(b=next(n,b));){
		int s[4]={},c[4]={};
		rep(i,n){
			s[b[i]-'0']+=l[i];
			c[b[i]-'0']++;
		}int tmp=0;
		if(!c[0]||!c[1]||!c[2])continue;
		rep(i,3){
			tmp+=(c[i]-1)*10+abs(a[i]-s[i]);
		}ans=min(ans,tmp);
	}cout<<ans<<endl;
}

//sub-EOF


Measured memory_bytes: 256
#include <iostream>
    #include <string>

    using namespace std;

    int N;
    string W[100];

    int main() {
        cin >> N;
        cin >> W[0];

        bool ret = true;

        for (int i = 1; i < N; i++) {
            cin >> W[i];
            if(W[i - 1][W[i - 1].length() - 1] != W[i][0]) ret = false;
            for (int j = 0; j < i; j++) {
                if(W[i] == W[j]) ret = false;
            }
        }

        if(ret) cout << "Yes" << endl;
        else cout << "No" << endl;
        return 0;
    }


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
# ifdef DEB
# define debug(...) fprintf(stderr, __VA_ARGS__)
# else
# define debug(...)
#endif
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define LL long long
#define LD long double
#define PII pair<int, int>
#define PLL pair<LL, LL>
#define pb pop_back
#define VI vector<int> 
#define VPI vector<PII> 
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define FORD(i,a,b) for(int i = (a); i >= (b); i--)
#define RE(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define ALL(x) (x).begin(), (x).end()
#define siz(V) ((int)V.size())
#define int LL
const int mod = 1e9 + 7;

int n[2], res;
vector<int> X[2];

main()
{
  //ios_base::sync_with_stdio(0);
  scanf("%lld%lld", n, n + 1);
  for (int i = 0; i < 2; i++)
  {
    int prev;
    scanf("%lld", &prev);
    for (int j = 1; j < n[i]; j++)
    {
      int a;
      scanf("%lld", &a);
      X[i].PB(a - prev);
      //debug("%lld %lld: %lld\n", i, j, a - prev);
      prev = a;
    }
  }
  LL tmp = 0;
  for (int i = 1; i < n[0]; i++)
  {
    tmp = (tmp + ((i * (n[0] - i)) % mod) * X[0][i - 1]) % mod;
  }
 // debug("tmp %lld\n", tmp);
  for (int i = 1; i < n[1]; i++)
  {
    res = (res + ((tmp * X[1][i - 1]) % mod) * ((i * (n[1] - i)) % mod)) % mod;
   // debug("%lld: %lld %lld %lld \n", i, res, tmp * X[1][i - 1], i * (n[1] - i));
  }
  printf("%lld\n", res);
  return 0;
}

Measured memory_bytes: 2548
#include <iostream>

using namespace std;
#define int long long


int A, B, C, X, Y;

signed main() {
    cin >> A >> B >> C >> X >> Y;
    int ans = 0;
    if (A >= 2 * C) {
        ans += 2 * X * C;
        Y -= X;
        X = 0;
        if (Y < 0)Y = 0;
    }
    //cerr << ans << endl;
    if (B >= 2 * C) {
        ans += 2 * Y * C;
        X -= Y;
        Y = 0;
        if (X < 0)X = 0;
    }
    //cerr << ans << endl;
    if (A + B >= 2 * C) {
        int k = min(X, Y);
        ans += 2 * k * C;
        X -= k;
        Y -= k;
    }
    //cerr << ans << endl;
    ans += A * X + B * Y;
    cout << ans << endl;
    return 0;
}

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

using namespace std;
#define lp(i,n) for(int i=0;i<n;i++)
#define lps(i,j,n) for(int i=j;i<n;i++)
#define fordebug int hoge;cin>>hoge;
#define DEKAI 1000000007;
#define INF (1<<28)
#define int long long


signed main(){
  cout<<fixed<<setprecision(10);
  int n,w;
  cin>>n>>w;
  vector<vector<double> > val;
  lp(i,n){
    int v,w;
    cin>>v>>w;
    double av=(double)v/w;
    vector<double> valmemo;
    valmemo.push_back(av);
    valmemo.push_back(v);
    valmemo.push_back(w);
    val.push_back(valmemo);
    valmemo.clear();
  }
  sort(val.begin(),val.end());
  reverse(val.begin(),val.end());
  double sumw=0,sumv=0;
  for(int i=0;i<n;i++){
    if(val[i][2]+sumw<=w){
      sumw+=val[i][2];
      sumv+=val[i][1];
    }
    else{
      sumv+=(w-sumw)*val[i][0];
      break;
    }
  }
  cout<<sumv<<endl;
	      
  return 0;
}



Measured memory_bytes: 8356
'use strict'

function main(inp) {
  inp = inp.trim().split('\n')
  inp[0] = inp[0].split(' ').map(n => Number(n));
  inp[1] = inp[1].split(' ').map(n => Number(n));

  const hand = ['r', 's', 'p']

  const N = inp[0][0]
  const K = inp[0][1]

  const point = inp[1]

  let T = inp[2]
  let W = ''
  let ans = 0
  
  for (let i = 0; i < T.length; i++) {
    let index = hand.indexOf(T[i])
    let next = hand[index ? index - 1 : 2]
    if (W.length >= K && W[W.length - K] === next) {
      W += '0'
    } else {
      W += next
      ans += point[hand.indexOf(next)]

    }
  }
  console.log(ans)
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 40860
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int ans[505][505];

void calc(int L,int R,int nxt){
    int n = (R-L+1);
	if(n <= 1) return;
	if(n == 2) {ans[L][R]=nxt;return;}
	int m = n/2;
	for(int i=L;i<L+m;i++) for(int j=L+m;j<=R;j++) ans[i][j] = nxt;
	calc(L,L+m-1,nxt+1);
	calc(L+m,R,nxt+1);
	
}
int main(){
	int n; cin>>n;
	calc(1,n,1);
	for(int i=1;i<=n;i++) {for(int j=i+1;j<=n;j++) cout << ans[i][j] << " " ;cout<<endl;}
}

Measured memory_bytes: 1408
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a[] = new int[3];
    a[0] = sc.nextInt();
    a[1] = sc.nextInt();
    a[2] = sc.nextInt();
    Arrays.sort(a);
    System.out.println(a[2]-a[0]);
  }
  

  
}

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

int dp[5005][5005] = {0};

int main() {
	int n,ans = 0;
	string s;
	
	cin >> n >> s;
	
	for(int i= n-1; i>=0; i--) {
		for(int j= n-1; j>=0; j--) {
			if (s[i] != s[j]) dp[i][j] = 0;
			else dp[i][j] = dp[i+1][j+1] + 1;
		}
	}
	
	for(int i=0;i<n-1;i++) {
		for(int j=i+1;j<n;j++) {
			int k = min(dp[i][j] , j-i);
			ans = max(ans , k);
		}
	}

	cout << ans << endl;
}



Measured memory_bytes: 98048
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
struct  E
{
	int a;
	int b;
	int w;
};
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	if (N == 2) {
		cout << 2 << " " << 2 << endl;
		cout << "1 2 0" << endl;
		cout << "1 2 1" << endl;
		return 0;
	}
	else if (N == 4) {
		cout << 2 << " " << 4 << endl;
		cout << "1 2 0" << endl;
		cout << "1 2 1" << endl;
		cout << "1 2 2" << endl;
		cout << "1 2 3" << endl;
		return 0;
	}
	bool p2 = false;
	//N--;
	int _N = N;
	//N = _N + 1;
	//while (N > 1) {
	//	if (N % 2 == 1) {
	//		break;
	//	}
	//	N /= 2;
	//}
	////cerr << N << endl;
	//if (N == 1) {
	//	p2 = true;
	//	_N--;
	//}

	string S;
	N = _N;

	while (N > 0) {
		S.push_back((N % 2) + '0');
		N /= 2;
	}
	reverse(S.begin(), S.end());

	cerr << S << endl;
	vector<E> es;
	//es.push_back(E{ 0, 1, 0 });
	for (int i = 1; i < (int)S.size(); i++) {
		es.push_back(E{ i,i + 1,0 });
		es.push_back(E{ i,i + 1,1 << ((int)S.size() - i - 1) });
	}
	for (int i = 1; i < (int)S.size(); i++) {
		if (S[i] == '1') {
			/*int j = i + 1;
			while (j < (int)S.size()) {
				if (S[j] == '1')break;
				j++;
			}*/
			int X = (_N / (1 << ((int)S.size() - i)))*(1 << ((int)S.size() - i));
		
			es.push_back(E{ 1, i + 1, X });
			
		
		}
	}

	cout << S.size() << " " << es.size() << endl;
	for (int i = 0; i < es.size(); i++) {
		cout << es[i].a<< " " << es[i].b << " " << es[i].w << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll          long long int
#define pll         pair<ll,ll>
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mod         1000000007
#define pb          push_back
#define inf         1000000000000000000LL
#define vl          vector<ll>
#define F           first
#define S           second
#define ld          long double
#define fix(n)      cout<<fixed<<setprecision(n)
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define pi          3.14159265358979323

map<char,ll>cnt;
set<char>c;

void solve()
{
       string s; cin>>s;
       for(char x:s)
       {
              c.insert(x);
              cnt[x]++;
       }
       if(c.size()==2)
       {
              char x = *c.begin();
              if(cnt[x] == 2)
              {
                     cout<<"Yes\n";
                     return;
              }
       }
       cout<<"No\n";
}


int main() {
	int T = 1;
//     pre();
	speed_up
	//cin>>T;
	while(T--)
	    solve();
	return 0;
}


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

for n_get in range(1, min(N, K)+1):
    for a in range(n_get+1):
        b = n_get - a
        temp = V[:a] + V[N-b:]
        temp = sorted(temp)
        rem = max(0, K - n_get)
        i = 0
        while rem > 0 and i < n_get:
            if temp[i] >= 0:
                break
            rem -= 1
            i += 1
        ans = max(ans, sum(temp[i:]))

print(ans)

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

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define between(a,x,b) ((a)<=(x)&&(x)<=(b))
using namespace std;
int N, T, H, L, d[101][2];
int main(){
  scanf("%d%d%d%d", &N, &T, &H, &L);
  rep(i, N) scanf("%d%d", &d[i][0], &d[i][1]);
  int t = T, m = 0, p = 0;
  while(1){
    if(d[p][0]) m += 10, t+=1, d[p][0]--;
    else if(d[p][1]) m += 100, d[p][1]--;
    else{printf("%d\n",p+1); return 0;}
    if(t > L){ printf("%d\n", p+1); return 0;}
    if(m >= 90){
      d[p][0] += (m-90)/10;
      t -= (m-90)/10;
      m = 0;
    }
    if(t < 0){ printf("%d\n", p+1); return 0;}
    p++;
    if(p >= N) p = 0;
  }
  return 0;
}

Measured memory_bytes: 1192
#include <stdio.h>

int main(){
  int a, b, k;  scanf("%d %d %d", &a, &b, &k);
  if((a+k-1) < (b-k+1)){
    for(int i=a; i<a+k; i++)
      printf("%d\n", i);
    for(int i=b-k+1; i<=b; i++)
      printf("%d\n", i);
  }else{
    for(int i=a; i<=b; i++)
      printf("%d\n", i);
  }
  return 0;
}


Measured memory_bytes: 1708
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		ArrayList<Integer>list = new ArrayList<Integer>();
		for(int i = 0 ; i < 10 ; i++){
			int h = sc.nextInt();
			list.add(h);
		}
		Collections.sort(list);
		
		System.out.println(list.get(list.size()-1));
		System.out.println(list.get(list.size()-2));
		System.out.println(list.get(list.size()-3));
	}

}

Measured memory_bytes: 17176
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

using lint = long long;
using P = pair<int, int>;
using LLP = pair<long long, long long>;

#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = (int)(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = (int)(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
#define REVERSE(x) reverse((x).begin(), (x).end())
#define TWINS(x) cout << ((x) ? "Yay!" : ":(") << '\n'

constexpr int IINF = (1 << 30) - 1;
constexpr long long LLINF = 1LL << 61;
constexpr double EPS = 1e-10;

constexpr int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
constexpr int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

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

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

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    int n;
    cin >> n;

    vector< vector<lint> > sum(2, vector<lint>(n + 1, 0LL));
    reps(j, n){
        lint t;
        cin >> t;
        rep(i, 2){
            sum[i][j] = sum[i][j - 1] + t;
        }
    }

    lint ans = LLINF;

    rep(i, 2){
        lint res = 0;
        lint dif = 0;

        reps(j, n){
            if((j & 1) ^ i){
                if(sum[i][j] + dif <= 0LL){
                    res += (1LL - (sum[i][j] + dif));
                    dif += (1LL - (sum[i][j] + dif));
                    sum[i][j] = 1LL;
                }
            }else{
                if(sum[i][j] + dif >= 0LL){
                    res += (sum[i][j] + dif - (-1LL));
                    dif -= (sum[i][j] + dif - (-1LL));
                    sum[i][j] = -1LL;
                }
            }
        }

        chmin(ans, res);
    }

    cout << ans << endl;

    cout << flush;

    return 0;
}

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

int main(){
    ll X; cin >> X;
    for(ll x = -1000; x < 1000;++x){
        for(ll y = -1000; y < 1000;++y){
            ll a = x*x*x*x*x;
            ll b = y*y*y*y*y;
            if(a-b == X) {
                cout << x << " " << y << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 3636
#include<stdio.h>
int isPrime(int n){
	int i;
	if(n<=1 || n!=2&&n%2==0)return 0;
	for(i=3;i*i<=n;i+=2){
		if(n%i==0)return 0;
	}
	return 1;
}
int main(){
	int n,i,ans;
	while(scanf("%d",&n),n){
		ans=0;
		for(i=2;i*2<=n;i++){
			if(isPrime(i) && isPrime(n-i))ans++;
		}
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 600
import java.util.*;
 
public class Main{
 
    int[] v;
    int[] dx = {0,0,1,-1};
    int[] dy = {1,-1,0,0};
 
    void solve(){
        Scanner sc = new Scanner(System.in);

        calc();
 
        while(sc.hasNext()){
            String pzl = "";
            for(int i=0; i<2; i++)
                for(int j=0; j<4; j++) pzl += sc.next();

            System.out.println(v[Integer.parseInt(pzl)/10]);
        }
    }
 
    void calc(){
        Queue<int[]> q = new LinkedList<int[]>();
        q.add(new int[]{1234567,0,0,0});

        v = new int[7654322];
        Arrays.fill(v,-1);
 
        while(q.size()>0){
            int[] pp = q.poll();
            int pzz = pp[0], x = pp[1], y = pp[2], cnt = pp[3];
  
            if(v[pzz/10]!=-1) continue;
            v[pzz/10] = cnt;
 
            String pzzs = String.valueOf(pzz);
            if(pzzs.length()==7) pzzs = "0" + pzzs;
            char[] c = pzzs.toCharArray();
 
            for(int i=0; i<4; i++){
                int nx = x+dx[i], ny = y+dy[i];
                if(nx<0 || nx>=4 || ny<0 || ny>=2) continue;
                c[y*4+x] = c[ny*4+nx];
                c[ny*4+nx] = '0';
                int ns = Integer.parseInt(String.valueOf(c));
                q.add(new int[]{ns,nx,ny,cnt+1});
                c[ny*4+nx] = c[y*4+x];
                c[y*4+x] ='0';
            }
        }
    }
 
    public static void main(String[] args){
        new Main().solve();
    }
}

Measured memory_bytes: 43000
n=int(input())
s=input()
t=s.count('R')*s.count('G')*s.count('B')
for i in range(n):
  j=1
  while i+j*2<n:
    if s[i]!=s[i+j] and s[i+j]!=s[i+2*j] and s[i]!=s[i+2*j]:
      t-=1
    j+=1
print(t)

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

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	int a, b;
	string ans;

	cin >> a >> b;

	if (a <= 0 && 0 <= b) ans = "Zero";
	else if (a > 0) ans = "Positive";
	else if ((b - a + 1) % 2 == 0) ans = "Positive";
	else ans = "Negative";

	cout << ans << endl;

	return 0;
}


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

int main(void){
    string s,t;
    cin >> s;
    cin >> t;
    int ans=0;
    rep(i,3) if(s[i]==t[i]) ans++;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);

		String s = sc.next();
		String t = sc.next();
		System.out.println(s.equals(t.substring(0, s.length())) ? "Yes" : "No");
	}

}


Measured memory_bytes: 26892
#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 <fstream>
#include <functional>
#include <bitset>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
const double eps=1e-10;

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

int main(){
    int n; cin>>n;
    vector<int> imos(100010, 0);
    for(int i=0; i<n; i++){
        int a, b; cin>>a>>b;
        imos[a]++;
        imos[b+1]--;
    }

    for(int i=0; i<100008; i++){
        imos[i+1] += imos[i];
    }

    int ans=0;
    for(int i=1; i<100006; i++){
        if(i - 1 <= imos[i]){
            chmax(ans, i - 1);
        }
    }

    cout << ans << endl;
}


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

#define eb emplace_back
#define ld long double
#define ll long long

using namespace std;

const ll mod = 1000000007;
const int nm = 200002;

int n;
ll a[nm];

int main() {
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
#endif
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n;
	ll s = 0;
	ll res = 0;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i];
		res = (res + a[i] * s) % mod;
		s = (s + a[i]) % mod;
	}
	cout << res << "\n";
}


Measured memory_bytes: 5172
#include <iostream>
#include <fstream>
#include <algorithm>
#include <functional>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>

#include <vector>
#include <string>
#include <stack>
#include <list>
#include <queue>
#include <bitset>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>

using namespace std;


#define INT_MIN  (-2147483647 - 1)
#define INT_MAX  2147483647

#define MOD 1000000007
#define maxN 100005




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

	string par = "CODEFESTIVAL2016";
	int res = 0;
	for (int i = 0; i < par.length(); i++)
	{
		if (str[i] != par[i])
			res++;
	}
	cout << res << endl;

	return 0;
}

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

int main(void)
{
	char str[100001]= {};
	long long int num;

	cin>>str>>num;

	int size= strlen(str);
	for(int i= 0; i<size; i++)
	{
		if(num==0)
			break;

		if(i!=size-1&&str[i]=='a')
			continue;

		if(26-(str[i]-'a')<=num)
		{
			num-=26-(str[i]-'a');
			str[i]= 'a';

			if(i==size-1)
				i= size-2;
		}

		else if(i!=size-1)
			continue;

		else if(i==size-1)
		{
			str[i]+= num;
			if(str[i]>'z')
				str[i]-= 'z';

			num= 0;
		}
	}

	cout<<str<<endl;
	return 0;
}

Measured memory_bytes: 512
//Rafiqul Islam, MBSTU,ICT

#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

#define pb push_back
#define mk make_pair
#define f0(i,b) for(int i=0;i<(b);i++)
#define f1(i,b) for(int i=1;i<=(b);i++)
#define f2(i,a,b) for(int i=(a);i<=(b);i++)
#define sf(a) scanf("%d",&a);
#define sfl(a) scanf("%lld",&a);
#define pf(a) printf("%d\n",a);
#define pfl(a) printf("%lld\n",a);
#define TEST int test; cin >> test ;while(test--)
#define ii pair<int,int>
#define iil pair<ll,ll>
#define loop(i,a,b) for(int i = a ; i < b ; i++)
#define INF 2147483647
#define endl "\n"
#define all(v) v.begin(),v.end()

int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};

const double pi = acos(-1.0);
const ll mod = 1e9 + 7;;
const ll maxn = 1e6+5;

ll power(ll x, unsigned long long y)
{
    ll res = 1;     // Initialize result

    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            res = (res*x)%mod;

        // y must be even now
        y = y>>1; // y = y/2
        x = (x*x)%mod;  // Change x to x^2
    }
    return res%mod;
}
ll modOp(ll a, ll b)
{
    ll c = a % b;
    if (c < 0)
        c += b;
    return c;
}
ll iv[maxn + 1];
void mod_inv()
{
    iv[1] = 1;
    for(ll i = 2 ; i <= maxn ; i++ )
    {

        iv[i] = (mod - mod/i * iv[mod%i]%mod)%mod;
        //cout << iv[i] << endl;
    }
}

ll Logn(ll n, ll base)
{
    return (n > base - 1) ? 1 + Logn(n / base, base) : 0;
}
vector<vector<int>> adj;
vector<int>sub_tree_size;
vector<array<int,2>> edge;
void dfs(int child, int parant)
{
    sub_tree_size[child] = 1;
    for(int x: adj[child])
    {
        if(x == parant)
            continue;

        dfs(x,child);
        sub_tree_size[child] += sub_tree_size[x];
    }

}


void run_case()
{
   ull n;
   cin >> n;
   ll ans = power(10LL,n);
   ans = modOp(ans - power(9LL,n), mod);
   ans = modOp(ans - power(9LL,n), mod);
   ans = modOp(ans+power(8LL,n), mod);

   cout << ans << endl;


}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //TEST
    run_case();
    //main();
    return 0;
}


Measured memory_bytes: 3532
#include <cstdio>
#include <algorithm>

#define maxn 1048576
#define dmax(_a, _b) ((_a) > (_b) ? (_a) : (_b))

int a[maxn], ans[maxn];
int main()
{
	int n; scanf("%d", &n);
	int _ = 1 << n;
	for (int i = 0; i < _; ++i) scanf("%d", a + i);
	for (int S = 1; S < _; ++S)
	{
		int maxx = 0, sec = 0;
		for (int i = S; ~i; i = (i - 1) & S)
		{
			if (a[i] >= maxx) sec = maxx, maxx = a[i];
			else if (a[i] > sec) sec = a[i];
			if (i == 0) break;
		}
		ans[S] = maxx + sec;
	}
	for (int i = 1; i < _; ++i) ans[i] = dmax(ans[i], ans[i - 1]), printf("%d\n", ans[i]);
	return 0;
}

Measured memory_bytes: 6016
#[allow(unused_macros)]
macro_rules! get {
    ([$t:ty] ; $n:expr) => {
        (0..$n)
        .map(|_| get!([$t])).collect::<Vec<_>>()
    };
    ($($t:ty),+ ; $n:expr) => {
        (0..$n).map(|_| get!($($t),+)).collect::<Vec<_>>()
    };
    ([$t:ty]) => {
        rl().split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect::<Vec<$t>>()
    };
    ($t:ty) => {
        rl().parse::<$t>().unwrap()
    };
    ($($t:ty),*) => {
        {
            let line =rl();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap()),*)
        }
    };
}
fn rl() -> String {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    line.trim().to_string()
}

fn main() {
    let (n, k) = get!(usize, usize);
    if k <= (n + 1) / 2 {
        println!("YES");
    } else {
        println!("NO");
    }
}


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

signed main() {
    int n, x, t;
    
    cin >> n >> x >> t;
    if (n%x != 0) {
        cout << (n/x + 1) * t << '\n';   
    } else {
        cout << (n/x) * t << '\n';
    }
    
    return (0);
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define all(a) (a).begin(),(a).end()
typedef long long ll;

using P = pair<string,string>;

void rec(string &s, map<P,ll> &mp, int i, string s1, string s2){
    if(i == (int)s.size()){
        mp[P(s1,s2)]++;
        return;
    }
    rec(s,mp,i+1,s1+s[i],s2);
    rec(s,mp,i+1,s1,s2+s[i]);
}

int main(void){
    int n;
    string s;
    cin>>n>>s;
    string s1 = s.substr(0,n);
    string s2 = s.substr(n,n);
    reverse(all(s2));
    map<P,ll> mp1,mp2;
    rec(s1,mp1,0,"","");
    rec(s2,mp2,0,"","");
    ll res = 0;
    for(auto itr : mp1){
        P p = itr.first;
        res += mp1[p]*mp2[p];
    }
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 104192
main :: IO ()
main = do
    s <- getLine :: IO String
    t <- getLine :: IO String
    putStrLn $ if judge s t then "Yes" else "No"

judge :: String -> String -> Bool
judge s t = t `elem` [ rotate i s | i <- [1 .. length s]]

rotate :: Int -> String -> String
rotate i s = let (u, v) = splitAt i s in v ++ u


Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> H(N);
  for (int i = 0; i < N; i++) {
    cin >> H.at(i);
  }
  bool ok = true;
  reverse(H.begin(), H.end());
  for (int i = 0; i < N - 1; i++) {
    if (H.at(i + 1) - H.at(i) == 1) {
      H.at(i + 1)--;
    }
    if (H.at(i + 1) - H.at(i) > 1) {
      ok = false;
      break;
    }
  }
  if (ok) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
      
}

Measured memory_bytes: 3796
#include <stdio.h>
#include <stdlib.h>
#define MAX 100
#define MAX_DIGIT 7

void push(int);
int pop(void);
int stack[MAX], top = 0;

int main(){
  int  x1, x2;
  char str[MAX_DIGIT];

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

  printf("%d\n",stack[0]);
  
  return 0;
}

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

int pop(void){
  top--;
  return stack[top];
}



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

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

Measured memory_bytes: 3916
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> PP;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
#define PI 3.141592653589
#define setdouble setprecision
#define REP(i,n) for(ll i=0;i<(n);++i)
#define OREP(i,n) for(ll i=1;i<=(n);++i)
#define RREP(i,n) for(ll i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "0" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl
#define debug false
#define debug2 false


int main(void){
    string S,T;
    ll Ans=0;
    cin >> S >> T;
    REP(i,S.size()){
        if(S[i]!=T[i]){
            Ans++;
        }
    }
    cout << Ans << endl;
    return 0;
}



Measured memory_bytes: 3828
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumparr(x) cerr << #x ; for(auto elem: x){cerr << " " << elem;} cerr << endl;
#define dumppairs(x) cerr << #x ; for(auto elem: x){cerr << "(" << elem.first << " " << elem.second << ") ";} cerr << endl;
#define dumpline cerr << "**********************" << endl;
#define dumpwline(x) cerr << "******** " << #x << "=" << (x) << " ********" << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

int main(void){
    string s; cin >> s;
    vector <ll> anss(s.size(), 0);
    s += 'R';
    ll r = 0;
    ll l = 0;
    ll idx;
    REP(i, s.size()){
        char c = s[i];
        if ((c == 'L') && s[i-1] == 'R'){
            idx = i;
        }
        if ((c == 'R') && (l > 0)){
            anss[idx-1] = (r+1)/2 + l/2;
            anss[idx] = r/2 + (l+1)/2;
            r = l = 0;
        }
        if (c == 'R'){
            r++;
        }
        if (c == 'L'){
            l++;
        }
    }
    REP(i, anss.size()){
        ll ans = anss[i];
        if (i == anss.size() - 1){
            cout << ans << endl;
        } else {
            cout << ans << " ";
        }
    }
    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD (1000000007)
#define INF (1e9)
#define INFL (1e18)

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
template<class T>using arr=vector<vector<T>>;
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} cout << a[a.size()-1] << endl;}
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; }

int main()
{
    string s, t; cin >> s >> t;
    int ans = 0;
    rep(i, s.size()){
        if(s[i]!=t[i]) ans++;
    }
    pr(ans);
    return 0;}

Measured memory_bytes: 3832
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 1000000
)

var sc *bufio.Scanner

func initScanner(r io.Reader) *bufio.Scanner {
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords) // bufio.ScanLines
	return sc
}

func main() {
	sc = initScanner(os.Stdin)
	fmt.Println(resolve(parseProblem()))
}

func parseProblem() int {
	n, d, x := scanInt(sc), scanInt(sc), scanInt(sc)
	as := nextIntSlice(sc, n)
	consumed := 0
	for i := 0; i < n; i++ {
		a := as[i]
		consumed += (d-1)/a + 1
	}
	return x + consumed
}

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	a, _ := strconv.Atoi(sc.Text())
	return int(a)
}

func nextString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

func nextIntSlice(sc *bufio.Scanner, n int) (a []int) {

	a = make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = nextInt(sc)
	}
	return a
}

func resolve(n int) int {
	return n
}

// snip-scan-funcs
func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return int(i)
}

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
long long dif(long long a, long long b)
{
    long long ans=a-b;
    if(ans<0) ans*=-1;
    return ans;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long long N, h[100005],i,ll,K,temp,mini,j;
    long long f1,f2;
    cin>>N>>K;
    for(i=0;i<N;i++)
        cin>>h[i];
    long long M[100005]={0};
    M[N-2]=dif(h[N-1],h[N-2]);
    for(i=N-3;i>=0;i--)
    {
        mini=2000000000000;
        temp=K;
        for(ll=i+1;ll<N&&temp--;ll++)
        {

        f1=dif(h[ll],h[i])+M[ll];
        M[i]=min(mini,f1);
        mini=M[i];
        }
    }
    cout<<M[0]<<endl;
    return 0;
}


Measured memory_bytes: 1792