akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <string>
#include <cstdlib>
using namespace std;

const int MY_NULL = 0;
const int MAX_MEM_SIZE = 20001;
const int INF = 1<<28;

string str;
int p;
bool error_flag;
int var[27];
class Heap* heap;

class Heap {
private:
  int mem[MAX_MEM_SIZE];
  int mem_ind;
  int mem_size;
public:
  Heap(int mem_size) : mem_size(mem_size), mem_ind(1) {
    fill(mem,mem+MAX_MEM_SIZE,0);
    mem[0] = -1;
  }
  Heap() {}

  int malloc(int size) {
    if(mem_size < size) return MY_NULL;
    mem_size -= size;
    mem[mem_ind] = size;
    return mem_ind++;
  }

  int clone(int p) {
    if(p == MY_NULL) return MY_NULL;
    if(p == INF || mem[p] ==  MY_NULL) {
      error_flag = true;
      return MY_NULL;
    }
    if(mem_size < mem[p]) return MY_NULL;
    mem_size -= mem[p];
    mem[mem_ind] = mem[p];
    return mem_ind++;
  }

  void free(int p) {
    if(p == MY_NULL) return;
    if(p == INF || mem[p] == MY_NULL) {
      error_flag = true;
      return;
    }
    mem_size += mem[p];
    mem[p] = 0;
  }

  int count_leak() {
    for(int i = 1; i <= 26; ++i) {
      if(var[i] == INF || var[i] == MY_NULL) continue;
      mem[var[i]] = 0;
    }
    int cnt = 0;
    for(int i = 1; i < 20001; ++i) cnt += mem[i];
    return cnt;
  }
};


void line();
int expr();
int assign();
int my_malloc();
void my_free();
int my_clone();
int variable();
int number();


void line() {
  if(str.substr(p,4) == "free") my_free();
  else expr();
}

int expr() {
  int res = MY_NULL;
  if(str[p] == '(') {
    ++p;
    res = expr();
    ++p;
  } else if(str.substr(p,4) == "NULL") {
    p += 4;
    res = MY_NULL;
  } else if(str.substr(p,6) == "malloc") {
    res = my_malloc();
  } else if(str.substr(p,5) == "clone") {
    res = my_clone();
  } else if(p+1 < str.size() && isalpha(str[p]) && str[p+1] == '=') {
    res = assign();
  } else if(isalpha(str[p])) {
    res = variable();
  }
  return res;
}

int assign() {
  int v = variable();
  ++p;
  int e = expr();
  if(e < 0) e = var[-e];
  return var[-v] = e;
}

int my_malloc() {
  p += 7;
  int n = number();
  ++p;
  return heap->malloc(n);
}

void my_free() {
  p += 5;
  int e = expr();
  if(e < 0) e = var[-e];
  ++p;
  heap->free(e);
}

int my_clone() {
  p += 6;
  int e = expr();
  if(e < 0) e = var[-e];
  ++p;
  return heap->clone(e);
}

int variable() {
  return -(str[p++]-'A'+1);
}

int number() {
  int begin = p;
  int length = 0;
  while(p < str.size() && isdigit(str[p])) ++p;
  return atoi(str.substr(begin,p-begin).c_str());
}

int main() {
  int M;
  cin >> M;
  cin.ignore();
  heap = new Heap(M);
  fill(var,var+27,INF);
  error_flag = false;

  while(getline(cin,str)) {
    p = 0;
    line();
  }

  if(error_flag) cout << "Error" << endl;
  else cout << heap->count_leak() << endl;
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,L,R;
string S,T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;

ll sn(ll n){
    ll ans = 0;
    while(n > 0){
        ans += n%10;
        n /= 10;
    }
    return ans;
}

int main(){
    cin>>K;
    N = 1;
    vec bit10(19,1);
    reps(i,1,19) bit10[i] = bit10[i-1] * 10;
    rep(i,K){
        cout<<N<<endl;
        ++N;
        ll next = N;
        for(ll m = N, d = 0; m >= 0; m /= 10){
            ll temp = bit10[d+1] * (N/bit10[d+1] + 1) - 1;
            if(next * sn(temp) > temp * sn(next)) next = temp;
            ++d;
            if(m == 0) break;
            //cout<<i<<' '<<m<<endl;
        }
        N = next;
    }
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if (a + b == c + d) {
		cout << "Balanced" << endl;
	}
	else if (a + b > c + d) {
		cout << "Left" << endl;
	}
	else {
		cout << "Right" << endl;
	}
	return 0;
}

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

using namespace std;

int solve(int N) {
    int ans = 0;
    for (int i = 2; i <= N; ++i) { // i???
        for (int j = 1; j <= N; ++j) { // j???????§???????
            // if ( j + (j+1) + ... + (j+i-1) == N ) {
            //     ++ans;
            // }
            int sum = (2*j+i-1)*i/2;
            if (sum == N) {
                ++ans;
            }
        }
    }
    return ans;
}

int main() {
    while (1) {
        int N; cin >> N;
        if (N == 0) {
            break;
        }
        cout << solve(N) << endl;
    }
}

Measured memory_bytes: 1156
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <queue>
#include <cstring>
#include <vector>
#include <string>
using namespace std;
typedef long long ll;

int main(){
    ios::sync_with_stdio(0); cin.tie(0), cout.tie(0);
    ll q, h, s, d; cin >> q >> h >> s >> d;
    ll n; cin >> n;
    q *= 4; h *= 2;
    s = min(s,min(q,h));
    if(s*2>d){
        cout << d*(n/2) + s*(n%2);
    }
    else cout << s*n;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const long long INF = 1e15;

#include <math.h>
#define PI 3.14159265358979323846264338327950L

bool isPrime(long long x) {
    if (x == 1) return true;
    for (long long i = 2; i*i <= x; i++) {
        if (x % i == 0) return false;
    }
    return true;
}

long long gcd(long long a, long long b) {
    if (a == 0)
        return b;
    return gcd(b % a, a);
}

vector<long long> common_divisors(long long a, long long b) {
    long long n = gcd(a, b);
    vector<long long> ans;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            if (n / i == i) {
                ans.push_back(i);
            }
            else {
                ans.push_back(n / i);
                ans.push_back(i);
            }
        }
    }
    return ans;
}

bool is_sorted(vector<int> a) {
    int n = a.size();
    for (int i = 0; i < n - 1; i++) {
        if (a[i + 1] < a[i]) return false;
    }
    return true;
}

int mxN = 1e5;
int main() {
    string s;
    cin >> s;
    int n = s.length();
    vector<int> a(n);
    int i = 0;
    while (i < n) {
        bool odd = false;
        int cnt = 0;
        int pos = -1;
        while (s[i] == 'R') {
            i++; cnt++;
        }
        pos = i - 1;
        if (cnt % 2) odd = true;
        while (i < n && s[i] == 'L') {
            i++; cnt++;
        }
        if (cnt % 2) {
            if (odd) {
                a[pos] = (cnt / 2) + 1;
                a[pos + 1] = cnt / 2;
            }
            else {
                a[pos+1] = (cnt / 2) + 1;
                a[pos] = cnt / 2;
            }
        }
        else {
            a[pos] = cnt / 2;
            a[pos + 1] = cnt / 2;
        }

    }
    for (int i = 0; i < n; i++) {
        cout << a[i] << " ";
    }
    return 0;
}

Measured memory_bytes: 3820
n = int(input())
sp = []
for i in range(n):
    sp_i = input().split()
    sp_i[1] = int(sp_i[1])
    sp_i.append(i)
    sp.append(sp_i)
sp = sorted(sp, key=lambda x: x[1], reverse=True)
sp = sorted(sp, key=lambda x: x[0])
for sp_i in sp:
    print(int(sp_i[2]) + 1)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
const lint MOD =1000000007;
const lint MAX = 10000000;
using Graph =vector<vector<lint>>;
typedef pair<lint,lint> P;

 
lint fac[MAX], finv[MAX], inv[MAX];

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

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

lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return 0;
        }
    }

    return 1;
}
   long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
    lint lcm(lint a,lint b){
        return a/__gcd(a,b)*b;
    }
    
    
  int main(){
     lint a,b;
     cin>>a>>b;
     lint ans=1;
     while(1){
        double x=ans*0.08;
        double y=ans*0.1;
        lint g=(lint)x;
        lint h=(lint)y;
        if(g==a&&h==b){
            cout<<ans;
            return 0;
        }
        ans++;
        if(ans==MAX){
            cout<<-1;
            return 0;
        }
     }
  }
     
  


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
typedef complex<D> P;
#define F first
#define S second
const ll MOD=1000000007;
//const ll MOD=998244353;

template<typename T,typename U>istream & operator >> (istream &i,pair<T,U> &A){i>>A.F>>A.S; return i;}
template<typename T>istream & operator >> (istream &i,vector<T> &A){for(auto &I:A){i>>I;} return i;}
template<typename T,typename U>ostream & operator << (ostream &o,const pair<T,U> &A){o<<A.F<<" "<<A.S; return o;}
template<typename T>ostream & operator << (ostream &o,const vector<T> &A){ll i=A.size(); for(auto &I:A){o<<I<<(--i?" ":"");} return o;}



int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N;
  cin>>N;
  vector<vector<int>> A(N,vector<int>(4));
  cin>>A;
  map<vector<int>,int> M;
  map<vector<int>,int> sq2idx;
  using itr=map<vector<int>,int>::iterator;
  vector<vector<itr>> cnt(N,vector<itr>(4));
  vector<int> col(4,0);
  vector<int> uku(4,0);
  for(int idx=0;idx<N;idx++){
    auto &I=A[idx];
    for(int i=0;i<4;i++){
      for(int j=0;j<4;j++){
        col[j]=I[(i+j)&3];
      }
      M[col]++;
      cnt[idx][i]=M.find(col);
      sq2idx[col]=idx;
    }
  }
  ll ans=0;
  for(int i=0;i<N;i++){
    for(int k=0;k<4;k++){
      cnt[i][k]->S--;
    }
    for(int j=0;j<N;j++){
      if(i==j){continue;}
      for(int k=0;k<4;k++){
        cnt[j][k]->S--;
      }
      for(int k=0;k<4;k++){
        ll dif=1;
        for(int l=0;l<4;l++){
          uku[0]=A[i][(l+1)&3];
          uku[1]=A[i][l];
          uku[2]=A[j][(16-(k+l-1))&3];
          uku[3]=A[j][(16-(k+l))&3];
          //if(i==4 && j==0 && k==0){
          //cout<<i<<" "<<j<<" "<<k<<" ! "<<l<<endl<<uku<<" "<<M[uku]<<endl;
          //}
          if(sq2idx.count(uku)==0){dif=0; break;}
          int idx=sq2idx[uku];
          if(uku[0]==uku[2] && uku[1]==uku[3]){
            if(uku[0]==uku[1]){dif*=M[uku];}
            else{dif*=M[uku];}
          }
          else{dif*=M[uku];}
          for(auto &I:cnt[idx]){I->S--;}
        }
        //assert(dif>=0);
        ans+=dif;
        //cout<<i<<" "<<j<<" "<<k<<" "<<dif<<endl;
        for(int l=0;l<4;l++){
          uku[0]=A[i][(l+1)&3];
          uku[1]=A[i][l];
          uku[2]=A[j][(16-(k+l-1))&3];
          uku[3]=A[j][(16-(k+l))&3];
          if(sq2idx.count(uku)==0){dif=0; break;}
          int idx=sq2idx[uku];
          for(auto &I:cnt[idx]){I->S++;}
        }
      }
      for(int k=0;k<4;k++){
        cnt[j][k]->S++;
      }
    }
    for(int k=0;k<4;k++){
      cnt[i][k]->S++;
    }
  }
  //cout<<ans<<endl;
  ans/=6;
  cout<<ans<<endl;
  

  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <math.h>
using namespace std;

int main() {
    int n; cin>>n;
    for (int x = 0;x<=n;x++){
        if (x*108/100==n){
            cout <<x<<endl;
            return 0;
        }
    }
    cout << ":("<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int yen, feliz = 0;
    scanf("%d", &yen);
    
    while (yen >= 5) {
        if (yen >= 500){
            yen = yen - 500;
            feliz = feliz + 1000;
        }
        else{
            yen = yen - 5;
            feliz = feliz + 5;
        }
    }
    printf("%d", feliz);
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int jud[2][100101]={0};
int main(){
    int a[5]={0};
    int t=6;
    while(t--){
        int x;
        cin>>x;
        a[x]++;
    }
    for(int i=1;i<=4;i++)if(a[i]>=3){
        cout<<"NO";
        return 0;
    }
    cout<<"YES";
}


Measured memory_bytes: 256
#include <cstdio>

int main()
{
    int a,b,c;
    scanf("%d %d %d", &a, &b, &c);
    if ((a * 100 + b * 10 + c) % 4 == 0)
    {
        printf("YES");
    }
    
    else 
    {
        printf("NO");
    }
}

Measured memory_bytes: 1708
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;

int main (){
  int D, E;
  while (cin >> D >> E, D + E) {
    double ans = 1 << 30;
    for (int x = 0; x <= D; x++) {
      int y = D - x;
      ans = min(ans, abs(sqrt(x * x + y * y) - E));
    }
    cout << fixed << setprecision(10) << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 3196
#include<bits/stdc++.h>
#define ll long long

using namespace std;

int main()
{
    ll N,M,L,R,max1 = 0,min1=1e7;
    cin >> N >> M;
    for(int i=0;i<M;i++)
    {
        cin >> L >> R;
        max1 = max(max1,L);
        min1 = min(min1,R);
    }
    cout << max(int(min1-max1+1),0);
    return 0;
}


Measured memory_bytes: 256
N = int(input())
lst = [int(i) for i in input().split()]
dp = [0 for i in range(N)]
dp[1] = abs(lst[0] - lst[1])
for i in range(2, N):
    dp[i] = min(
        dp[i - 1] + abs(lst[i] - lst[i - 1]), dp[i - 2] + abs(lst[i] - lst[i - 2])
    )
print(dp[N - 1])


Measured memory_bytes: 13780
a,b=map(int,input().split())
List = []
mid = ""
for i in range (a):
  List.append(input())
resList = []
for i in range(a+2):
  if i == 0 or i == a+1:
    for j in range(b+2):
      mid += "#"
    resList.append(mid)
    mid = ""
  else:
    mid = "#"+List[i-1]+"#"
    resList.append(mid)
    mid = ""
for element in resList:
  print(element)

Measured memory_bytes: 9060
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<unordered_map>
#include<queue>
#include<stack>
#include<string>
#include<bitset>
#include<random>
#include<time.h>
#define MOD 1000000007ll
#define INF 1000000000ll
#define EPS 1e-7
#define REP(i,m) for(long long i=0; i<(ll)m; i++)
#define FOR(i,n,m) for(long long i=n; i<(ll)m; i++)
#define DUMP(a) for(long long dump=0; dump<(ll)a.size(); dump++) { cout<<a[dump]; if(dump!=(ll)a.size()-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v) sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin>>s;
	if(s[0]==s[1]&&s[1]==s[2]) {
		cout<<"Yes"<<endl;
		return 0;
	}
	if(s[1]==s[2]&&s[2]==s[3]) {
		cout<<"Yes"<<endl;
		return 0;
	}
	cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>

using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long

#define maxN 100011

ll n, L, T, i, j, bonus;
ll x[maxN], aux;
int tp[maxN], sum[13];


int main()
{
  //  freopen("test.in","r",stdin);

    scanf("%lld%lld%lld", &n, &L, &T);
    for (i = 1; i <= n; i++) {
        scanf("%lld%d", &x[i], &tp[i]);
        sum[tp[i]]++;
    }

    bonus = 1LL * (T / L) * (n + sum[1] - sum[2]);
    bonus %= n;

    T %= L;
    for (i = 1; i <= n; i++) {
        if (tp[i] == 1) {
            if (x[i] + T >= L) bonus++;

            aux = x[i] + T;
            aux %= L;
            x[i] = aux;
        } else {
            if (x[i] - T < 0) bonus--;

            aux = x[i] + L - T;
            aux %= L;
            x[i] = aux;
        }
    }

    sort(x + 1, x + n + 1);

    bonus += n;
    bonus %= n;
    for (i = 1 + bonus; i <= n; i++) printf("%lld\n", x[i]);
    for (i = 1; i <= bonus; i++) printf("%lld\n", x[i]);



    return 0;
}


Measured memory_bytes: 2304
#include<iostream>

using namespace std;

int main()
{
    int n;
    int m[6];
    for(int i=0;i<6;i++) cin >> m[i];
    cin >> n;
    int a[5]={m[4],m[0],m[1],m[5],m[4]};
    int b[5]={m[4],m[3],m[1],m[2],m[4]};
    int c[5]={m[2],m[0],m[3],m[5],m[2]};
    for(int i=0;i<n;i++){
        int p=0;
        int x,y;
        cin >> x >> y;
        for(int j=0;j<4;j++){
            if(x==a[j]&&y==a[j+1]){
                cout << m[2] << endl;
                p++;
                break;
            }
            else if(y==a[j]&&x==a[j+1]){
                cout << m[3] << endl;
                p++;
                break;
            }
            else if(x==b[j]&&y==b[j+1]){
                cout << m[0] << endl;
                p++;
                break;
            }
            else if(y==b[j]&&x==b[j+1]){
                cout << m[5] << endl;
                p++;
                break;
            }
            else if(x==c[j]&&y==c[j+1]){
                cout << m[1] << endl;
                p++;
                break;
            }
        }
            if(p==0) cout << m[4] << endl;
    }

    return 0;
}



Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(i,n) for(ll i=0;i<n;++i)
#define ocut cout
#define ouct cout
#define itn int

struct Union{
  vector<ll> par;
  Union(ll a){
  par=vector<ll>(a,-1);
  }
  ll find(ll a){
    if(par[a]<0){
      return a;
    }
    else{
      return par[a]=find(par[a]);
    }
  }
  bool same(ll a,ll b){
    return (find(a)==find(b));
  }
  ll size(ll a){
    return -par[find(a)];
  }
  void unite(ll a,ll b){
    ll c=find(a),d=find(b);
    if(c==d)
      return;
    if(size(c)<size(d)){
      swap(c,d);
    }
    par[c]+=par[d];
    par[d]=c;
  }
};
ll Nagaemon1;
void swap(ll i,ll j){
  Nagaemon1=i;
  i=j;
  j=Nagaemon1;
}
ll euclidean_gcd(ll a, ll b) {
  if(a < b) return euclidean_gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
int main(void){
  ll n;
  cin >> n;
  ll a[n];
  ll ans=0;
  rep(i,n){
    cin >> a[i];
    ans^=a[i];
  }
  ll k;
  rep(i,n){
    k=ans^a[i];
    cout << k << ' ';
  }
}

Measured memory_bytes: 5096
#include <bits/stdc++.h>
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define IFOR(i, m, n) for(int i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
const ll INF = 1e18;
/* テンプレートここまで */

int main() {
  ll a, b; cin >> a >> b;
  if(a<=b) cout << a << endl;
  else cout << a-1 << endl;
}


Measured memory_bytes: 256
//  aoj-1280  / 2015-11-20
#include<iostream>
#include<vector>
#include<cassert>
#include<string>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<tuple>
using namespace std;

typedef long long ll;
typedef pair<ll,ll> pll;
typedef ll int__;
#define rep(i,j) for(int__ i=0;i<(int__)(j);i++)
#define repeat(i,j,k) for(int__ i=(j);i<(int__)(k);i++)
#define all(v) v.begin(),v.end()

template<typename T>ostream& operator << (ostream &os , const vector<T> &v){
    rep(i,v.size()) os << v[i] << (i!=v.size()-1 ? " " : "\n"); return os;
}
template<typename T>istream& operator >> (istream &is , vector<T> &v){
    rep(i,v.size()) is >> v[i]; return is;
}

#ifdef DEBUG
void debug(){ cerr << endl; }
#endif
template<class F,class...R> void debug(const F &car,const R&... cdr){
#ifdef DEBUG
    cerr << car << " "; debug(cdr...);
#endif
}
const int INF = 1<<30;

class UnionFindTree
{
public:
  int Node_num;
  vector<int> parents;
  vector<int> ranks;

  UnionFindTree(int n):Node_num(n+1)
  {
    n++;//index=1_to_n?????????
    parents.resize(n);
    ranks.resize(n);
    for(int i=0;i<n;i++)
      {
	parents[i]=i;
	ranks[i]=0;
      }
  }

  int get_root(int x)
  {
    if(parents[x]==x)return x;
    else 
      {
	//??¢?´¢??¨?????????????????????????????????
	return parents[x]=get_root(parents[x]);
      }
  }

  void unite(int x,int y)
  {
    //??°??????????????????????????±???
    if( (x=get_root(x))!=(y=get_root(y)) )
      {
	//??¨??????????????????????????±????????????
	if(ranks[x]>ranks[y])
	  parents[y]=x;
	else if(ranks[x]<ranks[y])
	  parents[x]=y;
	else
	  {
	    parents[x]=y;
	    ranks[y]++;
	  }
      }
  }

  //x??¨y???????????????????????????
  bool is_sameset(int x,int y)
  {
    return get_root(x)==get_root(y);
  }

};

struct Edge{
    int a,b;
    int w;
};

struct cmp{
    int w;
    cmp(int w):w(w){}
    
    bool operator ()(const Edge &a,const Edge &b){
        int da = a.w - w;
        int db = b.w - w;
        if(da<0)da = INF;
        if(db<0)db = INF;
        return da < db;
    }
};

bool solve(){
    int n,m;cin>>n>>m;
    if(n==0 and m==0)return false;
    vector<Edge> E(m);
    rep(i,m){
        cin>>E[i].a>>E[i].b>>E[i].w;
    }
    vector<Edge> EE = E;
    int ans = INF;
    for(Edge e : E){
        sort(EE.begin(),EE.end(),cmp(e.w));
        UnionFindTree ut(n);
        int mx = -1;
        int cnt =  1;
        rep(i,EE.size()){
            if(ut.is_sameset(EE[i].a, EE[i].b))continue;
            if(EE[i].w < e.w)goto END;
            ut.unite(EE[i].a,EE[i].b);
            mx = max(mx , EE[i].w - e.w);
            cnt++;
            if(cnt==n)break;
        }
        if(cnt==n){
            ans = min(ans,mx);
        }
        
  END:
        ;
    }
    if(ans == INF)cout<<-1<<endl;
    else cout <<ans<<endl;
    
    return true;
}

int main()
{
    ios::sync_with_stdio(false);
    while(solve());
    return 0;
}

Measured memory_bytes: 3276
#include <bits/stdc++.h>
#include <boost/range.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/algorithm_ext.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>
using namespace std;
constexpr char nl = '\n';
using ll = long long;
using boost::irange;
namespace rng { using namespace boost::range; }
namespace adp { using namespace boost::adaptors; }

struct init_ { init_(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(10); } } init_;

template<class C> auto operator>>(istream& in, C& c) -> typename enable_if<!is_void<decltype(c.begin())>::value && !is_same<C, string>::value, istream&>::type {
    for (auto& v : c) { in >> v; } return in; }
template<class C> auto operator<<(ostream& out, const C& c) -> typename enable_if<!is_void<decltype(c.begin())>::value && !is_same<C, string>::value, ostream&>::type {
    int i = 0; for (const auto& v : c) { if (i++) { out << ' '; } out << v; } return out; }
template<size_t N, class T, class R> using when_last = typename enable_if<N == tuple_size<remove_reference_t<T>>::value - 1, R>::type;
template<size_t N, class T, class R> using when_init = typename enable_if<N != tuple_size<remove_reference_t<T>>::value - 1, R>::type;
template<size_t N = 0, class T> auto operator>>(istream& in, T&& t) -> when_last<N, T, istream&> { return in >> get<N>(t); }
template<size_t N = 0, class T> auto operator>>(istream& in, T&& t) -> when_init<N, T, istream&> { return operator>><N + 1>(in >> get<N>(t), forward<T>(t)); }
template<size_t N = 0, class T> auto operator<<(ostream& out, const T& t) -> when_last<N, T, ostream&> { return out << get<N>(t); }
template<size_t N = 0, class T> auto operator<<(ostream& out, const T& t) -> when_init<N, T, ostream&> { return operator<<<N + 1>(out << get<N>(t) << ' ', t); }

#ifdef LOCAL
constexpr auto color_s_ = "\033[2m\033[33m", color_e_ = "\033[0m";
template<class T> void trace_(const T& v) { cerr << v; }
template<class T> void trace_(const vector<vector<T>>& m) { cerr << "\n"; for (const auto& v : m) { trace_(v); cerr << "\n"; } }
template<class T> void trace_(const char* s, const T& v) { cerr << color_s_ << s << "="; trace_(v); cerr << color_e_ << "\n"; cerr.flush(); }
template<class T, class... Ts> void trace_(const char* s, const T& v, const Ts&... vs) { cerr << color_s_; for (; *s != ','; ++s) { cerr << *s; } cerr << "="; trace_(v); cerr << ","; trace_(++s, vs...); }
#define TRACE(...) trace_(#__VA_ARGS__, __VA_ARGS__)
#else
#define TRACE(...)
#endif

bool match(const string& s, int i, const string& t) {
    TRACE(i, s.substr(i, t.size()), t);
    for (int j : irange(0ul, t.size())) {
        if (s[i+j] != '?' && s[i+j] != t[j]) {
            return false;
        }
    }
    return true;
}

int main() {
    string s, t;
    cin >> s >> t;
    for (int i : irange(0ul, s.size() - t.size() + 1) | adp::reversed) {
        if (match(s, i, t)) {
            rng::copy(t, s.begin() + i);
            rng::replace(s, '?', 'a');
            cout << s << nl;
            return 0;
        }
    }
    cout << "UNRESTORABLE" << nl;
}


Measured memory_bytes: 256
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(input())
def inpl(): return list(map(int, input().split()))
def inpl_str(): return list(input().split())

def cal(x,y,a):
    return (x+y*W)*4 + a

def uncal(val):
    a = val%4
    vxy = val//4
    x,y = vxy%W, vxy//W
    return x,y,a

def dijkstra(lines,N,s):
    weight = [INF]*N
    weight[s] = 0
    def search(s,w_0,q,weight):
        for t,w in lines[s]:
            w += w_0
            if weight[t] > w:
                heapq.heappush(q,[w,t])
                weight[t] = w
    q = [[0,s]]
    heapq.heapify(q)
    while q:
        w,n = heapq.heappop(q)
        search(n,w,q,weight)
    return weight



while True:
    N,M,s,g1,g2 = inpl()
    if N == 0 and M == 0:
        break
    else:
        lines1 = defaultdict(set)
        lines2 = defaultdict(set)
        for _ in range(M):
            x,y,c = inpl()
            x,y = x-1,y-1
            lines1[x].add((y,c))
            lines2[y].add((x,c))

        weights_s  = dijkstra(lines1,N,s-1)
        weights_b1 = dijkstra(lines2,N,g1-1)
        weights_b2 = dijkstra(lines2,N,g2-1)

        ans = INF
        for i in range(N):
            tmp = weights_s[i] + weights_b1[i] + weights_b2[i]
            ans = min(ans,tmp)
        print(ans)



Measured memory_bytes: 7572
import java.util.*;

public class Main {
    private static final int MOD = 1_000_000_007;
    private static final String YES = "Yes";
    private static final String NO = "No";

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

        int N = sc.nextInt();
        int[] A = new int[N];
        int[] B = new int[N];
        for (int i=0; i<N; i++) {
            A[i] = sc.nextInt();
            B[i] = sc.nextInt();
        }

        System.out.println(solve3(N, A, B));
    }

    private static long solve3(int N, int[] A, int[] B) {
        long count = 0;

        Arrays.sort(A);
        Arrays.sort(B);

        if (N%2 == 1) {
            count = B[N/2] - A[N/2] + 1;
        } else {
            count = (B[N/2-1] + B[N/2]) - (A[N/2-1] + A[N/2]) + 1;
        }

        return count;
    }

}

Measured memory_bytes: 62156
#include <iostream>
#include <string>
#include <algorithm>
#include <cassert>
#include <limits>
#include <numeric>
#include <type_traits>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <functional>
#include <utility>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <complex>
#include <climits>
#include <queue>

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef pair<ll, ll> P;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)

const double PI = 3.1415926535897932;
/******変数定義start******/
ll n, a, b;
/*******変数定義end*******/

ll solve(){
    cin >> n >> a >> b;
    ll ans;
    if(abs(a-b)% 2 == 1){
        if(n-a>b-1){
            ans = a + abs(b-a - 1)/2;
        }else{
            ans = n-b+1 + abs(b-a - 1)/2;
        }
    }else{
        ans = abs(a-b)/2;
    }
    cout << ans << endl;
    return 0;
}
int main(){

    //clock_t start = clock();
    cout << std::fixed << std::setprecision(10);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll end_solve = solve();
    /*
    clock_t end = clock();
    const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC * 1000.0;
    printf("time %lf[ms]\n", time);
    */
    return (int)end_solve;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int n,i,ac=0,w=0,t=0,r=0;
	char a[4];
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%s",a);
		if(a[0]=='A') ac++;
		else if(a[0]=='W') w++;
		else if(a[0]=='T') t++;
		else if(a[0]=='R') r++;
	}
	printf("AC x %d\n",ac);
	printf("WA x %d\n",w);
	printf("TLE x %d\n",t);
	printf("RE x %d\n",r);
	return 0;
}

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

const int MaxN = 100000;
uint_fast32_t S[ MaxN + 10 ];

int main()
{
uint_fast32_t i;
uint_fast32_t N;
uint_fast32_t M;
uint_fast32_t A;
uint_fast32_t x;
uint_fast32_t iCnt;
uint_fast32_t iSum;

	scanf( "%llu%llu", &N, &M );

	iSum = 0;
	iCnt = 0;
	for( i = 1; i <= N; i++ )
	{
		scanf( "%llu", &A );

		iSum += A;
		iSum %= M;
		S[ i ] = iSum;
	}

	sort( S, S + ( N + 1 ) );

	x = 0;
	for( i = 1; i <= N; i++ )
	{
		if( S[ i - 1 ] == S[ i ] )
			x++;
		else
		{
			iCnt += ( x + 1 ) * x / 2;
			x = 0;
		}
	}

	if( x > 0 ) iCnt += ( x + 1 ) * x / 2;

	printf( "%llu\n", iCnt );

	return 0;
}






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

int main() {
    ll a;
    double b;
    cin>>a>>b;
    ll bb=round(b*100);
    cout<<a*bb/100<<endl;
}


Measured memory_bytes: 3756
N = int(input())
A = list(map(int, input().split(" ")))
B = list(map(int, input().split(" ")))
C = list(map(int, input().split(" ")))
ans = B[A[0] - 1]
for i in range(1, N):
  ans += B[A[i] - 1]
  if A[i - 1] + 1 == A[i]:
    ans += C[A[i - 1] - 1]
  
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using p=pair<int,int>;
const int maxn=100001;

int main(){
	int n;cin>>n;
	vector<p> even(maxn),odd(maxn);
	for(int i=0;i<maxn;i++)even[i]=odd[i]=make_pair(i,0);	
	for(int i=0;i<n;i++){
	int w;cin>>w;
	if(i%2==0)(even[w].second)++;
	else (odd[w].second)++;
	}
	sort(even.begin(),even.end(),[&](p x,p y){return x.second>y.second;});
	sort(odd.begin(),odd.end(),[&](p x,p y){return x.second>y.second;});
	int ans;
	if(even[0].first==odd[0].first)ans=min(n-odd[0].second-even[1].second,n-odd[1].second-even[0].second);
	else ans=n-odd[0].second-even[0].second;
	cout<<ans<<endl;
	
}

Measured memory_bytes: 1792
package main

import (
	"fmt"
	"math"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)

	arr := make([]int,n) //make([]型,キャパシティー) 

	for i := 0; i < n; i++ {
		var a int
		fmt.Scan(&a)

		arr[i] = a
	}

	sort.IntSlice(arr).Sort()

	fmt.Println(int(math.Abs(float64(arr[0] - arr[len(arr)-1]))))

}


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

using namespace std;

#define MAX_N 100

int N,arr[MAX_N];
int dp[MAX_N][MAX_N];

int rec(int L,int R){
  if(L == R){ return dp[L][R] = 0; }
  if(dp[L][R] >= 0){ return dp[L][R]; }
  int res = 0;
  int i = L;
  while(i != R){
    int j = i%N,k = (i+1)%N;
    res = max(res,rec(L,j)+rec(k,R)+abs(arr[L]-arr[k]));
    i++; i %= N;
  }
  return dp[L][R] = res;
}

int main(){
  int Tc;
  cin >> Tc;
  while(Tc--){
    cin >> N;
    for(int i = 0 ; i < N ; i++){
      cin >> arr[i];
    }
    memset(dp,-1,sizeof(dp));
    int res = 0;
    for(int i = 0 ; i < N ; i++){
      int j = (i+N-1)%N;
      res = max(res,rec(i,j));
    }
    cout << res << endl;
  }
  return 0;
}

Measured memory_bytes: 1212
import java.util.*;
import java.io.*;

public class Main{

static BufferedReader s1;
static BufferedWriter out;
static String read() throws IOException{String line="";while(line.length()==0){line=s1.readLine();continue;}return line;}
static int int_v (String s1){return Integer.parseInt(s1);}
static long long_v(String s1){return Long.parseLong(s1);}
static int[] int_arr() throws IOException{String[] a=read().split("\\s+");int[] b=new int[a.length];for(int i=0;i<a.length;i++){b[i]=int_v(a[i]);}return b;}
static long[] long_arr() throws IOException{String[] a=read().split("\\s+");long[] b=new long[a.length];for(int i=0;i<a.length;i++){b[i]=long_v(a[i]);}return b;}
static void assign(){s1=new BufferedReader(new InputStreamReader(System.in));out=new BufferedWriter(new OutputStreamWriter(System.out));}
static int Modpow(int a,int p,int m){int res=1;while(p>0){if((p&1)!=0){res=(res*a)%m;}p >>=1;a=(a*a)%m;}return res;}
//......................................@uthor_Alx..............................................
static long mod=(long)1e9+7;
public static void main(String[] args) throws  IOException{
                assign();
                int[] a=int_arr();
                int r=(int)Math.ceil((double)a[0]/a[1])*a[2];
                out.write(r+"\n");            
                out.flush();

    }
}

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

int main(){
  string a, b, c; cin >> a >> b >> c;
  int aa=a.size();
  int bb=b.size();
  int cc=c.size();
  vector<char> A(aa+1);
  A.at(0)='w';
  for(int i=aa;i>=1;i--){
    A.at(i)=a.at(aa-i);
  }
  vector<char> B(bb+1);
  B.at(0)='w';
  for(int i=bb;i>=1;i--){
    B.at(i)=b.at(bb-i);
  }
  vector<char> C(cc+1);
  C.at(0)='w';
  for(int i=cc;i>=1;i--){
    C.at(i)=c.at(cc-i);
  }
  int turn=1;
  while(true){
    if(turn==1 && A.at(A.size()-1)=='w'){
      cout << "A" << endl;
      return 0;
    }
    if(turn==2 && B.at(B.size()-1)=='w'){
      cout << "B" << endl;
      return 0;
    }
    if(turn==3 && C.at(C.size()-1)=='w'){
      cout << "C" << endl;
      return 0;
    }
    if(turn==1 && A.size()>1){
      if(A.at(A.size()-1)=='a') turn=1;
      if(A.at(A.size()-1)=='b') turn=2;
      if(A.at(A.size()-1)=='c') turn=3;
      A.pop_back();
    }
    if(turn==2 && B.size()>1){
      if(B.at(B.size()-1)=='a') turn=1;
      if(B.at(B.size()-1)=='b') turn=2;
      if(B.at(B.size()-1)=='c') turn=3;
      B.pop_back();
    }
    if(turn==3 && C.size()>1){
      if(C.at(C.size()-1)=='a') turn=1;
      if(C.at(C.size()-1)=='b') turn=2;
      if(C.at(C.size()-1)=='c') turn=3;
      C.pop_back();
    }
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cstring> 
#include<cassert>
#include<cmath>
#include<sstream>
#include<fstream>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<stack>
#include<bitset>
using namespace std;
int main()
{
	int n,a,b,c,d;
	cin>>n>>a>>b>>c>>d;
	for(int i=0;i<n;i++)
	{
		long long r1=1ll*a-1ll*i*d+1ll*(n-1-i)*c,r2=1ll*a-1ll*i*c+1ll*(n-1-i)*d;
//		cout<<i<<" "<<r1<<" "<<r2<<" "<<b<<endl;
		if(r1<=b&&r2>=b)
		{
			cout<<"YES";
			return 0;
		}
	}
	cout<<"NO";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
 
#define pb push_back
 
const int maxi = 1e6+10;
string s;
vector<int> v[maxi];
int n;
long long a[maxi];
 
 
void dfs(int x, int pred)
{
    a[x]+=a[pred];
 
    for (int i:v[x])
        if (i!=pred) dfs(i,x);
}
int main()
{
     int q;
     cin>>n>>q;
 
     for (int i=1;i<n;i++)
     {
         int x,y;
         scanf("%d%d",&x,&y);
         v[x].pb(y);
         v[y].pb(x);
     }
 
     while(q--)
     {
         int x,y;
         scanf("%d%d",&x,&y);
         a[x]+=y;
     }
 
     dfs(1,0);
 
     for (int i=1;i<=n;i++)
        printf("%lld ",a[i]);
 
     printf("\n");
 
    return 0;
}

Measured memory_bytes: 44672
Q, H, S, D = map(int, input().split())
N = int(input())
Q *= 4
H *= 2
l = min(Q, H, S)

if N >= 2:
    n = N // 2
    price = min(2*l*n, D*n) + l*(N%2)
else:
    price = N * l

print(price)

Measured memory_bytes: 3060
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
#include <iostream>
#include <sstream>
#include <set>
using namespace std;


int main()
{
  string s;
  cin >> s;
  cout << s.substr(0, 4) << " " << s.substr(4, 8) << endl;
}


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

using namespace std;
int main(){

  int n, k;
  cin >> n >> k;
  vector<int> A(n);
  vector<int> C(n);




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

    C[0] = 0;
    C[1] = abs(A[1] - A[0]);

    for (int i = 2; i < n; i++){
        C[i] = 10000000000;
    }

  for (int i = 2; i < n; i++){
      for (int j = i; j >= i - k && j >= 0; j--)
          C[i] = min(C[i], C[j] + abs(A[j] - A[i]));
      }


    cout << C[n - 1] << endl;
    return 0;


}

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

int main() {
  int n, k;
  cin >> n >> k;
  
  long ans = k;
  
  if (k != 1){
    for (int i = 1; i < n; i++){
      ans *= (k - 1);
    }
  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 256
import java.awt.Point;
import java.util.ArrayDeque;
import java.util.Queue;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int W = sc.nextInt();
		char[][] c = new char[H][W];
		for(int i = 0; i < H; i++) {
			String s = sc.next();
			for(int j = 0; j < W; j++) {
				c[i][j] = s.charAt(j);
			}
		}
		sc.close();
		int sum = 0;
		for(int i = 0; i < H; i++) {
			for(int j = 0; j < W; j++) {
				if(c[i][j] == '.') {
					sum++;
				}
			}
		}
		Queue<Point> queue = new ArrayDeque<Point>();
		queue.add(new Point(0, 0));
		int[] dx = {1, -1, 0, 0};
		int[] dy = {0, 0, 1, -1};
		int[][] d = new int[H][W];
		boolean[][] vis = new boolean[H][W];
		for(int i = 0; i < H; i++) {
			for(int j = 0; j < W; j++) {
				if(c[i][j] == '.') {
					vis[i][j] = true;
				}else {
					vis[i][j] = false;
				}
			}
		}
		vis[0][0] = false;
		loop: while(!queue.isEmpty()) {
			Point p = queue.poll();
			for(int i = 0; i < 4; i++) {
				int nx = p.x + dx[i];
				int ny = p.y + dy[i];
				if(nx >= 0 && nx < W && ny >= 0 && ny < H) {
					if(vis[ny][nx]) {
						d[ny][nx] = d[p.y][p.x] + 1;
						queue.add(new Point(nx, ny));
						vis[ny][nx] = false;
						if(ny == H - 1 && nx == W - 1) {
							break loop;
						}
					}
				}
			}
		}
		int ans = sum - d[H - 1][W - 1] - 1;
		if(d[H - 1][W - 1] == 0) {
			ans = -1;
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 22740
#pragma GCC optimize(2)
#pragma GCC optimize(3)   
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include<cstdlib>
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds; 
//#define ordered_set tree<pair<int,int>, null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update>
typedef long long ll;
typedef vector < ll > vl;
typedef vector < vl > vvl;
typedef pair < ll, ll > pll;
typedef long double ld;
typedef vector < pair < ll, ll > > vpll;
#define Boost() ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define forn(i,n) for (ll i = 0; i < n; i++)
#define fo(i,n) for (ll i = 1; i <= n; i++)
#define fore(i,l,r) for (ll i = l; i <= r; i++)
#define rev(i,n) for(ll i=n-1;i>=0;i--)
#define all(c) c.begin(), c.end()
#define go(c,it) for(auto it=(c).begin(); it!=(c).end(); it++)
#define back(c,it) for(auto it=(c).rbegin(); it!=(c).rend(); it++)
#define fi first
#define se second
#define MOD 998244353
#define MAX 1000000007
ll power(ll a,ll b){ll res=1;a=a%MOD;while(b>0){if(b&1){res=(res*a)%MOD;}a=(a*a)%MOD;b>>=1;}return res;}
ll fact[500009];
ll fermat_inv(ll y){return power(y,MOD-2);}
ll nCrMod(ll n, ll r){ ll p=fact[n];ll q=(fact[r]*fact[n-r])%MOD;return (p*fermat_inv(q))%MOD;} 
ll gcd(ll a, ll b){return (b==0)?a:gcd(b,a%b);}
const ld PI = acos(-1.0);
vl g[20];

  int main(){
      #ifndef ONLINE_JUDGE
      freopen("input.cpp","r",stdin);
      freopen("output.cpp","w",stdout);
      #endif
      Boost();
      int t;
      //cin>>t;
      t=1;
      int t1=t;
      while(t--)
      {
        ll n,k;
        cin>>n>>k;
        ll a[n+1];
        fo(i,n)
        cin>>a[i];
        vl v;
        // ll p=1;
        // fo(i,k)
        // p*=a[i];
        // v.pb(p);
        ll i;
        for(i=k+1;i<=n;i++)
        {
          if(a[i]>a[i-k])
            cout<<"Yes"<<endl;
          else
            cout<<"No"<<endl;
        }
        // for(i=1;i<v.size();i++)
        // {
        //   if(v[i]>v[i-1])
        //     cout<<"Yes"<<endl;
        //   else
        //     cout<<"No"<<endl;
        // }
      }
      return 0;
      }
  

Measured memory_bytes: 5216
// #define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cmath>
using namespace std;

string nextChar(string in){
	for (int i = 0; i < in.length(); i++){
		// アルファベットなら
		if (in[i] >= 97 && in[i] <= 122){
			// 次に進める
			in[i]++;
			if (in[i] == 123)	in[i] = 97;
		}
	}
	return in;
}

int main(){
	string in;
	while (getline(cin, in)){
		while (1){
			in = nextChar(in);
			if (in.find("the") != string::npos || 
				in.find("this") != string::npos || 
				in.find("that") != string::npos){
				cout << in << endl;
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1180
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int N;
ll L;
string s;

int nxt[200050][2],cnt;

ll lowbit(ll x){return x&-x;}
void insert(string t){
	int p=0; 
	for(int i=0;i<t.size();++i){
		int x=t[i]-'0';
		if(nxt[p][x]==0){
			nxt[p][x]=++cnt;
		}
		p=nxt[p][x];
	}
}
ll query(int p,int d){
	if(!p&&d){return lowbit(L-d+1);}
	return query(nxt[p][0],d+1)^query(nxt[p][1],d+1);
}
void solve(){
	cin>>N>>L;
	//cerr<<N<<" "<<L<<endl; 
	for(int i=1;i<=N;++i){
		cin>>s;
		insert(s);
	}
	//cerr<<cnt<<endl;
	//cerr<<query(0,0)<<endl;
	if(query(0,0)==0)puts("Bob");
	else puts("Alice");
}
int main(){
	solve();
	return 0;
}

Measured memory_bytes: 4352
#pragma GCC optimize ("O3")
#pragma GCC optimize("unroll-loops")
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll

int32_t main()
{
	int n;cin>>n;
	int a[n];
	for(auto &i:a)cin>>i;
	int x=0;
	for(auto i:a)x^=i;
	for(auto i:a){cout<<(x^i)<<' ';}
}

Measured memory_bytes: 5136
#include <iostream>
using namespace std;
int n,rez,sol;
int main()
{
    cin>>n;
    if (n%500==0) cout<<(n/500)*1000;
    else
    {
        rez=n/500;
        sol+=rez*1000;
        n=n-500*rez;
        rez=n/5;
        sol+=rez*5;
        cout<<sol;
    }
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
using ll = long long;
#define in(v) v; cin >> v;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define repi(i,a,b) for(int i=(a),_i=(b);i<_i;++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}

const int MAX_N = 400;
ll sum[MAX_N+1];
ll dp[MAX_N+2][MAX_N+2];
ll dfs(int l, int r) {
  if (l + 1 == r) return 0;
  if (l + 2 == r) return sum[r] - sum[l];
  if (dp[l][r] != -1)
    return dp[l][r];

  ll ans = 1e15;
  rep(i, l+1, r)
    chmin(ans, dfs(l, i) + dfs(i, r) + sum[r] - sum[l]);
  return dp[l][r] = ans;
}
int main() {
  int in(N);
  rep(i, MAX_N+2) rep(j, MAX_N+2) dp[i][j] = -1;

  sum[0] = 0;
  rep(i, N) {
    int in(A);
    sum[i+1] = 0LL + sum[i] + A;
  }
  cout << dfs(0, N) << endl;

  return 0;
}


Measured memory_bytes: 1536
n = int(input().rstrip())
dict = {'AC':0, 'WA':0, 'TLE':0, 'RE':0}

for i in range(n):
  key = input().rstrip()
  dict[key] += 1

print('AC x',dict['AC'])
print('WA x', dict['WA'])
print('TLE x', dict['TLE'])
print('RE x', dict['RE'])


Measured memory_bytes: 9184
s = input()
acgt = ["A","C","G","T"]
cnt = 0
cnt_list = []
for i in range(len(s)):
    if s[i] in acgt:
        cnt +=1
        if s[-1] in acgt:
            cnt_list.append(cnt)
    else:
        cnt_list.append(cnt)
        cnt = 0
print(max(cnt_list))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using ll  = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define erep(e,v) for(auto && e :v)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? 1e9:1e18)
#define EPS 0.0000000001
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
template<class T> void join(T a){for(auto itr :a){if(itr != *a.begin())cout << " "; cout << itr;} }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
signed main(){
    string s; cin >> s;
    bool flag = true;
    flag = (s.front() == 'A');
    s[0] = 'a';
    int cnt = 0;
    for(int i = 2; i < s.size() -1;i++){
        if(s[i] == 'C'){
            cnt++;
            s[i] = 'c';
        }
    }
    int sum = 0;
    rep(i,s.size()){
        if(!('a' <= s[i] and s[i] <= 'z'))sum++;
    }
    cout << ((sum == 0 and flag and cnt == 1) ? "AC" :"WA") << endl;
}




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

int main(void){
    int k = 0, x = 0; 
    int sum = 0;

    scanf("%d%d", &k, &x);

    sum = 500 * k;

    if(sum >= x){
        printf("Yes\n");
    }else{
        printf("No\n");
    }

    return 0;

} 


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

int main()
{
  int num;
  cin >> num;
  set<string> prices = set<string>();
  for (int i = 0; i < num; i++)
  {
    string s;
    cin >> s;
    prices.insert(s);
  }
  cout << prices.size() << endl;
}


Measured memory_bytes: 19152
def resolve():
    MOD = 10 ** 9 + 7
    N = int(input())
    C = sorted(map(int, input().split()))
    P = [1] * (N + 1)
    for i in range(N):
        P[i + 1] *= P[i] * 2
        P[i + 1] %= MOD
    ans = 0
    for i in range(N):
        # 各ビットの係数: (2^r + 2^r-1 * r) * 2^l
        l, r = i, N - i - 1
        now = P[r]
        if r != 0:
            now += P[r - 1] * r
        now *= P[l]
        now *= C[i]
        ans += now
        ans %= MOD
    ans *= P[N]
    print(ans % MOD)


if __name__ == "__main__":
    resolve()

Measured memory_bytes: 31244
#わからんけどとりあえず貪欲
N = int(input())

robots = []
for i in range(N):
    X,L = list(map(int,input().split()))
    robots.append((X-L,X+L))

robots.sort(key=lambda x:x[1])

point = -(10**9)
ans = 0
for i in range(N):
    if point <= robots[i][0]:
        ans += 1
        point = robots[i][1]

print(ans)


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

int main(void){
  int n, ans;
  char flg[101];
  
  cin >> n;
  memset(flg, 0, n+1);
  for (int i=0; i<3; i++){
    int m; cin >> m;
    for (int j=0; j<m; j++){
      int id; cin >> id;
      flg[id] |= 1<<i;
    }
  }
  ans = 0;
  for (int i=1; i<=n; i++){
//    cout << i << ":" << (int)flg[i] << endl;
    if (flg[i]==4 || flg[i]==6 || flg[i]==7){
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3124