akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define ios ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0)
#define so sizeof
#define pb push_back
#define cl clear() ;
#define vl vector<ll>
#define sz size()
#define len length()
#define el endl;cout.flush()
#define be begin()
#define fi first
#define se second
#define br break
#define en end()
#define ro return 0
#define br break
#define mod %
#define eb emplace_back
#define con continue
#define ms(x) memset(x , 0, so x)
#define all(x) (x).be , (x).en
#define rall(x) (x).rbegin() , (x).rend()
#define acc(x) accumulate((x).be , (x).en , 0ll)
#define forn(i,a,b) for(ll i=a;i<=b;++i)
#define rng_58 mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define vll vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define plll pair<ll,pair<ll,ll>>
#define plvl pair<pair<ll,ll> ,ll>
#define mp make_pair
#define trace2(a,b) cerr <<"a is " << a << " b is " << b << el;
#define trace3(a,b,c) cerr <<"a is " << a << " b is " << b << " c is " << c << el;
#define trace4(a,b,c,d) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << el ;
#define trace5(a,b,c,d,e) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << " e is " << e << el;
#define trace6(a,b,c,d,e,f) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << " e is " << e << " f is " << f << el ;
unordered_map<ll,ll> mpp;
ll n , k ;
vl d ;

bool check(ll val){
   ll flag = -1 ;
   while(val){
      ll temp =  val % 10 ;
      if(mpp[temp]){
        flag = 0 ;
        br ;
      }
      val = val / 10 ;
   }
   if(flag == 0) return false ;
   else return true  ;
}
int main()
{
    ios;
    cin >> n >> k ;
    forn(i ,1 , k) {
      ll x;
      cin >> x;
      d.pb(x);
    }
    sort(all(d));
    for(auto &x : d) mpp[x]++;
    ll ans ;
    forn(i , n , 5000000){
        ll val = i;
        if(check(val) == true){
            ans =  i ;
            br ;
        }
    }
    cout << ans << el ;
}































Measured memory_bytes: 256
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
class Program
{
	static void Main()
	{
		long n = long.Parse(Console.ReadLine());//int.Parseは文字列を整数に変換。
		long[] nums = new long[n];
    for(long i = 0; i < n; i++)
    {
      nums[i] = long.Parse(Console.ReadLine());
    }
		long answer = 0;
    long numMemo = 0;
    bool isPossible = true;

    if(nums[0] != 0) isPossible = false;
    else
    {
      for(long i = 1; i < n; i++)
      {
      //Console.WriteLine(answer);
        if(nums[i] > numMemo+1)
        {
          isPossible = false;
          break;
        }
        else if(nums[i] == numMemo+1)
        {
          answer++;
          numMemo = nums[i];
        }
        else if(nums[i] < numMemo+1)
        {
          answer += nums[i];
          numMemo = nums[i];
        }
      }
    }
    
		Console.WriteLine((isPossible) ? answer : -1);
	}
}


Measured memory_bytes: 18652
class AtCoder {
  // 入力系
  input=require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/);
  input_i=-1;
  n(){
    this.input_i++;
    return Number(this.input[this.input_i]);
  }
  nn(n){
    const a=[];
    for(let i=0;i<n;i++){
      a.push(this.n());
    }
    return a;
  }
  s(){
    this.input_i++;
    return String(this.input[this.input_i]);
  }
  ss(n){
    const a=[];
    for(let i=0;i<n;i++){
      a.push(this.s());
    }
    return a;
  }

  // コンソール
  o(...a:any){
    console.log(...a);
  }

  // Math
  abs(a:number){
    return Math.abs(a);
  }
  min(...a:number[]){
    return Math.min(...a);
  }
  max(...a:number[]){
    return Math.max(...a);
  }
  floor(a:number){
    return Math.floor(a);
  }
  ceil(a:number){
    return Math.ceil(a);
  }
  round(a:number){
    return Math.round(a);
  }

  // ソート
  asc(ar:number[]){
    const t=[...ar];
    ar.sort((a,b)=>{return a-b});
  }
  desc(ar:number[]){
    const t=[...ar];
    ar.sort((a,b)=>{return b-a});
  }

  // 自作
  gcd(...arr):number{
    for(let i=0;i<arr.length-1;i++){
      let [x,y]=[arr[i],arr[i+1]];
      while(y){
        [x,y]=[y,x%y];
      }
      arr[i+1]=x;
    }
    return arr[arr.length-1];
  };
  lcm(...arr):number{
    for(let i=0;i<arr.length-1;i++){
      let [x,y]=[arr[i],arr[i+1]];
      while(y){
        [x,y]=[y,x%y];
      }
      arr[i+1]=arr[i]*arr[i+1]/x;
    }
    return arr[arr.length-1];
  };
  isPrime(n:number):boolean{
    if(n < 2) return false;
    const suq=Math.sqrt(n);
    for(let i=2;i<=suq;i++){
      if(n%i==0){
        return false;
      }
    }return true;
  };
  deduplicate(a:any[]):any[]{
    return Array.from(new Set(a));
  };
}

/* [入力]
  const [H,W]=o.nn(2)
  const [N,M]=o.nn(2)
  const N=o.n()
  const S=o.s()
  const arr1=[]
  for(let i=0;i<N;i++)arr1.push(o.n())
 */

/* [BFS,DFS]
  const [H,W]=o.nn(2),map=new Array(H),save=new Array(H)
  const DH=[0,0,-1,1]
  const DW=[1,-1,0,0]
  for(let i=0;i<H;i++){
    map[i]=o.s().split('')
    save[i]=new Array(W)
    save[i].fill(-1)
  }
  // let queue=[[?,?,1]]
  // save[?][?]=0
  while(queue.length>0){
    let [h,w,c]=queue.shift()
    for(let i=0;i<4;i++){
      if(h+DH[i]<0 || h+DH[i]>=H || w+DW[i]<0 || w+DW[i]>=W){
        continue
      }
      if(map[h+DH[i]][w+DW[i]]==?){
        continue
      }
      if(save[h+DH[i]][w+DW[i]]==-1){
        queue.push([h+DH[i], w+DW[i], c+1])
        save[h+DH[i]][w+DW[i]]=c
      }
    }
  }
*/
const o = new AtCoder()

o.o(o.n()==o.n()?'Yes':'No')

Measured memory_bytes: 7372
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<map>
#include<vector>
using namespace std;
const int N=100005;
long long d[N],m[N],dist[N];int id[N];
map<long long,int> ma;
bool cmp1(int i,int j){return d[i]>d[j];}
vector<int> ansu,ansv;
int n;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%lld",d+i);
		id[i]=i;m[i]=1;
		ma[d[i]]=i;
	}
	sort(id+1,id+1+n,cmp1);
	for(int i=1;i<n;i++){
		long long dv=d[id[i]]+2*m[id[i]]-n;
		if(ma[dv]==0){puts("-1");return 0;}
		int v=ma[dv];
		ansu.push_back(id[i]);
		ansv.push_back(v);
		m[v]+=m[id[i]];
		dist[v]+=dist[id[i]]+m[id[i]];
	}
	if(dist[id[n]]!=d[id[n]]) puts("-1");
	else
		for(int i=0;i<ansu.size();i++) printf("%d %d\n",ansu[i],ansv[i]);
}

Measured memory_bytes: 11380
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>

using namespace std;
int gcd(int p, int q);

int main() {
  int a, b, k;
  scanf("%d%d%d", &a, &b, &k);
  int c = gcd(a, b), d[100], cnt;
  for (int i = 0; i < c; i++) {
    if (c % (i + 1) == 0) {
      d[cnt] = i + 1;
      cnt++;
    }
  }
  printf("%d\n", d[cnt - k]);
}

int gcd(int p, int q) {
  if (p % q == 0) {
    return q;
  } else {
    return gcd(q, p % q);
  }
}


Measured memory_bytes: 128
#include <stdio.h>
int main(void){
    int n,i;
    float x1,y1,x2,y2,x3,y3,x4,y4;
    scanf("%d",&n);
    for(i=0;i<n;i++) {
        scanf("%f %f %f %f %f %f %f %f",&x1,&y1,&x2,&y2,&x3,&y3,&x4,&y4);
        if ((y2-y1)*(x4-x3)-(x2-x1)*(y4-y3)==0) {
            printf("YES\n");
        } else {
            printf("NO\n");
        }
    }
    return 0;
}

Measured memory_bytes: 612
#include <stdio.h>
#include <iostream>

using namespace std;

int main(void){
	int num, sum[30], first, second;
	char ch[101];

	while(1){
		scanf("%d", &num);
		if(num == 0) break;
		for(int i=0; i<num; i++){
			cin >> ch[i];
			ch[i] -= 'A';

		}

		fill(sum, sum+30, 0);
		first = int(ch[0]);
		second = 29;
		for(int i=0; i<num; i++){
			sum[ch[i]]++;
			if(sum[ch[i]] > sum[first]){
				second = first;
				first = int(ch[i]);
			} else if(sum[second] < sum[ch[i]] && ch[i] != first){
				second = int(ch[i]);
			}
			if(sum[first] > sum[second] + num - i-1){
				printf("%c %d\n", first+'A', i+1);
				goto END;
			}
		}
		printf("TIE\n");
END:;
	}

	return 0;
}


Measured memory_bytes: 3180
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    int a,b,c,d,ans;
    cin>>a>>b>>c>>d;
    int x = max(a,c);
    int y = min(b,d);
    ans = y-x;
    cout<<max(0,ans)<<endl;
    return 0;
}


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

int main() {
	ll h;
	cin >> h;

	int cnt = 0;
	while (h > 1) {
		h /= 2;
		cnt++;
	}
	cout << (ll)pow(2, cnt+1) - 1;
}




Measured memory_bytes: 256
n,m=map(int,input().split())
MOD=10**9+7
def factorization(n):
    arr = []
    temp = n
    if n==1:
        return arr
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append((i, cnt))

    if temp!=1:
        arr.append((temp, 1))

    if arr==[]:
        arr.append((n, 1))

    return arr
arr=factorization(m)
#print(arr)
l=len(arr)
N=30
comb=[1]*31
inv_t = [0]+[1]
for i in range(2,N+1):
  inv_t += [inv_t[MOD % i] * (MOD - int(MOD / i)) % MOD]
for i in range(1,31):
    comb[i]=comb[i-1]*(n-1+i)*inv_t[i]
    comb[i]%=MOD
count=1
for fact,num in arr:
    #print(fact,num,comb[num])
    count*=comb[num]
    count%=MOD
print(count)

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

using namespace std;

typedef long long ll;

class SegmentTree {

    int sz;
    vector< vector<int> > t;

    void build(int v, int vl, int vr, const vector<int> &a) {
        if (vl == vr) {
            t[v].push_back(a[vl]);
            return;
        }
        int vm = vl + (vr - vl) / 2;
        build(2 * v + 1, vl, vm, a);
        build(2 * v + 2, vm + 1, vr, a);
        merge(t[2 * v + 1].begin(), t[2 * v + 1].end(), t[2 * v + 2].begin(), t[2 * v + 2].end(), back_inserter(t[v]));
    }

    int query(int v, int vl, int vr, int l, int r, int k) const {
        if (r < vl || vr < l)
            return 0;
        if (l <= vl && vr <= r)
            return t[v].end() - upper_bound(t[v].begin(), t[v].end(), k);
        int vm = vl + (vr - vl) / 2;
        int ql = query(2 * v + 1, vl, vm, l, r, k);
        int qr = query(2 * v + 2, vm + 1, vr, l, r, k);
        return ql + qr;
    }

public:

    SegmentTree(const vector<int> &a) {
        sz = a.size();
        t.resize(4 * sz);
        build(0, 0, sz - 1, a);
    }

    int query(int l, int r, int k) const {
        return query(0, 0, sz - 1, l, r, k);
    }

};

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, m;
    cin >> m >> n;
    vector<pair<int, int>> segs(m);
    for (int i = 0; i < m; ++i) {
        cin >> segs[i].first >> segs[i].second;
    }
    sort(segs.begin(), segs.end());
    vector<int> a(m);
    for (int i = 0; i < m; ++i) {
        a[i] = segs[i].second;
    }
    SegmentTree t(a);
    for (int i = 1; i <= n; ++i) {
        ll s = 0;
        for (int j = i; j <= n; j += i) {
            int pos1 = lower_bound(segs.begin(), segs.end(), make_pair(j - i + 1, 0)) - segs.begin();
            int pos2 = lower_bound(segs.begin(), segs.end(), make_pair(j + 1, 0)) - segs.begin() - 1;
            if (pos1 <= pos2) {
                s += t.query(pos1, pos2, j - 1);
            }
        }
        cout << s << '\n';
    }
    return 0;
}

Measured memory_bytes: 78964
N,M = map(int,input().split())
stu = [0]*N
for i in range(N):
    stu[i] = list(map(int,input().split()))

cp = [0]*M
for i in range(M):
    cp[i] = list(map(int,input().split()))

# print(stu,cp)
stumo = [0]*N
for i in range(N):
    min_move = 10000000000000000000000000
    for j in range(M):
        min_his = min_move 
        mhd = abs(stu[i][0]-cp[j][0]) + abs(stu[i][1]-cp[j][1])
        min_move = min(min_move,mhd)
        if(min_move != min_his):
            stumo[i] = j+1
# print(stumo)
for i in range(N):
    print(stumo[i])

Measured memory_bytes: 9244
S = input()
l = len(S)
ans = 0
for i in range(1,l):
    s = S[0:l-i]
    if len(s) % 2 == 0:
        l2 = len(s)//2
        if s[:l2] == s[l2:]:
            ans = l-i
            break
print(ans)


Measured memory_bytes: 2940
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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;
}

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------
int X, Y;

int main() {
  //
  cin >> X >> Y;
  repe(i, 0, 100) {
    repe(j, 0, 100) {
      if (i + j == X && 2 * i + 4 * j == Y) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
}


Measured memory_bytes: 3632
// AtCoder.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

// AtCoder.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//


#define _USE_MATH_DEFINES
#include<math.h>

//#include<cmath>

#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>



//#include "Ants.h"
using namespace std;
typedef long long ll;
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i,n) for(int i=0;i<n;i++)
#define show(s) cout<<s<<endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define LINF (1000000000000000000ll)
//typedef pair < int, int> P;
ll gcd(ll a, ll b) {//最大公約数を求める///最大公倍数a*b/gcd(a,b)
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcd(ll a, ll b) {//最小公倍数を求める　b=0のときaを返す
	if (b == 0) return a;
	return (a / gcd(a, b)) * b;
}
vector<int> divnum(ll num) {
	int dig;
	vector<int>p;
	while (num) {
		dig = num % 10;
		p.push_back(dig);
		num /= 10;
	}
	return p;
}
int digiter(ll num) {
	int dig;
	vector<int>p;
	while (num) {
		dig = num % 10;
		p.push_back(dig);
		num /= 10;
	}
	return p.size();
}
vector<int> stringconvert(string s) {
	vector<int> d;
	ll n = s.size();
	rep(i, n) {
		d.push_back(s[i] - '0');
	}
	return d;
}

int N, A[1000]; int sum = 0,M;
int main()
{
	cin >> N>>M;
	rep(i, N) {
		cin >> A[i];
		sum += A[i];
	}
	//cout << sum << endl;

	sort(A, A + N); reverse(A, A + N);
	//cout << A[M - 1] << endl;
	//cout << (sum + 4 * M - 1) /( 4 * M )<< endl;
	if (A[M - 1] >= (sum+4*M-1) / (4 * M)) {
		cout << "Yes" << endl;
	}else
	{
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
N = int(input())
S = input()

count = S.count("R")*S.count("G")*S.count("B")

for i in range(len(S)-2):
    j = i + 1
    while len(S) > 2*j - i:
        k = 2*j - i
        if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
            count -= 1
        j += 1

print(count)


Measured memory_bytes: 9192
#include <iostream>
#include <cstdio>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <cmath>
#include <complex>
#include <map>
#include <climits>
#include <sstream>
using namespace std;

#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define EPS 1e-8
#define F first
#define S second
#define mkp make_pair

static const double PI=6*asin(0.5);
typedef long long ll;
typedef complex<double> CP;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vint;
static const int INF=1<<24;

template <class T>
void initvv(vector<vector<T> > &v,int a,int b, const T  &t = T()){
	v.assign(a,vector<T>(b,t));
}

//v.erase(unique(v.begin(),v.end()),v.end());


int main(){
	int k;
	while(cin>>k,k){
		ll s=0;
		rep(i,(k*(k-1))/2){
			ll t;
			cin>>t;
			s+=t;
		}
		s/=(k-1);
		cout<<s<<endl;
	}
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;


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

    int N;
    cin >> N;
    int A[N];
    map <int,int> m;
    rep(i,N) {
        cin >> A[i];
        if(m[A[i]]==0) m[A[i]]++;
        else m[A[i]]--;
    }
    int ans=0;
    for(auto P:m){
        if(P.second>0) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 5376
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#define ll long long
void file(){
#ifndef ONLINE_JUDGE
	freopen("a_input.txt", "r", stdin);
	freopen("a_output.txt", "w", stdout);
#endif
}
void fast()
{
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
}
int dx[] = { 0, 0, 1, -1 };
int dy[] = { 1, -1, 0, 0 };
int main(){
//	file();
//	fast();
	int a, b, c;
	cin >> a >> b >> c;
	int mn = min(b + 1, c);
	c -= mn;
	b += mn;
	mn = min(c, a);
	b += mn;
	cout << b << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

const double EPS = 1e-10;

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;


int main(){
  int n; cin >> n;
  for(int k = 1; k <= n; k++){
    int ans = 0;
    for(int i = 1; i*i <= 2*k; i++){
      for(int j = 1; j*j <= 2*k; j++){
        int Z = 2*k-i*i-j*j;
        int s = sqrt(Z);
        if(Z >= 1 && s*s == Z && (i+j+s)%2 == 0 && i-j+s > 0 && s-i+j > 0 && i+j-s > 0) ans++;
      }
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 3532
#include <cstdio>
#include <iostream>

using namespace std;

int main() {
    string s;
    int ans = 0;
    cin >> s;
    for (int i = 0; i < s.length(); i++) {
       if (s[i] == '1') ans++;
    }
    printf("%d\n", ans);
    return 0;
}


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

using namespace std;
using namespace atcoder;

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

#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<<endl;

template<class T>
ostream &operator<<(ostream &os, const vector <T> &v) {
  os << "[";
  REP(i, SZ(v)) {
    if (i) os << ", ";
    os << v[i];
  }
  return os << "]";
}

template<class T, class U>
ostream &operator<<(ostream &os, const pair <T, U> &p) {
  return os << "(" << p.first << " " << p.second << ")";
}

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

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvll = vector<vll>;

const ll MOD = 1e9 + 7;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;
const ld eps = 1e-9;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  string s; cin >> s;
  vi sa = suffix_array(s);
  vi lcp = lcp_array(s, sa);

  int n = SZ(s);
  ll ans = (ll)n * (n+1) / 2;
  REP(i, n-1) {
    ans -= lcp[i];
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 15696
#include <vector>
#include <numeric>
#include <utility>
#include <cassert>
#include <functional>
#include <stack>

template<typename T>
struct PotentializedUnionFind {
public:
	using value_type = T;
	using const_reference = const value_type &;
	using size_type = std::size_t;
	using F = std::function<T(T, T)>;
	
	PotentializedUnionFind(size_type n, const F &f, const_reference id_elem)
			: n(n), f(f), id_elem(id_elem), size_(n, 1), val(n, id_elem) {
		par.resize(n);
		std::iota(par.begin(), par.end(), 0);
	}
	
	size_type size(size_type x) { return size_[find(x)]; }
	
	value_type get(size_type x) {
		find(x);
		if (par[x] == x) return val[x];
		return f(val[par[x]], val[x]);
	}
	
	size_type add(const_reference v) {
		size_.emplace_back(1);
		par.emplace_back(n);
		val.emplace_back(v);
		return n++;
	}
	
	size_type find(size_type x) {
		assert(x < n);
		std::stack<size_type> stk;
		stk.push(x);
		while (par[stk.top()] != stk.top()) stk.push(par[stk.top()]);
		
		size_type r = stk.top();
		stk.pop();
		bool r_child = true;
		while (!stk.empty()) {
			const size_type &t = stk.top();
			if (!r_child) val[t] = f(val[par[t]], val[t]);
			par[t] = r;
			r_child = false;
			stk.pop();
		}
		return r;
	}
	
	void link(size_type p, size_type x) {
		assert(par[x] == x);
		par[x] = p;
		size_[find(p)] += size_[x];
	}
	
	bool issame(size_type x, size_type y) { return find(x) == find(y); }
	
private:
	size_type n;
	value_type id_elem;
	F f;
	std::vector<size_type> size_, par;
	std::vector<value_type> val;
};

#include <cstdio>

int main() {
	int N, M;
	scanf("%d %d", &N, &M);
	
	using ll = long long;
	PotentializedUnionFind<ll> puf(N, [](ll a, ll b){ return a + b; }, 0);
	bool ans = true;
	for (int i = 0; i < M; ++i) {
		int L, R, D;
		scanf("%d %d %d", &L, &R, &D);
		--L; --R;
		if (puf.issame(L, R)) ans &= puf.get(R) - puf.get(L) == D;
		else {
			int u = puf.add(D - puf.get(R));
			puf.link(L, u);
			puf.link(u, puf.find(R));
		}
	}
	puts(ans ? "Yes" : "No");
	return 0;
}


Measured memory_bytes: 5072
N,M = map(int, input().split())

import math
def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

if not (N <= 1):
    a = comb(N,2)
else:
    a = 0
if not (M <= 1):
    b = comb(M,2)
else:
    b = 0

    
print(a+b)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using p = pair<int,int>;
 
const int INF = INT_MAX;
vector<int> to[100000];
 
int main() {
    int n, m;
    cin >> n >> m;
    rep(i,m) {
        int a,b;
        cin >> a >> b;
        --a; --b;
        to[a].push_back(b);
        to[b].push_back(a);
    }
  
    queue<int> q;
    vector<int> dist(n, INF);
    vector<int> pre(n, -1);
    dist[0] = 0;
    q.push(0);
    while(!q.empty()) {
        int v = q.front(); q.pop();
        for(int u : to[v]) {
            if(dist[u] != INF) continue;
            dist[u] = dist[v]+1;
            //通常のBFSとの違い
            pre[u] = v;
            //ここまで
            q.push(u);
        }
    }
  
    cout << "Yes" << "\n";
    rep(i,n) {
        if(i == 0) continue;
        int ans = pre[i];
        ++ans;
        cout << ans << "\n";
    }
    return 0;
}

Measured memory_bytes: 10692
#include <bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  vector<int> v[100005];
  for(int i = 0; i < n; i++){
    int a, b;
    cin >> a >> b;
    v[a].push_back(b);
  }
  priority_queue<int> pq;
  long long ans = 0;
  for(int i = 1; i <= m; i++){
    for(int x: v[i]) pq.push(x);
    if(pq.empty()) continue;
    ans += pq.top();
    pq.pop();
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 5632
N = int(input())
A = list(map(int,input().split()))
A.sort()
ans = A[-1]
if N%2==0:
    for i in range(1,(N-2)//2+1):
        ans += A[N-1-i]*2
else:
    for i in range(1,(N-2)//2+1):
        ans += A[N-1-i]*2
    ans += A[N-2-i]
print(ans)

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

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;

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


template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


#define ARRAY_MAX 100005
const int INF = INT32_MAX / 3;
const ll MOD = 1e9 + 7;

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


/******************************************************************************************/


int main() {

	ll n;
	cin >> n;
	vector<ll> s(n);
	for (int i = 0; i < n; i++)
	{
		cin >> s[i];
	}

	ll ans = 0;

	for (int p = 1; p <= n - 1; p++)
	{
		if ((n - 1) % p == 0) {

			//途中で同じところに来る
			ll tmp = 0;
			ll cnt = 0;
			ll left = 0, right = n - 1;
			while (left < right) {

				cnt += s[left] + s[right];
				ans = max(ans, cnt);
				left += p;
				right -= p;
			}

		}
		else
		{
			
			ll tmp = 0;
			ll cnt = 0;
			ll left = 0, right = n - 1;
			
			while (left < n - 1 && right > p) {

				cnt += s[left] + s[right];
				ans = max(ans, cnt);
				left += p;
				right -= p;
			}
		}
	}
	

	cout << ans << endl;
	

	return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
  string str;
  cin >> str;
  int q,i;
  cin >> q;
  string s1,s2;
  int a,b;
  for(i=0;i<q;i++){
    //cout << str << endl;
    cin >> s1 >> a >> b;
    if(s1=="print"){
      cout << str.substr(a,b-a+1) << endl;
    }else if(s1=="reverse"){
      string s3=str.substr(a,b-a+1);
      reverse(s3.begin(),s3.end());
      str=str.substr(0,a)+s3+str.substr(b+1,str.size()-a-1);
    }else{
      cin >> s2;
      str=str.substr(0,a)+s2+str.substr(b+1,str.size()-a-1);
    }
  }
}


Measured memory_bytes: 3208
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using E = System.Linq.Enumerable;

class Program
{
    static int[][] inf;
    static void Main(string[] args)
    {
      
        //入力を受け取る
        var N = int.Parse(Console.ReadLine());
        var ans = 0L;
        inf = new int[N][];
        //ピラミッドの情報を受け取る
        for(int i = 0;i < N;i++){
           inf[i] = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        }
        
      var flag = false;
        //条件を満たすX,Y,Hを探す
        for(int X = 0;X <= 100;X++){
          for(int Y = 0;Y <= 100;Y++){
            long NG = 1000000201;
            long OK = 0;
            var mid = (NG+OK)/2;
            while(NG-OK > 1){
              mid = (NG+OK)/2;
              if(check(X,Y,mid) == 1){
                OK = mid;
              }else if(check(X,Y,mid) == 0){
                NG = mid;
              }else{
                flag = true;
                break;
              }
            }
            //OKが可能な範囲であったら
            if(flag){
              Console.WriteLine(X+" "+Y+" "+mid);
              break;
            }
          }
          if(flag){
            break;
          }
        }
    }
  static int check(long X,long Y,long H){
    for(int i = 0;i < inf.Length ; i++){
      var tmp = Math.Max(H-Math.Abs(X-inf[i][0])-Math.Abs(Y-inf[i][1]),0);
      if      (tmp > inf[i][2]){
        return 0;
      }else if(tmp < inf[i][2]){
        return 1;
      }
    }
    return 2;
  }
}


Measured memory_bytes: 13396
import sys
input = sys.stdin.buffer.readline
N,Y= map(int,input().split())

for i in range(0,N+1):
    for j in range(0,N+1-i):
        res = N-i-j
        if 10000*i + 5000*j + 1000*res == Y:
            print(i,j,res)
            exit()
print(-1,-1,-1)


Measured memory_bytes: 40556
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

//const MAX:usize = 100006;
//const INF:u64 = u64::max_value();

fn main() {
    let n:u32 = read();
    let h:Vec<u32> = (0..n).map(|_| read()).collect();

    let mut ans:u32 = 0;
    let mut cnt:u32 = 0;
    for i in 0..n-1 {
        let i = i as usize;
        if h[i] >= h[i+1] {
            cnt += 1;
        } else {
            cnt = 0;
        }
        ans = max(ans, cnt);
    }

    println!("{}", ans);
    
}

Measured memory_bytes: 4352
fn next() -> String {
    let mut buffer = String::new();
    std::io::stdin().read_line(&mut buffer).ok();
    return buffer;
}

fn main() {
    let s = next();
    let a: Vec<&str> = s.trim().split(' ').collect();
    let x: i32 = a[0].parse().unwrap();
    let y: i32 = a[1].parse().unwrap();

    let g1 = vec![1, 3, 5, 7, 8, 10, 12];
    let g2 = vec![4, 6, 9, 11];
    let g3 = vec![2];
    if g1.contains(&x) && g1.contains(&y) {
        println!("Yes");
    } else if g2.contains(&x) && g2.contains(&y) {
        println!("Yes");
    } else if g3.contains(&x) && g3.contains(&y) {
        println!("Yes");
    } else {
        println!("No");
    }
}

Measured memory_bytes: 4352
fun main(args: Array<String>) {
    readLine()
    val t = readLine()!!.split(" ").map(String::toInt)
    val tsum = t.sumBy { i -> i }
    val m = readLine()!!.toInt()
    for (i in 1..m) {
        val (p, x) = readLine()!!.split(" ").map(String::toInt)
        println(tsum - t[p - 1] + x)
    }
}


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

struct UnionFind {
    vector<int> data;
    int sz;
    UnionFind(int sz) : data(sz, -1), sz(sz){ }
    bool unionSet(int x, int y) {
        if ((x = root(x)) == (y = root(y))) return false;
        if (data[x] > data[y]) swap(x, y);
        data[x] += data[y]; data[y] = x; sz--;
        return true;
    }
    bool findSet(int x, int y) { return root(x) == root(y); }
    int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }
    int size(int x) { return -data[root(x)]; }
    int size() { return sz; }
};

int main() {
  int w, h;
  while (cin >> w >> h) {
    if (w == 0 && h == 0) {
      break;
    }
    int count = 0;
    vector<vector<int>> c(h, vector<int>(w));
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        cin >> c[i][j];
        if (c[i][j] == 0) {
          count++;
        }
      }
    }
    auto idx = [&](int i, int j) {
      return i*w + j;
    };
    auto outfield = [&](int i, int j) {
      return i < 0 || i >= h || j < 0 || j >= w;
    };
    UnionFind uf(w*h);
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        for (int x = -1; x <= 1; x++) {
          for (int y = -1; y <= 1; y++) {
            if (outfield(i + x, j + y)) {
              continue;
            }
            if (c[i][j] == 1 && c[i + x][j + y] == 1) {
              uf.unionSet(idx(i, j), idx(i + x, j + y));
            }
          }
        }
      }
    }
    cout << uf.size() - count << endl;
  }
}


Measured memory_bytes: 3120
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define rep1(i,n) for (ll i = 1; i <= (n); ++i)
#define rrep(i,n) for (ll i = (n)-1; i >=0; --i)
#define ALL(a) a.begin(),a.end()
#define pb push_back
#define dame { puts("-1"); return 0;}
#define show(x) cerr<<#x<<" = "<<x<<endl;

using namespace std;
using ll = long long;
using ld = long double;
using pl = pair<ll, ll>;

typedef vector<ll> vl;
typedef vector<pl> vp;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }


// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const ll mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
// struct combination {
//   vector<mint> fact, ifact;
//   combination(int n):fact(n+1),ifact(n+1) {
//     assert(n < mod);
//     fact[0] = 1;
//     for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
//     ifact[n] = fact[n].inv();
//     for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
//   }
//   mint operator()(int n, int k) {
//     if (k < 0 || k > n) return 0;
//     return fact[n]*ifact[k]*ifact[n-k];
//   }
// } c(200005);

ll LINF = 1000000000000000000;

int main() {
  ll n;
  cin >> n;

  vector<ll> a(n);
  vector<ll> b(n);
  rep(i, n){
    cin>>a[i]>>b[i];
  }

  sort(ALL(a));
  sort(ALL(b));

  ll med_a,med_b,ans;
  if(n%2==1){
    med_a = a[n/2];
    med_b = b[n/2];
    ans = med_b - med_a + 1;
  }
  else{
    med_a = a[n/2]+a[n/2-1];
    med_b = b[n/2]+b[n/2-1];
    ans = (med_b-med_a + 1);
  }
  cout <<ans<<endl;
  return 0;
}


Measured memory_bytes: 6384
#include <iostream>
#include <algorithm>
using namespace std;
const int x[12]={1,6,9,36,81,216,729,1296,6561,7776,46656,59049};
int n;
int dp[100000];
int main(){
    cin>>n;
    for(int i=0;i<=n;i++){
        dp[i]=1000000000;
    }
    dp[0]=0;
    for(int i=0;i<n;i++){
        for(int j=0;j<12&&i+x[j]<=n;j++){
            dp[i+x[j]]=min(dp[i]+1,dp[i+x[j]]);
        }
    }
    cout<<dp[n]<<endl;
    return 0;
}

Measured memory_bytes: 640
import math

l1 = input()
n = int(l1.split()[0])
d = int(l1.split()[1])

ans = 0
for _ in range(n):
    l = list(map(int, input().split()))
    dist = math.sqrt(l[0] ** 2 + l[1] ** 2)
    if dist <= d:
        ans += 1

print(ans)

Measured memory_bytes: 9076
def mod_pow(a,p,mod):# a^p を求めるアルゴリズム

    if p == 0:
        return 1
    elif p%2 == 1:
        return a * mod_pow(a,p-1,mod)
    else:
        half = mod_pow(a,p//2,mod) %mod
    return half * half % mod

N = int(input())
A = list(map(int,input().split()))

B = [0 for i in range(N)]
max_b = 0
mod =10**9 + 7

for i in range(N):
    B[A[i]] += 1

if N%2 == 1:
    for i,b in enumerate(B):
        if i == 0:
            if b != 1:
                print(0)
                exit()

        elif b != 2 and b != 0:
            print(0)
            exit()
    p = (N - 1)//2

else:
    for i,b in enumerate(B):
        if b != 2 and b != 0:
            print(0)
            exit()
    p = (N)//2

ans = mod_pow(2,p,mod)
print(ans)


Measured memory_bytes: 14008
#include <cstdio>
#include <cstring>
using namespace std;

#define L 3194304
bool HA[L];
int T[256];

inline int get( unsigned char c ) {
    return T[c];
}

int main() {
    int n, sum, t, c;
    T['A'] = 1, T['C'] = 2, T['G'] = 3, T['T'] = 4;
    scanf("%d", &n);
    while ( getchar() != '\n' );
    for ( register int i = 0; i++ < n; ) {
        sum = 0;
        t = 1;
        bool flag = ( c = getchar() ) == 'i';
        while ( ( c = getchar() ) != ' ' );
        while ( ( c = T[getchar()] ) != 0 ) {
            sum += c * t;
            t *= 4;
        }
        if ( flag ) {
            HA[sum] = true;
        } else {
            puts( HA[sum] ? "yes" : "no" );
        }
    }
    return 0;
}

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	int n,w;
	cin>>n>>w;
	int a[n];
	int b[n];
	int i,j;
	for(i=0;i<n;i++)
	cin>>a[i]>>b[i];
	long long int dp[n+1][w+1];
	for(i=0;i<=n;i++)
	dp[i][0]=0;
	for(i=0;i<=w;i++)
	dp[0][i]=0;
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=w;j++)
		{
			if(j>=a[i-1])
			dp[i][j]=max(dp[i-1][j],b[i-1]+dp[i-1][j-a[i-1]]);
			else
			dp[i][j]=dp[i-1][j];
		}
	}
	cout<<dp[n][w]<<endl;
	return 0;
}



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

int main(){
  int64_t N;
  cin >> N;
  vector<int64_t> A(N+1),B(N);
  int64_t ans=0;
  for(int64_t i=0;i<N+1;i++){
    cin >> A.at(i);
  }
  for(int64_t i=0;i<N;i++){
    cin >> B.at(i);
  }
  for(int64_t i=N-1;i>=0;i--){
    if(A.at(i+1)>=B.at(i)){
      ans+=B.at(i);
    }else{
      ans+=A.at(i+1);
      B.at(i)-=A.at(i+1);
      if(B.at(i)>=A.at(i)){
        ans+=A.at(i);
        A.at(i)=0;
      }else{
        ans+=B.at(i);
        A.at(i)-=B.at(i);
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <typeinfo>
#include <map>

using namespace std;
typedef long long LL;
#define REP(i,N) for(int i = 0; i < (int)N; i++)
int yokosen[110][1010];
int main(){
	int n,m,a;
	while( cin >> n >> m >> a){
		if(n==m and m==a and n == 0)break;
		REP(i,110)memset(yokosen[i],0,sizeof(yokosen[i]));
		int nowx,nowy;
		nowx = a;
		nowy = 0;
		REP(i,m){
			int h,a,b;
			cin >> h >> a >> b;
			yokosen[a][h] = 1;
			yokosen[b][h] = -1;
			nowy = max(nowy,h);
		}

		while(nowy != 0){
			if(yokosen[nowx][nowy] == -1){
				nowx--;
			}else if(yokosen[nowx][nowy] == 1){
				nowx++;
			}
			nowy--;
		}
		cout << nowx << endl;
	}
	return 0;
}

Measured memory_bytes: 3440
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define lli long long int
#define ld long double
#define pb push_back
#define is insert
#define iamspid ios_base::sync_with_stdio(false); cin.tie(NULL);
int main()
{
    iamspid
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int n, k;
    cin>>n>>k;
    vector<int> pthr(n);
    for(int i = 0; i < n; i++) cin>>pthr[i];
    vector<int> dp(n, 1000000005);
    dp[0]=0;
    for (int i=0; i<n; i++)
    {
        for (int j=i+1; j<=i+k; j++)
        {
            if (j<n) dp[j]=min(dp[j], dp[i]+abs(pthr[j]-pthr[i]));
        }
    }
    cout<<dp[n - 1];
    return 0;
}


Measured memory_bytes: 3972
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

ll median(vector<ll> &A) {
    int N = (int)A.size();
    if(N % 2 == 0) return (A[N / 2 - 1] + A[N / 2]) / 2;
    else {
        return A[N / 2];
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int N;
    cin >> N;
    vector<pair<ll, ll>> A(N);
    rep(i, N) cin >> A[i].first >> A[i].second;
    vector<ll> L(N), R(N);
    rep(i, N) {
        A[i].first *= 2;
        A[i].second *= 2;
        L[i] = A[i].first;
        R[i] = A[i].second;
    }
    sort(all(L));
    sort(all(R));
    
    if(N % 2 == 0) {
        ll lm = median(L);
        ll rm = median(R);
        output(rm - lm + 1);
    } else {
        ll lm = median(L);
        ll rm = median(R);
        output(rm / 2 - lm / 2 + 1);
    }
    
    
    return 0;
}


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

typedef long long int ll;

ll powk(ll a, ll n){
    ll r = 1;
    for(ll i = 0;i < n;i++){
        r *= a;
    }

    return r;
}

int main()
{
    ll n, ans = 0;
    cin >> n;
    vector<ll> a(n), t(n + 1);
    for(ll i = 0;i < n;i++){
        cin >> a[i];
        if(a[i] > n){
            ans++;
        }
        else{
            t[a[i]]++;
        }
    }


    for(ll i = 1;i < n + 1;i++){
        if(t[i] >= i){
            ans += t[i] - i;
        }
        else{
            ans += t[i];
        }
    }

    cout << ans;

    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<deque>
#include<queue>
#include<math.h>
#include<string>
#include<string.h>
#include<stdio.h>
#include<set>
#include<vector>
#include<iomanip>
#include<map>
#include<bitset>
#include<algorithm>
#include<unordered_map>
 
#include<unordered_map>
#include<algorithm>
#define inf 0x3f3f3f3f
#define sup_inf 2e18
#define pb push_back
 
#define ii pair<long long,long long>
#define f first
#define s second
#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define iii pair<int, ii >
#define in freopen("entrada","r",stdin);
#define out freopen("myfile.txt", "w", stdout);
#define eps 1e-9
#define id pair<int ,double > 
#define di pair<double, int>
 
#define pi 3.14159265359
#define nl (no<<1)
#define nr ( (no<<1)|1)
#define mid l + ( (r-l)>>1)
 
using namespace std;
 
 
typedef long long ll;
typedef vector< int> vi;
 
const int MAX = 24;
const int maxn = 1 << 22;


int main (){
	int a, b; cin >> a >> b;
	int ans = -1;
	if ( a < 1 or a > 9 or b < 1 or b > 9)
		return cout << ans << '\n', 0;
	cout << a * b << '\n';
}



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

int atai (int n) {
    int sum = 0;
    while (n > 0) {
    sum += n % 10;
    n = n / 10;
    }
    return sum;
}

int main () {
    int N, t;
    cin >> N;
    t = atai(N);
    if (N % t == 0) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int W = sc.nextInt();
        int H = sc.nextInt();
        int x = sc.nextInt();
        int y = sc.nextInt();
        int r = sc.nextInt();
        
        if (x-r >= 0 && y-r >= 0 && x+r <= W && y+r <= H){
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


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

int main(){
  int N;
  cin>>N;
  vector<int> cards(N);
  for(int i=0;i<N;i++){
   cin>>cards.at(i);
  }
  sort(cards.begin(), cards.end());
  reverse(cards.begin(),cards.end());
  int Alice=0,Bob=0;
  for(int i=0;i<N;i++){
   if(i%2==0)Alice+=cards.at(i);
   else Bob+=cards.at(i);
  }
  cout<<Alice-Bob<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <iomanip>
#include <cstdlib>
#include <cctype>
#define ll long long
#define PI 3.14159265358979323846
using namespace std;
const int maxn = 1e6+7;

int main(){
	ll res[3];
	cin>>res[0]>>res[1]>>res[2];
	int cnt=0;
	while(!(res[0]==res[1]&&res[0]==res[2]&&res[1]==res[2])){
		sort(res,res+3);
		if(res[0]!=res[2]&&res[1]!=res[2]){
			res[0]++;
			res[1]++;
		}
		else if(res[1]==res[2]&&res[0]<res[2]){
			res[0]+=2;
		}
		cnt++;
	}
	cout<<cnt<<endl;
	return 0;
}


Measured memory_bytes: 256
def solve(string):
    n, *a = map(int, string.split())
    ans = [0] * n
    for i, _a in enumerate(a, 1):
        ans[_a - 1] = str(i)
    return " ".join(ans)


if __name__ == '__main__':
    print(solve('\n'.join([input(), input()])))


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

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

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

int main(){
	ll l,r;
	cin>>l>>r;

	if(r-l>=2019){
		cout<<0<<endl;
		return 0;
	}

	ll ans=2018;
	for (ll i = l; i < r; i++){
		for (ll j = i+1; j <= r ; j++){
			ans=min(ans,(i*j)%2019);
		}
	}

	cout<<ans<<endl;

	return 0;
}
	


Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    string s; cin>>s;
    for(int i=(int)s.size()-1;i>=2;i--){
        if(i%2)continue;
        bool flag=true;
        for(int l=0;l<i/2;l++)
            if(s[l]!=s[i/2+l])flag=false;
        if(flag){cout<<i<<endl;return 0;}
    }
    return 0;
}


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

int main() {
  int n, k, q;
  vector<int> a(101234, 0);
  cin >> n >> k >> q;
  int entrada;
  while (cin >> entrada)
    a[entrada]++;
  for (int i = 1; i < n+1; i++) 
    if (a[i] - q + k > 0) printf("Yes\n");
    else printf("No\n");
  return 0;}


Measured memory_bytes: 1024