akhauriyash/Code-Regression huggingface dataset:
module.exports=function(t){var e={};function r(n){if(e[n])return e[n].exports;var i=e[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)r.d(n,i,function(e){return t[e]}.bind(null,i));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=0)}([function(t,e,r){"use strict";var n=r(1);r(2)(n.readFileSync("/dev/stdin","utf8"))},function(t,e){t.exports=require("fs")},function(t,e,r){"use strict";var n=r(3),i=r(5);t.exports=function(t){var e=new n(t);i(e)}},function(t,e,r){"use strict";var n=r(4);t.exports=class{constructor(t){var e=t.trim().split(/\s+/g);this.inp=new n(e)}inr(){return this.inp.deq()}in(){return parseInt(this.inp.deq(),10)}fin(){this.inp.clear()}}},function(t,e,r){"use strict";t.exports=class{constructor(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];this.size=t.length,this.items=t,this.ind=0}enq(t){this.size+=1,this.items.push(t)}deq(){var t=this.items[this.ind];return this.size-=1,this.ind+=1,t}clear(){this.items=[],this.size=0,this.ind=0}}},function(t,e,r){"use strict";t.exports=function(t){for(var e=t.inr(),r=e.length,n=0,i=0;i<r;i++){for(var s=0,o=i;o<r&&("A"==e[o]||"C"==e[o]||"G"==e[o]||"T"==e[o]);o++)s++;n=Math.max(n,s)}console.log(n)}}]);

Measured memory_bytes: 7372
#include <iostream>
using namespace std;
struct Node{
  int u;
  int k;
  int v[99];

  int start;
  int finish;
};

int deep(Node nod[],int x,int count){
  if(nod[x].start)
    return count;

  nod[x].start=(++count);
  for(int i=0; i<nod[x].k; i++)
    count = deep(nod,nod[x].v[i]-1,count);

  nod[x].finish= (++count);
  return count;
}

int main(){
  int n,count=0;
  Node nod[100];

  cin >> n;
  for(int i=0; i<n; i++){
    cin >> nod[i].u >> nod[i].k;
    
    for(int j=0; j<nod[i].k; j++)
      cin >> nod[i].v[j];
    
    nod[i].start=0;
    nod[i].finish=0;
  }

  for(int i=0; i<n; i++)
    count = deep(nod,i,count);
  
  for(int i=0; i<n; i++){
    cout << nod[i].u << " " << nod[i].start << " " << nod[i].finish << endl;
  }
}

Measured memory_bytes: 3120
inputs = list(map(lambda x: int(x), input().split()))

max = 0
v = 1

for i in inputs[0:3]:
    if i > inputs[3]:
        i = inputs[3]
    max += v * i
    inputs[3] -= i
    v -= 1
    if inputs[3] <= 0:
        break

print(max)


Measured memory_bytes: 9184
#include <stdio.h>
#define WHITE -1
#define F 0
#define RED 1
#define N 8
int A[N][N],row[N],col[N],dpos[2*N],dneg[2*N];
void First();
void FindQ(int);
void print();
char putQ(int, int);
int main() {
    int i, j, n, r, c;
    First();
    scanf("%d", &n);
    for (i = 0; i < n; i++) {
        scanf("%d%d", &r, &c);
        A[r][c] = 1;
    }
    FindQ(0);
    return 0;
}
void First() {
    int i,j;
    for (i = 0; i < N; i++) {
        row[i] = col[i] = WHITE;
    }
    for (i = 0; i < N*2-1; i++) {
        dpos[i] = dneg[i] = WHITE;
    }
    for (i = 0; i < N; i++) {
        for (j = 0; j < N; j++) {
            A[i][j] = F;
        }
    }
}
void FindQ(int i) {
    int j;
    if (i == N) {
        //全パターン出力されることに
        print();
        return;
    }
    
    for (j = 0; j < N; j++) {
        //check
        if (col[j] == WHITE && dpos[i + j] == WHITE && dneg[i - j + (N - 1)] == WHITE) {
            //set
            //rowはQ(i,j)も兼ねる
            row[i] = j;
            col[j] = dpos[i + j] = dneg[i - j + (N - 1)] = RED;
            FindQ(i + 1);
            //reset
            row[i] = col[j] = dpos[i + j] = dneg[i - j + (N - 1)] = WHITE;
        }
    }
}

void print() {
    int i, j;
    /*
    for (i = 0; i < N; i++) {
        printf("%d", row[i]);
    }
    */
    for (i = 0; i < N; i++) {
        for (j = 0; j < N; j++) {
            //(2,2)(5,3)のときパターンは1通り
            if (A[i][j]) {
                //printf("%d = %d\n", row[i], j);
                if (row[i] != j) {
                    return;
                }
            }
        }
    }
    for (i = 0; i < N; i++) {
        for (j = 0; j < N; j++) {
            printf("%c", putQ(row[i],j));
        }
        printf("\n");
    }
    //printf("\n");
}
char putQ(int k,int j) {
    int i;
    if (k == j) {
        return 'Q';
    }
    return '.';
}


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

int main(){
  int N,D,X;
  cin>>N>>D>>X;
  vector<int> vec(N);
  int sum=0;
  
  for(int i=0;i<N;i++){
    cin>>vec.at(i);
    if(D%vec.at(i)==0)
      sum+=D/vec.at(i);
    else
      sum=sum+1+D/vec.at(i);
  }
  
  cout<<sum+X<<endl;
}

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

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

    if(N % 2 == 0) {
        for(int i=N-1; i>0; i -= 2) cout << A[i] << ' ';
        for(int i=0; i<=N-2; i += 2) cout << A[i] << (i==N-2 ? '\n' : ' ');
    } else {
        if(N == 1) cout << A[0] << endl;
        else {
            for(int i=N-1; i>=0; i -= 2) cout << A[i] << ' ';
            for(int i=1; i<=N-2; i += 2) cout << A[i] << (i==N-2 ? '\n' : ' ');
        }
    }
}


Measured memory_bytes: 2944
//↓見なくていいよ！ここから--------------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
var obj;
var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error("\n");
  var start = new Date();
  Main();
  var end = new Date() - start;
  
  myerr("time : " + (end) + "ms");
  myerr("memory : " + Math.round(process.memoryUsage().heapTotal / 1024) + "KB");
});
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  var returnObj = {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す 1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map(Number);case 6:return i.split("");case 7:return i.split("").map(Number);case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}


//↑見なくていいよ！ここまで--------------------------------------------------
function Main(){
	var D = nextInt();
	var clist = nextIntArray();
	var output = new Array(D);
	var lastContest = new Array(26).fill(0);
	for(var i = 1; i <= D; i++){
		var list = nextIntArray();
		var max = -1;
		var maxIndex = -1;
		for(var j = 0; j < list.length; j++){
			if(max < list[j]){
				max = list[j];
				maxIndex = j;
			}
		}
		lastContest[maxIndex] = i;
		for(var j = 0; j < 26; j++){
			max -= clist[j] * (i - lastContest[j]);
		}
		if(i == 1){
			//output[i - 1] = max;
		}else{
			//output[i - 1] = max + output[i - 2];
		}
		myerr(max);
		output[i - 1] = maxIndex + 1;
		//output[i] = Math.ceil(Math.random() * 26);
	}
	myout(myconv(output,9));
}


Measured memory_bytes: 34884
/*     ####   ####  #               ####  #        ##   #    # #    # ###### #####
	  #      #    # #              #      #       #  #  ##  ## ##  ## #      #    #
	   ####  #    # #               ####  #      #    # # ## # # ## # #####  #    #
		   # #  # # #                   # #      ###### #    # #    # #      #####
	  #    # #   #  #              #    # #      #    # #    # #    # #      #   #
	   ####   ### # ###### #######  ####  ###### #    # #    # #    # ###### #    #
*/
 
#include<bits/stdc++.h>
using namespace std;
 
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<string> VS;
typedef vector<pair<LL, LL> > VP;
 
 
#define For(in) for (LL i = 0; i < (n); i++)
#define FOR(in) for(LL i=1; i <= (n); i++)
#define pb push_back
#define srt(v) sort(v.begin(), v.end())
#define rev(v) reverse(v.begin(), v.end())
#define uniq(v) v.erase(unique(v.begin(), v.end()), v.end());
#define exit(); return 0;
#define no "NO"
#define yes "YES"
#define con continue;
 
 
bool is_prime[1000001];
VLL primes;
void seive()
{
	LL maxN = 1000001;
	is_prime[0]=true;
	is_prime[1]=true;
	
	for(LL i=2; i*i<=maxN; i++)
	{
		if(!is_prime[i])
		{
			for(LL j=i*i; j<=maxN; j+=i)
				is_prime[j]=true;
		}
	}
	for(LL i=2; i<=maxN; i++)
	{
		if(!is_prime[i])primes.pb(i);
	}
}

 
LL binpow(LL a, LL b, LL c)
{
	a %= c;
	LL res = 1 ;
	while(b > 0){
		if(b & 1)
		res = res * a % c ;
		a = a * a % c ;
		b >>= 1;
		//cout<<res<<endl;
	}
	return res;
}
 
LL mod = 1e9+7;
 
int main()
{
	ios_base::sync_with_stdio(false);

	LL q,t;
	//seive();
	//cin>>t;
	//while(t--)
	//{
		LL a=0,b=0,c=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,r=0,u=0,w=0,x=0,y=0,z=0;
		//LL aa[10000];
		LL flag=0, flag1=0, co=0, co1=0, co2=0, co3=0, x1=0, x2=0, y1=0, y2=0, z1=0, z2=0;
		LL ma=0, mi=100000000;
		LL mid=0, temp=0, stop=0, start=0, ans=0;
		double pi= 3.141592653589793;
		double d1=0.0, d2, d3, d4;
		VLL v,v1,v2,v3,v4,v5,v6,v7,v8,v9,v10;
		VS vs, vs1, vs2, vs3, vs4;
		VP vp, vp1,vp2;
		char ch, ch1, ch2[1001];
		string str, str1, str2, str3, str4, str5;
		pair<LL, LL> pa;
		list<LL> li, li1;
		map<LL, LL> mp, mp1;
		set<LL> st;
		map<LL ,LL> :: iterator imll;
		VLL :: iterator ivll;
		set<LL> :: iterator isll;
		VP :: iterator ivp;
		
		cin>>str;
		cout<<str[0]<<str[1]<<str[2]<<endl;
		
		

		

		
	//}
	exit()
 
 
}


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

int main(){
  int n;
  ll c;
  cin >> n >> c;
  ll x[n+2] = {}; ll v[n+2] = {};
  rep(i,n) cin >> x[i+1] >> v[i+1];
  x[n+1] = c;
  ll l[n+1] = {};
  ll r[n+1] = {};
  rep(i,n){
    l[i+1] = l[i] + v[i+1] - x[i+1] + x[i];
    r[i+1] = r[i] + v[n-i] + x[n-i] - x[n-i+1];
  }
  ll rm[n+1] = {};
  ll lm[n+1] = {};
  rep(i,n){
    rm[i+1] = max(r[i+1],rm[i]);
    lm[i+1] = max(l[i+1],lm[i]);  
  }
  ll ans = 0;
  for(int i = 1; i <= n; i++) ans = max(ans,max(r[i],l[i]));
  for(int i = 1; i <= n; i++){
    ans = max(ans, l[i] - x[i] + rm[n-i]);
    ans = max(ans, r[i] - (c-x[n-i+1]) + lm[n-i]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4992
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<iomanip>
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;
int main(){
 char a[9];
  rep(i, 0, 9){
    cin >> a[i];
  }
  cout << a[0] << a[4] << a[8] << "\n";
}

Measured memory_bytes: 3584
#import math
#import bisect
#import numpy as np
#import itertools
#import copy
import sys
from collections import deque

ipti = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)

def main():
    n = int(input())
    ans = 0

    if n % 2 == 0:
        dv = 2 * 5
        while dv <= n:
            ans += n // dv
            dv *= 5

    print(ans)


if __name__ == '__main__':
    main()


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

int main() {
  int64_t N, K;
  cin >> N >> K;
  vector<int64_t> C(N);
  vector<int> P(N);
  for(int i = 0; i < N; i++) {
    cin >> P.at(i);
    P.at(i)--;
  }
  for(int i = 0; i < N; i++) {
    cin >> C.at(i);
  }
  int64_t ans = -1000000000;
  for(int i = 0; i < N; i++) {
    int64_t roop = 0;
    int64_t count = 0;
    int keep = i;
    while(1) {
      roop += C.at(P.at(keep));
      keep = P.at(keep);
      count++;
      if(keep == i) {
        break;
      }
    }
    if(K < count || roop <= 0) {
      int64_t total = 0;
      int keep1 = i;
      for(int j = 0; j < min(K, count); j++) {
        total += C.at(P.at(keep1));
        keep1 = P.at(keep1);
        if(total > ans) {
          ans = total;
        }
      }
    }
    else {
      int64_t total = 0;
      int keep1 = i;
      for(int j = 0; j < count; j++) {
        total += C.at(P.at(keep1));
        keep1 = P.at(keep1);
        if(total + roop * ((K - j - 1) / count) > ans) {
          ans = total + roop * ((K - j - 1) / count);
        }
      }
    }
  }
  cout << ans << endl;    
}


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

long long gcd(long long a,long long b){
	if(a==0 || b==0){
		return max(a,b);
	}
	else if(a%b==0 || b%a==0){
		return min(a,b);
	}
	
	long long q;
	bool pro =true;
	while(pro){
		q=a%b;
		a=b;
		b=q;
		if(a%b==0){
			return q;
			pro=false;
		}
	}
}


signed main() {
	int A,B;
	cin>>A>>B;
	int g=gcd(A,B);
	int l=A/g*B;
	cout<<l<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define REPA(x, v) for(auto&& x:v)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(v.rbegin(),v.rend())
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> void pr_vec(vector<T> &v, char ep=' '){int n=v.size();REP(ni,n){cout<<v[ni];if(ni!=n-1)cout<<ep;}cout<<endl;};
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int count_prime(int n){
    int p = 0;
    vector<int> prime(n+1, true);
    prime[0] = prime[1] = false; 
    for(int i = 2; i <= n; i++)
        if(prime[i]) {
            p++;
            for (int j = i*2; j <= n; j += i) prime[j] = false;
        }
    return p;
}

ll gcd(ll a, ll b) {return (b==0)?a:gcd(b,a%b);}
ll lcm(ll a, ll b) {return a*(b/gcd(a, b));}

int main(void)
{
    int N;
    cin >> N;
    vector<int> A(N);
    int n = 1000005;
    vector<int> v(n);
    REP(i,N) cin >> A[i];
    REP(i,N) v[A[i]]++;

    ll g = gcd(A[0], A[1]);
    Rep(i, 1, N-1){
        g = gcd(g, A[i+1]);
    }
    
    int p = 0;
    vector<int> prime(n+1, true);
    prime[0] = prime[1] = false; 
    for(int i = 2; i <= n; i++) if(prime[i]) {
        p++;
        for (int j = i*2; j <= n; j += i) prime[j] = false;
    }

    vector<ll> ans(n);
    Rep(i, 2, n){
        if(!prime[i]) continue;
        ll t = i;
        while(t < n){
            ans[i] += v[t];
            t += i;
        }
    }

    ll m = 1;
    Rep(i, 1, n){
        chmax(m, ans[i]);
    }

    if(m == 1){
        pr("pairwise coprime");
    }else if(g == 1){
        pr("setwise coprime");
    }else{
        pr("not coprime");
    }
}

Measured memory_bytes: 22724
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <climits>
#include <sstream>

using namespace std;

int main(){
  int N, M, X, A[110], masu[110] = {0}, f=0, b=0;

  cin >> N >> M >> X;
  for(int i = 0; i < M; i++) cin >> A[i];
  for(int i = 0; i < M; i++) masu[A[i]] = 1;

  for(int i = 0; i < X; i++) f += masu[i];
  for(int i = X; i <= N; i++) b += masu[i];

  if(f < b) cout << f << endl;
  else cout << b << endl;

	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

constexpr long long MOD = 1000000007;

int main()
{
  int N, M;
  std::cin >> N >> M;
  std::vector<long long> S(N), T(M);
  for (auto& val: S)
    std::cin >> val;
  for (auto& val: T)
    std::cin >> val;
  std::vector<std::vector<long long>> dp(N, std::vector<long long>(M, 0));
  std::vector<std::vector<long long>> acc(N, std::vector<long long>(M, 0));
  dp[0][0] = S[0] == T[0] ? 1 : 0;
  acc[0][0] = dp[0][0] + 1;
  for (int i = 1; i < N; ++i)
  {
    dp[i][0] = S[i] == T[0] ? 1 : 0;
    acc[i][0] = (acc[i - 1][0] + dp[i][0]) % MOD;
  }
  for (int j = 1; j < M; ++j)
  {
    dp[0][j] = S[0] == T[j] ? 1 : 0;
    acc[0][j] = (acc[0][j - 1] + dp[0][j]) % MOD;
  }

  for (int i = 1; i < N; ++i)
  {
    for (int j = 1; j < M; ++j)
    {
      if (S[i] == T[j])
      {
        dp[i][j] = acc[i - 1][j - 1];
        acc[i][j] = (acc[i][j - 1] + acc[i - 1][j]) % MOD;
      }
      else
      {
        dp[i][j] = 0;
        acc[i][j] = ((acc[i][j - 1] + acc[i - 1][j]) - acc[i - 1][j - 1] + MOD) % MOD;
        if (acc[i][j] < 0)
          throw std::runtime_error("");
      }
    }
  }
  std::cout << acc.back().back() % MOD << std::endl;
  return 0;
}



Measured memory_bytes: 62976
#include <algorithm>
#include <iostream>
#include <queue>
using namespace std;

int main() {
  int N, K;
  string line;
  cin >> N >> K;
  cin >> line;
  int now = 1;
  int cnt = 0;
  vector<int> lines;
  for (int i = 0; i < N; i++) {
    if (line[i] == (char)('0' + now)) {
      cnt++;
    } else {
      lines.push_back(cnt);
      now = 1 - now;
      cnt = 1;
    }
  }
  if (cnt != 0) {
    lines.push_back(cnt);
  }
  if (lines.size() % 2 == 0) {
    lines.push_back(0); // 1-0-1-0-1-...-0-1
  }
  int add = 2*K+1;
  int ans = 0;

  /// normal
  // 1-0-1... start from even number
  /*for (int i = 0; i < lines.size(); i+=2) {
    int tmp = 0;
    int left = i;
    int right = min(i + add, (int)lines.size());
    for (int j = left; j < right; j++) {
      tmp += lines[j];
    }
    ans = max(tmp, ans);
  }*/

  /// syakutori-method
  /* 
   * int left = 0, right = 0;
   * int tmp = 0; // sum of [left, right)
   * for (int i = 0; i < lines.size(); i+=2) {
   *   int next_left = i;
   *   int next_right = min(i+add, (int)lines.size());
   * 
   *   while (next_left > left) {
   *     tmp -= lines[left];
   *     left++;
   *   }
   *   while (next_right > right) {
   *     tmp += lines[right];
   *     right++;
   *   }
   *   ans = max(tmp, ans);
   * }
   */

  /// ruisekiwa
  // 0 1 2 3 4 5 6
  //  0 1 2 3 4 5
  vector<int> sum(lines.size() + 1);
  for (int i = 0; i < lines.size(); i++) {
    sum[i+1] = sum[i] + lines[i];
  }
  for (int i = 0; i < lines.size(); i+=2) {
    int left  = i;
    int right = min(i+add, (int)lines.size());
    int tmp = sum[right] - sum[left];
    ans = max(tmp, ans);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1272
#include <iostream>

using namespace std;

bool isPalindrome(string s)
{
    if (s.size() == 1)
        return 1;
    for (int i = 0; i < s.size(); i++){
        if (s[i] != s[s.size() - 1 - i])
            return 0;
    }
    return 1;
}

int main()
{
    string s;
    cin >> s;
    string ins = s;
    int n = s.size();
    string s1 = "";
    string s2 = "";
    s = '1' + s;
    for (int i = 1; i <= (n-1) / 2; i++)
        s1+= s[i];
    for (int i = (n+3) / 2; i <= n; i++){
        s2+= s[i];
    }
    //cout << s1 <<"\n";
    //cout << s2 << "\n";
    if (isPalindrome(s1) && isPalindrome(s2) && isPalindrome(ins))
        cout << "Yes";
    else
        cout << "No";
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <string>
#include <iostream>
using namespace std;

int main(void) {
	long long int a,b,c,k;
	scanf("%lld%lld%lld%lld",&a,&b,&c,&k); 
	int ans;
	if(k%2){
		ans = b-a;
	}
	else ans=a-b;

	if(ans <= 1000000000000000000 && ans >= -1000000000000000000)printf("%d",ans);
	else printf("Unfair");
	return 0;
}

Measured memory_bytes: 256
/**
 *    author:  otera    
**/
#include<iostream>
#include<string> 
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm> 
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int k, n; 

vector<int> a;
vector<vector<int>> dict;

void dfs(int pos) {
    if(pos == n) return;
    for(int i = 1; i <= k; ++ i) {
        a.push_back(i);
        dict.pb(a);
        dfs(pos + 1);
        a.pop_back();
    }
}

void solve() {
	cin >> k >> n;
    // dfs(0);
    // sort(all(dict));
    // for(int i = 0; i < (int)dict.size(); ++ i) {
    //     if(i != ((int)dict.size() + 1) / 2 - 1) continue;
    //     for(int e: dict[i]) {
    //         cout << e << " ";
    //     }
    //     if(i == ((int)dict.size() + 1) / 2 - 1) cout << " half";
    //     cout << endl;
    // }
    if(k % 2 == 0) {
        cout << k / 2 << " ";
        rep(i, n - 1) {
            if(i) cout << " ";
            cout << k;
        }
        cout << endl;
        return;
    } else {
        vector<int> ans(n, (k + 1) / 2);
        rep(i, n / 2) {
            if(ans.back() == 1) ans.pop_back();
            else {
                ans.back() --;
                while(ans.size() != n) ans.push_back(k); 
            }
        }
        for(int x: ans) {
            cout << x << " ";
        }
        cout << endl;
    }
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

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

typedef long long ll;
int main()
{
    string S,T;
    cin>>S>>T;
    int ans=3;
    for(int i=0;i<3;i++)
    {
        if(S[i]!=T[i])
        {
            ans--;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<stdlib.h>
#include<utility>
#include<functional>
#include<cfenv>
#include<cmath>
#include<string>
#include<queue>
#include<stack>
#include<map>
#include<set>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define vint vector<int>
#define vvint vector<vint>
#define P pair<ll,ll>
#define INT_MAX 2147483647
#define MOD 998244353
#define PI 3.14159265358979323846
#define all(a) (a).begin(),(a).end()
using namespace std;
typedef long long ll;

#define MAX 1000000000000

int main(void) {
	int n, k; cin >> n >> k;
	string s; cin >> s;
	int ans = 0;
	rep(i, n-1) {
		if (s[i] == s[i + 1]) {
			ans++;
		}
	}
	ans = min(ans + 2 * k, n - 1);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3712
#include "bits/stdc++.h"
using namespace std;
using ld = long double;
const ld eps = 1e-9;
vector<int>path;
vector<int>oks;
void getpath(const int now, const int from, const vector<vector<int>>&edges) {

	path.emplace_back(now);
	if (now == edges.size()-1) {
		throw(false);
	}
	else {
		for (auto e : edges[now]) {
			if (e == from)continue;
			getpath(e, now, edges);
		}
		path.pop_back();
	}
}
int dfs(const int now, const int from, const vector<vector<int>>&edges) {
	int sum = 1;
	for (auto e : edges[now]) {
		if (e == from)continue;
		if (!oks[e])continue;
		sum += dfs(e, now, edges);
	}
	return sum;
}
int main() {
	int N; cin >> N;
	oks.assign(N, 1);
	vector<vector<int>>edges(N);
	for (int i = 0; i < N-1; ++i) {
		int a, b; cin >> a >> b;
		a--; b--;
		edges[a].push_back(b);
		edges[b].push_back(a);
	}
	try {
		getpath(0, -1, edges);
		for (auto p : path) {
			oks[p] = false;
		}
	}
	catch (...) {
	}
	for (auto p : path) {
		oks[p] = false;
	}
	int asum = 0, bsum = 0;
	for (int i = 0; i < path.size(); ++i) {
		if (i <int(path.size()+1) / 2) {
			asum += dfs(path[i], -1, edges);
		}
		else {
			bsum += dfs(path[i], -1, edges);
		}
	}
	if (asum > bsum)cout << "Fennec" << endl;
	else cout << "Snuke" << endl;
	return 0;
}

Measured memory_bytes: 12920
n, k, q = map(int, input().split())

a = list(int(input()) for i in range(q))
s = list([k] * n)
n_list = []

for i in a:
  s[i - 1] += 1

for i in s:
  if(i - q > 0):
    n_list.append('Yes')
  else:
    n_list.append('No')


for i in n_list:
  print(i)


Measured memory_bytes: 11280
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int h=sc.nextInt();
		int a=sc.nextInt();
		
		int num=0;
		while(h>0){
			h-=a;
			num++;
		}
		System.out.println(num);
	}
}


Measured memory_bytes: 22740
#include<cstdio>
#include<algorithm>
#include<functional>
#include<cstring>
#define MM 1000000007
using namespace std;
int main(void)
{
	char s1[53],s2[53];
	int i,n,p,flg;
	long long sum;
	scanf("%d",&n);
	scanf("%s",s1);
	scanf("%s",s2);
	if(s1[0]==s1[1])	{
		p=2;	sum=6;	flg=2;
	}
	else {
		p=1;	sum=3;	flg=1;
	}
	while(p<n)	{
		if(s1[p]!=s1[p+1])	{
			if(flg==1)	{
				sum=(sum*2)%MM;
				p++;
			}
			else {
				flg=1;
				p++;
			}
		}
		else {
			if(flg==1)	{
				flg=2;
				p+=2;
				sum=(sum*2)%MM;
			}
			else {
				sum=(sum*3)%MM;
				p+=2;
			}
		}
//		printf("x=%d p=%d flg=%d\n",sum,p,flg);
	}
	printf("%d\n",sum);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <cmath>
#include <map>
#include <iomanip>

using namespace std;
typedef long long  ll;

int main() {
	int n;
	cin >> n;
	int i = 1;
	while (++i <= n) {
		int x = i;
		if (x % 3 == 0) {
			cout << " " << i;
		}
		else {
			while (x) {
				if (x % 10 == 3) {
					cout << " " << i;
					break;
				}
				x /= 10;
			}
		}
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 3084
fn input_pair<T: std::str::FromStr + Copy> () -> (T, T) {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let arr: Vec<_> = s.trim().split_whitespace().flat_map(str::parse).collect();
    (arr[0], arr[1])
}

fn main() {
    let (n, k) = input_pair::<usize>();
    let mut a = n;
    let mut r = 0;
    while a > 0 {
        a /= k;
        r += 1;
    }
    println!("{}", r);
}


Measured memory_bytes: 2076
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>
#include <unordered_map>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

int main() {
    int64 n,x,m;
    cin >> n >> x >> m;

    int k = log2(n) + 1;
    vector<int> tb;
    unordered_map<int, int> mp;
    tb.emplace_back(x);
    mp[0] = x;
    int64 s = -1;
    {
        int cnt = 1;
        int64 t = x;
        while(true) {
            t *= t;
            t %= m;
            tb.emplace_back(t);
            if (mp[t]) {
                s = mp[t];
                break;
            }
            mp[t] = cnt;
            cnt++;
        }
    }

//    debug(tb);


    int64 ans = 0;
    for (int i=0; i<s; i++) ans += tb[i];

    int64 t = 0;
    for (int i=s; i<tb.size()-1; i++) t += tb[i];

//    debug(s);
//    debug(tb.size());
    int loop = tb.size() - s - 1;

    if (loop > 0) {
        int64 k = (n-s) / loop;
        t *= k;
        n -= s + k * loop;
        for (int i=s; i<n+s; i++) t += tb[i];
    }

    cout << ans + t << endl;
}
/*
 * 492443244981950
 * 492443256176507
 * 492443256176507
 */

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

#define pb push_back
#define mp make_pair
#define sz(x) (int)(x).size()
#define ll long long
#define ld long double
#define ft first
#define sc second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define forn(i, t) for(int i = 0; i < (t); i++)
#define fore(i, f, t) for(int i = (f); i < (t); i++)
#define forr(i, f, t) for(int i = (f) - 1; i >= (t); i--)
#define all(x) (x).begin(), (x).end()
#define ins insert

const int INF = 2147483647;
const int MOD = 1000000007;
const ll INF64 = 9223372036854775807;
const ld EPS = 1e-7;

using namespace std;


int main(){
    int n, k, t;
    cin >> k >> n;
    vector<int> ans(k);
    set<pii> a;
    forn(i, n){
        cin >> t;
        a.insert(mp(t, i));
    }
    pii cur;
    forn(i, k){
        cur = *(--a.end());
        if (!i){
            ans[i] = cur.sc;
            a.erase(cur);
            if (cur.ft != 1)
                a.insert(mp(cur.ft - 1, cur.sc));
        }
        else{
            if (ans[i - 1] == cur.sc && sz(a) > 1){
                cur = *(--(--a.end()));
                ans[i] = cur.sc;
                a.erase(cur);
                if (cur.ft != 1)
                    a.insert(mp(cur.ft - 1, cur.sc));
            }
            else{
                ans[i] = cur.sc;
                a.erase(cur);
                if (cur.ft != 1)
                    a.insert(mp(cur.ft - 1, cur.sc));
            }
        }     
    }
    int res = 0;
    fore(i, 1, k){
        if (ans[i] == ans[i - 1])
            res++;
    }
    cout << res << "\n";
    return 0;
}

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

int A,B,C,X;

int main(){
	cin >> A >> B >> C >> X;

	int res = 0;
	for(int a = 0; a <= A; a++){
		for(int b = 0; b <= B; b++){
			for(int c = 0; c <= C; c++){
				int total = 500*a + 100*b + 50*c;
				if(total == X) res++;
			}
		}
	}
	cout << res << endl;

	return 0;
}


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

using ll = long long;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(c) (c).begin(), (c).end()
const int MOD = 1000000007;

int main() {
    char a, b;
    cin >> a >> b;

    if (a == 'H') {
        cout << (b == 'H' ? 'H' : 'D') << endl;
    } else {
        cout << (b == 'H' ? 'D' : 'H') << endl;
    }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MOD1 1000000007
#define MOD2 998244353
#define LIMIT1 200002
#define LIMIT2 500002
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(i=0;i<n;i++)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
#define zt(a,b) (max(a,b)-min(a,b))
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll nPr(int n,int r){ll i,result=1;rep(i,r){result*=(ll)(n-i);}return result;}
ll nCr(int n,int r){ll i,result=1; rep(i,min(r,n-r)){result*=(ll)(n-i);result/=(ll)(i+1);}return result;}
#define fact(n) nPr((int)n,(int)n)
#define nHr(n,r) nCr((int)(n+r+1),(int)r)
#define sankaku(x) ((1+x)*x)/2
int dx[8]={1,0,-1,0,1,-1,-1,1};
int dy[8]={0,1,0,-1,1,1,-1,-1};
int upint(const void *a, const void *b) { return *(int *)a < *(int *)b ? -1 : *(int *)a > *(int *)b ? 1 : 0; }
int downint(const void *a, const void *b) { return *(int *)a < *(int *)b ? 1 : *(int *)a > *(int *)b ? -1 : 0; }
int upchar(const void* left, const void* right) {return strcmp((char *)left,(char *)right);}
int downchar(const void* left, const void* right) {return strcmp((char *)right,(char *)left);}
void initialize(){
  
}
int main(void){
  initialize();
  int n,m,i,j;
  int result=0;
  int a[LIMIT2]={0};
  int b[LIMIT1]={0};
  char s[LIMIT1];

  scanf("%d",&n);
  rep(i,n-1) scanf("%d",&a[i]);
    
  rep(i,n-1) b[a[i]-1]++;
  
  rep(i,n) printf("%d\n",b[i]);
  
  return 0;
}



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

int main() {
  int N, A,B;
  cin >> N >> A;
  
  B = N % 500;
  
  
  if (A >=  N % 500) {
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

}

Measured memory_bytes: 3588
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
typedef vector<string> vstring;
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
const long double PI=3.14159265358979323846264338327950;
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  vint a(n);
  set<pair<int,int> > S;
  rep(i,n){
    cin>>a[i];
    S.insert(make_pair(a[i],(i+1)%2));
  }
  int count=0;
  sort(all(a));
  rep(i,n){
    if(S.find(make_pair(a[i],(i+1)%2))==S.end()){
      count++;
    }
    i++;
  }
  cout<<count<<'\n';
  return(0);
}

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

int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> ab(n);
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        ab[b-1].push_back(a-1);
    }

    int bledge = -1;
    int ans = 0;
    for (int i = 0; i < n; i++) {
        for (const auto& e : ab[i]) {
            if (bledge < e) {
                bledge = i - 1;
                ans++;
            }
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 4864
n, x = gets.split.map(&:to_i)
xs = [*gets.split.map(&:to_i), x].sort!

ds = Array.new(n, 0)
n.times do |i|
  ds[i] = xs[i + 1] - xs[i]
end

ans = ds[0]

ds.each do |d|
  ans = ans.gcd(d)
end

puts ans


Measured memory_bytes: 11264
from math import gcd
n,m = map(int, input().split())
x = list(map(int, input().split()))

x.append(m)
x = sorted(x)

dis = [0]*n
for i in range(n): dis[i] = x[i+1] - x[i]

ans = dis[0]
for i in range(1,n): ans = gcd(ans,dis[i])
print(ans)

Measured memory_bytes: 20208
#include<bits/stdc++.h>
using namespace std;
int main(){
int N;cin>>N;
  vector<int64_t>A(N);
  vector<int64_t>B(N);
  for(int i=0;i<N;i++)
    cin>>A.at(i);
  for(int i=0;i<N;i++)
    cin>>B.at(i);
  bool update=true;
  int64_t ans=0;
  while(update){
  update=false;
    for(int i=0;i<N;i++){
    int64_t a=B[(N+i-1)%N];
      int64_t b=B[i];
      int64_t c=B[(N+i+1)%N];
      if(a+c<b && A[i]<=b-a-c){
      int64_t d=(b-A.at(i))/(a+c);
        ans+=d;update=true;
        B.at(i)-=d*(a+c);
      }
    }
  
  }bool x=true;
  for(int i=0;i<N;i++)
    if(A[i]!=B[i]){x=false;break;}
  if(!x)
    cout<<-1<<endl;
  else
    cout<<ans<<endl;
return 0;
}

Measured memory_bytes: 6388
#include<stdio.h>

int main(void) {

  char str[4];
  int count = 0;
  int k;
  
  scanf("%s",str);

  for(k = 0; k < 4; k++) {
    if (str[k] == '+') {
      count++;
    } else if (str[k] == '-') {
      count--;
    }
  }
  printf("%d\n",count);
  return 0;
}


Measured memory_bytes: 128
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
MOD = 10**9 + 7

n = int(input())
a = [int(item) for item in input().split()]

a.sort(reverse=True)
ans = 0
inv2 = pow(2, MOD-2, MOD)
for i, item in enumerate(a):
    k = i + 1
    total = pow(2, 2 * n - k, MOD)
    coef = (k + 1) * pow(2, k-1, MOD) * inv2
    val = total * coef * item % MOD
    ans += val
    ans %= MOD
    
print(ans)

Measured memory_bytes: 27116
#include<map>
#include<cmath>
#include<stack>
#include<queue>
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
template<class AC>void r(AC &x){
    x=0;
    int f=0;
    char ch=getchar();
    while(ch<'0'||ch>'9'){
        f|=(ch=='-');
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        x=(x<<1)+(x<<3)+(ch^48);
        ch=getchar();
    }
    x=f?-x:x;
    return;
}
string s;
int ans;
int main(){
	cin>>s;
	for(int i=0;s[i];i++)ans+=s[i]=='p';
	printf("%d\n",s.size()/2-ans);
    return 0;
}

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

#define maxn 411
#define maxm 111111

bitset<maxn> g[maxn];
bool canalive[maxn];
int a[maxm], b[maxm];
int n, m;

int main()
{
    scanf("%d%d", &n, &m);

    for (int i = 1; i <= m; i++)
    {
        scanf("%d%d", a + i, b + i);
    }

    for (int i = 1; i <= n; i++)
    {
        bitset<maxn>& w = g[i];
        w.set(i);
        canalive[i] = true;

        for (int j = m; j >= 1; j--)
        {
            int p = a[j], q = b[j];

            if (w[p] && w[q])
            {
                canalive[i] = false;
                break;
            }

            if (w[p] && !w[q])
            {
                g[i].set(q);
            }

            if (!w[p] && w[q])
            {
                g[i].set(p);
            }
        }
    }

    int ans = 0;

    for (int i = 1; i <= n; i++)
    {
        if (!canalive[i])
        {
            continue;
        }

        for (int j = i + 1; j <= n; j++)
        {
            if (!canalive[j])
            {
                continue;
            }

            if ((g[i]&g[j]).count() == 0)
            {
                ans++;
            }
        }
    }

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


Measured memory_bytes: 1024
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

func floatScanner() float64 {
	n, _ := strconv.ParseFloat(Scanner(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func stringSliceScanner(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scanner()
	}
	return a
}
func intSliceScanner(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = intScanner()
	}
	return a
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}

var mod int
var t float64

func main() {
	mod = 1000000007
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n := intScanner()
	a := make([][]int, n)
	b := make([][]int, n)
	for i := 0; i < n; i++ {
		a[i] = make([]int, n)
		b[i] = make([]int, n)
		for j := 0; j < n; j++ {
			a[i][j] = intScanner()
			b[i][j] = a[i][j]
		}
	}
	for k := 0; k < n; k++ {
		for i := 0; i < n; i++ {
			for j := 0; j < n; j++ {
				b[i][j] = smaller(b[i][j], b[i][k]+b[j][k])
			}
		}
	}
	ans := 0
	for i := 0; i < n; i++ {
		for j := i + 1; j < n; j++ {
			f := false
			for k := 0; k < n; k++ {
				if k != i && k != j {
					if b[i][k]+b[j][k] == a[i][j] {
						f = true
					} else if b[i][k]+b[j][k] < a[i][j] {
						ans = -1
					}
				}
			}
			if ans == -1 {
				break
			}
			if !f {
				ans += a[i][j]
			}
		}
		if ans == -1 {
			break
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 4876
import sys
input = sys.stdin.readline
from math import sqrt

x=int(input())

DIV=[]

for i in range(1,int(sqrt(x))+2):
    if x%i==0:
        DIV.append(i)
        DIV.append(x//i)

ANS=[]
for d in DIV:
    if d==1:
        continue
    k=x
    while k%d==0:
        k//=d
    if k%d==1:
        ANS.append(d)

t=x-1
for i in range(1,int(sqrt(t))+2):
    if t%i==0:
        ANS.append(i)
        ANS.append(t//i)

print(len(set(ANS))-1)


Measured memory_bytes: 40668
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
using namespace std;
#define loop(i,N) for(ll (i)=0; (i)<(N);++(i))
struct _OMAZINAI_ { _OMAZINAI_() { std::ios::sync_with_stdio(false); std::cin.tie(0); } } __omazinai_instance__;
#define INF ((1LL<<61) + (1<<29))
#define YesNo(x) {std::cout << ((x)?"Yes":"No") << std::endl;}
#define YESNO(x) {std::cout << ((x)?"YES":"NO") << std::endl;}
#define OddEven(x) {std::cout << ((x)%2?"Odd":"Even") << std::endl;}
#define ODDEVEN(x) {std::cout << ((x)%2?"ODD":"EVEN") << std::endl;}
typedef long long int ll;
ll my_gcd(ll a, ll b) { return b ? my_gcd(b, a%b) : a; };
void _INPUT_IMPL_() {};
template <class T, class... Args> void _INPUT_IMPL_(T& dest, Args&... args) { cin >> dest; _INPUT_IMPL_(args...); }
void _OUTPUT_IMPL_() {};
template <class T, class... Args> void _OUTPUT_IMPL_(T dest, Args... args) { cout << dest << (sizeof...(Args) ? " " : ""); _OUTPUT_IMPL_(args...); }
#define in(type, ...) type __VA_ARGS__; _INPUT_IMPL_(__VA_ARGS__)
#define in_v(type, name, cnt) vector<type> name(cnt); loop(i, cnt) cin >> name[i];
#define sort_v(v) std::sort(v.begin(), v.end())
#define out(...) (_OUTPUT_IMPL_(__VA_ARGS__), std::cout<<std::endl)
#define set_fix(x) ((std::cerr<<std::fixed<<std::setprecision(x)),(std::cout<<std::fixed<<std::setprecision(x)))
//小さい方に寄る
#define space_op(x, y, a, b, c) ([](auto x_, auto y_, auto a_, auto b_, auto c_){if(x_<y_)return a_;if(x_>y_)return c_;return b_;}(x,y,a,b,c))
#define space_out(x, y, a, b, c) out(space_op(x, y, a, b, c))

// ^^^ Template ^^^ //

int main() {
	in(ll, n);
	map <ll , ll> even, odd;

	// 出現回数のカウント
	auto ins = [](auto& dst, ll num) {
		/*if (dst.count(num))
			dst[num] += 1;
		else
			dst[num] = 1;*/
		++dst[num];
	};
	
	// 入力
	loop(i, n/2) {
		ll a, b;
		cin >> a >> b;
		ins(odd, a);
		ins(even, b);
	}

	// 最頻
	auto od_pair = *max_element(odd.begin(), odd.end(), [](auto a, auto b) { return a.second < b.second; });
	auto ev_pair = *max_element(even.begin(),even.end(),[](auto a, auto b) { return a.second < b.second; });

	auto od = od_pair.second;
	auto ev = ev_pair.second;

	// 2番目の最頻
	auto od_2_pair = *max_element(odd.begin(), odd.end(), [=](auto a, auto b) {
		return a.first == od_pair.first ? true : (b.first == od_pair.first ? false : a.second < b.second);
	});
	auto ev_2_pair = *max_element(even.begin(),even.end(),[=](auto a, auto b) {
		return a.first == ev_pair.first ? true : (b.first == ev_pair.first ? false : a.second < b.second);
	});

	auto od_2 = od_2_pair.second;
	auto ev_2 = ev_2_pair.second;

	// 但し2番目が無いなら0
	if (odd.size() == 1) od_2 = 0;
	if (even.size() == 1) ev_2 = 0;

	// 出力
	if (od_pair.first == ev_pair.first)
		out(n - max(od_2 + ev, od + ev_2));
	else
		out(n - od - ev);
}


Measured memory_bytes: 6528
def binary_search(key,S,start,end):
    if(start > end):
        return 0
    tmp_med=(start + end)//2
    if(S[tmp_med] == key):
        return 1
    elif(S[tmp_med] <key):
        return binary_search(key,S,tmp_med + 1, end)
    else:
        return binary_search(key,S,start,tmp_med-1)





n=int(input())
S=input().split()

q=input()
T=input().split()

S.sort()

cnt=0
for x in T:
    cnt+=binary_search(x,S,0,n-1)

print(cnt)


Measured memory_bytes: 15724
/**
 *      ABC 87 C
 *      author  : kyomukyomupurin
 *      created : 2018-09-01 20:23:23
**/

#include <bits/stdc++.h>
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int N; cin >> N;
    vector<int> A1, A2;
    for (int i = 0; i < N; ++i) {
        int x; cin >> x;
        A1.push_back(x);
    }
    for (int i = 0; i < N; ++i) {
        int x; cin >> x;
        A2.push_back(x);
    }

    int max = 0;
    int sum;
    for (int i = 0; i < N; ++i) {
        int sum1 = 0; int sum2 = 0;
        for (int j = 0; j <= i; ++j) {
            sum1 += A1[j];
        }
        for (int j = i; j <= N - 1; ++j){
            sum2 += A2[j];
        }
        sum = sum1 + sum2;
        if (sum > max){
            max = sum;
        }
    }
    cout << max << endl;

    return 0;
}

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

int main() {
    int input;

    for (int i = 1; i <= 10000; ++i) {
        cin >> input;
        if(input == 0){
            return 0;
        }
        cout << "Case "<< i << ": " << input << endl;
    }

    return 0;
}


Measured memory_bytes: 3056
if __name__ == "__main__":
    N = int(input())
    D = [list(map(int, input().split())) for _ in range(N)]
    T = 0
    X = 0
    Y = 0
    for d in D:
        t, x, y = d
        ans = "Yes"
        dxy = abs(X-x) + abs(Y-y)
        dt = t-T
        if dxy > dt or dxy % 2 != dt % 2: 
            # 直進したとしても到達できない，移動による偶奇
            ans = "No"
            break
    print(ans)


Measured memory_bytes: 27380
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

N, X = map(int, input().split())
x = list(map(int, input().split()))
x.append(X)
x.sort()
array = []
for i in range(N):
    array.append(x[i+1]-x[i])

if len(array) > 1:
    result = gcd(array[0], array[1])
    for i in range(2, len(array)):
        result = gcd(result, array[i])
else:
    result = array[0]
    
print(result)


Measured memory_bytes: 14224
n=int(input())
l=[list(map(int,input().split())) for i in range(n)]
ans=[[0,0,0] for i in range(n+1)]
for i in range(n):
    ans[i+1][0]=max(ans[i][1]+l[i][0],ans[i][2]+l[i][0])
    ans[i+1][1]=max(ans[i][2]+l[i][1],ans[i][0]+l[i][1])
    ans[i+1][2]=max(ans[i][0]+l[i][2],ans[i][1]+l[i][2])
print(max(ans[-1]))

Measured memory_bytes: 47344
// --霊長類の競プロ
#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 <numeric>

using namespace std;

int main(int argc, const char * argv[]) {
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string S;
    long cnt= 0;
    long N = 0;
    int flg = 0;
    
    cin >> S;
    
    flg = 0;
    N = S.length();
    for (int i=0;i<N; i++){
        if(i<N && S[i] == S[i+1] && flg == 0){
            flg = 1;
            i++;
        }else{
            flg = 0;
        }
        cnt++;
    }
    
    cout << cnt << endl;

    return 0;
}



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

int main() {
    string s;
    long long K;
    cin >>s;
    cin >>K;
    long long N;
    N=s.size();
    std::vector<string> sub;
    
    for (int i = 0; i < N; i++) {
        for (int j = 1; j+i <= N && j<=K; j++) {
            sub.push_back(s.substr(i,j));
        }
    }
    sort(sub.begin(),sub.end());
    unique(sub.begin(), sub.end());
    
    std::cout << sub[K-1] << std::endl;
}



Measured memory_bytes: 1660