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

int main() {
    int n;
    cin>>n;
    
    string s;
    cin>>s;
    int ans=0;
    vector<vector<int>> dp(n+1,vector<int>(n+1));
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            if(s[i]==s[j] && j-i>=dp[i][j]+1){
                dp[i+1][j+1]=dp[i][j]+1;
                ans = max(ans,dp[i+1][j+1]);
            }
        }
    }
    // for(int i=0;i<=n;i++){
    //     for(int j=0;j<=n;j++)
    //         cout<<dp[i][j]<<" ";
    //     cout<<endl;
    // }
    cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 98176
#include <vector>
#include <cstdio>

using namespace std;

int main()
{
  int n=0;
  scanf("%d", &n);
  vector<int> v;
  for(int i=0; i<n; ++i) {
    int data=0;
    scanf("%d", &data);
    v.push_back(data);
  }
  int ans=1;
  int acc=v[0];
  for(int i=1; i<n; ++i) {
    if (v[i] >= acc) {
      acc = v[i];
      ++ans;
    }
  }
  printf("%d", ans);
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
using namespace std;
typedef long long LL;
const LL INF = 0x3f3f3f3f3f3f3f3f;

LL ec = 0,hed[200005] = {0},to[400005],w[400005],nxt[400005];
void add_edge(LL f,LL t,LL cst){
	++ ec; to[ec] = t; nxt[ec] = hed[f]; w[ec] = cst; hed[f] = ec;
}

LL siz[200005],mx[200005];
LL ans = 0,n;

void dfs(LL u,LL f){
	siz[u] = 1;
	for(LL i = hed[u];i;i = nxt[i]){
		LL v = to[i];
		if(v == f) continue;
		dfs(v,u);
		siz[u] += siz[v]; mx[u] = max(mx[u],siz[v]);
		ans += 2 * min(siz[v],n - siz[v]) * w[i];
	}
	mx[u] = max(mx[u],n - siz[u]);
}

int main(){
	ios::sync_with_stdio(false);
	LL u,v,ww,g = INF,sub = INF,p1 = 0,p2 = 0;
	cin >> n;
	for(LL i = 1;i < n;i ++){
		cin >> u >>	v >> ww;
		add_edge(u,v,ww);
		add_edge(v,u,ww);
	}
	dfs(1,0);
	for(LL i = 1;i <= n;i ++) g = min(g,mx[i]);
	for(LL i = 1;i <= n;i ++){
		if(mx[i] != g) continue;
		if(!p1) p1 = i;
		else p2 = i;
	}
	for(LL i = hed[p1];i;i = nxt[i]){
		LL v = to[i];
		if(p2 && v != p2) continue;
		sub = min(sub,w[i]);
	}
	cout << ans - sub << endl;
	return 0;
}

Measured memory_bytes: 16512
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>		//UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>		//do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)
#define ALL(u) (u).begin(),(u).end()

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

typedef pair<int, int> PII;

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;

const int MR = 2e5 + 10;

vector<int> g[MR];

int dist[MR];

void dfs(int nr)
{
	for(int i : g[nr])
		if (!dist[i])
		{
			dist[i] = dist[nr] + 1;
			dfs(i);
		}
}

int main()
{
	int N;
	scanf("%d", &N);
	REP(i, N - 1)
	{
		int A, B;
		scanf("%d%d", &A, &B); A--; B--;
		g[A].push_back(B);
		g[B].push_back(A);
	}

	dist[0] = 1;
	dfs(0);
	int mxnr = 0;
	FOR(i, 1, N)
		if (dist[i] > dist[mxnr])
			mxnr = i;

	memset(dist, 0, sizeof(dist));
	dist[mxnr] = 1;
	dfs(mxnr);

	int mxl = 0;
	REP(i, N)
		mxl = max(mxl, dist[i]);

	if (mxl % 3 == 2)
		printf("Second\n");
	else
		printf("First\n");

	return 0;
}

// FOR GNU C++ use the following pattern:
// Uncomment the code below and change your main into main2
// It does not build in MS C++
// But it does increase the stack size from 256 MB on CF and uses GNU C++

//#include <Processthreadsapi.h>
//#include <iostream>
//#include <Synchapi.h>
//#include <windows.h>
//#include <process.h>
//
//DWORD WINAPI MyThreadFunction(LPVOID lpParam) {
//    main2(nullptr);
//    return 0;
//}
//int main() {
//    auto h = CreateThread(nullptr, 1024 << 20, MyThreadFunction, nullptr, STACK_SIZE_PARAM_IS_A_RESERVATION, nullptr);
//    WaitForSingleObject(h, INFINITE);
//}

Measured memory_bytes: 17536
#include<iostream>
using namespace std;
 
int main(){
  
  int a,b;
  cin >> a >> b;
  
  if(b < 0){
    cout << "IMPOSSIBLE" << endl;
  }else if(b+(a-b)/2 == a-(a-b)/2){
    cout << b+(a-b)/2 << endl;
  }
  else{
    cout << "IMPOSSIBLE" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
IDENTIFICATION DIVISION.
PROGRAM-ID. 164B.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 INP        PIC X(20).
01 A          PIC 9(3).
01 B          PIC 9(3).
01 C          PIC 9(3).
01 D          PIC 9(3).
01 K1         PIC 9(3).
01 K2         PIC 9(3).
*>
PROCEDURE DIVISION.
  ACCEPT INP.
  UNSTRING INP DELIMITED BY ' '
      INTO A B C D.
*>
  COMPUTE K1 = (A + D - 1) / D.
  COMPUTE K2 = (C + B - 1) / B.
*>
  IF (K1 >= K2)
    DISPLAY 'Yes'
  ELSE
    DISPLAY 'No'
  END-IF. 
*>
  STOP RUN.


Measured memory_bytes: 3940
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>
#include <queue>
#include <string>
#include <map>
#include <set>

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

int w, h;
int cnt;
char dirtoc[200];
int mapto[40][40];
char field[40][40];
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
char ans[100];

struct State {
  int used;
  int x;
  int y;
  int dir;
  State() {;}
  State(int used, int x, int y, int dir) : used(used), x(x), y(y), dir(dir) {;}
  bool operator<(const State &rhs) const {
    if (used != rhs.used) { return used < rhs.used; }
    if (x != rhs.x) { return x < rhs.x; }
    if (y != rhs.y) { return y < rhs.y; }
    return dir < rhs.dir;
  }
};

set<State> visit;
bool calc(State state) {
  if (visit.count(state)) { return false; }
  int depth = __builtin_popcount(state.used);
  if (depth == cnt - 1) { return true; }
  visit.insert(state);
  field[state.y][state.x] = '.';
  int nused = state.used | (1 << mapto[state.y][state.x]);
  REP(i, 4) {
    if (i == 2) { continue; }
    int ndir = (state.dir + i) % 4;
    int nx = state.x;
    int ny = state.y;
    ans[depth] = dirtoc[ndir];
    while (field[ny][nx] != 'o') {
      nx += dx[ndir];
      ny += dy[ndir];
      if (nx < 0 || nx >= w || ny < 0 || ny >= h) { goto ng; }
    }
    if (calc(State(nused, nx, ny, ndir))) { return true; }
ng:;
  }
  field[state.y][state.x] = 'o';
  return false;
}

int main() {
  dirtoc[0] = 'R';
  dirtoc[1] = 'D';
  dirtoc[2] = 'L';
  dirtoc[3] = 'U';
  while (scanf("%d %d", &h, &w) > 0) {
    int px, py, dir;
    cnt = 0;
    MEMSET(mapto, -1);
    MEMSET(ans, 0);
    visit.clear();
    REP(y, h) {
      scanf("%s", field[y]);
      REP(x, w) {
        if (field[y][x] == 'R') { dir = 0; field[y][x] = 'o'; px = x; py = y; }
        if (field[y][x] == 'D') { dir = 1; field[y][x] = 'o'; px = x; py = y; }
        if (field[y][x] == 'L') { dir = 2; field[y][x] = 'o'; px = x; py = y; }
        if (field[y][x] == 'U') { dir = 3; field[y][x] = 'o'; px = x; py = y; }
        if (field[y][x] == 'o') {
          mapto[y][x] = cnt++;
        }
      }
    }
    bool ok = calc(State(0, px, py, dir));
    puts(ans);
  }
}

Measured memory_bytes: 0
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

long long solve(long long a)
{
    long long ans = 0;
    if(a / 2 % 2 != 0)
        ans ^= 1;
    if(a % 2 != 0)
        ans ^= a & ~1;
    return ans;
}

int main()
{
    long long a, b;
    cin >> a >> b;
    ++ b;

    long long ans = solve(a) ^ solve(b);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
//#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
//#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
//#pragma GCC target("avx2")  //Enable AVX
#include<bits/stdc++.h>
using namespace std;

#define all(a) begin(a),end(a)
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define sz(a) ((int)a.size())
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif

const int mod=1e9+7;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int mul(int a,int b){
  return ((a)*1ll*(b))%mod;
}

void add(int &a,int b){
  a+=b;
  if(a>=mod)a-=mod;
}

int sub(int a,int b){
  a-=b;
  if(a<0){
    a+=mod;
  }
  return a;
}

int powz(int a,int b){
  int res=1;
  while(b){
    if(b&1){
      res=mul(res,a);
    }
    b/=2;
    a=mul(a,a);
  }
  return res;
}

template <typename A, typename B>
istream& operator>>(istream& input,pair<A,B>& x) {
  input>>x.F>>x.S;
  return input;
}

template <typename A>
istream& operator>>(istream& input,vector<A>& x) {
  for(auto& i:x)
    input>>i;
  return input;
}

template<typename A>
ostream& operator<<(ostream& output,vector<A>& x) {
  for(auto& i:x)
    output<<i<<' ';
  return output;
}

template<typename T>
vector<pair<T,int>> getvec(int n){
  vector<pair<T,int>>a(n);
  for(int i=0;i<a.size();i++){
    cin>>a[i].F;
    a[i].S=i;
  }
  return a;
}

const int N=200005;
/*
double nthRoot(ll A, int N) 
{ 
    // intially guessing a random number between 
    // 0 and 9 
    double xPre = rand() % 10; 
  
    //  smaller eps, denotes more accuracy 
    double eps = 1e-18; 
  
    // initializing difference between two 
    // roots by INT_MAX 
    double delX = 1e18+100; 
  
    //  xK denotes current value of x 
    double xK; 
  
    //  loop untill we reach desired accuracy 
    while (delX > eps) 
    { 
        //  calculating current value from previous 
        // value by newton's method 
        xK = ((N - 1.0) * xPre + 
              (double)A/pow(xPre, N-1)) / (double)N; 
        delX = abs(xK - xPre); 
        xPre = xK; 
    } 
  
    return xK; 
} 

const double eps=1e-20;
bool check(ll val){
  double zz=nthRoot(val,5);
  //if(val==-1)
  debug(zz);
  ll valz=zz;
  if(fabs(valz*valz*valz*valz*valz-val)<eps){
    return true;
  }
  return false;
  }*/

void solve(){
  /*int X;
  cin>>X;
  for(int i=1;i<=5000;i++){
     ll val=i*1ll*i*i*i*i;
    ll val2=val-X;
    if(i==2){
      debug(val2,check(val2));
    }
    if(check(val2)){
      cout<<val<<' '<<val2;
      return;
    }
    }*/
  int n;
  cin>>n;
  vi a(n);
  cin>>a;
  map<int,int>val;
  ll ans=0;
  //a[j]+a[i]==j-i
  for(int i=0;i<n;i++){
    ans+=val[a[i]-i];
    val[-a[i]-i]++;
  }
  cout<<ans;
  
      
}

signed main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int tc=1;
  //cin>>tc;
  for(int _=0;_<tc;_++){
    // cout<<"Case #"<<_+1<<": ";
    solve();
    if(_!=tc-1){
      cout<<'\n';
    }
  }
}



Measured memory_bytes: 21084
b = gets()
a = b.split
W = a[0].to_i
H = a[1].to_i
x = a[2].to_i
y = a[3].to_i
r = a[4].to_i

if 0 <= x - r && x + r <= W && 0 <= y - r && y + r <= H
    puts "Yes"
else
    puts "No"
end



Measured memory_bytes: 6872
#include<iostream>
#include<cmath>
#include<string>
#include<vector>

using namespace std;
#define ll long long 

int  main(){
    int a,b;
    cin >> a >> b;
    if((a+b)%2 ==0){
        int ans = (a+b)/ 2;
        cout << ans << endl;
    }else{
        int ans = (a+b)/ 2 + 1;
        cout << ans << endl;
    }
}    

Measured memory_bytes: 888
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(vector<int> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%d%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}
void array_show(vector<LL> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%lld%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}

int main(){
	int n,m;
	int i,j,k;
	int a,b,c;
	cin>>a>>b;
	cin>>b>>c;
	if(a!=b)cout<<"1"<<endl;
	else cout<<"0"<<endl;
}

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

#define int long long

using namespace std;

int a[100001];

 main () {
 	int n;
 	cin >> n;
 	int k;
 	cin >> k;
 	for (int i = 1;i <= n;i ++) {
 		cin >> a[i];
 	}
 	sort (a + 1, a + n + 1);
	int kol = 0;
	for (int i = 1;i <= n;i ++) {
		if (k >= a[i]) k -= a[i], kol ++;
	}
	if (kol == n && k) {
		cout << kol - 1;
	}
	else cout << kol;
	return 0; 
}

Measured memory_bytes: 256
#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>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
#define seg_size 524288
int main() {
	int n;
	cin >> n;
	vector<int> pe;
	int for_good[30000] = {};
	REP(i, n) {
		int tmp;
		cin >> tmp;
		for_good[tmp-1] = i + 1;
	}
	for (int i = 0;i < n;++i) {
		cout << 30000 * (i + 1) + for_good[i] << " ";
	}
	cout << endl;
	for (int i = 0;i < n;++i) {
		cout << 30000 * (n - i) << " ";
	}
	cout << endl;
	return 0;
}

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

int main() {
	int N;
	cin >> N;
	vector<int> A(N + 1);
	vector<int> B(N);
	unsigned long ans = 0;
	for(int i = 0; i < N + 1; i++){
		cin >> A.at(i);
	}
	for(int i = 0; i < N; i++){
		cin >> B.at(i);
	}
	for(int i = 0; i < N; i++){
		int a0, a1, b;
		a0 = A.at(i);
		a1 = A.at(i + 1);
		b = B.at(i);
		ans += min(a0, b);
		b -= min(a0, b);
		ans += min(a1, b);
		a1 -= min(a1, b);
		A.at(i + 1) = a1;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
const int MAXN=1e5+7;
int n,a1,a2;
char s[MAXN];
int main(){
	cin>>n;
	cin>>s;
	for(int i=0;i<n;i++) if(s[i]=='R') a1++;else a2++;
	if(a1>a2) puts("Yes");else puts("No");
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args)throws IOException {
		BufferedReader br = new  BufferedReader(new InputStreamReader(System.in));
		int num = Integer.parseInt(br.readLine());
		for(int i =1; i<10001; i++){
			if(num != 0){
				System.out.println("Case "+ i +": " + num );
				num = Integer.parseInt(br.readLine());
			}else{
				break;
			}
		}
	}
}

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

using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  int64_t n, k;
  cin >> n >> k;

  if (k == 0) {
    cout << (n * n) << "\n";
    return 0;
  }

  uint64_t ans = 0;
  for (int b = k + 1; b <= n; ++b) {
    int repeats = n / b;
    int reminder = n % b;
    ans += repeats * (b - k);
    if (k <= reminder) {
      ans += reminder - k + 1;
    }
  }
  cout << ans << "\n";
}


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

#define MAX_V 201
#define  INF 10000
int V, N;
int dmin[MAX_V][MAX_V];
int d[MAX_V][MAX_V];
int main()
{
    
    string S;
    int ans = 0;
    cin >> N;
    for (int i = 0; i < N; i++){
        cin >> S;
        for (int j = 0; j < N; j++){
            if (S[j] == '1'){
                d[i][j] = dmin[i][j] = 1;
            } else {
                d[i][j] = dmin[i][j] = INF;
            }
        }             
    }
    V = N;
    for (int k = 0; k < V; k++)
        for (int i = 0; i < V; i++)
            for (int j = 0; j < V; j++)
                dmin[i][j] = min(dmin[i][j], dmin[i][k] + dmin[k][j]);
    int max_l = 0;
    int max_i, max_j;
    for (int i = 0; i < V; i++){
        for (int j = i + 1; j < V; j++){
            if (max_l < dmin[i][j]){
                max_l = dmin[i][j];
                max_i = i;
                max_j = j;
            }
        }
    }
    
    vector<int> state(N,-1);
    queue<int> Q;
    state[0] = 0;
    Q.push(0);
    while(!Q.empty()){
        int u = Q.front();
        Q.pop();
        for(int v=0;v<N;v++){
            if(d[u][v] == 1){
                if(state[v]==-1){
                    if(state[u]==0) state[v] = 1;
                    else state[v] = 0;
                    Q.push(v);
                } else if(state[u]==state[v]){
                    cout << -1 << endl;
                    return 0;
                }
            }
        }
    }

    set<int> used_each[MAX_V], used, cand;
    
    cand.insert(max_i);
    used_each[0].insert(max_i);
    used.insert(max_i);
    //fprintf(stderr, "%d, %d, %d\n", max_i, max_j, max_l);
    for (int n = 0; n < max_l + 1; n++){
        set<int> cand2;
        for (auto i = cand.begin(); i != cand.end(); i++){
            //fprintf(stderr, "i = %d ***\n", *i);
            for (int j = 0; j < N; j++){
                if (d[*i][j] != INF){
                    if (!(n >= 1 && used_each[n - 1].find(j) != used_each[n - 1].end())){    
                    //fprintf(stderr, "  j = %d\n", j);
                        cand2.insert(j);
                    }
                }
            }
        }
        for (auto i = cand2.begin(); i != cand2.end(); i++){
            //fprintf(stderr, "%d,", *i);
            if (used.find(*i) != used.end()){
                 cout << -1 << endl;
                 return 1;
             }
            used_each[n + 1].insert(*i);
            used.insert(*i);
        }
        //cout << "\n";
        cand = cand2;
    }
    cout << max_l + 1 << endl;
    return 0;    
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s,t;
	cin>>s>>t;
	int minchange = t.length()+100;
	int begin = 0;
	while(begin+t.length()<=s.length()){
		int change = 0;
		for(int i=0; i<t.length(); i++){
			if(t[i]!=s[begin+i]) change++;
		}
		minchange = min(minchange,change);
		begin++;
	}
	cout<<minchange;
}

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)

using namespace std;

int i,j,k,l,m,n;
/////////////////////////////////////////////////////

ll N,X;
ll x[202020];
ll suma[202020];
ll ref;

inline ll getting(ll i,ll x){
    return i==1?5*x:(i*2+1)*x;
}

int main(){
    scanf("%lld%lld",&N,&X);
    for(i=1;i<=N;i++){
        scanf("%lld",&x[i]);
    }
    
    for(i=1;i<=N;i++){
        suma[i]=suma[i-1]+x[N-i+1];
        //printf("\n%lld ",suma[i]);
    }

    ref=LLONG_MAX;
    
    for(i=1;i<=N;i++){
        j=N/i*i;
        ll sum=getting(j/i+1,suma[N]-suma[j]);
        for(;j>=1&&sum>=0;j-=i){
            sum+=getting(j/i,suma[j]-suma[j-i]);
        }
        //printf("\n%d:%lld ",i,sum);
        if(sum<0)
            continue;
        sum+=X*i;
        if(sum<ref&&sum>0)ref=sum;
    }
    printf("%lld\n",ref+X*N);

    return 0;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  map<char,int>m;
  m['a']=10;
  m['b']=11;
  m['c']=12;
  m['d']=13;
  m['e']=14;
  m['f']=15;
  int col[8][3];
  col[0][0]=0;col[0][1]=0;col[0][2]=0;
  col[1][0]=0;col[1][1]=0;col[1][2]=255;
  col[2][0]=0;col[2][1]=255;col[2][2]=0;
  col[3][0]=0;col[3][1]=255;col[3][2]=255;
  col[4][0]=255;col[4][1]=0;col[4][2]=0;
  col[5][0]=255;col[5][1]=0;col[5][2]=255;
  col[6][0]=255;col[6][1]=255;col[6][2]=0;
  col[7][0]=255;col[7][1]=255;col[7][2]=255;
  while(cin>>s,s!="0"){
    int a,b,c,a1,a2;
    if(isdigit(s[1]))a1=s[1]-'0';
    else a1=m[s[1]];
    if(isdigit(s[2]))a2=s[2]-'0';
    else a2=m[s[2]];
    a=a1*16+a2;
    if(isdigit(s[3]))a1=s[3]-'0';
    else a1=m[s[3]];
    if(isdigit(s[4]))a2=s[4]-'0';
    else a2=m[s[4]];
    b=a1*16+a2;
    if(isdigit(s[5]))a1=s[5]-'0';
    else a1=m[s[5]];
    if(isdigit(s[6]))a2=s[6]-'0';
    else a2=m[s[6]];
    c=a1*16+a2;
    int p,ss=INT_MAX;
    for(int i=0;i<8;i++){
      int x=(col[i][0]-a)*(col[i][0]-a)+
            (col[i][1]-b)*(col[i][1]-b)+
            (col[i][2]-c)*(col[i][2]-c);
      if(x<ss){
        ss=x;
        p=i;
      }
    }
    if(p==0)cout<<"black"<<endl;
    if(p==1)cout<<"blue"<<endl;
    if(p==2)cout<<"lime"<<endl;
    if(p==3)cout<<"aqua"<<endl;
    if(p==4)cout<<"red"<<endl;
    if(p==5)cout<<"fuchsia"<<endl;
    if(p==6)cout<<"yellow"<<endl;
    if(p==7)cout<<"white"<<endl;
  }
}

Measured memory_bytes: 3108
n=int(input())
a=list(map(int,input().split()))
for i in range(n):
  a[i]-=i+1

a.sort()

def menseki(b):
  temp=0
  for i in range(n):
    temp+=abs(a[i]-b)
  return temp


middle=n//2
b=a[middle]
ans=min(menseki(b),menseki(b-1),menseki(b+1))

print(ans)

Measured memory_bytes: 26836
using System;
using System.Collections.Generic;
using System.Linq;

class ABC125C{
    public static void Main(){
        var N = int.Parse(Console.ReadLine());
        var A = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var S = new int[N-1];
        var R = new int[N-1];
        S[0] = A[0];
        R[0] = A.Last();
        for(int i = 1;i < N-1;i++){
            S[i] = GCD(S[i-1],A[i]);
            R[i] = GCD(R[i-1],A[N-(i+1)]);
        }
        var list = new List<int>();
        for(int i = 0;i < N-2;i++){
            list.Add(GCD(S[i],R[N-(i+3)]));
        }
        list.Add(GCD(S.Last(),A[N-2]));
        list.Add(GCD(R.Last(),A[1]));
        Console.WriteLine(list.Max());
    }
    public static int GCD(int a,int b){
        if(b == 0){
            return a;
        }
        return GCD(b,a%b);
    }
}

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

#define N 26
#define MAX_T 1.9

const int INF = 1 << 30;
const double mean = 0.0;
const double stddev = 1.0;

int c[N];
int s[365][N];
int last[N];
std::chrono::time_point<std::chrono::steady_clock> start, endt;
random_device rd;
mt19937 generator(rd());
uniform_real_distribution<> dist(0.0, 1.0);

struct ContestInfo {
	int D;
	long score;
	vector<int> t;
	vector<int> best_t;
	set<int> held[N];
	ContestInfo(int dd) : D(dd), score(0) {
		t.resize(D, -1);
		for (int i = 0; i < N; i++) {
			held[i].insert(-1);
			held[i].insert(D);
			score -= c[i] * D * (D + 1) / 2;
		}
	}

	void add(int dd, int qq) {
		if (t[dd] != -1) {
			cout << "Add faild!" << endl;
			exit(1);
		}

		t[dd] = qq;
		score += s[dd][qq];
		held[qq].insert(dd);
		auto itr = held[qq].find(dd);
		auto ritr = next(itr);
		auto litr = prev(itr);
		auto range = [](int l, int r) {
			int k = r - l - 1;
			return -k * (k + 1) / 2;
		};
		score -= c[qq] * range(*litr, *ritr);
		score += c[qq] * (range(*litr, *itr) + range(*itr, *ritr));
	}

	void erase(int dd) {
		if (t[dd] == -1) {
			cout << "Erase faild!" << endl;
			exit(1);
		}
		int qq = t[dd];
		t[dd] = -1;
		score -= s[dd][qq];
		auto itr = held[qq].find(dd);
		auto ritr = next(itr);
		auto litr = prev(itr);
		auto range = [](int l, int r) {
			int k = r - l - 1;
			return -k * (k + 1) / 2;
		};
		score += c[qq] * range(*litr, *ritr);
		score -= c[qq] * (range(*litr, *itr) + range(*itr, *ritr));
		held[qq].erase(itr);
	}

	void change(int dd, int qq) {
		erase(dd);
		add(dd, qq);
	}

	void save() { best_t = t; }

	void output() {
		for (int i = 0; i < D; i++)
			cout << best_t[i] + 1 << endl;
	}
};

double dice() {
	return dist(generator);
}

double prob(double rem) {
	return 1.0 / exp(rem);
}

void tic() {
	start = std::chrono::steady_clock::now();
}

double toc() {
	endt = std::chrono::steady_clock::now();
	std::chrono::duration<double> elapsed_seconds = endt - start;
	return elapsed_seconds.count();
}

int main() {
	int d;
	cin >> d;
	for (int i = 0; i < N; i++)
		cin >> c[i];
	for (int i = 0; i < d; i++) {
		for (int j = 0; j < N; j++) {
			cin >> s[i][j];
		}
	}

	tic();
	int t;
	ContestInfo ci(d);
	for (int i = 0; i < d; i++) {
		t = rand() % N;
		ci.add(i, t);
	}

	int current_score = ci.score;
	int best_score = current_score;
	ci.save();

	int dd, qq;
	while (toc() < MAX_T) {
		dd = rand() % d;
		qq = rand() % N;
		int old_q = ci.t[dd];
		ci.change(dd, qq);
		long new_score = ci.score;
		current_score = new_score;
		if (new_score < current_score || prob(MAX_T - toc()) < dice())
			ci.change(dd, old_q);
		else
			current_score = new_score;
		if (best_score < current_score) {
			best_score = current_score;
			ci.save();
		}
	}
	ci.output();
	// cout << ci.score << endl;
}

Measured memory_bytes: 4272
<?php

$cards = array(
    "S" => array(),
    "H" => array(),
    "C" => array(),
    "D" => array(),
);
$ranks = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13);
$n = intval(trim(fgets(STDIN)));
for ($i = 0; $i < $n; $i++) {
    $stdin = preg_split('/ /', trim(fgets(STDIN)));
    $picture = $stdin[0];
    $rank = intval($stdin[1]);
    
    array_push($cards[$picture], $rank);
}

foreach ($cards as $p => $r) {
    $differences = array_diff($ranks, $r);
    foreach ($differences as $difference) {
        print($p . " " . $difference . "\n");
    }
}

Measured memory_bytes: 6704
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD 1000000007
#define PI 3.1415926535897932384

template <class T>ostream &operator<<(std::ostream &o, const vector<T> &v)
{
	rep(i, v.size()) {
		o << (i > 0 ? " " : "") << v[i];
	}
	return o;
}

int h, w, k;

int clean(vvi &test) {
	int s = 0;
	int l;
	rep(i, h) {
		int t = 1;
		rep(j, w) {
			if (j != 0 && test[i][j] && test[i][j - 1] == test[i][j]) {
				t++;
			}
			else t = 1;
			if (t == k) {
				int tgt = test[i][j - t + 1];
				s += test[i][j - t + 1];
				test[i][j - t + 1] = 0;
				for (l = j - t + 2; l < w && test[i][l]==tgt; l++) {
					s += test[i][l];
					test[i][l] = 0;
				}
				j = l - 1;
				t = 1;
			}
		}
	}
	return s;
}

void drop(vvi &test) {
	rep(j, w) {
		vi v;
		rep(i, h) {
			if (test[i][j]) {
				v.push_back(test[i][j]);
			}
		}
		rep(i, h) {
			if (i<v.size()) {
				test[i][j]=v[i];
			}
			else test[i][j] = 0;
		}
	}
}



int main() {
	ll mul = 1;
	char c;
	ll ans = 0, score = 0, tmp = 0;
	cin >> h >> w >> k;
	vvi vv(h,vi(w,0)), test(h, vi(w, 0));
	rep(i,h) {
		rep(j, w) {
			cin >> c;
			vv[i][j] = (c - '0');
		}
	}
	rep(i, h) {
		rep(j, w) {
			rep(ii, h) {
				rep(jj, w) {
					test[ii][jj] = vv[h-ii-1][jj];
				}
			}
			test[i][j] = 0;
			drop(test);
			while (tmp = clean(test), tmp) {
				drop(test);
				score += (tmp*mul);
				mul *= 2;
			}
			mul = 1;
			ans = max(score,ans);
			score = 0;
		}
	}
	cout << ans << endl;

}


Measured memory_bytes: 256
//#include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <limits.h>
#include <string>
#include <cmath>

using namespace std;

#define rip(i, n, s) for (int i = (s);i < (int)( n ); i++)
#define mp make_pair
#define all(a) (a).begin(), (a).end()
typedef long long ll;
typedef pair<int,int> P;

int main(){
    int n;
    cin >>n;
    vector<int> a(n),b(n);
    vector<P> da(n);
    rip(i,n,0){
        cin >> a[i];
        da[i].first = a[i];
    }
    rip(i,n,0){
        cin >> b[i];
        da[i].second = b[i];
    }
    sort(all(a));
    sort(all(b));
    rip(i,n,0){
        if(a[i] > b[i]){
            cout << "No" << endl;
            return 0;
        }
    }
    rip(i,n-1,0){
        if(b[i] >= a[i+1]){
            cout << "Yes" << endl;
            return 0;
        }
    }
    sort(da.begin(),da.end());
    rip(i,n,0){
        da[i].first = da[i].second;
        da[i].second = i;
    }
    int co = 0;
    sort(all(da));
    while(da[0].second != 0){
        swap(da[0].second,da[da[0].second].second);
        co ++;
    }
    if(co != n-1){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    //cout << co << endl;
}

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

using namespace std;

#define sqr(x) ((x)*(x))
#define mp make_pair
#define pb push_back
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define RE(i, n) FOR(i,1,n)
#define REP(i,n) FOR(i, 0, (int)(n)-1)
#define fst first
#define snd second

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;
typedef tuple<int,int,int> iii;

string to_string(string s) {
    return '"' + s + '"';
}
    
string to_string(const char* s) {
    return to_string((string) s);
}
    
string to_string(bool b) {
    return (b ? "true" : "false");
}
    
template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
    
template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for (const auto &x : v) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

void fastIO() {
    cin.sync_with_stdio(false);
    cin.tie(0);
}


int XMOV[4] = {0, 0, 1, -1};
int YMOV[4] = {1, -1, 0, 0};

//#############################
const int MAXN = 1000005;
int n;
vector<ll> a, b, c;
map<int, vector<ll>> m;
ll memo[MAXN][3];

ll dp(int i, int act) {
    if (i == -1)
        return 0;

    if (memo[i][act] != -1)
        return memo[i][act];
    
    memo[i][act] = max(dp(i-1, (act+1)%3) + m[(act+1)%3][i], dp(i-1, (act+2)%3) + m[(act+2)%3][i]);
    return memo[i][act];
}

int main() {
    cin >> n;
    int x,y,z;
    for (int i = 0; i < n; i++)
        cin >> x >> y >> z, a.pb(x), b.pb(y), c.pb(z);
    m[0] = a;
    m[1] = b;
    m[2] = c;
    memset(memo, -1, sizeof(memo));
    ll ans = dp(n-1, 0);
    memset(memo, -1, sizeof(memo));
    ans = max(ans, dp(n-1, 1));
    memset(memo, -1, sizeof(memo));
    ans = max(ans, dp(n-1, 2));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 36448
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define INF 10000000000000
#define MOD 1000000007LL
#define RANGE(a,b,c) (a).begin()+(b),(a).begin()+(c) // [b,c) イテレータ
using PII = pair<int64_t, int64_t>;
using VI = vector<int64_t>;
using VVI = vector<VI>;
using VS = vector<string>;
using VP = vector<PII>;
using i64 = int64_t;
template<typename T> void invec(vector<T> &A){for(T& a : A) cin >> a;} // input vector

struct DisjointSet {
    vector<int64_t> par; //根.連結成分の根にはその成分の要素数を符号反転して保存する．

    DisjointSet(int64_t n) : par(n, -1) {} //.0-indexed 
    void init(int64_t n) {par.assign(n, -1);}// 初期化

    int root(int64_t x) {
        if (par[x] < 0) return x; //根が負なら自身が根．
        else return par[x] = root(par[x]); //径路圧縮
    }

    // 連結判定
    bool issame(int64_t x, int64_t y) { return root(x) == root(y); }

    bool unite(int64_t x, int64_t y) { // 結合が行われればtrue.行われなければfalse.
        x = root(x); y = root(y); // 径路圧縮
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); 
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int64_t size(int64_t x){ return -par[root(x)]; }
};

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

int64_t N, M; cin >> N >> M;
VI A(M), B(M); 
rep(i, 0, M) cin >> A[i] >> B[i];

DisjointSet DS(N+1);
VI incov(M, N*(N-1)/2);
Rrep(i, M-1, 1){
    int rank1 = DS.size(A[i]), rank2 = DS.size(B[i]);
    if (DS.unite(A[i], B[i]))
        incov[i-1] = incov[i] - rank1 * rank2;
    else 
        incov[i-1] = incov[i];
}

for(int64_t i: incov) cout << i << "\n";

}
// 書いて考える．場合分け．情報整理．
// 境界，出力文字列 チェック．行末にスペース入れない．
// 可読性優先．高速化次点．
// まずは全探索，分割，次にDP
// 制限を見る．境界に注意．求めたい量の変域．動かせる量．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性，二分探索
// 存在判定：構成方法，入力の特徴
// gcd, lcm ,素因数分解．
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理．前処理によるクエリ高速化．
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// テストケース作成は数表あり
// 実行エラー：vector添え字超え．0割り．



Measured memory_bytes: 4480
s = input()
a = [int(c) for c in s]

ans = 0
for b in range(0, pow(2, len(a) - 1)):
    subans = 0
    for i in range(0, len(a)):
        subans += a[i]
        if b >> i & 1 == 1:
            ans += subans
            subans = 0
        elif i < len(a) - 1:
            subans *= 10
    ans += subans
print(ans)

# print(*data, sep='\n')


Measured memory_bytes: 40944
#!/usr/bin/env python3
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def solve():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))

    if K == 1:
        print(0)
        return

    dp = [0]
    for i in range(N):
        dp.append(dp[-1] + (A[i] - 1))

    dp = [d % K for d in dp]

    ans = 0
    d = defaultdict(int)
    d[0] = 1
    for i in range(1, N + 1):
        ans += d[dp[i]]
        d[dp[i]] += 1

        if i - K + 1 >= 0:
            d[dp[i - K + 1]] -= 1

    print(ans)


def main():
    solve()


if __name__ == '__main__':
    main()


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

int main()
{
	int x, y;
	int ans = 1;
	int N;	//足の数

	cin >> x >> y;

	for (int i = 0; i <= x; i++) {
		// i: 鶴の数，　x-i: 亀の数
		N = i * 2 + (x - i) * 4;
		if (N == y)	ans = 0;
	}

	if (ans == 0)	cout << "Yes" << endl;
	else			cout << "No"  << endl;

	return 0;
}

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

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

    char[] s = scanner.next().toCharArray();
    char[] t = scanner.next().toCharArray();
    int N = s.length;

    int[][] table = new int[N][26];
    Arrays.fill(table[N - 1], -1);
    for (int i = 0; i < N; i++) if (table[N - 1][s[i] - 'a'] < 0) table[N - 1][s[i] - 'a'] = i;

    for (int i = N - 2; i >= 0; i--) {
      table[i] = Arrays.copyOf(table[i + 1], 26);
      table[i][s[i + 1] - 'a'] = i + 1;
    }

    long res = 0;
    int cur = N - 1;
    for (char c : t) {
      int next = table[cur][c - 'a'];
      if (next < 0) {
        System.out.println(-1);
        return;
      }
      res += next - cur;
      if (next <= cur) res += N;
      cur = next;
    }
    System.out.println(res);
  }
}


Measured memory_bytes: 55572
#include <iostream>
#include <vector>

using namespace std;

void failure () {
  cout << "Impossible" << endl;
  exit(0);
}

const int MAX_N = 105;

int atds [MAX_N]; // # of vertices with such farthest dist

int main () {
  ios::sync_with_stdio(false);

  int n;
  cin >> n;

  int diam = 0;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;

    atds[x]++;
    diam = max(diam, x);
  }

  if (diam == 1 && n > 2) failure();

  int blw, abv;
  if (diam % 2 == 0) {
    if (atds[diam / 2] != 1) failure();
    blw = diam / 2 - 1;
    abv = diam / 2 + 1;
  } else {
    if (atds[(diam + 1) / 2] != 2) failure();
    blw = diam / 2;
    abv = (diam + 1) / 2;
  }

  for (int i = 0; i <= blw; i++) {
    if (atds[i] > 0) failure();
  }
  for (int i = abv; i <= diam; i++) {
    if (atds[i] < 2) failure();
  }

  cout << "Possible" << endl;
}


Measured memory_bytes: 256
#pragma warning disable
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System;
using System.Collections;

class E { static void Main() => new J(); }
class J
{
	int F() => int.Parse(Console.ReadLine());
	int[] G() => Console.ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();
	public J()
	{
		Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
		var N = F();
		Console.WriteLine(800 * N - 200 * (N / 15));
		Console.Out.Flush();
	}
	long GCD(long a, long b)
	{
		var n = (ulong)Math.Abs(a); var m = (ulong)Math.Abs(b);
		if (n == 0) return (long)m; if (m == 0) return (long)n;
		int zm = 0, zn = 0;
		while ((n & 1) == 0) { n >>= 1; zn++; }
		while ((m & 1) == 0) { m >>= 1; zm++; }
		while (m != n)
		{
			if (m > n) { m -= n; while ((m & 1) == 0) m >>= 1; }
			else { n -= m; while ((n & 1) == 0) n >>= 1; }
		}
		return (long)n << Math.Min(zm, zn);
	}
}

Measured memory_bytes: 11092
#include <stdio.h>

#define max 1000000000000000000

long long a,sum=1;
double s=1;

int main(void){
    
    int n;
    
    scanf("%d",&n);
    
    for(int i=0;i<n;i++){
        
        scanf("%lld",&a);
        sum*=a;
        s*=a;
    }
    
    if(sum>max || s>max) printf("-1\n");
    else printf("%lld\n",sum);
    
    return 0;
    
}


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

typedef long long   ll;
typedef long double ld;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    vector<ll> a(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(a.begin(),a.end());

    int idx=n-2;
    ll ref=a[n-1];
    ll ls=0;
    bool flag=false;
    while(idx>=0) {
        if(a[idx]==ref){
            if(flag){
                cout << ref*ls << "\n";
                return 0;
            }
            ls=ref;
            flag=true;
            ref=a[idx-1];
            idx--;
        }
        else ref=a[idx];
        idx--;
    }
    cout << "0" << "\n";
    return 0;
}

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

#define kais 4
using namespace std;


typedef struct{
  int f,b,t,u,r,l;
}_sai;
_sai s;
bool tate,yoko,kaiten;

void dice(_sai* tmp,char muki){
  int b1=(*tmp).f,b2=(*tmp).b,b3=(*tmp).t,b4=(*tmp).u,b5=(*tmp).r,b6=(*tmp).l;
  if(muki=='S'){
    (*tmp).u=b1;
    (*tmp).f=b3;
    (*tmp).t=b2;
    (*tmp).b=b4;
  }
  else if(muki=='N'){
    (*tmp).t=b1;
    (*tmp).b=b3;
    (*tmp).u=b2;
    (*tmp).f=b4;
  }
  else if(muki=='E'){
    (*tmp).r=b3;
    (*tmp).u=b5;
    (*tmp).l=b4;
    (*tmp).t=b6;
  }
  else if(muki=='W'){
    (*tmp).l=b3;
    (*tmp).u=b6;
    (*tmp).r=b4;
    (*tmp).t=b5;
  }
}


/*
両方s ：ftはSWで、tfもSWで
両方w：ft(S)はWで、困る
一個ずつ：ftはSWで、困る
ftとtfの並びの違いの場合
場所を保持したほうがいいか？？
どっちみち度の並びか探査の必要ある 
*/
void roll(int top,int front){
  //f
  for(int i=0; i<kais; i++){
    if(s.f==front){
      tate=true;
      break;
    }
    dice(&s,'S');
  }
  
  if(!tate){
    dice(&s,'E');

    for(int i=0; i<kais; i++){
      if(s.f==front){
	tate=true;
	break;
      }
      dice(&s,'S');
    }
  }
  
  for(int i=0; i<kais; i++){
    if(s.t==top){
      yoko=true;
      break;
    }
    dice(&s,'W');
  }
}

int main(){

  string x;
  int q;
  cin>> s.t>> s.f>> s.r>> s.l>> s.b>> s.u>>q;

  int top,front;
  for(int i=0; i<q; i++){
    tate=false;
    yoko=false;
    cin >> top >>front;
    roll(top,front);
    cout << s.r<<endl;
  }

  return 0;
}



Measured memory_bytes: 3072
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int N, A, B, C,D[100], ret, hoge;

  cin >> N;
  cin >> A >> B;
  cin >> C;

  hoge = C;
  ret = hoge / A;
  for(int i = 0; i < N; i++){
    cin >> D[i];
  }
  sort( D, D + N, greater<int>());

  for(int i = 0; i < N; i++){
    hoge += D[i];
    ret = max( ret, hoge / ( A + ( i + 1) * B));
  }
  cout << ret << endl;
}

Measured memory_bytes: 1176
#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>;

int main() {
  int a;
  cin >> a;
  int ans = a + a*a + a*a*a;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
#define int long long
#define ld long double
#define ri register int
#define il inline
#define mk make_pair
#define pb push_back
#define fi first
#define se second
#define pii pair<int,int>
#define vi vector<int>
#define all(x) x.begin(),x.end() 
#define rep(i,a,b) for(ri i=(a);i<=(b);++i)
#define per(i,a,b) for(ri i=(a);i>=(b);--i)
#define ls (x<<1)
#define rs (x<<1|1)
#define mid (l+r>>1)
#define db(x) cout << "#x:" << x << endl
#define dd() cout << "Out put!\n"
const int mod=1e9+7,eps=1e-6,pi=acos(-1.0),maxn=1000010;
const int inf=0x7f7f7f7f7f7f7f7f;
using namespace std;
int a[maxn],b[maxn],v[maxn];
string s; 
signed main()
{
	ios::sync_with_stdio(0);
	int t=1;
//	cin >> t;
	while(t--)
	{
		int n;
		cin >> n;
		rep(i,1,n)
			cin >> a[i],v[a[i]]++;
		if(v[1])
		{
			if(v[1] > 1)
				cout << 0;
			else
				cout << 1;
			return 0;
		}
		int ans = 0;
		rep(i,1,n)
		{
			int flag  = 1;
			if(v[a[i]] > 1)
				continue;
			for(int j=2;j<=sqrt(a[i]);j++)
			{
				if(a[i]%j==0)
				{
					if(v[j])
						flag = 0;
					if(v[a[i]/j])
						flag = 0;
					if(flag == 0)
						break;
				}
			}
			if(flag)
				ans++;
		}
		cout << ans ;
	}
	return 0;
}

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

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
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; }
#define fls(x) (64 - __builtin_clzll(x))
#define pcnt(x) __builtin_popcountll(x)
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <ll,ll> P;
typedef long double ld;

int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    ll d; cin >> d;
    vector<P> p(n);
    rep (i, n) cin >> p[i].first >> p[i].second;
    int ans = 0;
    rep (i, n) {
        eprintf("%lld %lld\n", p[i].first * p[i].first + p[i].second * p[i].second, d * d);
        if (p[i].first * p[i].first + p[i].second * p[i].second <= d * d) ans++;
    }
    cout << ans << "\n";
    return 0;
}

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

int main(){
    int n;
    cin >> n;
    int F[50];
    F[0] = F[1] = 1;
    for(int i = 2; i <= n; i++) F[i] = F[i-1] + F[i-2];

    cout << F[n] << endl;

    return 0;
}


Measured memory_bytes: 3116
using System;
using System.Linq;
using System.Collections.Generic;


public class HelloWorld
{
    
    
    static List<long>[] Hedge;
    static long ans = 0;
    static Queue<long> que;
    
    static long N;
    
    static public void Main ()
    {
        var NM = Console.ReadLine().Split().Select(a => long.Parse(a)).ToArray();
        N = NM[0];
        var M = NM[1];
        Hedge = new List<long>[N+1];
        for(long i = 0;i <= N ;i++){
            Hedge[i] = new List<long>();
        }
        
        for(long i = 0;i < M ;i++){
            var AB = Console.ReadLine().Split().Select(a => long.Parse(a)).ToArray();
            var A = AB[0];
            var B = AB[1];
            Hedge[A].Add(B);
            Hedge[B].Add(A);
        }
       // Console.WriteLine(ans);
        que = new Queue<long>();
        var Used = new long[N+1];
        que.Enqueue(1);
        CountPath(Used,0);
        Console.WriteLine(ans);
    }
    
    static void CountPath(long[] Used,long count){
        if(que.Count == 0){
            return;
        }
      // Console.WriteLine(String.Join(" ",Used));
        var top = que.Dequeue();
        Used[top] = 1;
        count++;
        if(count == N){
            ans++;
            return;
        }else if(count > N){
            return;
        }
        foreach(long item in Hedge[top]){
            if(Used[item] == 0){
                que.Enqueue(item);
            var copy = new long[N+1];
            Used.CopyTo(copy, 0);
            CountPath(copy,count);
            }
            
        }
        
    }

}


Measured memory_bytes: 13780