akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using Int = long long;

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int n,m,t;
  cin>>n>>m>>t;
  t--;
  vector<Int> w(n);
  for(Int i=0;i<n;i++) cin>>w[i];

  vector<Int> g(m);
  vector<vector<Int> > R;
  for(Int i=0;i<m;i++){
    Int c;
    cin>>g[i]>>c;
    g[i]--;
    R.emplace_back(vector<Int>(c));
    for(Int j=0;j<c;j++)
      cin>>R.back()[j],R.back()[j]--;
  }
  const Int INF = 1e9;
  vector<Int> dp(n,INF);
  for(Int i=0;i<n;i++) if(w[i]) dp[i]=1;

  auto comp=[&](Int i,Int j){return dp[i]>dp[j];};
  while(1){
    Int flg=0;
    for(Int i=0;i<m;i++){
      Int ok=1;
      for(auto x:R[i]) ok&=dp[x]<INF;
      if(!ok) continue;
      Int tmp=0;
      sort(R[i].begin(),R[i].end(),comp);
      for(Int j=0;j<(Int)R[i].size();j++)
	chmax(tmp,j+dp[R[i][j]]);
      
      if(tmp<dp[g[i]]){
	dp[g[i]]=tmp;
	flg=1;
      }
    }
    if(!flg) break;
  }
  
  if(dp[t]>=INF) dp[t]=-1;
  cout<<dp[t]<<endl;
  return 0;
}



Measured memory_bytes: 3244
#include<iostream>

int main() {
	int a, b, n;
	bool flag = false;
	bool aflag = false;

	std::cin >> n;
	std::cin >> b;
	a = b;

	for (int i = 0; i < n - 1; i++) {
		std::cin >> b;

		if (a - 2 >= b) {
			flag = true;
		}
		else if (a - 1 == b) {
			if (!aflag) {
				aflag = true;
			}
			else {
				flag = true;
			}
		}
		else if (a < b && aflag) {
			aflag = false;
		}

		a = b;
	}

	if (flag) {
		std::cout << "No" << std::endl;
	}
	else {
		std::cout << "Yes" << std::endl;
	}
}

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

void fnMaxHeapifyUp(vector<int>& rvnPrtyHeap, int nx)
{
  int nParnt = nx / 2;
  int nLrge = nx;

  if (nParnt > 0  &&
      rvnPrtyHeap[nParnt] < rvnPrtyHeap[nLrge])
  {
    swap(rvnPrtyHeap[nParnt], rvnPrtyHeap[nLrge]);
    fnMaxHeapifyUp(rvnPrtyHeap, nParnt);
  }
}

void fnMaxHeapifyDown(vector<int>& rvnPrtyHeap, int nx)
{
  int nLeft = nx * 2;
  int nRigt = nLeft + 1;
  int nLrge = nx;

  if (nLeft < rvnPrtyHeap.size()  &&
      rvnPrtyHeap[nLrge] < rvnPrtyHeap[nLeft])  
    nLrge = nLeft;
  if (nRigt < rvnPrtyHeap.size()  &&
      rvnPrtyHeap[nLrge] < rvnPrtyHeap[nRigt])
    nLrge = nRigt;

  if (nx != nLrge)
  {
    swap(rvnPrtyHeap[nx], rvnPrtyHeap[nLrge]);
    fnMaxHeapifyDown(rvnPrtyHeap, nLrge);
  }
}

void fnPriorityQueue(vector<int>& rvnPrtyHeap)
{
  rvnPrtyHeap.push_back(-1);
  string sCmd;
  while (cin >> sCmd && sCmd != "end")
  {
    if (sCmd[0] == 'i')
    {
      int nNo;
      cin >> nNo;
      rvnPrtyHeap.push_back(nNo);
      int nx = rvnPrtyHeap.size() - 1;
      fnMaxHeapifyUp(rvnPrtyHeap, nx);
    }
    else if (sCmd[0] == 'e')
    {
      cout << rvnPrtyHeap[1] << endl;
      rvnPrtyHeap[1] = rvnPrtyHeap.back();
      rvnPrtyHeap.pop_back();
      if (rvnPrtyHeap.size() > 1)
        fnMaxHeapifyDown(rvnPrtyHeap, 1);
    }
    else;
  }
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<int> vnPrtyHeap; 

  fnPriorityQueue(vnPrtyHeap);
  return 0;
}

Measured memory_bytes: 6960
/* 
   AOJ 2399
   Save Your Privacy!
   2015/7/14
*/

#include<stdio.h>

void init(int *criminal, int **known)
{
  int i, j;

  for(i = 0; i < 101; i++)
    {
      criminal[i] = 1;
      for(j = 0; j < 101; j++)
	{
	  known[i][j] = 0;
	}
    }
  return ;
}

int main(void)
{
  int member_num, known_num, leaked_num, i, j, x, flag = 0, target = 0;
  int known[101][101] = {{0}, {0}}, criminal[101] = {1};


  while(1)
    {
      //      init(criminal, known);
      target = 0;
      flag = 0;
      for(i = 0; i < 101; i++)
	{
	  criminal[i] = 1;
	  for(j = 0; j < 101; j++)
	    {
	      known[i][j] = 0;
	    }
	}
      
      scanf("%d", &member_num);

      if(member_num == 0)
	{
	  break;
	}

      for(i = 1; i < member_num + 1; i++)
	{
	  scanf("%d", &known_num);

	  for(j = 1; j < known_num + 1; j++)
	    {
	      scanf("%d", &x);
	      known[i][x] = 1;
	    }
	}

      scanf("%d", &leaked_num);

      for(i = 0; i < leaked_num; i++)
	{
	  scanf("%d", &x);

	  for(j = 1; j < member_num + 1; j++)
	    {
	      if(known[j][x] == 0)
		{
		  criminal[j] = 0;
		}
	    }
	}
      //for a debug------------------------------
      /* for(i = 1; i < member_num + 1; i++) */
      /* 	{ */
      /* 	  for(j = 1; j < member_num + 1; j++) */
      /* 	    { */
      /* 	      printf("%3d", known[i][j]); */
      /* 	    } */
      /* 	  printf("\n"); */
      /* 	} */
  
      /* for(i = 1; i < member_num + 1; i++) */
      /* 	{ */
      /* 	  printf("%3d", criminal[i]); */
      /* 	} */
      /* printf("\n"); */
      //-----------------------------------------
      for(i = 1; i < member_num + 1; i++)
	{
	  if(criminal[i] == 1)
	    {
	      if(flag == 0)
		{
		  target = i;
		  flag = 1;
		}
	      else
		{
		  target = -1;
		}
	    }
	}
      if(target == 0)
	{
	  target = -1;
	}
      printf("%d\n", target);
  }
  return 0;  
}

Measured memory_bytes: 648
h, w = map(int, input().split())
paint = [list(input()) for _ in range(h)]
ans = 'Yes'
for i in range(h):
    for j in range(w):
        if paint[i][j] == '#':
            if i > 0:
                if paint[i - 1][j] == '#':
                    continue
            if i < h - 1:
                if paint[i + 1][j] == '#':
                    continue
            if j > 0:
                if paint[i][j - 1] == '#':
                    continue
            if j < w - 1:
                if paint[i][j + 1] == '#':
                    continue
            ans = 'No'
            break
print(ans)


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

typedef unsigned uint;
typedef long long INT;
typedef unsigned long long UINT;
const int INF = 1001001001;
const INT INFLL = 1001001001001001001LL;

 int in() { int x; scanf("%d", &x); return x; }
double fin() { double x; scanf("%lf", &x); return x; }
INT lin() { INT x; scanf("%lld", &x); return x; }


int main(){
    int a, b, c;
    double fa, fb, fc;
    char sa[128], sb[128], sc[128];

    int N = in();
    int M = in();
    std::vector<int> vec;
    INT nTotal = 0;
    for (int i = 0; i < N; ++i) {
        int Ai = in();
        nTotal += Ai;
        vec.push_back(Ai);
    }

    int nPop = 0;
    for (int nA : vec) {
        nPop += (4 * M * nA < nTotal) ? 0 : 1;
    }

    if (nPop >= M) {
        printf("Yes");
    }
    else {
        printf("No");
    }

    return 0;
}







Measured memory_bytes: 256
#include <string>
#include <vector>
#include <iostream>
using namespace std;
vector<int> x, y; int t;
bool same(vector<int> a, vector<int> b) {
	for(int i = 0; i < 4; i++) {
		for(int j = 0; j < 4; j++) {
			for(int k = 0; k < 4; k++) {
				for(int l = 0; l < 4; l++) {
					string s;
					for(int m = 0; m < i; m++) s += 'N';
					for(int m = 0; m < j; m++) s += 'E';
					for(int m = 0; m < k; m++) s += 'S';
					for(int m = 0; m < l; m++) s += 'W';
					for(int i = 0; i < s.size(); i++) {
        				t = a[0];
        				switch(s[i]) {
        				case 'N':
            				a[0] = a[1];
            				a[1] = a[5];
        					a[5] = a[4];
        				    a[4] = t;
        				    break;
        				case 'E':
        				    a[0] = a[3];
        				    a[3] = a[5];
        				    a[5] = a[2];
        				    a[2] = t;
        				    break;
        				case 'S':
        				    a[0] = a[4];
        				    a[4] = a[5];
        				    a[5] = a[1];
        				    a[1] = t;
        				    break;
        				case 'W':
        				    a[0] = a[2];
        				    a[2] = a[5];
        				    a[5] = a[3];
    					    a[3] = t;
    					   	break;
	    				}
					}
					if(a == b) return true;
				}
			}
		}
	}
	return false;
}
int main() {
	x.resize(6); for(int i = 0; i < 6; i++) scanf("%d", &x[i]);
	y.resize(6); for(int i = 0; i < 6; i++) scanf("%d", &y[i]);
	printf("%s\n", same(x, y) ? "Yes" : "No");
	return 0;
}

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

import heapq

N, M = map(int,input().split())
A = list(map(int, input().split()))
q = []
heapq.heapify(q)
for i in range(N):
    heapq.heappush(q,-A[i])

cnt = M
while cnt>0:
    a=heapq.heappop(q)
    a=-a
    a=a//2
    heapq.heappush(q,-a)
    
    cnt-=1
print(-sum(q))




Measured memory_bytes: 14204
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,a[105],i,mx=-1,mn=500000;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
		if(mn>a[i]){
			mn=a[i];
		}
		if(mx<a[i]){
			mx=a[i];
		}
	}
	printf("%d",mx-mn);
}

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

int main() {
    int N;
    cin >> N;

    vector<string> W(N);
    for (int i = 0; i < N; i++) {
        cin >> W[i];
    }

    bool flag = true;
    for (int i = 0; i < N - 1; i++) {
        if (W[i][W[i].size() - 1] != W[i + 1][0]) {
            flag = false;
        }
    }
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < i; j++) {
            if (W[i] == W[j]) {
                flag = false;
            }
        }
    }

    if (flag) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
/*2019/10/19 */
/*template*/
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#define MOD 1000000007
#define MIN 999999999
#define MAX -999999999
typedef long long int ll;
typedef unsigned long long int ull;
void llswap(ll *x,ll *y){ll tmp;tmp=*x;*x=*y;*y=tmp;}
void swap(int *x,int *y){int tmp;tmp=*x;*x=*y;*y=tmp;}
int rmax(int x,int y){return x>y?x:y;}
int rmin(int x,int y){return x>y?y:x;}
ll llrmax(ll x,ll y){return x>y?x:y;}
ll llrmin(ll x,ll y){return x>y?y:x;}
int asc(const void *a,const void *b){if(*(int*)a < *(int*)b)return -1;else if(*(int*)a == *(int*)b)return 0;else return 1;}
int desc(const void *a,const void *b){if(*(int*)a < *(int*)b)return 1;else if(*(int*)a == *(int*)b)return 0;else return -1;}
int llasc(const void *a,const void *b){if(*(ll*)a < *(ll*)b)return -1;else if(*(ll*)a == *(ll*)b)return 0;else return 1;}
int lldesc(const void *a,const void *b){if(*(ll*)a < *(ll*)b)return 1;else if(*(ll*)a == *(ll*)b)return 0;else return -1;}
int gcd(int x,int y){if(y==0)return x;return gcd(y,x%y);}
 
//int asc_t(const void *a,const void *b){if(((pair_t*)a)->d < ((pair_t*)b)->d)return -1;else if(((pair_t*)a)->d == ((pair_t*)b)->d)return 0;else return 1;}
//int asc_t(const void *a,const void *b){if(((pair_t*)a)->d < ((pair_t*)b)->d)return 1;else if(((pair_t*)a)->d == ((pair_t*)b)->d)return 0;else return -1;}

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

Measured memory_bytes: 128
#include <iostream>

int main() {
    std::string s;
    std::cin >> s;
    unsigned long long cnt = 0;
    int b = 0;

    for (auto& c: s) {
        if (c == 'W') {
            cnt += b;
        } else {  // 'B'
            b++;
        }
    }
    std::cout << cnt << std::endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#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 INF 999999999
#define M_PI 3.14159265358979323846
#define ALL(X) (X).begin(),(X).end()

#ifdef __LOCAL
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

#ifdef __LOCAL
    #include <filesystem>
    namespace fs = std::filesystem;
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 0};
int dy[]={0, 1, 0, -1, 0};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);
const int NIL = -1;
static mt19937 _g(time(nullptr));
 
std::string pad(int num){ char buffer[4]; std::snprintf(buffer, sizeof(buffer), "%03d", num); return buffer;}
inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << "," << el.second << "] "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int N;
vector<string> V;
map<string,ll> C;

int input(){
    #ifdef __LOCAL
        fs::path path_to_file = __FILE__;
        fs::path input,output;
        input = output = path_to_file.parent_path();
        input += string("/input/") + string(path_to_file.stem()) + string(".txt");
        output += string("/output/") + string(path_to_file.stem()) + string(".txt");
        freopen(input.c_str(), "r", stdin);
        freopen(output.c_str(), "w", stdout);
    #endif
    cin >> N;
    V = fetch_vec<string>(N);
    REP(i,N) sort(V[i].begin(),V[i].end());
    // VSORT(V)
    return 0;
}

int solve(){
    REP(i,N) C[V[i]]++;
    ll ans=0;
    for(auto c:C) ans += c.second*(c.second-1)/2;
    cout << ans << endl;
    return 0;
}

int main()
{
    input();
    solve();
    return 0;
}


Measured memory_bytes: 18176
process.stdin.setEncoding('utf-8');
process.stdin.on('data', input => {
  [num1, num2] = input.split(' ')
  a = parseInt(num1);
  b = parseInt(num2);
  if (a < b) {
    console.log('a < b');
  } else if (a > b) {
    console.log('a > b');
  } else {
    console.log('a == b');
  }
});



Measured memory_bytes: 15264
#include <stdio.h>
#include <stdlib.h>

int A[100000];

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

int main(){
  int i, n;
  long long int s;
  scanf("%d", &n);
  s=0;
  for(i=0;i<n;i++){
    scanf("%d",A+i);
    s+=A[i];
  }

  qsort(A, n, sizeof(int), cmpfunc);

  s -= A[n-1];
  for(i=n-2;i>=0;i--){
    if(2*s < A[i+1]) break;
    s -= A[i];
  }

  printf("%d\n", n-1-i);

  return 0;
}


Measured memory_bytes: 892
#include <iostream>
using namespace std;
int main(){
        int a,b,x;
        cin >> a >> b >> x;
        for(int i=0; i<=b; i++) {
                int neko=a;
                neko+=i;
                if(neko==x) {
                        cout << "YES" << endl;
                        return 0;
                }
        }
        cout <<"NO" << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

// c++11
#include <array>
#include <tuple>
#include <unordered_map>
#include <unordered_set>

#define mp make_pair
#define mt make_tuple
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

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

const int INF = 1 << 29;
const double EPS = 1e-9;
const ll MOD = 1000000007;

const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
int N;
const int MAX_N = 11;
int dp[MAX_N][2];
vector<int> A;
int memo(int pos, int flag){
  if (pos >= N){
    if (flag){
      return 1;
    }
    return 0;
  }
  int &res = dp[pos][flag];
  if (res >= 0){
    return res;
  }
  res = 0;
  res += memo(pos + 1, flag | ((A[pos] - 1) % 2 == 0));
  res += memo(pos + 1, flag | (A[pos] % 2 == 0));
  res += memo(pos + 1, flag | ((A[pos] + 1)% 2 == 0));
  return res;
}

int main() {
  cin >> N;
  A.resize(N);
  for (auto &val : A){
      cin >> val;
  }
  memset(dp, -1, sizeof(dp));
  cout << memo(0, 0) << endl;
  return 0;
}


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

using namespace std;

const int MAX = 10000000;
const int MOD = 1000000007;

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

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

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

int main() {

    COMinit();

    long long H, W, A, B;
    cin >> H >> W >> A >> B;

    long long result = 0;

    for(int i=B; i<W; i++) {
        long long y = H - A - 1;
        long long x = i;
        long long temp1 = COM(x+y, x);
        y = H - 1 - (H - A);
        x = W - 1 - i;
        long long temp2 = COM(x+y, x);
        result += (temp1 * temp2);
        result %= MOD;
    }

    cout << result << endl;

    return 0;
}

Measured memory_bytes: 234752
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
typedef long long ll;
int main() {
  int n;
  cin >> n;
  vector<int> d(n);
  rep(i,n) cin >> d[i];
  sort(d.begin(), d.end());
  int ans = 0;
  for(int i=1; i<100001; i++){
    if(i<=d[n/2] && i>d[n/2-1]){
      ans++;
    }
  }
  cout << ans << endl;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,X,Y;
int A[2020];
int memoX[2020][2020];
int memoY[2020][2020];

int turnY(int op,int left);
int turnX(int op,int left) {
	if(memoX[left][op]>=0) return memoX[left][op];
	// all
	int ret=abs(A[0]-A[op]);
	if(left>1) ret=max(ret,turnY(left-1,left-1));
	if(left>1) ret=max(ret,turnX(op,left-1));
	return memoX[left][op]=ret;
}
int turnY(int op,int left) {
	if(memoY[left][op]>=0) return memoY[left][op];
	// all
	int ret=abs(A[0]-A[op]);
	if(left>1) ret=min(ret,turnX(left-1,left-1));
	if(left>1) ret=min(ret,turnY(op,left-1));
	return memoY[left][op]=ret;
}


void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>X>>Y;
	FOR(i,N) cin>>A[i];
	reverse(A,A+N);
	A[N]=Y;
	MINUS(memoX);
	MINUS(memoY);
	cout<<turnX(N,N)<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 32384
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = a; i < b; ++i)
#define all(c) c.begin(), c.end()
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
using namespace std;

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

int main(){
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	int n;
	cin >> n;
	vector<int> v(n+2, 0);
	rep(i,1,n+1)cin >> v[i];
	int cst = 0;
	rep(i,0,n+1)cst += abs(v[i+1] - v[i]);
	rep(i,1,n+1){
		cout << cst - abs(v[i-1] - v[i]) - abs(v[i+1] - v[i]) + abs(v[i-1] - v[i+1]) << '\n';
	}
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
template<class T> inline bool chmin(T&a, T b){if(a > b){a = b; return true;}else{return false;}}
template<class T> inline bool chmax(T&a, T b){if(a < b){a = b; return true;}else{return false;}}
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1.0)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    string a, b, c, ans = "";
    cin >> a >> b >> c;
    ans += toupper(a[0]);
    ans += toupper(b[0]);
    ans += toupper(c[0]);
    cout << ans << endl;
}

Measured memory_bytes: 3636
#include<stdio.h>
int main(void)
{
  int a,b,num,ans=0,arr[5];
  scanf("%d%d",&a,&b);
  for(int i=a;i<b+1;i++){
    num=i;
    for(int j=0;j<5;j++){
      arr[j]=num%10;
      num=num/10;
      if(j>2){
        if(arr[j]!=arr[4-j]){
          break;
        }else if(j==4){
          ans++;
        }
      }
    }
  }
  printf("%d",ans);
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <algorithm>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,b) FOR(i,0,b)
#define PB push_back
#define MP make_pair
int main(){
  string data[10]={"* = ****","* =* ***","* =** **","* =*** *","* =**** "," *= ****"," *=* ***"," *=** **"," *=*** *"," *=**** "};
  string s;
  int n=0;
  while(cin>>s){
    if(n!=0)cout<<endl;
    n=1;
    string ans[5];
    for(int i=0;i<5-s.size();i++)ans[i]="* = ****";
    int k=5-s.size();
    for(int i=0;i<s.size();i++){
      ans[k]=data[s[i]-'0'];
      k++;
    }
    for(int i=0;i<8;i++){
      for(int j=0;j<5;j++){
        cout<<ans[j][i];
      }
      cout<<endl;
    }
  }
}

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP (i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back

using namespace std;

typedef long long ll;

const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const int MOD = 1000000007;

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> h(n);
  rep (i, n) cin >> h[i];

  vector<int> dp(n, INF);
  dp[0] = 0;

  rep (i, n) REP (j, 1, k + 1) {
    if (i - j >= 0) dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
  }

  cout << dp[n - 1] << endl;
}


Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.CookieHandler;
import java.util.*;

public class Main {
    static PrintWriter out = new PrintWriter(System.out);
    static Scanner sc = new Scanner(System.in);
    static BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    public static void main(String[] args) throws IOException {
        Main main = new Main();
        main.solve();
//        System.out.println(main.solve());
    }
    void solve() throws IOException {
        int n = sc.nextInt();
        int[] x = new int[n];
        for(int i=0;i<n;i++) x[i] = sc.nextInt();
        long mini = Long.MAX_VALUE/2;
        for(int i=0;i<=100;i++){
            long cur = helper(x,i);
            mini = Math.min(mini,cur);
        }
        System.out.println(mini);
    }
    long helper(int[] x, int guess){
        long ans = 0;
        for(int s:x){
            long diff = s-guess;
            ans += diff*diff;
        }
        return ans;
    }
}



Measured memory_bytes: 21588
//#include"pch.h"
//#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<algorithm>
#include<iostream>

using namespace std;
int main() {

	int N;
	int l[100000], r[100000];
	int ans = 0;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> l[i] >> r[i];
	}
	for (int i = 0; i < N; i++) {
		ans += r[i] - l[i] + 1;
	}
	cout << ans << endl;




	return(0);
}

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

using namespace std;

int main() {
	int N;
	int a[100000], ans, num, p;

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

	sort(a, a + N);

	num = a[0]; p = 0;
	ans = 0;
	for (int i = 0; i < N; i++) {
		if (num != a[i]) { 
			if (i - p >= num) { ans = ans + i - p - num; }
			else { ans = ans + i - p; }
			num = a[i]; p = i; 
		}
	}
	if (N - p >= num) { ans = ans + N - p - num; }
	else { ans = ans + N - p; }

	printf("%d\n", ans);
}

Measured memory_bytes: 512
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <unordered_set>
using namespace std;
#define inf 999999999
#define loop(i, a, b) for (int i = (a), i##len = (b); i < i##len; ++i)
#define rep(i, n) loop(i, 0, n)
#define lin long long

lin n, a, b;
lin r[300001];

int main(void)
{
    cin >> n >> a >> b;

    if (n > a * b)
    {
        cout << -1 << endl;
        return 0;
    }

    if (n + 2 <= a + b)
    {
        cout << -1 << endl;
        return 0;
    }

    if (b == 1)
    {
        rep(i, n - 1)
        {
            cout << (i + 1) << " ";
        }

        cout << n << endl;

        return 0;
    }

    rep(i, a)
    {
        r[i] = (n - a) + 1 + i;
    }

    int rest = (n - a) % (b - 1);
    rep(i, rest)
    {
        r[a + i] = rest - i;
    }

    int full = (n - a) / (b - 1);
    rep(i, full)
    {
        rep(j, b - 1)
        {
            int index = a + rest + i * (b - 1) + j;
            r[index] = rest + i * (b - 1) + (b - 1 - j);
        }
    }

    rep(i, n - 1)
    {
        cout << r[i] << " ";
    }

    cout << r[n - 1] << endl;

    return 0;
}


Measured memory_bytes: 4480
import java.util.*;
class Main
{
    public static void main (String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        long k = sc.nextLong() % 2;
        System.out.println((k == 0) ? a - b : b - a);
    } 
 }




Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define MOD 1000000007
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
typedef long long ll;
typedef int64_t in;

using namespace std;

ll a,b,c,d;
ll cnt=0;

ll gcd(ll c, ll d){
    if(d == 0) return c;
    else return gcd(d, c % d);
}

int main(){
    //ll a,b,c,d;
    cin >> a >> b >> c >> d;
    ll l;
    l = c * d / gcd(c,d);
    cnt += b / c - (a - 1) / c;
    
    cnt += b / d - (a - 1) / d;
    
    cnt -= b / l - (a - 1) / l;
    ll ans;
    
    ans = b - a  - cnt + 1;
    

    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <numeric>
#include <string>
#include <cassert>
#include <bitset>

using namespace std;
typedef long long ll;

int main() {
  int H, N;
  cin >> H >> N;
  vector<int> A(N);

  for (int i = 0; i < N; ++i) {
    cin >> A[i];
  }
  
  int sum = 0;
  for (int i = 0; i < N; ++i) {
    sum += A[i];
  }
  
  if (sum >= H) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  
  return 0;
}


Measured memory_bytes: 640
/*

This Submission is to determine how many 120/240 min const. delivery point there are.

//info
120 req. steps <= 5
*/
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;
typedef string::const_iterator State;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 1e18
#define GOLD 1.61803398874989484820458
#define MAX_MOD 998244353
#define MOD 998244353
#define seg_size 262144
#define REP(a,b) for(long long a = 0;a < b;++a)

unsigned long xor128() {
	static unsigned long x = time(NULL), y = 362436069, z = 521288629, w = 88675123;
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}
long long dp[8] = {};
int main(){
	int n;
	string s;
	cin >> n;
	cin >> s;
	long long ans = 1;
	long long remaining[5] = { 0,n,n,0,n };
	REP(i, s.length()) {
		int hoge = 0;
		if (s[i] == 'R') {
			hoge = 1;
		}
		else if (s[i] == 'G') {
			hoge = 2;
		}
		else if (s[i] == 'B') {
			hoge = 4;
		}
		if (dp[7 - hoge] != 0) {
			ans *= dp[7 - hoge];
			dp[7 - hoge]--;
			ans %= MAX_MOD;
			remaining[hoge]--;
			continue;
		}
		int ok = 0;
		for (int q = 1; q <= 8; q *= 2) {
			if (hoge != q && dp[q] != 0) {
				ans *= dp[q];
				ans %= MAX_MOD;
				dp[q]--;
				dp[q + hoge]++;
				remaining[hoge]--;
				ok = 1;
				break;
			}
		}
		if (ok == 0) {
			dp[hoge]++;
			ans *= remaining[hoge];
			ans %= MAX_MOD;
			remaining[hoge]--;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 900
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    n = int(input().strip())
    a_list = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

    print(a_list[n - 1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
get_number(Number) :-
    get_string(String),
    number_string(Number, String).

get_number(A, B) :-
    get_number(A),
    get_number(B).

get_number(A, B, C) :-
    get_number(A, B),
    get_number(C).

get_string(String) :-
    current_input(Input),
    read_string(Input, ' \n', '', _, String).

/* memo
    code(int)
    string_code(1, S, C), (C: code)
    char_code(X, Y) (X: char, Y: code)
    string_chars(S, S2) (S: string, S2: [char])
    to_lower(C, C2) (C: char? C2: code?)
    sub_string

    f(0, [], []).
    f(Z, [X|Xs], [Y|Ys]) :- X = Y, f(Z1, Xs, Ys), Z is Z1 + 1.
    f(Z, [_|Xs], [_|Ys]) :- f(Z, Xs, Ys).

    match: =, \=

    numeric: <,=<, >, >= (eval)
    lexicographically: @<. @=<, @>, @>=
    value?: =:=, =\= (eval)
    identical: ==, \==
*/

f("<", S, T) :- S @< T.
f("=", S, T) :- S == T.
f(">", S, T) :- S @> T.

main :-
    get_string(S),
    get_string(T),
    f(X, S, T),
    writeln(X).


Measured memory_bytes: 8088
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		ArrayList<Integer> list = new ArrayList<Integer>();
		
		boolean check = true;
		Integer temp;
		while(check) {
			temp = scan.nextInt();
			if(temp.equals(0)) {
				check = false;
			}else {
				list.add(temp);
			}
		}
		
		for(int i = 0; i < list.size(); i++) {
			System.out.println("Case" + " " + (i + 1) + ": " + list.get(i));
		}
		
	}

}



Measured memory_bytes: 43596
#include<iostream>
#include<vector>
#include<string>
using namespace std;

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

int main() {
	int h, w; cin >> h >> w;
	vector<string>s(h);
	for (int i = 0; i < h; i++) {
		string tmp; cin >> tmp;
		s[i] = tmp;
	}
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (s[i][j] == '.') {
				int cnt = 0;
				for (int xy = 0; xy < 8; xy++) {
					int ni = dx[xy] + i;
					int nw = dy[xy] + j;
					if (0 <= ni && ni < h && 0 <= nw && nw < w) {
						if (s[ni][nw] == '#')cnt++;
					}
				}
				cout << cnt;
			}
			else cout << s[i][j];
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;

int n, w[100], s1, s2;
int s = 10000000;
int main(){
	cin >> n;
	for (int i = 0; i < n; i++) cin >> w[i];


	for (int i = 0; i < n; i++){

		for (int j = 0; j <= i; j++){
			s1 += w[j];
		}

		for (int k = n - 1; k > i; k--){
			s2 += w[k];
		}
		s = min(s, abs(s2 - s1));

		s2 = 0;
		s1 = 0;
	}

	cout << s << endl;
	return 0;
}

Measured memory_bytes: 384
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        
        final long A = Integer.parseInt(sc.next());
        final long B = Integer.parseInt(sc.next());
        
        out.println(A * B / gcd(A,B));
        
        out.flush();
    }
    
    public static long gcd(long m, long n) {
        long rem;
        while ((rem = m % n) != 0) {
            m = n;
            n = rem;
        }
        return n;
    }
}

Measured memory_bytes: 23252
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(m);(i)<(n);++(i))
#define rREP(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;
template<class T>inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T>inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}


int main() {
	init();

	int N; cin >> N;
	map<int, int>mp;
	rep(i, 1, 101) {
		rep(j, 1, 101) {
			rep(k, 1, 101) {
				int sum = i * i + j * j + k * k + i * j + j * k + k * i;
				mp[sum]++;
			}
		}
	}
	rep(i, 1, N + 1) {
		cout << mp[i] << "\n";
	}

	return 0;
}

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

#define int long long
#define ci(m)     for(int i=0;i<m;i++)
#define cj(m)     for(int j=0;j<m;j++)
#define ck(m)     for(int k=0;k<m;k++)
#define gcd            __gcd
#define endl           "\n"
#define pb             emplace_back
#define setbits(x)     __builtin_popcountll(x)
#define zrobits(x)     __builtin_ctzll(x)
#define mod            1000000007
#define mod2           998244353
#define maxe           *max_element
#define mine           *min_element
#define inf            1e18
#define deci(x, y)      fixed<<setprecision(y)<<x
#define w(t)           int t; cin>>t; while(t--)
#define nitin          ios_base::sync_with_stdio(false); cin.tie(NULL)
#define PI             3.141592653589793238
using namespace std;

int32_t main() {
    nitin;
    long double r;
    cin>>r;
    cout<<fixed<<setprecision(10)<<2*PI*r<<endl;
    return 0;
}

Measured memory_bytes: 3832
import java.util.Arrays;
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int[] array = new int[N];
		int[] array_ = new int[N];
		for (int i = 0; i < N; i++) {
			int current = Integer.parseInt(sc.next());
			array[i] = current;
			array_[i] = current;
		}
		sc.close();
		Arrays.sort(array_);
		int count = 0;
		for (int i = 0; i < N; i++) {
			if (array[i] != array_[i]) {
				count++;
			}
		}
		if (count > 2) {
			System.out.println("NO");
		} else {
			System.out.println("YES");
		}
	}
}

Measured memory_bytes: 21844
n, m = map(int, input().split())
matrix = []
vector = []
for _ in range(n):
    matrix.append([int(i) for i in list(input().split())])
for _ in range(m):
    vector.append(int(input()))
# print(matrix)
# print(vector)

for i in range(n):
    print(sum([ma * ve for ma, ve in zip(matrix[i], vector)]))
    


Measured memory_bytes: 6024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		for (int i = 1; i <= n; i++) {
			//int i = 1;

			int x = i;

			if (x % 3 == 0) {
				System.out.print(" " + i);
			} else {
				while (x >= 3) {
					if (x % 10 == 3) {
						System.out.print(" " + i);
						break;
					}
					x = x / 10;
				}
			}
		}
		System.out.println();
	}

}



Measured memory_bytes: 28968
#include <iostream>
#include <string>
#include <cstdio>
#include <cstring>
#include <map>
using namespace std;

map<string, int> mp;
string s;

int solve(int l, int r) {
    int pos = l, ret = 0;
    while(pos < r) {
        // Atom (Number)
        if(isupper(s[pos])) {
            string atom;
            if(pos<r-1 && islower(s[pos+1])) {
                atom = s.substr(pos, 2);
                pos += 2;
            }
            else {
                atom = s[pos];
                pos += 1;
            }

            if(!mp.count(atom)) return -1;
            else {
                int A = mp[atom], B = 0;
                while(isdigit(s[pos])) {
                    B = (B * 10) + (s[pos++] - '0');
                }
                ret += A * max(B, 1);
            }
        }
        else if(s[pos] == '(') {
            int sum = 0, nl = pos+1, val = -1;
            for(;;pos++) {
                if(s[pos] == '(') sum++;
                if(s[pos] == ')') {
                    sum--;
                    if(sum == 0) {
                        int nr = pos++;
                        val = solve(nl, nr);
                        if(val == -1) return -1;
                        break;
                    }
                }
            }

            int A = val, B = 0;
            while(isdigit(s[pos])) {
                B = (B * 10) + (s[pos++] - '0');
            }
            ret += A * max(B, 1);
        }
    }
    return ret;
}

int main() {
    while(1) {
        string t; cin >> t;
        if(t == "END_OF_FIRST_PART") break;
        int val; cin >> val;
        mp[t] = val;
    }

    while(1) {
        cin >> s;
        if(s == "0") break;

        int N = s.length();
        int ans = solve(0, N);
        cout << (ans == -1 ? "UNKNOWN" : to_string(ans)) << endl;
    }
    return 0;
}


Measured memory_bytes: 3164
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep2(j,n) for(int j = 0; j < (n); ++j)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define drep2(j,n) for(int j = (n)-1; j >= 0; --j)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define srep2(j,s,t) for (int j = s; j < t; ++j)
#define srep3(k,s,t) for (int k = s; k < t; ++k)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
  
int main() {
  int N;
  cin >> N;
  vi A(N+1);
  rep(i,N) {
    cin >> A[i+1];
  }
  int now = 1;
  vi history;
  while(true) {
    now = A[now];
    if(now == 2) {
      cout << sz(history) + 1 << endl;
      return 0;
    }
    if(sz(history) > sz(A)) {
      cout << -1 << endl;
      return 0;
    }
    history.push_back(now);
  }
  return 0;
}

Measured memory_bytes: 1276
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int k = sc.nextInt();

        for (int i = 0 ; i <= n ; i++) {
            for (int j = 0 ; j <= m ; j++) {
                if (i * m + j * n - i * j * 2 == k) {
                    System.out.println("Yes");
                    return;
                }
            }
        }
        System.out.println("No");
    }
}

Measured memory_bytes: 23252
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.numeric;
import std.stdio;
import std.string;

void main()
{
    long n = readln.chomp.to!long;
    long[] a = readln.chomp.split(" ").to!(long[]);

    long sum;

    foreach (x; a)
    {
        sum += x - 1;
    }

    writeln(sum);
}


Measured memory_bytes: 380
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <iterator>  // std::back_inserter()
#include <algorithm>  // std::copy()
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
using namespace std;

#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (int i=0; i < (int)(n); i++)  // 0 ~ n-1
#define REPN(i, n) for (int i=1; i <= (int)(n); i++)  // 1 ~ n
#define DESCEND greater<int>()  // sort 降順 大きい順
#define UNIQUE(vec) (vec).erase(unique(ALL((vec))), (vec).end());  // 必ずsortを行なってから
#define MIN(vec) min_element(ALL((vec)))  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(ALL((vec)))
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(ALL((vec)), 0)  // 0 は初期値
#define COPY(vec1, vec2) copy(ALL(vec1), back_inserter(vec2))  // vec1をvec2にコピーする vec2は空にしておく必要あり
typedef long long ll;

const int MOD = 1000000007;  // 1 000 000 007


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

    // input
    int N;
    cin >> N;
    vector<float> vec(N);
    REP(i, N) cin >> vec.at(i);
    
    // calculation
    float ave = (float)SUM(vec)/(float)vec.size();
    REP(i, N) {
        vec.at(i) = abs(vec.at(i) - ave);
    }
    cout << IDX(vec, MIN(vec)) << "\n";
    
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <map>
using namespace std;
 
int a[100000];
 
int main() {
	int N; cin >> N;
	for (int i = 0; i < N; i++)
		cin >> a[i];
 
	map<int, int> mp;
	for (int i = 0; i < N; i++)
		mp[a[i]]++;
 
	int ans = 0;
	
	map<int , int>::iterator iter;
	
	for (iter = mp.begin();iter != mp.end();iter++)
	{
		int x = iter->first;
		int n = iter->second;
		if (n < x) ans += n;
		else ans += n - x;
	}
 
	cout << ans << endl;
}

Measured memory_bytes: 5120
import sys
import copy
import math
import bisect
import pprint
import bisect
from functools import reduce
from copy import deepcopy
from collections import deque
from decimal import *

import numpy


if __name__ == '__main__':
    an = int(input())
    a = [i for i in input().split()]
    ans = len(set(a))

    if ans == 4:
        print("Four")
    else:
        print("Three")




Measured memory_bytes: 14820
#include <stdio.h>

#define SENTINEL 1000000001

int count = 0;

void trace(int a[], int size) {
    for (int i = 0; i < size; ++i) {
        if (i > 0) {
            printf(" ");
        }
        printf("%d", a[i]);
    }
    printf("\n");
}

void Merge(int A[], int left, int mid, int right) {
    int n1 = mid - left;
    int n2 = right - mid;
    int L[n1], R[n2];
    for (int i = 0; i < n1; ++i) {
        L[i] = A[left + i];
    }
    for (int i = 0; i < n2; ++i) {
        R[i] = A[mid + i];
    }
    L[n1] = SENTINEL;
    R[n2] = SENTINEL;
    int m = 0;
    int n = 0;
    for (int i = left; i < right; ++i) {
        if (L[m] <= R[n]) {
            A[i] = L[m];
            ++m;
        }
        else {
            A[i] = R[n];
            ++n;
        }
        count++;
    }
}

void MergeSort(int A[], int left, int right) {
    if (left >= right - 1) return;
    int mid = (left + right) / 2;
    MergeSort(A, left, mid);
    MergeSort(A, mid, right);
    Merge(A, left, mid, right);
}

int main() {
    int N;
    int A[500000];

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

    MergeSort(A, 0, N);
    trace(A, N);
    printf("%d\n", count);
    return 0;
}

Measured memory_bytes: 6588
using System;
using static System.Console;

class Program
{
    public static void Main()
    {
        int n = int.Parse(ReadLine());
        string s = ReadLine();

        int res = 0;
        int[,] dp = new int[n+1, n+1];
        for (int i = n-1; i >= 0; i--)
        {
            for (int j = n-1; j > i; j--)
            {
                if (s[i] == s[j])
                    dp[i,j] = Math.Max(dp[i,j], dp[i+1, j+1] + 1);
                res = Math.Max(res, Math.Min(dp[i, j], j-i));
            }
        }

        WriteLine(res);
    }
}


Measured memory_bytes: 108640
#include<algorithm>
#include<iomanip>
#include<iostream>
#include<queue>
#include<stack>
#include<vector>
using namespace std;

typedef long long lint;

int main(){
    int n;
    cin >> n;
    if(n < 1000){
        cout << "ABC" << endl;
    }else{
        cout << "ABD" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <bitset>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef long long LL;

typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
const LL MOD = 1e9+7; 
//vector <vector<int>> x(20, vector<int> (20)), y(20,vector<int> (20));
/*int counter_1 (int x) {
    if(x == 0) return 0;
    return counter_1(x >> 1) + (x & 1);
}*/

//int Counter(int x)
int main(){
   int n, k;
   cin >> n >> k;
   VL h(n);
   REP(i, n){
       cin >> h[i];
       //cout << h[i] << endl;
   }
   sort(ALL(h), greater<LL>());
   LL ans = MOD;
   REP(i, n-k+1){
       LL tmp=h[i]-h[i+k-1];
       //cout << tmp << endl;
       ans = min(ans, tmp);
   }
   cout << ans << endl;


   


}

    



Measured memory_bytes: 1024