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

#define INF 1e9
#define llINF 1e18
#define MOD 1e9+7
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  string str[a];
  for(int i=0;i<a;i++)
    cin>>str[i];
  int vx[4]={1,0,-1,0};
  int vy[4]={0,1,0,-1};
  bool flag=true;
  for(int i=0;i<a;i++){
    for(int j=0;j<b;j++){
      bool flag2=false;
      if(str[i][j]=='.')continue;
      for(int k=0;k<4;k++){
	int x=i+vx[k],y=j+vy[k];
	if(x>=0&&y>=0&&x<a&&y<b){
	  if(str[x][y]=='#')
	    flag2=true;
	}
      }
      if(!flag2){
	//cout<<i<<" "<<j<<endl;
	flag=false;
      }
    }
  }
  if(flag)cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second

ll n,cnt,ans,a[ohara],b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};
pair<ll,ll> p[ohara];

//-------------------------↓↓↓↓↓↓------------------------

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

    cin>>n;
    rep(i,n){
        cin>>a[i];
        p[i]=make_pair(a[i],i);
    }
    sort(p,p+n);
    rep(i,n){
        if(abs(p[i].se-i)%2==1)cnt++;
    }
    Cout(cnt/2);
    return 0;
}


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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 60;
const int mod = 1000000007;
//const int mod = 998244353;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};



int main()
{
  int n, m; cin >> n >> m;
  vector<int> s(m), c(m);
  rep(i, m) cin >> s[i] >> c[i];
  rep(i, m) --s[i];

  for(int i = 0; i < 1000; ++i) {
    string t = to_string(i);
    if(t.size() != n) continue;
    bool ok = true;
    rep(j, m) if(t[s[j]]-'0' != c[j]) ok = false;

    if(ok) {
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
}


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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

typedef long long ll;
typedef pair<ll,ll> P;

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

	string a, b;cin >> a >> b;
	ll ans = 0;
	REP(i, a.size())if(a[i] == b[i])ans++;
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bitset>
#include <iostream>
#include <cmath>

std::bitset<64> hoge(unsigned long long x) {
  const unsigned long long start = (x / 4) * 4;
  std::bitset<64> ans(0);
  for (unsigned long long i = start; i <= x; ++i) {
    ans = ans ^ std::bitset<64>(i);
  }
  return ans;
}

int main() {
  const unsigned int bit = 64;
  unsigned long long a, b;
  std::cin >> a >> b;

  std::bitset<bit> ans(0);
  if (a == 0) {
    ans = hoge(b);
  } else {
    std::bitset<64> a_hoge = hoge(a - 1);
    std::bitset<64> b_hoge = hoge(b);
    ans = a_hoge ^ b_hoge;
  }

  std::cout << ans.to_ullong() << std::endl;

  return 0;
}


Measured memory_bytes: 256
/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
template <typename T>
void cosp(const T n){cout << n << ' ';}
template <typename T>
void co(const T n){cout << n << '\n';}
template <typename T1, typename T2>
void co(pair<T1, T2> p){cout << p.fs << ' ' << p.sc << '\n';}
template <typename T>
void co(const Vec1<T> &v){for(T i : v) cosp(i); cout << '\n';}
template <typename T>
void co(initializer_list<T> v){for(T i : v) cosp(i); cout << '\n';}
template <typename T>
void ce(const T n){cerr << n << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
constexpr ll INF = 1e9+1;
constexpr ll LINF = 1e18+1;
constexpr ll MOD = 1e9+7;
//constexpr ll MOD = 998244353;
constexpr ld PI = acos(-1);
constexpr ld EPS = 1e-11;

int main(void){
	ll a, b;
	cin >> a >> b;
	repn(i, 100000){
		ll c = i * 0.08, d = i * 0.1;
		if(c == a && d == b){
			co(i);
			return 0;
		}
	}
	co(-1);

	return 0;
}


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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll N;
    cin >> N;

    vector<ll> x(N+1);
    for (ll i = 2; i <= N; i++) {
        ll tmp = i;
        for (ll j = 2; j <= tmp; j++) {
            while (tmp > 0 && tmp%j == 0) {
                x[j]++;
                tmp /= j;
            }
        }
    }

    ll ans = 1;
    rep (i, N+1) {
        if (x[i] > 0) {
            ans *= (x[i]+1);
            ans %= MOD;
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <bits/stdc++.h>
using namespace std;
using i32 = int; using i64 = long long int; using f64 = double; using str = string;
template <typename T> using vec = vector<T>;
template <typename T> using heap = priority_queue<T, vec<T>, greater<T>>;
#define times(n, i) for (i32 i = 0; i < (n); ++i)
#define range(a, b, i) for (i32 i = (a); i < (b); ++i)
#define upto(a, b, i) for (i32 i = (a); i <= (b); ++i)
#define downto(a, b, i) for (i32 i = (a); i >= (b); --i)
#define all(xs) (xs).begin(), (xs).end()
#define sortall(xs) sort(all(xs))
#define reverseall(xs) reverse(all(xs))
#define uniqueall(xs) (xs).erase(unique(all(xs)), (xs).end())
#define even(x) (((x) & 1) == 0)
#define odd(x) (((x) & 1) == 1)
#define append emplace_back
#define findge lower_bound
#define findgt upper_bound
const i64 MOD = 1000000007;
const f64 EPS = 1e-10;

i64 n;
i64 m[26];

i32 main()
{
    cin >> n;
    times(26, i) m[i] = LLONG_MAX;
    times(n, i) {
        str s; cin >> s;
        i64 t[26] = {};
        for (char c : s) {
            t[c-'a']++;
        }
        times(26, j) {
            m[j] = min(m[j], t[j]);
        }
    }
    str ans = "";
    times(26, i) {
        if (m[i] == LLONG_MAX) continue;
        times(m[i], j) {
            ans += 'a'+i;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
program festival
  implicit none
  integer(8) :: k, dp(0:600,0:8) = 0_8
  integer :: i, j, l, c, n
  character(5000) :: s = ""
  character(1) :: t
  read(*,*) k
  dp(0,0) = 1_8
  l = 1
  do
    do i = 1, 8
      do j = 0, i
        dp(l,i) = dp(l,i)+dp(l-1,j)
      end do
    end do
    if (dp(l,8) > k) exit
    l = l+1
    if (l > 600) exit
  end do
  n = 0
  do i = l-1, 1, -1
    c = k/dp(i,8)
    do j = n+1, n+c
      s(j:j) = "L"
    end do
    n = n+c
    s(n+1:n+7) = "AVITSEF"
    n = n+7
    k = k-int(c,8)*dp(i,8)
  end do
  do i = 1, n/2
    t = s(i:i)
    s(i:i) = s(n-i+1:n-i+1)
    s(n-i+1:n-i+1) = t
  end do
  write(*,'(a)') trim(s)
end program festival

Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
	}
	counter := 0
	positiveA := make([]int, n)
	for i := 0; i < n; i++ {
		if a[i] < 0 {
			positiveA[i] = -a[i]
			counter++
		} else {
			positiveA[i] = a[i]
		}
	}
	sort.Sort(sort.IntSlice(positiveA))
	sum := 0
	for _, x := range positiveA {
		sum += x
	}

	if (counter % 2) == 0 {
		fmt.Println(sum)
	} else {
		fmt.Println(sum - 2*positiveA[0])
	}

}


Measured memory_bytes: 5504
#include <set>
#include <map>
#include <list>
#include <stack>
#include <queue>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
#define int long long


signed main(void){
  int n,c,k;
  cin >> n >> c >> k;
  vector<int> t;
  int buf;

  for(int i = 0; i < n; i++){
    cin >> buf;
    t.push_back(buf);
  }
  sort(t.begin(), t.end());

  int ret = 0;
  int i = 1;
  int first = 0;
  while(i < n){
    //cout << i << first  << "\r\n";
    if(t[i]- t[first] > k){
      first = i;
      ret++;
    }else if(i - first >= c){
      first = i;
      ret++;
    }else{
      i++;
    }
  }

  cout << ret+1 << "\r\n";

  return 0;
}


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

using namespace std;

int judge(double sum)
{
    double distance = sqrt(sum);

    if(distance == ceil(distance)){
        return 1;
    }else{
        return 0;
    }

}

int main()
{
    int N = 0, dimension = 0;

    cin >> N >> dimension;
    vector<vector<int>> data(N, vector<int>(dimension));

    for(int i = 0; i < N; i++){
        for(int j = 0; j < dimension; j++){
            cin >> data.at(i).at(j);
        }
    }


    int ans = 0, result = 0;

    for(int i = 0; i < N; i++){
        for(int j = 1 + i; j < N; j++){
            double sum = 0;
            //ここ計算
            for(int k = 0; k < dimension; k++){
                sum += pow(data.at(i).at(k) - data.at(j).at(k), 2);
            }

            //cout << i << " " << j  << ":" << sqrt(sum) << endl;
            result = judge(sum);

            if(result == 1){
                ans++;
            }
        }
    }

    cout << ans << endl;

    return 0;
}



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

int main(void)
{
  int n;
  int r, rmin, rmax;
  cin >> n;
  cin >> rmin;
  rmax = -1000000000;
  for (int i=0; i<n-1; ++i) {
    cin >> r;
    if ((r - rmin) > rmax) rmax = r - rmin;
    if (r < rmin) rmin = r;
  }
  cout << rmax << endl;
}

Measured memory_bytes: 1164
#include <stdio.h>
#define K 50

int main(void){
  int x,y;
  int w,b;
  char grid[2*K][2*K];
  
  /* Init Grid */
  for( x=0; x<2*K; x++) for( y=0; y<K; y++){
    grid[x][y] = '#'; // Black
  }
  for( x=0; x<2*K; x++) for( y=K; y<2*K; y++){
    grid[x][y] = '.'; // White
  }
  
  scanf("%d %d",&w,&b);
  
  for( x = 0, y = 0; 1 < w; w--){
    grid[x][y] = '.'; //White
    
    x += 2;
    if(x > 2*K-1){
      x=0;
      y+=2;
    }
  }
  
  for( x = 0, y =K+1; 1 < b; b--){
    grid[x][y] = '#'; //Black
    
    x += 2;
    if(x > 2*K-1){
      x=0;
      y+=2;
    }
  }
  
  printf("%d %d\n",2*K,2*K);
  for( y=0; y<2*K; y++) for( x=0; x<2*K; x++){
    printf("%c",grid[x][y]);
    if(x == 2*K-1) printf("\n");
  }
  
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
using namespace __gnu_pbds;
using namespace std;

typedef long long int lli;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<lli> vli;
typedef vector<pii> vii;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> OrderedSet;

const int MOD	= 1e9 + 7;
const double PI = acos(-1.0);

#define fastio			ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(auto &i : c)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define fill(a)  memset(a, 0, sizeof (a))
#define error(x) cerr << #x << " = " << (x) << endl
#define errorp(p) cerr << #p << " = " << (p.first) << ", " << (p.second) << endl

template<typename T> T gcd(T a, T b){return(b?__gcd(a,b):a);}
template <typename T> T lcm(T a, T b){return (a*b)/gcd(a,b); }
int mul(int a, int b, int c){lli res=(lli)a*b;return (int)(res>=c?res%c:res);}
template<typename T>T power(T e, T n, T m){T x=1,p=e;while(n){if(n&1)x=mul(x,p,m);p=mul(p,p,m);n>>=1;}return x;}
int mod_neg(int a, int b, int c){int res;if(abs(a-b)<c)res=a-b;else res=(a-b)%c;return(res<0?res+c:res);}
template<typename T>T extended_euclid(T a, T b, T &x, T &y){T xx=0,yy=1;y=0;x=1;while(b){T q=a/b,t=b;b=a%b;a=t;\
t=xx;xx=x-q*xx;x=t;t=yy;yy=y-q*yy;y=t;}return a;}
template<typename T>T mod_inverse(T a, T n){T x,y,z=0;T d=extended_euclid(a,n,x,y);return(d>1?-1:mod_neg(x,z,n));}
template <class T>  inline void smax(T &x,T y){ x = max((x), (y));}
template <class T>  inline void smin(T &x,T y){ x = min((x), (y));}


int main(){
    // #ifndef ONLINE_JUDGE
	// 	freopen("test", "r", stdin);
	// #endif
    fastio;
    
    lli A, B, N;
    cin >> A >> B >> N;
    lli ans = 0;
    ans = (A * min(N, B - 1) ) / B;
    

    cout << ans << endl;

    return 0;
}


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

#define mp make_pair
#define pb push_back


typedef long long ll;
typedef long long llong;
typedef long double ld;

using namespace std;

template <typename T> void dprint(T begin, T end) {
    for (auto i = begin; i != end; i++) {
        cerr << (*i) << " ";
    }
    cerr << "\n";
}

int n, m;
int x[120000];
int y[120000];
int rq[410][410];
int fl[410];

int main() {
    cin >> n >> m;
    for (int i = 0; i < m; ++i) {
        cin >> x[i] >> y[i];
        --x[i], --y[i];
    }
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j)
            rq[i][j] = 0;
        rq[i][i] = 1;
        for (int j = m - 1; j >= 0; --j) {
            if (rq[i][x[j]]) {
                if (rq[i][y[j]]) {
                    fl[i] = 1;
                    break;
                }
                else {
                    rq[i][y[j]] = 1;
                }
            }
            else {
                if (rq[i][y[j]]) {
                    rq[i][x[j]] = 1;
                }
            }
        }
    }
    int ans = 0;
    for (int i = 0; i < n; ++i)
        for (int j = i + 1; j < n; ++j) {
            if (fl[i] || fl[j])
                continue;
            int ffl = 0;
            for (int k = 0; k < n; ++k)
                if (rq[i][k] && rq[j][k])
                    ffl = 1;
            if (!ffl)
                ans += 1;
        }
    cout << ans << "\n";
    return 0;
}




Measured memory_bytes: 1664
import java.util.*;

public class Main {
  public static void main(String[] args ) throws Exception {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();

    if((a * b) % 2 == 0) {
        System.out.println("Even");
    } else {
        System.out.println("Odd");
    }
  }
}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
#define int long long

// typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

// rep
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
#define DEBUG(x) cerr << #x << ": " << x << '\n'

int n;
int k;

VI v;
map<int, int> mp;


signed main()
{
    cin >> n >> k;
    int temp;
    REP(i, n){
        cin >> temp;
        if (mp[temp] != 0){ 
            mp[temp]++; 
        }else {
            mp[temp] = 1;
        }
    }

    for (auto itr = mp.begin(); itr != mp.end(); itr++){
        v.push_back(itr-> second);
    }

    sort(ALL(v));

    int res = 0;
    int cnt = 0;

    if (v.size() > k){
        for (int i = 0; i < v.size() - k; i++){
            res += v[i];
        }
    }
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 14964
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using P = pair<ll, ll>;

constexpr double PI = 3.14159265358979323846;
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

class DBrickBreak {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int n; cin >> n;
      vector<int> a(n);
      rep(i, n) {
        cin >> a[i];
      }
      int k = 1;
      rep(i, n) {
        if (a[i] == k) {
          k++;
        }
      }
      if (k==1) {
        cout << -1 << endl;
        return;
      }
      cout << n-k+1 << endl;
    }
};

signed main() {
  DBrickBreak solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var inputs = new List<string>();

            // 入力が終わるまで全行読み込む
            for (int i = 0; i < 1; i++) 
            {

                string input = Console.ReadLine();
                if (input == null)
                    break;
                else
                    inputs.Add(input);
            };

            String[] temp = inputs[0].Split(' ');
            int A = int.Parse(temp[0]);
            int B = int.Parse(temp[1]);

            if(A >= 13)
            {
                Console.WriteLine(B);
            } else if ( A <= 5)
            {
                Console.WriteLine(0);
            }
            else
            {
                Console.WriteLine(B / 2);
            }

            return;
        }
    }
}


Measured memory_bytes: 13140
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int answer=1;
        List<Integer> list = new ArrayList<>();
        boolean returnFlag=false;
        
        list.add(a);
        answer+=1;
        if(a%2!=0){
            a=3*a+1;
        }else{
            a=a/2;
        }

        if(list.contains(a)){
            System.out.println(answer);
            return;
        }
        
        while(!returnFlag){
            list.add(a);
            answer+=1;
            if(a%2!=0){
                //奇数の時
                a=3*a+1;
                
            }else{
                a=a/2;
            }

            if(list.contains(a)){
                System.out.println(answer);
                return;
            }
        }    
    }
}


Measured memory_bytes: 21972
import java.util.Scanner;
 
public class Main{
		
	public static void main(String args[]){
		  
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int k = sc.nextInt();
		String s = sc.next();
		
		int no = (int)s.charAt(k-1) - (int)'A' + (int)'a';
        char c = (char)no;
        
        String out = "";
        for(int i = 0; i < s.length(); i++) {
        	if(i == k-1) {
        		out += c;
        	}else {
        		out += s.charAt(i);
        	}
        }
        
        System.out.println(out);
		
		
		
	}
}


Measured memory_bytes: 21844
#include <iostream>
#include <queue>
#include <algorithm>
#include <string>
#include <utility>
#include <vector>
#include <map>
#include <stack>
#include <iomanip>
#include <set>
#include <sstream>
#include <cmath>
#include <deque>
#include <list>
#include <bitset>
using namespace  std;
typedef pair<long long , long long> P;
typedef long long ll;
typedef long long lint;
#define REP(i, n) for(long long (i)=0; (i)<(n); ++i)
#define FOR(i, a, b) for(long long (i)=(a); (i)<(b); ++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define FST first
#define SND second

signed main(){
    lint N, K; cin>>N>>K;
    vector<lint> V(N);
    REP(i, N) cin>>V[i];
    vector<lint> C(N+1, 0);
    REP(i, N) C[i+1] = C[i] + V[i];
    lint res = 0;
    for(lint l=0; l<=N; l++){
        for(lint r=0; r<=N-l and l+r<=K; r++){
            lint k= K-l-r;
            priority_queue<lint, vector<lint>, greater<lint> > pq;
            REP(i, l) if(V[i]<0) pq.push(V[i]);
            FOR(i, N-r, N) if(V[i]<0) pq.push(V[i]);
            lint sc = C[l] - C[0] + C[N] - C[N-r];
            //cout << sc << " "; 
            while(k and pq.size()){
                sc -= pq.top(); pq.pop();
                k--;
            }
            res = max(res, sc);
            //cout << sc << endl;
        }
    }
    cout << res << endl;
    return 0;
}

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

int main()
{

    int a1,a2,a3;
    cin>>a1>>a2>>a3;
    vector<int>v;
    v.pb(a1);
    v.pb(a2);
    v.pb(a3);
    sort(v.begin(),v.end());
    cout<<v[2]-v[0]<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#include <iomanip>
//#pragma GCC optimize("Ofast")  //デバッグ時にoptimized-outされて邪魔だった
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define floatprec(dig) fixed << setprecision(dig)
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
#define invar(typ, var) typ var; cin >> var;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;

signed main(void) {
  cin.tie(0); ios::sync_with_stdio(false);
  
  invar(int, r);
  
  fin(r * r);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 105;
char str[N];
int main()
{
    int n;
    int ans = 0;
    scanf(" %s",str+1);
    n = strlen(str+1);
    for(int i=1;i<=n/2;i++) ans+=str[i]!=str[n-i+1];
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[6]= {100,101,102,103,104,105},n,dp[1000002];
int main()
{
    scanf("%d",&n);
    dp[0]=1;
    for(int i=0; i<6; i++)
        for(int j=a[i]; j<=n; j++)
            dp[j]=dp[j]+dp[j-a[i]];
    if(dp[n])
        printf("1");
    else
        printf("0");
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int,int> pii;
typedef long long ll;
const long long MOD=1000000007;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep2(i,m,n) for(ll i=(m);i<(n);i++)
#define ALL(v) v.begin(), v.end()
#define pb push_back





int main(){

    string n;
    cin>>n;

    int  keta=int(n.size());

    ll sum=0;

    rep(i,keta){
        sum+=(n.at(i)-'0');
    }

    if (sum%9==0){
        cout<<"Yes"<<endl;
    }

    else {
        cout<<"No"<<endl;
    }

    

}

Measured memory_bytes: 3712
shared void main(){
  assert(exists sve=process.readLine());
  value tve=sve.split();
  //assert(exists v=parseInteger(tve.first));
  assert(exists e=parseInteger(tve.last));
  for(_ in 0:e+1){
    process.readLine();
  }
  assert(exists stmax=process.readLine());
  assert(exists tmax=parseInteger(stmax));
  for(_ in 0:tmax){
    print(-1);
  }
}

Measured memory_bytes: 193168
#include<stdio.h>
#include<algorithm>
#include<iostream>
using namespace std;

int main(){

  int i;
  int a[5]={0};

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

  sort(a,a+5,greater<int>());

  printf("%d %d %d %d %d\n",a[0],a[1],a[2],a[3],a[4]);

  return 0;
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
#define MAX_L 101
using namespace std;

int w, h;
int x = 0, y = 0;
char table[MAX_L+1][MAX_L+1];
bool used[MAX_L+1][MAX_L+1];

void forward(char operate) {
    
    switch(operate) {
            case '^':
            y--; break;
            case 'v':
            y++; break;
            case '>':
            x++; break;
            case '<':
            x--; break;
        default: break;
    }
}

void solve() {
    x = 0; y = 0; memset(used, false, sizeof(used));
    while(table[y][x] != '.' && !used[y][x]) {
        //printf("%d %d\n", x, y);
        used[y][x] = true;
        forward(table[y][x]);
    }
    if(used[y][x])
    {
        puts("LOOP");
    } else {
        printf("%d %d\n", x, y);
    }
}

int main(void) {
    while(cin >> h >> w, w|h) {
        for(int r = 0; r < h; r++) {
            for(int c = 0; c < w; c++) {
                cin >> table[r][c];
            }
        }
        solve();
    }
    return(0);
}

Measured memory_bytes: 1176
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;
int main(){
    int n,x,t;
    cin >> n >> x >> t;
    int time = (n+x-1)/x;
    cout<<time*t<<endl;
    return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <bitset>

using namespace std;
typedef pair<int, int> Pi;
typedef long long ll;
#define pii Pi
#define pll PL
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define sz(x) ((int)(x).size())
#define rep(i, n) for(int i=0;i<n;i++)
#define all(x) (x).begin(), (x).end()
typedef tuple<int, int, int> t3;
typedef pair<ll, ll> PL;
typedef long double ldouble;

void solve(){
	ll n; cin >> n;
	vector <int> v;
	while(n > 1){
		if(n & 1)v.pb(1), n = (n-1) / 2;
		else v.pb(0), n = n - 1;
	}
	vector <int> a, b;
	a.pb(1); b.pb(1);
	reverse(all(v));
	int t = 1;
	for(int e : v){
		++t;
		if(e == 0){
			a.pb(t);
			reverse(all(b));
			b.pb(t);
			reverse(all(b));
		}
		else{
			a.pb(t);
			b.pb(t);
		}
	}
	printf("%d\n", sz(a) + sz(b));
	for(int e : a)printf("%d ", e);
	for(int e : b)printf("%d ", e); puts("");
}

int main(){
	int Tc = 1; // scanf("%d\n", &Tc);
	for(int tc=1;tc<=Tc;tc++){
		solve();
	}
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    long N, K;
    cin >> N >> K;

    long min_1 = N % K;

    long min_2 = min_1 - K;
    if (min_2 < 0) min_2 *= -1;

    if (min_1 < min_2) cout << min_1;
    else cout << min_2;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 2500005

ll M,N,m_0,m_d,n_0,n_d;
ll to_carrot[NUM],to_kiwi[NUM];
ll ruiseki_carrot[NUM],ruiseki_kiwi[NUM];

ll calc(int carrot_index,int kiwi_index){
	return (M-carrot_index)*(N-kiwi_index)+ruiseki_carrot[carrot_index]+ruiseki_kiwi[kiwi_index];
}

int main(){

	scanf("%lld %lld %lld %lld %lld %lld",&M,&N,&m_0,&m_d,&n_0,&n_d);

	to_carrot[0] = m_0;
	for(int i = 1; i < M; i++){
		to_carrot[i] = (to_carrot[i-1]*58+m_d)%(N+1);
	}

	to_kiwi[0] = n_0;
	for(int i = 1; i < N; i++){
		to_kiwi[i] = (to_kiwi[i-1]*58+n_d)%(M+1);
	}

	sort(to_carrot,to_carrot+M);
	sort(to_kiwi,to_kiwi+N);

	ruiseki_carrot[0] = 0;
	for(int i = 1; i <= M; i++){
		ruiseki_carrot[i] = to_carrot[i-1];
		ruiseki_carrot[i] += ruiseki_carrot[i-1];
	}

	ruiseki_kiwi[0] = 0;
	for(int i = 1; i <= N; i++){
		ruiseki_kiwi[i] = to_kiwi[i-1];
		ruiseki_kiwi[i] += ruiseki_kiwi[i-1];
	}

	int kiwi_index = N;

	ll ans = ruiseki_kiwi[kiwi_index];

	for(int carrot_index = 1; carrot_index <= M; carrot_index++){
		while(kiwi_index > 0 && calc(carrot_index,kiwi_index-1) <= calc(carrot_index,kiwi_index)){
			kiwi_index--;
		}
		ans = min(ans,calc(carrot_index,kiwi_index));
	}

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

	return 0;
}



Measured memory_bytes: 81432
from bisect import*
class BTreeNode:
    def __init__(self):self.key,self.child=[],[]
class BTree:
    def __init__(self):self.root=BTreeNode()
    def search_higher(self,key):
        ptr=self.root
        ret=None
        while ptr.child:
            i=bisect(ptr.key,key)
            if i!=len(ptr.key):ret=ptr.key[i]
            ptr=ptr.child[i]
        i=bisect(ptr.key,key)
        if i!=len(ptr.key):ret=ptr.key[i]
        return ret
    def search_lower(self,key):
        ptr=self.root
        ret=None
        while ptr.child:
            i=bisect_left(ptr.key,key)
            if i:ret=ptr.key[i-1]
            ptr=ptr.child[i]
        i=bisect_left(ptr.key,key)
        if i:ret=ptr.key[i-1]
        return ret
    def insert(self,key):
        def insert_rec(ptr):
            b_size=256
            if not ptr.child:
                insort(ptr.key,key)
                if len(ptr.key)==b_size*2-1:
                    ret=BTreeNode()
                    ret.key=ptr.key[:b_size]
                    ptr.key=ptr.key[b_size:]
                    return ret
            else:
                i=bisect(ptr.key,key)
                tmp=insert_rec(ptr.child[i])
                if tmp:
                    ptr.key.insert(i,tmp.key.pop())
                    ptr.child.insert(i,tmp)
                    if len(ptr.child)==b_size*2:
                        ret=BTreeNode()
                        ret.child=ptr.child[:b_size]
                        ptr.child=ptr.child[b_size:]
                        ret.key=ptr.key[:b_size]
                        ptr.key=ptr.key[b_size:]
                        return ret
        tmp=insert_rec(self.root)
        if tmp:
            root=BTreeNode()
            root.key=[tmp.key.pop()]
            root.child=[tmp,self.root]
            self.root=root
def main():
    n,*a=map(int,open(0).read().split())
    l=[0]*n
    for i,v in enumerate(a,1):l[v-1]=i
    t=BTree()
    t.insert(0)
    t.insert(n+1)
    c=0
    for i,v in enumerate(l,1):
        c+=(t.search_higher(v)-v)*(v-t.search_lower(v))*i
        t.insert(v)
    print(c)
main()

Measured memory_bytes: 25884
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <utility>
#include <map>
#include <set>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) int((x).size())
#define OUT(x) cout << (x) << endl;
typedef long long ll;
typedef pair<int, int> P;

int main(){
    int n,k;
    cin >> n >> k;
    map<int, int> a;
    for(int i = 0; i < n; i++)
    {
        int tmp;
        cin >> tmp;
        a[tmp]++;
    }
    int change = SZ(a) - k;
    vector<int> num;
    for(P p : a){
        num.push_back(p.second);
    }
    sort(ALL(num));
    int ans = 0;
    for(int i = 0; i < change; i++)
    {
        ans += num[i];
    }
    OUT(ans);
}

Measured memory_bytes: 10748
#![allow(unused)]

use std::cmp;
use std::io::{self, BufRead};
use std::iter;

macro_rules! destruct_ {
  ($e: expr, ()) => (
    assert!($e.next().is_none())
  );
  ($e: expr, ($arg: ident, $( $args: ident, )*)) => (
    $arg = $e.next().unwrap();
    destruct_!($e, ($($args,)*))
  );
  ($e: expr, ($arg: ident $(, $args: ident )*)) => (
    $arg = $e.next().unwrap();
    destruct_!($e, ($($args,)*))
  );
}

macro_rules! into {
  ($e: expr, $($name: ident)*) => {
    let mut iter = $e.into_iter();
    destruct_!(iter, ($($name)*));
  }
}

macro_rules! get {
  ($i: ident) => (
    let stdin = io::stdin();
    let mut $i = Vec::new();
    for line in stdin.lock().lines() {
      $i.push(
        line
          .unwrap()
          .split_whitespace()
          .map(|a| a.parse().unwrap())
          .collect()
      );
    }
  )
}

macro_rules! p {
  ($a: expr) => (
    println!("{}", $a);
  )
}

macro_rules! pp {
  ($a: expr) => (
    println!("{:?}", $a);
  )
}

fn main() {
  let mut args: Vec<Vec<String>>;
  let mut ss: Vec<String>;
  let mut s: String;
  get!(args);
  into!(args, ss);
  into!(ss, s);

  let bs = s.as_bytes();
  for a in 0 .. bs.len() {
    for b in 0 .. bs.len() {
      if a != b && bs[a] == bs[b] {
        p!("no");
        return;
      }
    }
  }
  p!("yes");
}


Measured memory_bytes: 4352
#include <iostream>
#include <math.h>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

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


Measured memory_bytes: 256
#include<stdio.h>
main(){
int s[9000],n,m,t,f,i;
while(scanf("%d%d",&n,&m),i=0,t=f=1,n)
	while(++i<=n+m)
		if(scanf("%d",&s[i]),i>n)if(t+=s[t+=s[i]],t>=n&f==1)
			printf("%d\n",i-n,f=0);
	
}

Measured memory_bytes: 0
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<string>
#include<unordered_map>
#include<set>
using namespace std;

#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j,k
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define all(a) a.begin(),a.end()
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define sizeoof(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
/*約数*/vector<ll>div(ll a){vector<ll>b;ll i;rep(i,1,a){if(!a%i)push(b,a);}return b;}
llfor;///////////////////////////////////////////////////////////
int main(){
 double pi=acos(-1);
 int r;sc(r);
 printf("%.10lf\n",pi*2*r);
return 0;}



Measured memory_bytes: 3692
let () = Scanf.scanf "%d %d %d\n" @@ fun n m p ->
  let abc = Array.init m @@ fun _ ->
    Scanf.scanf "%d %d %d\n" @@ fun a b c -> a - 1, b - 1, c - p in
  let d = Array.make n (-1145141919) in
  let ng = Array.make n false in
  d.(0) <- 0;
  for i = 0 to 2 * n - 1 do
    Array.iter (fun (a, b, c) ->
      if d.(b) < d.(a) + c then begin
        d.(b) <- d.(a) + c;
          if n - 1 <= i then
            ng.(b) <- true
      end) abc
  done;
  if ng.(n - 1)
  then print_endline "-1"
  else Printf.printf "%d\n" @@ max 0 d.(n - 1)

Measured memory_bytes: 4864
import bisect


def main():
    n, k = map(int, raw_input().split())
    xx = map(int, raw_input().split())
    yy = [0]
    for i in range(1, n):
        yy.append(yy[-1] + xx[i] - xx[i - 1])

    ori = bisect.bisect_left(xx, 0)
    best = float('inf')
    for i in xrange(max(0, ori - k), min(n - k + 1, ori + 1)):
        dest = yy[i + k - 1] - yy[i] + min(abs(xx[i]), abs(xx[i + k - 1]))
        best = min(dest, best)
    print(best)


if __name__ == '__main__':
    main()


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

int main() {
  string a,b;
  int c=0;
  cin >> a >> b;
  for (int i=0; i<a.length(); i++) {
    if (a.at(i) == b.at(i)) c++;
  }
  cout << c << endl;
}


Measured memory_bytes: 3592
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
using namespace std;

typedef long long ll;
#define modulo 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9

int N, C;
bool tv[31][100001]; // tv[i][j] : チャンネルiで時間j～j+1に番組がある

void input() { // 重複がないのでtvの数以下の回数で済む
	cin >> N >> C;
	for (int i = 0; i < N; i++) {
		int s, t, c;
		cin >> s >> t >> c;
		for (int j = s - 1; j < t; j++) tv[c][j] = true;
	}
}

void solve() {
	int ans = 0;
	for (int j = 0; j < 100001; j++) {
		int tmp = 0;
		for (int i = 1; i <= C; i++) tmp += tv[i][j];
		ans = max(ans, tmp);
	}

	cout << ans << endl;
}

int main() {
	input();
	solve();

	return 0;
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1ll << 61);
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int r;
	cin >> r;
	if (r < 1200) cout << "ABC" << endl;
	else if (r < 2800) cout << "ARC" << endl;
	else cout << "AGC" << endl;
	return 0;
}

Measured memory_bytes: 3648
package main

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

func main() {
	n, k := readInt(), readInt()
	s := readBytes()

	unhappy := 0
	for i := range s {
		if i == n-1 {
			continue
		}
		if s[i] == 'R' && s[i+1] == 'L' {
			unhappy += 2
		}
	}
	if s[0] == 'L' {
		unhappy++
	}
	if s[n-1] == 'R' {
		unhappy++
	}

	if unhappy <= 2*k {
		fmt.Println(n - 1)
	} else {
		fmt.Println(n - (unhappy - 2*k))
	}
}

// sort ------------------------------------------------------------

type xxx struct {
	x int
}

type sortArray []xxx

func (s sortArray) Len() int           { return len(s) }
func (s sortArray) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s sortArray) Less(i, j int) bool { return s[i].x < s[j].x }

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

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func gcd(m, n int) int {
	for m%n != 0 {
		m, n = n, m%n
	}
	return n
}

func lcm(m, n int) int {
	return m / gcd(m, n) * n
}


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

using std::pair;
using std::vector;
using std::string;

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

#define fst first
#define snd second
#define pb(a) push_back(a)
#define mp(a, b) std::make_pair(a, b)
#define debug(...) fprintf(stderr, __VA_ARGS__)

template <typename T> bool chkmax(T& a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> bool chkmin(T& a, T b) { return a > b ? a = b, 1 : 0; }

const int oo = 0x3f3f3f3f;

string procStatus() {
    std::ifstream t("/proc/self/status");
    return string(std::istreambuf_iterator<char>(t), std::istreambuf_iterator<char>());
}

template <typename T> T read(T& x) {
    int f = 1; x = 0;
    char ch = getchar();
    for(;!isdigit(ch); ch = getchar()) if(ch == '-') f = -1;
    for(; isdigit(ch); ch = getchar()) x = x * 10 + ch - 48;
    return x *= f;
}

const int N = (int) 3e5;

int n;
int ans[2], a[N + 5];

int main() {
#ifdef Wearry
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif

    read(n);
    for(int i = 1; i <= n; ++i) {
        read(a[i]), ans[i & 1] += a[i];
    }

    if(n & 1) {
        int l = 0, r = ans[0];

        while(l < r) {
            int mid = (l + r + 1) >> 1, cur = 0, lst = 0;
            for(int i = 1; i <= n; ++i) {
                if(!(i & 1)) {
                    if(ans[0] + cur - lst >= ans[1] + mid) {  
                        chkmin(lst, cur - a[i]);
                    }
                }
                cur += (i & 1) ? a[i] : -a[i];
            }

            if(ans[0] + cur - lst >= ans[1] + mid) {
                l = mid;
            } else {
                r = mid - 1;
            }
        }
        printf("%d %d\n", ans[1] + l, ans[0] - l);
    } else {
        if(ans[0] < ans[1])
            std::swap(ans[0], ans[1]);
        printf("%d %d\n", ans[0], ans[1]);
    }

    return 0;
}


Measured memory_bytes: 1408
from collections import deque

S = list(input())
S.reverse()
l = len(S)

def rev(x):
    x = list(x)
    x.reverse()
    return x

a = list(map(rev,['dream','dreamer','erase','eraser']))
q = deque()
q.append(["",0])

while len(q):
    b,i = q.pop()
    if i == l:
        print('YES')
        exit()
    x = 0
    f = True
    for B in b:
        if i+x >= l or S[i+x] != B:
            f = False
        x += 1
    if f:
        for A in a:
            q.append([A,i+x])

print('NO')


Measured memory_bytes: 7576
n=int(input())

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

yakusu = factorization(n)

ans = 0

for i in range(len(yakusu)):
    l = yakusu[i]
    a,b = l[0],l[1]
    j = 1
    k = 2
    if a != 1:
        while b>=j:
            ans += 1
            j += k
            k += 1
if n==1:
    print(0)
else:
    print(max(ans,1))

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

int main(){
	int x, h, m, s;
	cin >> x;
	s = x % 60;
	m = (x - s) / 60 % 60;
	h = (x - s - 60 * m) / 3600;
	cout <<h <<":"<<m<<":"<<s<< endl;

	return 0;
}


Measured memory_bytes: 1164