akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <set>
#include <map>

#pragma GCC optimize(2)

#define ll long long
#define ull unsigned long long

#define gc (c = getchar())
#define gi(x) scanf("%d", &x)
#define gid(x, y) scanf("%d%d", &x, &y)
#define gll(x) scanf("%lld", &x)
#define glld(x, y) scanf("%lld%lld", &x, &y)

#define pi(x) printf("%d\n", x)
#define pr(x) return !(printf("%lld\n", (long long)(x)))
#define pcs(ch, cs, x) printf("Case %s%d: %d\n", ch, cs, x)
#define pllcs(ch, cs, x) printf("Case %s%d: %lld\n", ch, cs, x)
#define pyncs(cs, st) printf("Case %s%d: %s\n", ch, cs, (st) ? "YES" : "NO")
#define pyn(st) printf("%s\n", (st) ? "yes" : "no")
#define pryn(st) return !(printf("%s\n", (st) ? "YES" : "NO"))
#define pll(x) printf("%lld\n", x)

#define dbg(x) std::cerr << #x << " " << x << std::endl
#define fi(x) freopen("in.txt", "r", stdin)
#define fo(x) freopen("out.txt", "w", stdout)

inline ll abs(ll x) { return x > 0 ? x : -x; }
inline ll max(ll x, ll y) { return x > y ? x : y; }
inline ll min(ll x, ll y) { return x > y ? y : x; }
inline ll gcd(ll x, ll y) { return y == 0 ? x : gcd(y, x % y); }

const int lm = -1000000;
const int rm = 1000000;
std::map<std::string,long long > vis;
int main(){
    int n;
    std::string str;
    std::cin >> n;

    for(int i =1;  i<= n; ++ i){
        std::cin >> str;
        std::sort(str.begin(),str.end());
        vis[str]++;
    }
    long long ret = 0;
    for(auto it: vis){
        long long tm = it.second;
        ret += tm * (tm - 1) / 2;
    }
    std::cout << ret << std::endl;
}

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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    for(int i=0; i<3; i++)
    {
        cout << s.at(i);
    }
    cout << '\n';

    return 0;
}

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

ll x = 1e9 + 7; 
const int INF = 1001001001;


int main() {
  int n, m;
  cin >> n >> m;
  string  ans;
  rep(i,n) ans.push_back('0');
  vector<bool> t(n, false);
  rep(i,m) {
    int s;
    char c;
    cin >> s >> c;
    s--;
    if (t[s] && ans[s] != c) {
      cout << -1 << endl;
      return 0;
    }
    ans[s] = c;
    t[s] = true;
  }
  if (ans == "0") {
    cout << ans << endl;
    return 0;
  }
  if (t[0] && ans[0] == '0') {
    cout << -1 << endl;
    return 0;
  }
  if (ans[0] == '0') ans[0] = '1';
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3580
use std::collections::BTreeSet;

use proconio::input;

fn gcd(mut m: usize, mut n: usize) -> usize {
    while n > 0 {
        let tmp = m % n;
        m = n;
        n = tmp;
    }
    m
}

fn main() {
    input! {
        n: usize,
        a: [usize; n],
    }

    let m = 1000000usize;

    let mut whole = 0;
    for &ai in &a {
        whole = gcd(whole, ai);
    }

    if whole != 1 {
        println!("not coprime");
        return;
    }

    let mut lp = vec![0; m + 1];
    for i in 1..=m {
        lp[i] = i;
    }

    for i in 2..=m {
        if lp[i] < i {
            continue;
        }
        let mut j = i * i;
        while j <= m {
            if lp[j] == j {
                lp[j] = i;
            }
            j += i;
        }
    }

    let mut s = BTreeSet::new();
    for &ai in &a {
        let mut si = BTreeSet::new();
        let mut x = ai;
        while x > 1 {
            si.insert(lp[x]);
            x /= lp[x];
        }

        for &sij in si.iter() {
            if s.contains(&sij) {
                println!("setwise coprime");
                return;
            }
            s.insert(sij);
        }
    }

    println!("pairwise coprime");
}


Measured memory_bytes: 24456
S=input()
N=len(S)
MOD=10**9+7
res=0
dp = [[0]*4 for _ in range(100001)]
for i in reversed(range(N + 1)):
    for j in reversed(range(4)):
        if i == N:
            dp[i][j] = int(j == 3)
        else:
            dp[i][j] = dp[i+1][j] * (3 if S[i] == '?' else 1)
            if(j < 3 and (S[i] == '?' or S[i] == "ABC"[j])): dp[i][j] += dp[i+1][j+1]
            dp[i][j] %= MOD

print(dp[0][0])


Measured memory_bytes: 27624
N, x = map(int, input().split())
a = list(map(int, input().split()))

ans = 0
for i in range(1, N):
    if a[i - 1] + a[i] > x:
        diff = a[i - 1] + a[i] - x
        ans += diff
        a[i] = max(0, a[i] - diff)

print(ans)

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

int main() {
  int n;
  cin >> n;
  string s;
  if (n == 25 ) s = "Christmas";
  else if (n == 24) s = "Christmas Eve";
  else if (n == 23) s = "Christmas Eve Eve";
  else if (n == 22) s = "Christmas Eve Eve Eve";
  cout << s << endl;
  return 0;
}

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


int main(){
  int N, M;
  cin >> N >> M;
  vector<int> data(M*2);
  for(int i=0; i<M*2;i++)cin >> data.at(i);
  sort(data.begin(), data.end());
  for(int i = 1; i<N+1;i++){
    int res = 0;
    for(int j = 0; j<M*2; j++){
      if(data.at(j) == i)res+=1;
    }
    cout << res << endl;
  }
}

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

int main() {
    char C;
    string alphabet = "abcdefghijklmnopqrstuvwxyz";
    int answer;
    cin >> C;
    rep(i,25){
        if(alphabet[i] == C){
            answer = i;
            break;
        }
    }

    cout << alphabet[answer +1] << endl;
}

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



int main()
{
	int n;
	int i = 1;

	cin >> n;

	for (int x = i; x <= n; x++){
		int xx = x;
		if (x % 3 == 0){
			cout << " " << x;
		}
		else if (x % 10 == 3){
			cout << " " << x;
		}
		else{
			while (xx){
				xx = xx / 10;
				if (xx % 10 == 3){
					cout << " " << x;
					break;
				}
			}
		}
		

	}
	cout << endl;
	
	return 0;
}


Measured memory_bytes: 3084
#include <iostream>

const int N = 100;
const int M = 100;

int main(void) {
  int A[N][M] = {0};
  int b[M] = {0};
  int c[M] = {0};

  int n = 0;
  int m = 0;

  std::cin >> n >> m;

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

  for (int i = 0; i < m; i++) {
    std::cin >> b[i];
  }

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      c[i] = c[i] +  A[i][j] * b[j];
    }
  }

  for (int i = 0; i < n; i++) {
    std::cout << c[i] << std::endl;
  }
  
  return 0;
}

Measured memory_bytes: 1208
import std.stdio;
import std.string;
import std.format;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
import std.concurrency;
import std.traits;
import std.uni;
import core.bitop : popcnt;
alias Generator = std.concurrency.Generator;

enum long INF = long.max/5;
enum long MOD = 10L^^9+7;

void main() {
  long N, M;
  scanln(N, M);
  if (N == M) {
    writeln("Yes");
  } else {
    writeln("No");
  }
}

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


void times(alias fun)(long n) {
  // n.iota.each!(i => fun());
  foreach(i; 0..n) fun();
}
auto rep(alias fun, T = typeof(fun()))(long n) {
  // return n.iota.map!(i => fun()).array;
  T[] res = new T[n];
  foreach(ref e; res) e = fun();
  return res;
}

T ceil(T)(T x, T y) if (isIntegral!T || is(T == BigInt)) {
  // `(x+y-1)/y` will only work for positive numbers ...
  T t = x / y;
  if (y > 0 && t * y < x) t++;
  if (y < 0 && t * y > x) t++;
  return t;
}

T floor(T)(T x, T y) if (isIntegral!T || is(T == BigInt)) {
  T t = x / y;
  if (y > 0 && t * y > x) t--;
  if (y < 0 && t * y < x) t--;
  return t;
}

ref T ch(alias fun, T, S...)(ref T lhs, S rhs) {
  return lhs = fun(lhs, rhs);
}
unittest {
  long x = 1000;
  x.ch!min(2000);
  assert(x == 1000);
  x.ch!min(3, 2, 1);
  assert(x == 1);
  x.ch!max(100).ch!min(1000); // clamp
  assert(x == 100);
  x.ch!max(0).ch!min(10); // clamp
  assert(x == 10);
}

mixin template Constructor() {
  import std.traits : FieldNameTuple;
  this(Args...)(Args args) {
    // static foreach(i, v; args) {
    foreach(i, v; args) {
      mixin("this." ~ FieldNameTuple!(typeof(this))[i]) = v;
    }
  }
}

void scanln(Args...)(auto ref Args args) {
  enum sep = " ";
  enum n = Args.length;
  enum fmt = n.rep!(()=>"%s").join(sep) ~ "\n";
  static if (__VERSION__ >= 2071) {
    readf!fmt(args);
  } else {
    enum argsTemp = n.iota.map!(
      i => "&args[%d]".format(i)
    ).join(", ");
    mixin(
      "readf(fmt, " ~ argsTemp ~ ");"
    );
  }
}

// fold was added in D 2.071.0
static if (__VERSION__ < 2071) {
  template fold(fun...) if (fun.length >= 1) {
    auto fold(R, S...)(R r, S seed) {
      static if (S.length < 2) {
        return reduce!fun(seed, r);
      } else {
        return reduce!fun(tuple(seed), r);
      }
    }
  }
}

// popcnt with ulongs was added in D 2.071.0
static if (__VERSION__ < 2071) {
  ulong popcnt(ulong x) {
    x = (x & 0x5555555555555555L) + (x>> 1 & 0x5555555555555555L);
    x = (x & 0x3333333333333333L) + (x>> 2 & 0x3333333333333333L);
    x = (x & 0x0f0f0f0f0f0f0f0fL) + (x>> 4 & 0x0f0f0f0f0f0f0f0fL);
    x = (x & 0x00ff00ff00ff00ffL) + (x>> 8 & 0x00ff00ff00ff00ffL);
    x = (x & 0x0000ffff0000ffffL) + (x>>16 & 0x0000ffff0000ffffL);
    x = (x & 0x00000000ffffffffL) + (x>>32 & 0x00000000ffffffffL);
    return x;
  }
}


Measured memory_bytes: 256
// AOJ 2928 Mail Order
// 2019.4.5 bal4u

#include <stdio.h>
#include <stdlib.h>

//// 高速入力
#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif
int in()
{
	int n = 0, c = gc();
	do n = 10 * n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

int H, W;
int _a[100005];
int _b[100005];
int *a, *b;
long long s[100005];

int upper_bound(int x)
{
	int m, l = 0, r = W;

	while (l < r) {
		m = (l + r) >> 1;
		if (b[m] == x) return m;
		if (b[m] < x) l = m + 1; else r = m;
	}
	return l - 1;
}

int cmp(const void *a, const void *b) { return *(int *)a - *(int *)b; }

int main()
{
	int i, k, t;
	long long ans;

	H = in(), W = in();
	for (i = 0; i < H; i++) _a[i] = in();
	for (i = 0; i < W; i++) _b[i] = in();
	if (H > W) t = H, H = W, W = t, a = _b, b = _a;  // 短い方を H, a[] にする
	else a = _a, b = _b;
	qsort(b, W, sizeof(int), cmp);
	for (i = 0; i < W; i++) s[i + 1] = s[i] + b[i];  // 累計和

	ans = 0; for (i = 0; i < H; i++) {
		k = upper_bound(a[i]);   // バイナリサーチでa[i]を超えない最大値のindexを得る
		ans += s[k + 1] + (long long)(W - k - 1)*a[i];
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 3428
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;

int main()
{
	string s;
	int K;
	cin >> s >> K;

	for (auto i = 0; i < (int)s.length(); ++i)
	{
		if (s[i] == 'a')
		{
			continue;
		}
		auto temp = (int)('z' - s[i]) + 1;
		if (temp <= K)
		{
			K -= temp;
			s[i] = 'a';
		}
	}

	if (K > 0)
	{
		auto num = K % ((int)('z' - 'a') + 1);
		s[(int)s.length() - 1] += num;
	}
	cout << s << endl;

	return 0;
}

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

typedef long long int ll;
typedef unsigned long long int ull;
#define rep(i,n) for(auto i=0;i<(n);i++)
#define rep1(i,n) for(auto i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()

using namespace std;


struct init{ init(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20); }; }aaaaaaa;



int main(){
  ll n;
  cin >> n;
  vector<ll> x(n);
  vector<ll> y(n);
  rep(i, n) cin >> x[i] >> y[i];


  if(n == 1){
    cout << 1 << endl;
    return 0;
  }

  vector<vector<pair<ll, ll>>> memo(n, vector<pair<ll, ll>>(n, {0, 0}));

  map<pair<ll, ll>, set<pair<ll, ll>>> ma;
  rep(i, n){
    for(ll j = i+1; j < n; j++){
      ll q = y[i]-y[j];
      ll p = x[i]-x[j];

      if(q < 0) q *= -1, p *= -1;

      if(q == 0){
        ma[{q, p}].insert({i, j});
        ma[{q, -p}].insert({i, j});
        continue;
      }
      
      ma[{q, p}].insert({i, j});
    }
  }

  ll minn = 1e9;
  for(auto iter = ma.begin(); iter != ma.end(); iter++){
    minn = min(minn, n - (ll)iter->second.size());
  }

  cout << minn << endl;




  return 0;
}


Measured memory_bytes: 512
#include <stdio.h>
//#include <math.h>


int main()
{
int x, a, b;
int kyori2_a,kyori2_b;
scanf("%d %d %d",&x,&a,&b);
kyori2_a = (x-a)*(x-a);
kyori2_b = (x-b)*(x-b);

if(kyori2_a < kyori2_b){
  printf("A\n");
}else{
  printf("B\n");
}


return 0;
}


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

int main(){
    int n, m, x, y, max_x, min_y;
    ios::sync_with_stdio(false);
    cin >> n >> m >> x >> y;
    max_x = x;
    min_y = y;
    if (x >= y){
        printf("War\n");
        return 0;
    }
    int temp;
    for (int i = 0; i < n; i++){
        cin >> temp;
        max_x = max(max_x, temp);
    }
    for (int i = 0; i < m; i++){
        cin >> temp;
        min_y = min(min_y, temp);
    }
    if (max_x < min_y) printf("No War\n");
    else printf("War\n");
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main()
{
    int n,k;
    double nn;
    double ans = 0;
    double p = 1;
    scanf("%d%d",&n,&k);
    nn=(double)n;
    for(int i=n;i>=0;i--){
        while((double)i*p<k){
            p*=2;
        }
        ans+=1/(nn*p);
    }
    printf("%14.12lf",ans);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll k,q;
	cin>>k>>q;
	vl d(k);
	rep(i,k)cin>>d[i];
	while(q--){
		ll n,x,m;
		cin>>n>>x>>m;
		ll sum=x%m;
		ll cnt=0;
		rep(i,k){
			ll rem=d[i]%m;
			if(rem==0)cnt+=((n-1)/k+(i<((n-1)%k)));
			sum+=rem*((n-1)/k+(i<((n-1)%k)));
			//sum%=MOD;
		}
		cnt+=sum/m;
		puta(n-1-cnt);
	}
}


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

int main()
{
    int a,b;
    int ans = -1;
    cin >> a >> b;
    for( int i = 1; i <= 10000; i++ )
    {
        if( a == int(i*0.08) && b == int(i*0.10) )
        {
            ans = i;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>

using namespace std;

int main(){
    int n;
    // char s[3];
    scanf("%d", &n);
    int ans = 0;
    for(int i = 0; i < 3; i++){
        if (n % 10 == 1) ans++;
        n /= 10;
        // if (s[i] == '1') ans++; 
    }
    printf("%d\n", ans);
    
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>
#include <iomanip>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <complex>
#include <ctime>


using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e9;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用
#define ret return 0

template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

using Graph = vector<vector<ll>>;

#define ketasitei setprecision(15) //15桁表示

const ll MOD = 1000000007;
const double PI = 3.1415926535897932;


int main(void)

{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << ketasitei;

	int n;
	cin >> n;
	vector<string> s(n);
	rep(i, n)
	{
		cin >> s[i];
	}
	map<string, int> m;
	int ans = 0;
	rep(i, n)
	{
		if (m[s[i]] == 0)
		{
			ans++;
			m[s[i]] = 1;
		}
	}

	cout << ans << endl;



	return 0;
}

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

using namespace std;

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

    int n, h, w;
    cin >> n >> h >> w;

    int c = 0;

    for (int i = 0; i < n; ++i) {
        int a, b;
        cin >> a >> b;
        c += (a >= h && b >= w);
    }

    cout << c << '\n';

    return 0;
}


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))

def linked_merge_sort(l): #マージソート
    if len(l) == 1:
        return
    q, r = divmod(len(l), 2)
    left = [l.pop() for _ in range(q)]
    right = [l.pop() for _ in range(q + r)]
    
    linked_merge_sort(left)
    linked_merge_sort(right)
    
    left.reverse()
    right.reverse()
    while left and right:
        if left[-1] <= right[-1]:
            l.append(left.pop())
        else:
            l.append(right.pop())
    while left:
        l.append(left.pop())
    while right:
        l.append(right.pop())
    return

linked_merge_sort(a)
b=[0]*n
for i in range(n):
    b[i]=a[n-1-i]
ans=0
for i in range(1,n):
    ans+= b[(i//2)]
print(ans)


Measured memory_bytes: 124424
N = int(input())
A = list(map(int, input().split()))
even_cnt = []
for i in range(N):
  c = 0
  if A[i] % 2 == 0:
    even_cnt.append(1)
    A[i] = 2
  else:
    even_cnt.append(2)
    A[i] = 1

x = 3 ** N 
ans = 0
for i in range(N):
  x = x // 3
  ans += even_cnt[i] * x
  x *= A[i]
print(ans)

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.ABC_131
{
    class B
    {
        static void Main(string[] args)
        {
            Method(args);
        }

        static void Method(string[] args)
        {
            int[] nl = ReadInts();
            int n = nl[0];
            int l = nl[1];
            long sum = l * n - n + n * (n + 1) / 2;

            int index = 0;
            for(int i = 1; i < n; i++)
            {
                int now = l + i;
                int prev = l + index;
                if (Abs(now)<Abs(prev))
                {
                    index = i;
                }
            }

            WriteLine(sum - (l + index));
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 13140
fn main() {
    let (n, m) = {
        let tmp: Vec<i32> = read_vec();
        (tmp[0], tmp[1])
    };
    let mut arr = vec![0; n as usize];

    for _ in 0..m {
        let (a, b) = {
            let tmp: Vec<usize> = read_vec();
            (tmp[0] - 1, tmp[1] - 1)
        };

        arr[a] += 1;
        arr[b] += 1;
    }

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

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


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

int main(){
  int sx,sy,tx,ty;
  cin >> sx >> sy >> tx >>ty;
  const int dx=tx-sx,dy=ty-sy;
  cout << string(dy,'U') <<string(dx,'R');
  cout << string(dy,'D') <<string(dx,'L');
  cout << 'L' << string(dy+1,'U') <<string(dx+1,'R')<<'D';
  cout << 'R' << string(dy+1,'D') <<string(dx+1,'L')<<'U';
  cout << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
ll rec(vector<pair<int,int>> &v, int i, int h, vector<vector<int>> &dp){
    if(h<=0)
    return 0;
    
    if(i==v.size())
    return INT_MAX;
    
    if(dp[i][h]!=-1)
    return dp[i][h];
    
    ll ans1 = rec(v,i+1,h,dp);
    ll ans2 = rec(v,i,h-v[i].first,dp);
    if(ans2!=INT_MAX)
    ans2+=v[i].second;
    return dp[i][h] = min(ans1,ans2);
}
int main() {
	int n,h;
	cin>>h>>n;
	vector<pair<int,int>> v;
	for(int i=0;i<n;i++){
	    int x,y;
	    cin>>x>>y;
	    v.push_back(make_pair(x,y));
	}
	vector<vector<int>> dp(n+1,vector<int>(h+1,-1));
	ll ans = rec(v,0,h,dp);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 40320
#include <cstdio>

inline void swap(int &x, int &y) { x ^= y ^= x ^= y; }

typedef long long LL;
const int MN = 200005;
const int MS = 524288;
const int Mod = 924844033;
const int G = 5, iG = 554906420;

inline int qPow(int b, int e) {
	int a = 1;
	for (; e; b = (LL)b * b % Mod, e >>= 1)
		if (e & 1) a = (LL)a * b % Mod;
	return a;
}

int N;
int h[MN], nxt[MN * 2], to[MN * 2], tot;
inline void ins(int x, int y) {
	nxt[++tot] = h[x], to[tot] = y, h[x] = tot;
}

int Inv[MN], Fac[MN], iFac[MN];
int R[MS], A[MS], B[MS];

void Init(int N) {
	Inv[1] = 1;
	for (int i = 2; i <= N; ++i) {
		Inv[i] = (LL)(Mod - Mod / i) * Inv[Mod % i] % Mod;
	}
	Fac[0] = iFac[0] = 1;
	for (int i = 1; i <= N; ++i) {
		Fac[i] = (LL)Fac[i - 1] * i % Mod;
		iFac[i] = (LL)iFac[i - 1] * Inv[i] % Mod;
	}
}

int DFS(int u, int f) {
	int sz = 1, sv;
	for (int i = h[u]; i; i = nxt[i]) if (to[i] != f) {
		sz += sv = DFS(to[i], u);
		--A[sv], --A[N - sv];
	} return sz;
}

void FNTT(int *A, int Sz, int Ty) {
	for (int i = 0; i < Sz; ++i)
		if (R[i] < i) swap(A[R[i]], A[i]);
	for (int j = 1; j < Sz; j <<= 1) {
		int j2 = j << 1, wn = qPow(~Ty ? G : iG, (Mod - 1) / j2);
		for (int i = 0; i < Sz; i += j2) {
			for (int k = 0, w = 1; k < j; ++k, w = (LL)w * wn % Mod) {
				int X = A[i + k], Y = (LL)w * A[i + j + k] % Mod;
				A[i + k] = X + Y; if (A[i + k] >= Mod) A[i + k] -= Mod;
				A[i + j + k] = X - Y; if (A[i + j + k] < 0) A[i + j + k] += Mod;
			}
		}
	}
	if (Ty == -1) {
		int InvSz = qPow(Sz, Mod - 2);
		for (int i = 0; i < Sz; ++i) A[i] = (LL)A[i] * InvSz % Mod;
	}
}

int main() {
	scanf("%d", &N);
	Init(N);
	for (int i = 1, x, y; i < N; ++i) {
		scanf("%d%d", &x, &y);
		ins(x, y), ins(y, x);
	}
	DFS(1, 0), A[N] = N;
	for (int i = 1; i <= N; ++i) A[i] = ((LL)A[i] * Fac[i] % Mod + Mod) % Mod;
	for (int i = 0; i < N; ++i) B[i] = iFac[N - 1 - i];
	int Sz = 1, Bt = 0;
	for (; Sz < N + N; Sz <<= 1, ++Bt) ;
	for (int i = 0; i < Sz; ++i) R[i] = R[i >> 1] >> 1 | (i & 1) << (Bt - 1);
	FNTT(A, Sz, 1), FNTT(B, Sz, 1);
	for (int i = 0; i < Sz; ++i) A[i] = (LL)A[i] * B[i] % Mod;
	FNTT(A, Sz, -1);
	for (int i = 1; i <= N; ++i) printf("%d\n", (LL)A[i + N - 1] * iFac[i] % Mod);
	return 0;
}

Measured memory_bytes: 22400
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws Exception {
        try (BufferedReader reader = new BufferedReader(new InputStreamReader(System.in))) {
            int N = Integer.parseInt(reader.readLine());

            int max1 = 0, max2 = 0;

            int[] A = new int[N];
            for (int i = 0; i < N; i++) {
                A[i] = Integer.parseInt(reader.readLine());

                if (A[i] > max2) {
                    max2 = A[i];
                }
                if (A[i] > max1) {
                    max2 = max1;
                    max1 = A[i];
                }
            }

            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < N; i++) {
                if (A[i] != max1) {
                    sb.append(max1);
                } else {
                    sb.append(max2);
                }
                sb.append("\n");
            }

            System.out.println(sb.toString());
        }
    }

}


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

int main(void){
	int N,M;
	cin >> N >> M;

	vector<int> x(N);
	vector<int> nums(200001);
	vector<int> cnt(100001);
	for(int i=0;i<N;i++){
		cin >> x[i];
		nums[ abs( x[i] - ceil(1. * x[i] / M) * M ) ]++;
		cnt[x[i]]++;
	}

	vector<int> kumi(200001);
	for(int i=0;i<100001;i++){
		if( cnt[i] >= 2 ){
			kumi[ abs( i - ceil( 1. * i / M ) * M ) ] += cnt[i] / 2 * 2;
		}
	}

	// if( M == 1 ){
	// 	cout << N/2 << endl;
	// 	return 0;
	// }

	int ret = 0;
	for(int i=0;i<M;i++){
		if(nums[i]){
			// cout << i << " " << nums[i] << endl;
			if(i != 0 && i != M-i){
				int mx = min(nums[i],nums[M-i]);
				nums[i] -= mx;
				nums[M-i] -= mx;
				ret += mx;

				int same = min( kumi[i] , nums[i] ) / 2;
				cerr << i << " " << same << endl;
				ret += same;
				nums[i] -= same * 2;
			}else{
				int same = nums[i] / 2;
				ret += same;
				nums[i] -= same * 2;
			}
		}
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 2688
#include<bits/stdc++.h> 
//#define <- プログラムの文字列を置換する
//typedef <- 新しい型に名前を付けるためのキーワード

using namespace std;

#define MAX_N 100000

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

const double PI = 3.141592653589793;
const long long MOD = 1e9 + 7;
const long long INF = 1e15;
const int INF_INT = 1e9;

int main(){
    int k;
    cin >> k;
    string s;
    cin >> s;
    if(s.length() <= k) cout << s << endl;
    else cout << s.substr(0,k) + "..." << endl;
    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <math.h>
#include <string>
#include <numeric>
#include <queue>
#include <cstdio>
#include <cstring>
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define rep1(i,n) for(ll i=1;i<n;++i)
#define mrep(i,n) for(ll i=n;i>=0;--i)
#define all(a) (a).begin(),(a).end()
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vb vector<bool>
#define vvb vector<vector<bool> >
#define pl pair<ll,ll>
#define inf 1001001001001001000
//#define mod 1000000007
#define mod 998244353
#define pi 3.1415926535
using namespace std;
struct __INIT {
	__INIT() {
		cin.tie(0);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(15);
	}
}__init;

int main(void) {
    ll n,k;
    cin>>n>>k;
    string s;
    cin>>s;
    ll now = '1';
    ll cnt = 0;
    vl pitsu;
    rep(i,n){
        if(s[i] == now) cnt++;
        else{
            pitsu.push_back(cnt);
            cnt = 1;
            now = s[i];
        }
    }
    pitsu.push_back(cnt);
    if(s[n-1] == '0') pitsu.push_back(0);
    if(k >= (pitsu.size()-1)/2){
        cout<<n<<endl;
        return 0;
    }
    ll score = pitsu[0];
    rep(i,k){
        score += pitsu[2*i+1]+pitsu[2*i+2];
    }
    ll maxi = score;
    rep(i,(pitsu.size()-1)/2-k){
        score -= (pitsu[2*i]+pitsu[2*i+1]);
        score += (pitsu[2*i+2*k+1]+pitsu[2*i+2*k+2]);
        //cout<<score<<endl;
        maxi = max(maxi,score);
    }
    cout<<maxi<<endl;
    return 0;
}


Measured memory_bytes: 4448
#include <stdio.h>
#include <math.h>
long long int f(long long int a,long long int b){
  long long int k;
  if(b==0)return -a;
  if(a>b){
    k=a;
    a=b;
    b=k;
  }
  
 return 2*a*(b/a)+f(a,b%a);
}
int main(){
  long long int N,X;
  scanf("%lld %lld",&N,&X);
  long long int ans;
  ans=N+f(N-X,X);
  printf("%lld\n",ans);
  return 0;
}


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

using pii = pair<int, int>;

constexpr int INF = 1e9;

int main() {
    string s;
    while(cin >> s) {
        int joi = 0, ioi = 0;
        for(int i = 0; i + 3 <= s.size(); ++i) {
            joi += s.substr(i, 3) == "JOI";
            ioi += s.substr(i, 3) == "IOI";
        }
        cout << joi << "\n" << ioi << endl;
    }
}


Measured memory_bytes: 3092
#include<bits/stdc++.h>
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[6] = {1, 0, -1, 0,1,1};
const int dy[6] = {0, 1, 0, -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; }
// ---------------------------------------------------------------------------

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int A=0,B=0;
    for(int i=0; i<4; i++){
        int a;
        cin >> a;
        A += a;
    }
    for(int i=0; i<4; i++){
        int a;
        cin >> a;
        B += a;
    }
    cout << max(A,B) << enld;
    return 0;
}


Measured memory_bytes: 3116
#include <stdio.h>
int main()
{
  int a,b;

  scanf("%d%d",&a,&b);
  
  if(a<b && -1000<=a && a<= 1000 && b >= -1000 && b <= 1000)printf("a < b\n");
  if(a>b && -1000<=a && a <= 1000 && b >= -1000 && b <= 1000)printf("a > b\n");
  if(a==b && -1000<=a && a <= 1000 && b >= -1000 && b <= 1000)printf("a == b\n");
  return 0;
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ll long long
#define ld long double
#define mod 1000000007
#define mod1 mod
#define mod2 100000009
//#define endl "\n"
#define show(a) for(int i=0;i<a.size();i++) cout<<a[i & 1]<<" ";
#define fi first
#define se second
#define vi vector<int>
#define vs vector<string>
#define vll vector<ll>
#define pb push_back
#define pi pair<int,int>
#define si set<int>
#define sll set<ll>
#define pll pair<ll, ll>
#define sci(x) scanf("%d",&x)
#define scs(x)  scanf("%s", x)
#define scll(x) scanf("%I64d",&x)
#define all(v) v.begin(),v.end()
#define sot(v) sort(v.begin(), v.end())
#define maxheap priority_queue<int>
#define mp make_pair
#define fast_io() cin.sync_with_stdio(false);cout.sync_with_stdio(false);
#define PI 3.1415926535
#define long_zero 0ll
#define long_one 1ll

inline int sbt(int x) {return __builtin_popcount(x);}

using namespace std;
using namespace __gnu_pbds;
#define FOR(i, j, k, in) for ( i=j ; i<k ; i+=in)
#define TRACE
#ifdef TRACE
#define deb(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cout << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
#else
#define deb(...)
#endif
#define N 10003
bool ok;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ost;

inline int mul(int a, int b, int m = mod) { return (a * b) % m; }
inline int add(int a, int b, int m = mod) { return (a + b) % m; }
inline int sub(int a, int b, int m = mod) { return (a - b + m) % m; }

bool Comparator (pair <int, int> x, pair <int, int> y) {
	return x.first < y.first;
}
int main() {
	
	int a,b;
  	cin>>a>>b;
  	cout<<a*b<<endl;
}

Measured memory_bytes: 3632
#include <iostream>
using namespace std;
int main(void){
    int a = 0, b = 0;
    cin >> a >> b;
    
    if( a > b ) {
        cout << "a > b" << endl;
    }else if( a == b ) {
        cout << "a == b" << endl;
    }else{
        cout << "a < b" << endl;
    }
}

Measured memory_bytes: 1156
import sys
input = sys.stdin.readline

N=int(input())
K=[tuple(map(int,input().split())) for i in range(N)]

if N%2==1:
    
    NG=-1
    OK=10**9+1

    while OK-NG>1:
        mid=(OK+NG)//2

        count=0
        for a,b in K:
            if a<=mid:
                count+=1

            if count>=N//2+1:
                OK=mid
                break
        else:
            NG=mid

    MIN=OK

    OK=-1
    NG=10**9+1

    while NG-OK>1:
        mid=(OK+NG)//2

        count=0
        for a,b in K:
            if b>=mid:
                count+=1

            if count>=N//2+1:
                OK=mid
                break
        else:
            NG=mid

    MAX=OK

    print(MAX-MIN+1)

else:
    
    NG=-1
    OK=10**9+1

    while OK-NG>1:
        mid=(OK+NG)//2

        count=0
        for a,b in K:
            if a<=mid:
                count+=1

            if count>=N//2+1:
                OK=mid
                break
        else:
            NG=mid

    MIN0=OK

    NG=-1
    OK=10**9+1

    while OK-NG>1:
        mid=(OK+NG)//2

        count=0
        for a,b in K:
            if a<=mid:
                count+=1

            if count>=N//2:
                OK=mid
                break
        else:
            NG=mid

    MIN1=OK

    OK=-1
    NG=10**9+1

    while NG-OK>1:
        mid=(OK+NG)//2

        count=0
        for a,b in K:
            if b>=mid:
                count+=1

            if count>=N//2+1:
                OK=mid
                break
        else:
            NG=mid

    MAX0=OK

    OK=-1
    NG=10**9+1

    while NG-OK>1:
        mid=(OK+NG)//2

        count=0
        for a,b in K:
            if b>=mid:
                count+=1

            if count>=N//2:
                OK=mid
                break
        else:
            NG=mid

    MAX1=OK

    #print(MIN0,MIN1,MAX0,MAX1)

    print(int(((MAX1+MAX0)/2-(MIN1+MIN0)/2)*2+1))
    

        


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

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

    int n;
    cin >> n;
    vector<int> B(n - 1);
    for(int i = 0; i < n - 1; i++){
        cin >> B[i];
    }

    int ans = 0;
    vector<int> A(n);
    for(int i = 0; i < n - 1; i++){
        if(i == 0){
            A[i] = B[i];
            A[i + 1] = B[i];
        }else{
            if(A[i] > B[i]){
                A[i] = B[i];
                A[i + 1] = B[i];
            }else{
                A[i + 1] = B[i];
            }
        }
    }

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

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3652
//#pragma comment(linker, "/STACK:102400000,102400000") 
#pragma warning(disable:4996)
#include <fstream>
#include <iostream>
#include <functional>
#include <algorithm>
#include <cstring>
#include <vector>
#include <string>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <ctime>
#include <list>
#include <set>
#include <map>
using namespace std;

typedef long long ll;
#define eps 1e-10
#define LL_INF 0x3fffffffffffffff
#define INF 0x3f3f3f3f
#define mem(a, b) memset(a, b, sizeof(a))
#define pper(i,n,m) for(int i = n;i >= m; i--)
#define repp(i, n, m) for (int i = n; i <= m; i++)
#define rep(i, n, m) for (int i = n; i < m; i++)
#define sa(n) scanf("%d", &(n))
#define mp make_pair
#define ff first
#define ss second
#define pb push_back

const int maxn = 1e5 + 5;
const ll mod = 1e9 + 7;
const double PI = acos(-1.0);
ll po(ll a, ll b, ll mod) { ll res = 1; a %= mod; for (; b; b >>= 1) { if (b & 1)res = res*a%mod; a = a*a%mod; }return res; }
ll gcd(ll a, ll b) { if (a == 0) { return b; } else { return gcd(b%a, a); } }

int n, m;
int q;
int val[maxn], app[maxn], idx[maxn], res[maxn];

void solve()
{
	scanf("%d%d", &n, &m);
	scanf("%d", &q);

	for (int i = 1; i <= q; i++)
	{
		scanf("%d", &val[i]);
	}
	vector<int>pre;
	for (int i = q; i >= 1; i--)
	{
		if (app[val[i]] == 0)
		{
			app[val[i]] = 1;
			idx[val[i]] = pre.size();
			pre.push_back(val[i]);
		}
	}
	for (int i = 1; i <= m; i++)
	{
		if (!app[i])
		{
			idx[i] = pre.size();
			pre.push_back(i);
		}
	}
	int sz = pre.size();
	while (sz >= 2)
	{
		if (pre[sz - 2] > pre[sz - 1])
		{
			break;
		}
		else
		{
			sz--;
			pre.pop_back();
		}
	}
	pre.pop_back();
	res[0] = n;
	for (int i = q; i >= 1; i--)
	{
		if (res[idx[val[i]]])
		{
			res[idx[val[i]]]--;
			res[idx[val[i]] + 1]++;
		}
	}
	sz = pre.size();
	for (int i = 0; i < sz;i++)
	{
		if (res[i])
		{
			puts("No");
			return;
		}
	 }
	puts("Yes");
}
int main()
{
	solve();
	return 0;
}

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

int main(void){
    
    string S;
    long int K;
    cin >> S >> K;

    long int ans = 0;
    int tmp = 1;
    for(int i=0; i<S.size()-1; i++){
        if(S.at(i) == S.at(i+1)){
            tmp++;
            if(i == S.size()-2){
                ans += tmp/2;
            }
        }
        else{
            ans += tmp/2;
            tmp = 1;
        }
    }

    if(tmp == S.size()){ // Sが全て同じ文字の場合の処理
        ans = (long int)S.size()*K / 2;
        cout << ans << endl;
        return 0;
    }

    ans *= K;

    // 先頭と末尾が同じ場合の処理
    if(S.at(0) == S.at(S.size()-1)){
        int start_size = 1;
        int end_size = 1;

        for(int i=0; i<S.size(); i++){
            if(S.at(i) == S.at(i+1)){
                start_size++;
            }
            else{
                break;
            }
        }

        for(int i=S.size()-1; i>0; i--){
            if(S.at(i) == S.at(i-1)){
                end_size++;
            }
            else{
                break;
            }
        }

        ans -= (K-1) * (start_size/2 + end_size/2 - (start_size+end_size)/2);

    }

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

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

#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

using ll = long long;
#define INF 1e9

int H, W;
vector<string> s;
vector<vector<int>> dist;

int main(){
  cin >> H >> W;
  s.resize(H);
  REP(i, H){
    cin >> s[i];
  }
  dist.resize(H, vector<int>(W, -1));
  int black = 0, white = 0;
  REP(i, H){
    REP(j, W){
      if(s[i][j] == '#'){
        black++;
      }
      else{
        white++;
      }
    }
  }
  queue<pair<int, int>> que;
  que.push({0, 0});
  dist[0][0] = 1;
  int dx[] = {0, 1, 0, -1};
  int dy[] = {1, 0, -1, 0};
  while(!que.empty()){
    pair<int, int> cp = que.front();
    que.pop();
    REP(i, 4){
      int nx = cp.second + dx[i], ny = cp.first + dy[i];
      if(nx < 0 || W <= nx || ny < 0 || H <= ny || s[ny][nx] == '#' || dist[ny][nx] != -1) continue;
      dist[ny][nx] = dist[cp.first][cp.second] + 1;
      que.push({ny, nx});
    }
  }
  if(dist[H-1][W-1] == -1){
    cout << -1 << endl;
  }
  else{
    cout << white - dist[H-1][W-1] << endl;
  }

  return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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

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

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

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

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int main(){
  int n,m;
  cin>>n>>m;
  if(n==1 && m==1){
    puts("1");
  }else if(n==1){
    printf("%d\n",m-2);
  }else if(m==1){
    printf("%d\n",n-2);
  }else{
    ll corner = 4;
    ll side = 2ll*(n-2) + 2ll*(m-2);
    ll inner = (ll)(n-2)*(ll)(m-2);
    ll ans = inner;
    printf("%lld\n",ans);
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n;
int main(){
	scanf("%d",&n);
	while(n>0){
		if(n%10==7){
			printf("Yes\n");
			break;
		}
		n/=10;
	}
	if(!n)printf("No\n");
	
	return 0;
} 

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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
typedef vector<ll> VL; const int MD = (int)1e9 + 7;
void dbg(){ cerr << "\n"; } template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amax(T& a,T2 b){ if(a < b) a = b;}

const ll INF = 1LL<<50;

int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n, k;
	cin >>n >>k;
	double ans =0;
	rep2(i, 1, n+1){
		int t = i, su = 0;
		while(t < k){ t*=2; su++;}
		ans += 1.0 / n /(1LL<<su);
	}
	printf("%.14f\n", ans);
	return 0;
}


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

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	string s; cin>>s;
	cout<<((s=="AAA"||s=="BBB")?"No":"Yes")<<"\n";
	return 0;
}

Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;

public class Main{

	public static void main(String args[]) {
		Scanner scan = new Scanner(System.in);
		int s = scan.nextInt();
		
		HashSet<Integer> hs = new HashSet<>();
		int a1 = s;
		hs.add(s);
		int m = 1;
		boolean found = false;
		
		while(found == false) {
			if((a1 % 2 == 0)) {
				a1 = a1 / 2;
			}else {
				a1 = 3 * a1 + 1;
			}
			
			m++;
			
			if(hs.contains(a1)) {
				System.out.println(m);
				found = true;
			}
			
			hs.add(a1);
		}
		
	}
	
}

Measured memory_bytes: 23892
#include<iostream>
int main() {
	int n, x;
	std::cin >> n >> x;
	int m[100];
	for (int i = 0; i < n; i++)
		std::cin >> m[i];

	int count;

	for (int i = 0; i < n; i++)
		x -= m[i];
	count = n;

	int min = m[0];
	for (int i = 1; i < n; i++)
		if (min > m[i]) min = m[i];
	while (true) {
		if ((x - min) >= 0) {
			x -= min;
			count++;
		} else
			break;
	}
	std::cout << count << std::endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b;
  cin >> a >> b;
  if ( a > b){
    cout << "a > b" << endl;
  }
  else if ( a < b){
    cout << "a < b" << endl;
  }
  else{
    cout << "a == b" << endl;
  }
}



Measured memory_bytes: 3092
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>
#include<set>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
typedef pair<ll, ll> pll;
//int dx[4] = { 1,0,0,-1 };
//int dy[4] = { 0,1,-1,0 };
#define MOD 1000000007
#define ARRAY_MAX 350

const int INF = 1e9 + 7;



int main() {


	ios::sync_with_stdio(false);
	cin.tie(0);

	int n;
	char mp[ARRAY_MAX][ARRAY_MAX];
	char next[ARRAY_MAX][ARRAY_MAX];

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

	int ans = 0;

	for (int tm = 0;tm < n; tm++)
	{
		//(0,0)から初めて(0,n-1)まで試す
		//横にずらす
		
		bool exist = true;

		//次の盤面を作成
		for (int y = 0; y < n; y++)
		{
			for (int x = 0; x < n; x++)
			{
				next[y][x] = mp[y][(x + 1) % n];
			}
		}

		for (int y = 0; y < n; y++)
		{
			for (int x = 0; x < n; x++)
			{
				mp[y][x] = next[y][x];
			}
		}

		for (int y = 0; y < n; y++)
		{
			for (int x = 0; x < n; x++)
			{
				exist &= (mp[y][x] == mp[x][y]);
			}
		}

		if (exist)
		{
			ans += n;
		}

	}
	cout << ans << endl;


	return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<functional>
#include<fstream>
#include<utility>
#include<bitset>
#include<map>
#include<deque>
#include<cmath>
#include<random>
#include<string.h>
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define rep(N) for (int i = 0; i < N; ++i)
#define Rep(a, b) for (int i = a; i < b; ++i)
#define For(i, N) for (int i = 0; i < N; ++i)
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()
#define makei(N) int N; cin >> N;
#define makel(N) ll N; cin >> N;
#define makes(s) string s; cin >> s;
#define maked(d) double d; cin >> d;
#define makev(v, N) vi v(N); rep(N)cin >> v[i];
#define mod 1000000007
#define re return 0

using namespace std;
using ll = long long int;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using msi = map<string, int>;

template<typename T>
void say(T s) {
	cout << s << "\n";
}

template<typename T>
void say(vector<T> s) {
	auto itr = s.begin();
	cout << *(itr++);
	while (itr != s.end()) {
		cout << " " << *(itr++);
	}
	cout << "\n";
}

void yn(bool b) {
	if (b)say("Yes");
	else say("No");
}

int main() {
	ll ans = 0;
	makei(N);
	makei(K);
	makev(l, N);
	sort(rev(l));
	rep(K) {
		ans += l[i];
	}
	say(ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin(), v.end()
#define inputv(v, n)                                                           \
    vl v;                                                                      \
    rep(i, n) {                                                                \
        ll x;                                                                  \
        cin >> x;                                                              \
        v.push_back(x);                                                        \
    }
bool chmin(ll& a, ll& b) { if (b < a) { a = b; return 1; } return 0; }
bool chmax(ll& a, ll& b) { if (b > a) { a = b; return 1; } return 0; }
const ll INF = 999999999999999;
const ll MOD = 1000000007;
const ll MAX_N = 500010;
ll a, b, c, d, e, f, p, t, x, y, z, q, m, n, r, h, k, w, l, ans;
int main() {
    cin >> n;
    inputv(A, n);
    vl dp(n + 1, 0);
    rep(i, n) {
        dp[A[i]] = dp[A[i] - 1] + 1;
        ans = max(ans, dp[A[i]]);
    }

    cout << n - ans << endl;
}


Measured memory_bytes: 3952