akhauriyash/Code-Regression huggingface dataset:
// --------------
// Tejas Pandey  |
// 01 - 09 - 19  |
// ABC #139      |
// --------------

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

#define mod 1000000007
#define vi vector<int>
typedef long long int ll;

int main (void)
{
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t = 1;
	//cin >> t;
	while(t--)
	{
		//cout << "Case #" << c-t << ": ";
		int n;
		cin >> n;
		int ans = 0,cur = -1,curh = -1;
		for(int i = 0;i < n;i++){
			int k;
			cin >> k;
			if(curh == -1 || curh >= k)
			cur++;
			else
			cur = 0;
			curh = k;
			ans = max(cur,ans);
		}
		cout << ans << "\n";
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>

using namespace std;

const int MAX=1000010;
int n;
int dp[MAX];
int a[MAX];

int main()
{
	while(cin>>n)
	{
		memset(a,0,sizeof(a));
		memset(dp,0,sizeof(dp));
		for(int i=1;i<=n;i++)
		{
			cin>>a[i];
		}
		dp[0]=0;
		dp[1]=0;
		dp[2]=abs(a[2]-a[1]);
		for(int i=3;i<=n;i++)
		{
			dp[i]=min(dp[i-2]+abs(a[i]-a[i-2]),dp[i-1]+abs(a[i]-a[i-1]));
		}
		cout<<dp[n]<<endl;
    }
	return 0;
} 

Measured memory_bytes: 11448
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
typedef long long ll;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> indexed_set; 
const ll INF = 1e18 + 10 ; 
const ll MAXN = 1e5 + 10 ; 
int main(){
    fastio
    ll n , k;
    cin >> n >> k; 
    vector<int> v(n) ; 
    for(ll i=0;i<n;i++){
    	cin >> v[i] ; 
    }
    ll dp[n] ; 
    for(int i=0;i<n;i++){
    	dp[i] = INF ; 
    }
    dp[0] = 0 ; 
    for(int i=1;i<n;i++){
    	for(int j=0;j<=k;j++){
    		if ( i - j >= 0 ){
    			dp[i] = min(dp[i],abs(v[i]-v[i-j]) + dp[i-j]) ;
    		}
    	}
    }
    cout << dp[n-1] << endl;
    return 0 ;
}


Measured memory_bytes: 1408
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<stdlib.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<numeric>
#include<iomanip>
using namespace std;

int main()
{
	int n;
	cin >> n;
	int count = 0;
	for (int i = 0; i * 4 <= n; i++) {
		for (int j = 0; j * 7 + i* 4 <= n; j++) {
			if (i * 4 + j * 7 == n) {
				cout << "Yes" << endl;
				count++;
				i = 300; j = 500;
			}
		}
	}
	if (count == 0) {
		cout << "No" << endl;
		
	}

}


Measured memory_bytes: 256
#include <stdio.h>

int n, S[100001], q, T[50001];
int count = 0;

void nibutan(int l, int r, int tt){
	if(r - l <= 1) {
		if(S[l] == tt || S[r] == tt) count ++;
		return;
	}
	int nibu = (r + l)/2;
	if(S[nibu] < tt) {
		nibutan(nibu, r, tt);
		return;
	}
	if(S[nibu] > tt){
		nibutan(l, nibu, tt);
		return;
	}
	if(S[nibu] == tt)count ++;
	return;
}

int main(){
	scanf("%d", &n);
	for(int i = 0;i < n;i ++){
		scanf("%d", &S[i]);
	}
	scanf("%d", &q);
	for(int i = 0; i < q;i ++) scanf("%d", &T[i]);
	for(int tt = 0;tt < q;tt ++) nibutan(0, n, T[tt]);
	printf("%d\n", count);
	return 0;
}



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

def gcd(p, q):
    if q == 0:
        return p
    else:
        return gcd(q, p % q)

g = gcd(a[0], a[1])
for i in range(2, n):
    g = gcd(g, a[i])

print(g)

Measured memory_bytes: 20084
'use strict'
function Main(input){
  var N=input.trim()-0;
  var a=1,b=1;
  roop: while(true){
    for(b=a;b<=3500;b++){
      if(4*a*b-N*a-N*b>0&&(a*b*N)%(4*a*b-N*b-N*a)===0)
        break roop;
      }
    a++;
  }
  var c=Math.round(a*b*N/(4*a*b-N*a-N*b));
  console.log(a+' '+b+' '+c);
}

Main(require('fs').readFileSync('/dev/stdin','utf8'));

Measured memory_bytes: 21576
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>

#define EPS 1e-10
#define PI 3.14159265358979
#define DEG_TO_RAD(x) (x * PI / 180.0)
#define RAD_TO_DEG(x) (x * 180.0 / PI)

struct POINT_DOUBLE {
  double x;
  double y;

  POINT_DOUBLE(double x, double y) : x(x), y(y) {}

  bool operator == (const POINT_DOUBLE& other) const {
    return (std::abs(x - other.x) < EPS) && (std::abs(y - other.y) < EPS);
  }

  bool operator < (const POINT_DOUBLE& other) const {
    return x < other.x || (x == other.x && y < other.y);
  }

  void move(double len, double angle) {
    x += len * std::cos(angle);
    y += len * std::sin(angle);
  }
};

int main(void)
{
  int n;
  
  std::cout << std::fixed << std::setprecision(2);

  while (std::cin >> n && n != -1) {
    POINT_DOUBLE pt(1.0, 0.0);
    double angle = DEG_TO_RAD(90);
    for (int i = 0; i < n - 1; i++) {
      pt.move(1.0, angle);
      angle = std::atan2(pt.y, pt.x) + DEG_TO_RAD(90);
    }
    std::cout << pt.x << std::endl;
    std::cout << pt.y << std::endl;
  }

  return 0;
}



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

using pii = pair<int, int>;

int main() {
    string s; cin >> s;
    const int n = s.size();
    bool ng = s[0] == '0' || s.back() == '1';
    for(int i = 0; i < (n - 1) / 2; ++i) {
        ng |= s[i] != s[n - 2 - i];
    }
    if(ng) {
        cout << -1 << endl;
        return 0;
    }
    vector<pii> ans;
    int now_a = 1, iter = 2, prev_a = -1;
    for(int i = 1; i < n; ++i) {
        if(s[i] == '1') {
            if(prev_a != -1) {
                ans.emplace_back(prev_a, now_a);
            }
            for(int j = now_a + 1; j <= iter; ++j) {
                ans.emplace_back(now_a, j);
            }
            prev_a = now_a;
            now_a = iter + 1;
        }
        iter++;
    }
    ans.emplace_back(prev_a, n);
    sort(begin(ans), end(ans));
    for(auto& p : ans) {
        cout << p.first << " " << p.second << endl;
    }
}


Measured memory_bytes: 2420
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));

console.log(main());
function main(){
  var n = o.a();
  var k = o.a();
  return (n+1)/2 >= k ? "YES":"NO";
}

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

int main() {
  while (true) {
    int n;
    cin >> n;
    if (n == 0) return 0;
    
    vector<vector<char>> s(n);
    string keep;
    for (int i = 0; i < n; i++) {
      cin >> keep;
      for (int j = 0; j < keep.size(); j++) {
        s[i].emplace_back(keep.at(j));
      }
    }
    
    for (int i = 1; i < n; i++) {
      for (int j = 1; j < s[i].size(); j++) {
        if ('a' <= s[i][j] && s[i][j] <= 'z' && s[i][j - 1] == '.') {
          s[i][j - 1] = '+';
          int nowi = i - 1, nowj = j - 1;
          while (nowi > 0) {
            if (s[nowi][nowj] == '.') {
              s[nowi][nowj] = '|';
              nowi--;
            }
            else {
              break;
            }
          }
          break;
        }
      }
    }
    
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < s[i].size(); j++) {
        if (s[i][j] == '.') cout << " ";
        else cout << s[i][j];
      }
      cout << '\n';
    }
  }
}


Measured memory_bytes: 3656
// StandardDeviation.c
// n 人の学生を含むクラスでプログラミングの試験を行った。
// それぞれの得点をs1, s2 ... snとしたときの、標準偏差を求めるプログラムを作成せよ。
//
// 得点の平均値をｍとすれば、分散α2は以下の式で得られる：
// α^2 = (∑i=1 n (s[i] - m)^2) / n
//
// 分散の正の平方根が標準偏差αとなる。
//
// 【入力】
// 複数のデータセットが入力として与えられる。各データセットは以下の形式で与えられる：
// 学生の数 n
// s1 s2 ... sn
// n が 0 のとき入力の終わりとする。
// 【出力】
// 各データセットに対して、標準偏差を１行に出力せよ。
// ただし、0.0001以下の誤差があってもよい。
// 【制約】
// ・入力で与えられる n が1000を超えることはない。
// ・0 ≤ si ≤ 100
// 【例】
// 入力：
// 5
// 70 80 100 90 20
// 3
// 80 80 80
// 0
// 出力：
// 27.85677655
// 0.00000000
#include<stdio.h>
#include<math.h>

int main( void) {
  int n;	// 学生の数；
  int s[1000];	// 得点。学生は1000人を超えることはない。
  double S;	// 得点の合計
  double m;	// 平均点
  double sigma;
  double alpha;	// 標準偏差

  while ( 1) {
    scanf( "%d", &n);
    if ( n == 0) break;

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

    m = S / n;

    sigma = 0;
    for ( int i = 0; i < n; i++) {
      sigma += pow( s[i] - m, 2);
    }
    
    alpha = sqrt( sigma / n);

    printf( "%.8lf\n", alpha);
  }

  return 0;
}



Measured memory_bytes: 2108
#include<bits/stdc++.h>
 
using namespace std;
 
#define INF 1000000007
#define LINF 1000000000000000007
 
typedef long long i64;
typedef pair<i64,i64> P;


int a[5];

int main(){
	int c = 0, d = 0;
	for(int i = 0; i < 5; i++){
		cin >> a[i];
		c += a[i]/10*10;
		if(a[i]%10){
			if(!d) d = a[i]%10;
			else d = min(d, a[i]%10);
			c += 10;
		}
	}
	cout << c + d - !!d*10 << endl;
	
	return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;
//const int mod = 998244353;

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

    int x;
    cin >> x;
    for (int i = 1; 100 * i <= x; i++)
    {
        int n = x - 100 * i;
        if (n <= 5 * i)
        {
            cout << 1 << endl;
            return 0;
        }
    }
    cout << 0 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
    #include <ext/pb_ds/assoc_container.hpp>
    #include <ext/pb_ds/tree_policy.hpp>
    #include <ext/pb_ds/detail/standard_policies.hpp>
 
    using namespace std;
    using namespace __gnu_pbds;
 
    #define endl "\n"
    #define fi first
    #define se second
    #define pb push_back
    #define int long long 
    #define ll long long
    #define ld long double
    #define pii pair<ll,ll>
 
    #define read(t) ll t;cin>>t;
    #define all(x) x.begin(),x.end()
    #define f(a,b,c) for(ll a=b;a<c;a++)
    #define For(i,n) for(ll i=0;i<n;i++)
 
    #define what(x) cerr << #x << " is " << x << endl;
    #define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) ;
 
    typedef tree<pair<ll,ll>, null_type,less<pair<ll,ll>>, rb_tree_tag,tree_order_statistics_node_update> omultiset;
    typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> oset;
    typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> oset1;
 
/*.....................................................................................................................*/
 
    const ll mod=(ll)1e9+ 7;
 
    ll add(ll x,ll y) {return (x+y)%mod;}
    ll mult(ll x, ll y){return ((x%mod )* (y%mod)) % mod;}
 
    long long binpow(long long x, long long p) 
    {
        if (p == 0) {return 1;} 
    	if (p == 2 || (p & 1)) {return mult(x, binpow(x, p - 1));}
    	return binpow(binpow(x, p / 2), 2);
    }
    ll modinv(ll a) {return binpow(a,mod-2);}
 
    //A.erase(unique(A.begin(),A.end()),A.end());
    double pi=3.141592653589793238462641;
    ll dx[4]={1,-1,0,0},dy[4]={0,0,1,-1};
    const ll  man  =   (int)200005   ,  inf   =   1e18;
 
 
/*......................................................................................................................*/



signed main()
{
    fast;
    int n;
    cin>>n;
    vector<int>a(n);
    for(int i=0;i<n;i++)cin>>a[i];
    vector<vector<int>>dp(n+1,vector<int>(n+1));
    for(int l=n-1;l>=0;l--)
    {
        for(int r=l;r<n;r++)
        {
            if(r==l)dp[r][r]=0;
            else 
            {
                dp[l][r]=inf;
                int sum=0;
                for(int i=l;i<=r;i++)sum+=a[i];
                for(int i=l;i<r;i++)
                {
                    dp[l][r]=min(dp[l][r],sum+dp[l][i]+dp[i+1][r]);
                }
            }
        }
    }
    cout<<dp[0][n-1]<<endl;
}   

Measured memory_bytes: 4508
#include<iostream>
#include<algorithm>
using namespace std;
#define rep(i,ra,re) for((i)=ra;(i)<(re);(i)++)
#define puts(n) cout << n << endl;
#define MAX 2000
bool a[MAX][MAX];
int l[MAX][MAX],r[MAX][MAX],u[MAX][MAX],d[MAX][MAX];
int ui,di,lj,rj,k,i,j,maxs=-1;
int main(void){
	int h,w;
	cin >> h >> w;
	rep(i,0,h){
		rep(j,0,w){
			char s;cin >> s;
			a[i][j]=(s=='#'?true:false);
		}
	}
		
	rep(i,0,h){
		int lx=-1,rx=w;
		rep(k,0,w){
			lj=k;rj=w-k-1;
				if(a[i][lj])
					lx=lj;
				else
					l[i][lj]=lj-lx-1;
			
				if(a[i][rj])
					rx=rj;
				else
					r[i][rj]=rx-rj-1;
			}
		}
		
	rep(j,0,w){
		int ux=-1,dx=h;
			rep(k,0,h){
				ui=k;di=h-k-1;
				if(a[ui][j])
					ux=ui;
				else
					u[ui][j]=ui-ux-1;
				
				if(a[di][j])
					dx=di;
				else
					d[di][j]=dx-di-1;
			}
		}
		rep(i,0,h)
			rep(j,0,w)
				if(!a[i][j])
					maxs=max(maxs,r[i][j]+l[i][j]+u[i][j]+d[i][j]);
		
		puts(maxs+1);
		return 0;
}

Measured memory_bytes: 66688
#from collections import deque,defaultdict
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

n = inn()
b = inl()
ans = []
for i in range(n):
    #ddprint(i)
    #ddprint(b)
    #ddprint(ans)
    for j in range(n-i-1,-1,-1):
        if b[j]==j+1:
            ans.append(j+1)
            for k in range(j,n-i-1):
                b[k] = b[k+1]
            break
    if len(ans)<i+1:
        print(-1)
        exit()
ans.reverse()
for x in ans:
    print(x)


Measured memory_bytes: 38768
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <math.h>
#define MOD 1000000007
typedef long long ll;
using namespace std;

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

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

  int now=1;
  int used[n+1]={};
  vector<int> ans1,ans2;
  ans1.push_back(1);
  used[1]=1;

  for(;;){
    bool flag=0;
    for(int i=0;i<v[now].size();i++){
      int next=v[now][i];
      if(used[next]) continue;
      used[next]=1;
      ans1.push_back(next);
      now=next;
      flag=1;
      break;
    }
    if(!flag) break;
  }

  now=1;
  for(;;){
    bool flag=0;
    for(int i=0;i<v[now].size();i++){
      int next=v[now][i];
      if(used[next]) continue;
      used[next]=1;
      ans2.push_back(next);
      now=next;
      flag=1;
      break;
    }
    if(!flag) break;
  }

  cout<<ans1.size()+ans2.size()<<endl;
  for(int i=ans2.size()-1;i>=0;i--) cout<<ans2[i]<<" ";
  for(int i=0;i<ans1.size();i++) cout<<ans1[i]<<" ";
  cout<<endl;

  return 0;
}


Measured memory_bytes: 7160
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

typedef struct TREE{
	int id;
	struct TREE *parent;
	struct TREE *child[2];
	int depth;
	int height;
}Tree;

void insert(Tree **root, Tree *z){
	Tree *y = NULL;
	Tree *x = *root;
	while( x != NULL ){
		y = x;
		if( z->id < x->id ){
			x = x->child[0];
		}else{
			x = x->child[1];
		}
	}
	z->parent = y;
	if( y == NULL ){
		*root = z;
	}else if( z->id < y->id ){
		y->child[0] = z;
	}else{
		y->child[1] = z;
	}
	return;
}

Tree* find(Tree *node, int key){
	if( key < node->id ){
		if( node->child[0] == NULL ){ return NULL; }
		return find(node->child[0], key);
	}else if( key > node->id ){
		if( node->child[1] == NULL ){ return NULL; }
		return find(node->child[1], key);
	}
	return node;
}

Tree* getNextNode(Tree *node){
	if( node->child[0] == NULL ){ return node; }
	return getNextNode(node->child[0]);
}

int delete(Tree *root, int key){
	Tree *node = find(root, key);
	//root?????´??????
	if( node == root ){
		free(node);
		return 0;
	}
	Tree *p = node->parent;
	if( node->child[0] == NULL && node->child[1] == NULL ){
		p->child[(p->child[0]==node?0:1)] = NULL;
		free(node);
	}else if( node->child[0] != NULL && node->child[1] != NULL ){
		Tree *nextNode = getNextNode(node->child[1]);
		int nnk = nextNode->id;
		//?????????????????¨?????????
		delete(root, nnk);
		node->id = nnk;
	}else{
		//?????????????????????NULL??§?????????
		Tree *child = (node->child[0]!=NULL?node->child[0]:node->child[1]);
		p->child[(p->child[0]==node?0:1)] = child;
		child->parent = p;
		free(node);
	}
	return 0;
}

int setDepthHeight(Tree *nt, int depth){
	if( nt == NULL ){ return -1; }
	nt->depth = depth;
	int lh = setDepthHeight(nt->child[0], depth+1);
	int rh = setDepthHeight(nt->child[1], depth+1);
	nt->height = (lh>rh?lh:rh) + 1;
	return nt->height;
}

void preOrder(Tree *tr){
	if( tr == NULL ){ return; }
	printf(" %d", tr->id);
	preOrder(tr->child[0]);
	preOrder(tr->child[1]);
	return;
}

void inOrder(Tree *tr){
	if( tr == NULL ){ return; }
	inOrder(tr->child[0]);
	printf(" %d", tr->id);
	inOrder(tr->child[1]);
	return;
}

void postOrder(Tree *tr){
	if( tr == NULL ){ return; }
	postOrder(tr->child[0]);
	postOrder(tr->child[1]);
	printf(" %d", tr->id);
	return;
}

void print(Tree *root){
	inOrder(root);
	printf("\n");
	preOrder(root);
	printf("\n");
	return;
}

int main(){
	int n, id, i, j;
	char str[128];
	Tree *root = NULL, *temp = NULL;
	scanf("%d", &n);
	for( i = 0; i < n; i++ ){
		scanf("%s", str);
		if( strcmp(str, "insert") == 0 ){
			scanf("%d", &id);
			scanf("%c", &str[0]);
			temp = (Tree*)malloc(sizeof(Tree));
			temp->id = id;
			temp->parent = NULL;
			temp->child[0] = NULL;
			temp->child[1] = NULL;
			insert(&root, temp);
		}else if( strcmp(str, "print") == 0 ){
			print(root);
		}else if( strcmp(str, "find") == 0 ){
			scanf("%d", &id);
			printf("%s\n", (find(root, id)!=NULL?"yes":"no"));
		}else if( strcmp(str, "delete") == 0 ){
			scanf("%d", &id);
			delete(root, id);
		}
	}
	setDepthHeight(root, 0);
	return 0;
}

Measured memory_bytes: 19364
import sys
from io import StringIO
import unittest
from decimal import Decimal, ROUND_HALF_UP


def resolve():
    N = int(input())
    X = [int(i) for i in input().split()]
    p = int(Decimal(str(sum(X) / N))
            .quantize(Decimal("0"), rounding=ROUND_HALF_UP))
    sumXP = 0
    for xi in X:
        sumXP += (xi - p)**2
    print(sumXP)


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """2
1 4"""
        output = """5"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """7
14 14 2 13 56 2 37"""
        output = """2354"""
        self.assertIO(input, output)


if __name__ == "__main__":
    # unittest.main()
    resolve()


Measured memory_bytes: 6680
#include <algorithm>
#include <bits/stdc++.h>
#include<iostream>
#include<string>
using namespace std;
#define rep(i, n) for (int i = 0; i <(int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
int main(){
int n;cin>>n;
int a[n];
rep(i,n)cin>>a[i];
bool ok=true;
for(int i=0;i<n;i++){
    if(a[i]%2==0&&a[i]%3!=0&&a[i]%5!=0)ok=false;
}
if(ok)cout<<"APPROVED"<<endl;
else cout<<"DENIED";

}

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];
  sort(a.begin(), a.end());
  
  string ans = "YES";
  for (int i = 0; i < n - 1; i++) {
    if (a[i] == a[i+1]) {
      ans = "NO";
      break;
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;

public class Prog
{
    private const int INF = 1000000007;
    public struct Pair<T> { public T x, y; public Pair(T x, T y) { this.x = x; this.y = y; } }
    public static void Solve()
    {
        long N = NextLong();
        long K = NextLong();
        long red = N - K;
        //どこの隙間を埋めるか
        int sukima = 0;
        for (int i = 1; i <= K; i++)
        {
            //if (K < sukima) { Console.WriteLine(0); continue; }
            //隙間が1の時、そこに1-K個と弾と、残った弾を自由に分配する
            //つまり隙間個を確定させて、他で自由に分配すればいいい
            //隙間も組み合わせで決められる
            long _sukima = PCH.nCr(K - 1, sukima) % INF;

            if (red - sukima < 0) { Console.WriteLine(0); continue; }

            long H = PCH.nHr(sukima + 2, red - sukima) % INF;

            //sukima個、隙間を埋めるのに使うので他をsukima個+2で使える

            Console.WriteLine((Math.Max(_sukima, 1) * Math.Max(H, 1)) % INF);

            sukima++;
        }
    }
    public static void Main()
    {
        var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
        Solve();
        Console.Out.Flush();
    }
}


public static class PCH
{
    public static long nPr(long n, long r, long m = 1000000007)
    {
        for (long i = 0; i < r; r++) { n *= (n - i); n %= m; }
        return n;
    }
    public static long nCr(long n, long r, long m = 1000000007)
    {
        if (r == 0) return 0;
        long a = 1;
        for (long i = 0; i < r; i++) { a *= (n - i); a %= m; }
        long b = 1;
        for (long x = 2; x <= r; x++) { b *= x; b %= m; }
        b = RepPow(b, m - 2) % m;
        return (a * b) % m;
    }
    public static long nHr(long n, long r, long m = 1000000007)
    {
        return nCr(n + r - 1, r, m);
    }
    public static long RepPow(long x, long p, long m = 1000000007)
    {
        if (p == 0) return 1;
        if (p == 1) return x % m;
        long b = RepPow(x, p / 2, m) % m;
        if (p % 2 == 0) { return (b * b) % m; }
        else { return (x * ((b * b) % m)) % m; }
    }
}
public class Input
{
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static char NextChar() { Confirm(); return char.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}


Measured memory_bytes: 11220
queue = []
 
n, q = map(int, input().split())
for i in range(n):
  name, time = input().split()
  queue.append([name, int(time)])
 
t = 0
while len(queue) > 0:
  entry = queue.pop(0)
  t += min(entry[1], q)
  entry[1] -= q
  if entry[1] > 0:
    queue.append(entry)
  else:
    print("{} {}".format(entry[0], t))

Measured memory_bytes: 15584
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
    int n;
    char[] cs;

    public static void main(String args[]) {
        new Main().run();
    }

    void run() {
        FastReader sc = new FastReader();
        n = sc.nextInt();
        cs = sc.next().toCharArray();
        solve();
    }

    void solve() {
        int[] sumEastL = new int[n];
        if (cs[0] == 'E') {
            sumEastL[0] = 1;
        }
        for (int i = 1; i < n; i++) {
            sumEastL[i] = sumEastL[i - 1] + (cs[i] == 'E' ? 1 : 0);
        }
        int min = 10000000;
        for (int i = 0; i < n; i++) {
            int num = sumEastL[n - 1] - sumEastL[i] + (i > 0 ? i - sumEastL[i - 1] : 0);
            if (min > num) {
                min = num;
            }
        }
        System.out.println(min);
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}


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

int main(){
  int n; cin >> n;
  vector<int> v(n);
  rep(i,n) cin >> v.at(i);
  sort(v.begin(),v.end());

  double ans = v.at(0);
  for(int i = 1; i < n;i++) {
    ans = (ans + v.at(i)) / 2;
  }

  cout << fixed << setprecision(10) << ans << endl;
}


Measured memory_bytes: 256
#include<string>
#include<iostream>
#include<set>
#include<cmath>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<functional>
//#define scanf scanf_s
#define fir first
#define sec second
#define mp make_pair
#define mt make_tuple
#define pub push_back
using namespace std;
typedef long long int llint;
const llint one = 1;
const llint big = (one<<30);

int main(void){
	string S,T;
	int i,Q,gen,a,b,c,d;
	vector<int> ambs={0};
	vector<int> ambt={0};
	cin>>S;
	cin>>T;
	gen=0;
	for(i=0;i<S.size();i++){
		if(S[i]=='A'){gen++;} else{gen--;}
		ambs.pub(gen);
	}gen=0;
	for(i=0;i<T.size();i++){
		if(T[i]=='A'){gen++;} else{gen--;}
		ambt.pub(gen);
	}
	scanf("%d",&Q);
	for(;Q>0;Q--){
		scanf("%d %d %d %d",&a,&b,&c,&d);
		if((ambs[b]-ambs[a-1]-ambt[d]+ambt[c-1]+399999)%3==0){
			printf("YES\n");
		} else{
			printf("NO\n");
		}
	}
	return 0;
}


Measured memory_bytes: 1788
import math

q = int(input())
for _ in range(q):
    a, b = sorted(map(int, input().split()))
    if a == b:
        print(2 * a - 2)
    elif a + 1 == b:
        print(2 * a - 2)
    else:
        c = math.ceil(math.sqrt(a * b)) - 1

        if c * (c + 1) >= a * b:
            print(2 * c - 2)
        else:
            print(2 * c - 1)

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

#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()

using namespace std;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;

const ll MOD = 1e9 + 7;
const ll INF = 1e18;
const ll N = 1e6 + 10;


int main(){
	ll pnt = 0, ans = 0;
	str s;
	cin >> s;
	for (int i = 0; i < s.size(); i++){
		if (s[i] == 'g' && pnt != 0){
			pnt --;
			ans ++;
		}else if(s[i] == 'g'){
			pnt ++;
		}else if(s[i] == 'p' && pnt != 0){
			pnt --;
		}else{
			pnt ++;
			ans --;
		}
	}
	cout << ans;



	return 0;
}


Measured memory_bytes: 512
#include <iostream>
using namespace std;
int main() {
	string S, T;
	int count = 0;
	cin >> S >> T;

	for (int i = 0; i < S.size(); i++) {
		if (S.at(i) != T.at(i)) {
			count++;
		}
		else {
			continue;
		}
	}
	cout << count << endl;
}

Measured memory_bytes: 3912
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};
fn main() {
    input! {//
        n:usize,h:i64,w:i64,
        ab:[(i64,i64);n],
    }
    println!("{}", ab.iter().filter(|(a, b)| *a >= h && *b >= w).count());
}


Measured memory_bytes: 2200
use std::fs;
use std::io::{stdin, Read};
struct UnionFind {
    parents: Vec<usize>,
}
impl UnionFind {
    pub fn new(n: usize) -> Self {
        let par = (0..n).collect();
        UnionFind { parents: par }
    }
    pub fn root(&mut self, x: usize) -> usize {
        if self.parents[x] == x {
            return x;
        }
        let par = self.parents[x];
        self.parents[x] = self.root(par);
        self.parents[x]
    }
    pub fn union(&mut self, x: usize, y: usize) {
        let rx = self.root(x);
        let ry = self.root(y);
        if rx == ry {
            return;
        }
        self.parents[rx] = ry;
    }
    pub fn is_same(&mut self, x: usize, y: usize) -> bool {
        let rx = self.root(x);
        let ry = self.root(y);
        rx == ry
    }
}

macro_rules! parse {
    ($it: ident) => {
        $it.next().unwrap().parse().unwrap()
    };
    ($it: ident,2) => {
        (parse!($it), parse!($it))
    };
    ($it: ident,3) => {
        (parse!($it), parse!($it), parse!($it))
    };
    ($it: ident,4) => {
        (parse!($it), parse!($it), parse!($it), parse!($it))
    };
    ($it: ident, $n: expr) => {
        (&mut $it).take($n).map(|e| e.parse().unwrap()).collect();
    };
}
fn binary_search_left<T: Ord>(v: &Vec<T>, x: T) -> usize {
    let mut l: isize = -1;
    let mut r: isize = v.len() as isize;
    while r - l > 1 {
        let m = (r + l) / 2;
        if v[m as usize] < x {
            l = m;
        } else {
            r = m;
        }
    }
    r as usize
}

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    let n = parse!(it);
    let mut a: Vec<usize> = parse!(it, n);
    a.sort();
    let mut counts = std::collections::HashMap::<usize, usize>::new();
    for &a in a.iter() {
        *counts.entry(a).or_insert(0) += 1;
    }
    let mut ret = 0;
    for &a in a.iter().rev() {
        if counts[&a] == 0 {
            continue;
        }
        *counts.entry(a).or_insert(0) -= 1;
        let mut k = 1;
        while a > k {
            k <<= 1;
        }
        let b = if k == a { a } else { k - a };
        let mut e = counts.entry(b).or_insert(0);
        if *e > 0 {
            *e -= 1;
            ret += 1;
        }
    }
    println!("{}", ret);
}

fn test() {
    let mut f = fs::File::open("foo.txt").unwrap();
    let mut s = String::new();
    f.read_to_string(&mut s).unwrap();
    solve(&s);
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_main() {
        test();
    }
    #[test]
    fn test_input() {
        let s = "
        ";
        solve(s);
    }
}


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

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
const int INF = int (1e9) + int (1e5);
const ll INFL = ll(2e18) + ll(1e10);
const ui MOD = 1E9 + 7;
const double EPS = 1e-9;
#define FOR(i,n) for (int i=0;i<(n);++i)
#define ROF(i,x) for(int i = (x) ; i >= 0 ; --i)
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define ODD(x) (((x)&1)==0?(0):(1))
#define sign(x) ((x > 0) - (x < 0))
std::mt19937_64  generator(std::chrono::system_clock::now().time_since_epoch().count());

inline ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a, ll b) { return a ? gcd(b%a, a): b; }
ll lcm(ll a, ll b) { return a / gcd(a,b) * b; }


void READ(bool _local){
    ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef _DEBUG
    if (_local)
        freopen ("in.txt", "r", stdin);
#endif
}

int main() {
    READ(0);
    int n;cin>>n;
    string s;cin>>s;
    vvi dp(n,vi(n));
    for(int start=n-2;start>=0;--start){dp[start][n-1]= (s[start]==s[n-1]);};
    for(int fin=n-2;fin>0;--fin){
        for(int start=fin-1;start>=0;--start){
            if (s[start]==s[fin]){
                dp[start][fin]=min(fin-start,dp[start+1][fin+1]+1);
            }else{
                dp[start][fin]=0;
            }
        }
    }
    int ret=0;
    FOR(i,n){
        FOR(j,n){
            ret=max(ret,dp[i][j]);
        }
    }
    cout << ret;
    return 0;
}



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

int main() {
  string s, t;
  cin >> s >> t;
  sort(s.begin(), s.end());
  sort(t.begin(), t.end());
  reverse(t.begin(), t.end());
  if (s < t)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
a.sort()
count = 1
ans = 0
for i in range(n-1):
    if a[i+1] != a[i]:
        if count >= a[i]:
            ans += count-a[i]
        else:
            ans += count
        count = 1
    else:
        count+=1
if count >= a[-1]:
    ans += count-a[-1]
else:
    ans += count
print(ans)

Measured memory_bytes: 85400
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<ll> vl;
typedef vector<vector<int, int> > vvi;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
int main(){
    int n;
    cin >> n;
    int cnt = 0;
    for(int i = 1; i <= n; i++){
        if(i%2==1) cnt++;
    }
    cout << fixed << setprecision(6) << double(cnt)/double(n);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll x;
    int k;
    cin>>k>>x;
    int sum=k*500;
    
        if(sum>=x)
            cout<<"Yes"<<endl;
        else
            cout<<"No"<<endl;
    return 0;
}


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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    int n, m, c;
    cin >> n >> m >> c;
    vector<int> b(m);
    for (int i = 0; i < m; ++i)
        cin >> b[i];
    int odp = 0;
    for (int i = 0; i < n; ++i)
    {
        int w = c;
        for (int j = 0; j < m; ++j)
        {
            int a;
            cin >> a;
            w += a * b[j];
        }
        if (w > 0)
            ++odp;
    }
    cout << odp;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

const int M=2000;
ll C[M][M];

int n,m;

int main(){
	C[0][0]=1;
	for(int i=0;i<M-1;i++) for(int j=0;j<=i;j++){
		(C[i+1][j]+=C[i][j])%=mod;
		(C[i+1][j+1]+=C[i][j])%=mod;
	}
	cin>>n>>m;
	vl dp(n+1);
	dp[0]++;
	for(int i=0;i<m;i++){
		vl DP(n+1);
		int x;
		cin>>x;
		for(int j=0;j<=n;j++) if(dp[j]){
			for(int k=0;j+k<=n&&k<=x;k++){
				(DP[j+k]+=dp[j]*C[n-j][k]%mod*C[n-k][x-k])%=mod;
			}
		}
		dp=DP;
	}
	cout<<dp[n]<<endl;
}

Measured memory_bytes: 30080
s = input()
K = int(input())
d = list()
for l in range(len(s)):
  for r in range(l,min(l+K+1, len(s))):#左からl番目、右からr番目までの文字列
    n = s[l:r+1]
    if n not in d:
      d.append(n)
    d.sort()
    d = d[:5]
print(d[K-1])



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

using namespace std;
typedef long long ll;

int main(){
   int N,X,Y;
   cin >> N >> X >> Y;
   int ans[N];
   memset(ans,0,sizeof(ans));
   for (int i = 1; i <=N ; i++)
   {
      for (int j = i+1; j <= N; j++)
      {
         int dist = j-i;
         dist = min(dist,abs(X-i)+1+abs(Y-j));
         ans[dist]++;
      }
   }
   for(int i=1;i<N;i++){
      cout << ans[i]<<endl;
   }
   return 0;
}


Measured memory_bytes: 3640
read N Y

z0=$(( (Y % 5000) / 1000 ))

for (( z = z0; z <= N; z += 5 )); do
    Z=$(( Y - z * 1000 - 5000 * (N - z) ))
    x=$(( Z / 5000 ))
    y=$(( N - x - z ))
    (( x >= 0 && y >= 0 )) && echo ${x} ${y} ${z} && exit
done

echo -1 -1 -1


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

int main() {
  int x, a, b;
  cin >> x >> a >> b;
  a = x - a;
  b = x - b;
  if (a < 0) {
    a = -a;
  }
  if (b < 0) {
    b = -b;
  }
  if (a > b) {
    cout << 'B' << endl;
  } else {
    cout << 'A' << endl;
  }
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.lang.*;
public class Main{
public static void main(String[] args) throws FileNotFoundException, IOException{
       Scanner s=new Scanner(System.in);
      int n=s.nextInt(),n1=s.nextInt(),n2=s.nextInt();
      if(n+n1+n2>=22){System.out.println("bust");}
      else{System.out.println("win");}
     
      	
      }
        }
    


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

int main() {
  int n,m;
  cin>>n>>m;
  map<int,int> a;//money-cnt
  rep(i,n){
    int A,B;
    cin>>A>>B;
    a[A]+=B;
  }
  ll sum=0;//money
  int cnt=0;
  bool flag=0;
  for(auto x : a){
    while(x.second!=0){
      x.second--;
      cnt++;
      sum+=x.first;
      if(cnt==m){
        flag=1;
        break;
      } 
    }
    if(flag)break;
  }
  cout<<sum<<endl;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    int n;
    cin>>n;
    vector<int> a(n+1),boss(200010);
    repi(i,2,n+1){
        cin>>a[i];
        boss[a[i]]++;
    }
    repi(i,1,n+1){
        cout<<boss[i]<<endl;
    }
}

Measured memory_bytes: 4768
#include <vector>
#include <list>
#include <map>
#include <string>
#include <iostream>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <utility>

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


ll solve(void);

int main(void)
{
	while (solve())
	{
	}
	return 0;
}

ll hoge(ll x, ll y)
{
	if (x < y) {
		return hoge(y, x);
	}
	if (x == 1 || y == 1) {
		return 1;
	}
	if (x % y == 0) {
		return y;
	}
	
	return hoge(y, x % y);
}

ll solve(void)
{
	ll A, B;
	cin >> A >> B;
	ll k = hoge(A, B);

	ll ans = 1;
	for (ll i = 2; i * i < k; i++)
	{
		if (k % i) continue;
		ans ++;
		while (k % i == 0)
		{
			k /= i;
		}
	}

	if (k > 1) ans ++;

	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define RFOR(i,a,b) for(int i = (int)(b-1);i>=(int)(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

constexpr int mpow(const int &a, int n) noexcept {
   if(n == 0) return 1;
   auto t = mpow(a, n / 2);
   t = t * t;
   if(n & 1) t = t * a;
   return t;
}
  
signed main(){
  ios::sync_with_stdio(false);
  cout.tie(0);
  cout.precision(20);
  
  int n;
  cin >> n;
  vector<int> a(n);
  REP(i,n) {
    cin >> a[i];
    a[i]--;
  }
  vector<int> b(n);
  REP(i,n) cin >> b[i];
  vector<int> c(n - 1);
  REP(i,n - 1) cin >> c[i];
  
  int ans = 0;
  REP(i, n){
    ans += b[a[i]];
    if(i != n - 1 && a[i + 1] - a[i] == 1){
      ans += c[a[i]];
    }
  }

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

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

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


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

//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

    int n, m, k;
    cin >> n >> m >> k;
    ll a[n + 2], b[m + 2];
    memset(a, 0, sizeof(a));
    memset(b, 0, sizeof(b));
    for (int i = 1; i <= n; i++) {
    	cin >> a[i];
    	a[i] += a[i - 1];
    }
    for (int i = 1; i <= m; i++) {
    	cin >> b[i];
    	b[i] += b[i - 1];
    }
    int rep = 0;
    for (int i = 0, j = m; i <= n; i++) {
	    while (j && a[i] > (k - b[j])) {
	    	j--;
	    }
	    if (a[i] <= (k - b[j])) {
	    	rep = max(rep, i + j);
	    }
    }
    cout << rep << '\n';
    return 0;
}

Measured memory_bytes: 6624
#include <iostream>
#include <cmath>
#include <vector>
#include <numeric>
using namespace std;

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()

int main()
{
    int i,j;
    int max_number = 1e6;
    vector<int> era(max_number+1, 0);
    for(i = 2;i <= sqrt(max_number);++i){
        if(!era.at(i)){
            for(j = 2*i;j <= max_number;j += i){
                if(!era.at(j)) era.at(j) = i;
            }
        }
    }
    int n;
    cin >> n;
    vector<int> a(n);
    cin >> a.at(0);
    int tmp = a.at(0);
    for(i = 1;i < n;++i){
        cin >> a.at(i);
        tmp = gcd(tmp, a.at(i));
    }
    if(tmp != 1){
        cout << "not coprime" << endl;
        return 0;
    }
    vector<bool> v(1e6+1, false);
    rep(i,n){
        if(era.at(a.at(i)) == 0){
            if(a.at(i) == 1) continue;
            if(v.at(a.at(i))){
                cout << "setwise coprime" << endl;
                return 0;
            }else v.at(a.at(i)) = true;
        }else{
            for(j = era.at(a.at(i));j <= sqrt(a.at(i));++j){
                if(a.at(i) == 1) break;
                if(a.at(i)%j == 0){
                    if(v.at(j)){
                        cout << "setwise coprime" << endl;
                        return 0;
                    }else{
                        v.at(j) = true;
                        while(a.at(i)%j == 0) a.at(i) /= j;
                    }
                }
            }
            if(a.at(i) != 1){
                if(v.at(a.at(i))){
                    cout << "setwise coprime" << endl;
                    return 0;
                }else v.at(a.at(i)) = true;
            }
        }
    }
    cout << "pairwise coprime" << endl;

    return 0;
}


Measured memory_bytes: 10764
char v[];a=12;f(x,z){if(v[x]-->48)for(;z;)f(x+"HJ<V"[--z]-73,4);}main(j,c){for(;a?j=170,c=0,~scanf("%s",v+a--*13):--j?c+=v[j]>48,f(j,4),1:printf("%d\n",c,a=12););}

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

int main() {
	// your code goes here
	int n,a[2005],i,j,inv=0,b[2005],same=0;
	long long ans=0;
	long long k,mod;
	mod=1e9+7;
	cin >> n >> k;
	for(i=0;i<n;i++){
		cin >> a[i];
		b[i]=a[i];
	}
	sort(b,b+n);
	int memo=1;
	for(i=1;i<n;i++){
		if(b[i-1]==b[i]){
			memo++;
		} else {
			same+=(memo*memo);
			memo=1;
		}
	}
	same+=(memo*memo);
	same=(n*n-same)/2;
	for(i=0;i<n;i++){
		for(j=i+1;j<n;j++){
			if(a[i]>a[j]) inv++;
		}
	}
	if(k%2==0) ans=(k/2)*(k-1)%mod;
	else ans=k*((k-1)/2)%mod;
	ans=ans*same%mod;
	ans=(ans+(inv*k)%mod)%mod;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    unsigned long long i,j,m=0,n,sum=0;
    const long int k=1000000007;


    cin>>n;
    vector<long long>a;
    for(i=0;i<n;i++)
        {
            cin>>j;
            a.push_back(j);
            sum=sum+a[i];

        }
        for(i=0;i<n-1;i++)
        {
            sum=sum-a[i];
            m=m+(((sum%k)*(a[i]%k))%k);
            m%=k;
            

        }
        cout<<m<<endl;
}


Measured memory_bytes: 5388
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<ctype.h>
#include<algorithm>
#include<iostream>
using namespace std;
int main()
{
	int n,k;
	scanf("%d%d",&n,&k);
	int a[100008];
	for(int i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
	}
	sort(a,a+n);
	int min=999999999;
	int cha=0;
	for(int i=0;i<=n-k;i++)
	{
		cha=a[i+k-1]-a[i];
		if(cha<min)
		min=cha;
	}
	printf("%d\n",min);
	return 0;
}





Measured memory_bytes: 640
using System;
using System.Collections.Generic;

namespace ABC047B
{
    class Program
    {
        static void Main(string[] args)
        {
            var target = Console.ReadLine().Split(' ');
            int W = int.Parse(target[0]);
            int H = int.Parse(target[1]);
            int N = int.Parse(target[2]);
            int[,] c = new int[W,H];
            for(int p=0;p<N;p++){
                target = Console.ReadLine().Split(' ');
                int x = int.Parse(target[0]);
                int y = int.Parse(target[1]);
                int a = int.Parse(target[2]);
                if(a == 1){
                    for(int i = 0; i < x; i++)
                        for(int j=0;j<H;j++) c[i,j]++;
                }
                if(a == 2){
                    for(int i = x; i < W; i++)
                        for(int j=0;j<H;j++) c[i,j]++;
                }
                if(a == 3){
                    for(int i = 0; i < W; i++)
                        for(int j=0;j<y;j++) c[i,j]++;
                }
                if(a == 4){
                    for(int i = 0; i < W; i++)
                        for(int j=y;j<H;j++) c[i,j]++;
                }
            }
                int count = 0;
                for(int i = 0; i < W; i++)
                    for(int j=0;j<H;j++) if (c[i,j] == 0) count++;
            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 13220