akhauriyash/Code-Regression huggingface dataset:
package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	
	X := ScanInt(scanner)
	Y := ScanInt(scanner)
	
	ans := 0
	
	if X == Y {
	    
	} else if Abs(X) == Abs(Y) {
	    ans += 1
	} else {
	    ans += Abs(Abs(Y) - Abs(X))
	    if (X < 0 && Y < 0 && X > Y) || (X > Y && Y > 0) {
	        ans += 2
	    }
	    if X * Y < 0 {
	        ans += 1
	    }
	    if X == 0 && Y < 0 {
	        ans += 1
	    }
	    if Y == 0 && X > 0 {
	        ans += 1
	    }
	}
	fmt.Println(ans)
}

func ScanInt(scanner *bufio.Scanner) int {
	scanner.Scan()
	i, e := strconv.Atoi(scanner.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func ScanFloat64(scanner *bufio.Scanner) float64 {
	scanner.Scan()
	f, e := strconv.ParseFloat(scanner.Text(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func ScanText(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func Max(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func Min(a, b int) int {
	if a > b {
		return b
	}
	return a
}

func Abs(a int) int {
	if a < 0 {
		a *= -1
	}
	return a
}

Measured memory_bytes: 640
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
using namespace std;
#include <vector>
#define rep(i,n) for (int i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

//#include <stack>
//#include <queue>

/*
#include <math.h>
int standerd = int(pow(10.0,9.0)) + 7;
*/
string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 
 
int N;


int main(){

    cin >> N;
    int H[N];
    int point[N];

    rep(i,N) cin >>H[i];
    
    int maxv=0;
    int tmp=0;
    for( int i = 1 ; i <N ; i++ ){
        point[i] = 0;
        if(H[i] <= H[i-1]) point[i]=1;

        tmp = (tmp + point[i])*point[i];
        maxv = max(maxv,tmp);
    }
    
    cout << maxv << endl;


}


Measured memory_bytes: 1024
/*
*/
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>

int main()
{
    int n,ans=0;
    std::cin >> n;
    std::vector<int> v(n),c(n);
    for(int i=0;i<n;i++)
        std::cin >> v[i];
    for(int i=0;i<n;i++)
        std::cin >> c[i];

    for(int i=0;i<n;i++)
        ans = std::max(ans,ans + v[i]-c[i]);

    std::cout << ans << std::endl;


    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include <stdlib.h>
int asc(const void* a, const void* b) {
	return *(int*)a - *(int*)b;
}
int main(void) {
	int n;
	int a[200000];
	//int b[200000];
	scanf("%d", &n);
	int max = 0;
	int smax = 0;
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
		if (a[i] > smax) {
			if (a[i] < max) {
				smax = a[i];
			}else {
				smax = max;
				max = a[i];
			}
		}
	}

	//qsort(a, n, sizeof(int), asc);
	for (int i = 0; i < n; i++) {
		//printf("*%d*", b[i]);
		if (a[i] == max) {
			if (i == 0) {
				printf("%d", smax);
			}
			else {
				printf(" %d", smax);
			}
		}
		else {
			if (i == 0) {
				printf("%d", max);
			}
			else {
				printf(" %d", max);
			}
		}
	}
	return 0;
}

Measured memory_bytes: 2304
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
using namespace std;
using LL = long long int;

const LL MOD = 1000000007;

LL mpow(LL a, LL x) {
	if (x == 0)return 1;
	LL half = mpow(a, x / 2);
	half *= half;
	half %= MOD;
	if (x % 2) {
		half *= a;
		half %= MOD;
	}
	return half;
}


int N;
int par[222222];
vector<int>child[222222];
int vnum[222222];
int cnt[222222];
int dep[222222];

void dfs(int v, int cou) {
	dep[v] = cou;
	for (int ch : child[v]) {
		dfs(ch, cou + 1);
	}
}

struct node {
	LL nil, one;
	LL sum;
};

node operator+(const node&n1, const node&n2) {
	LL nil = (n1.nil * n2.nil) % MOD;
	LL one = (n1.nil * n2.one + n1.one * n2.nil) % MOD;
	return {
		nil,one,n1.sum + n2.sum
	};
}

void merge(vector<node> &prime, vector<node> &brnch) {
	assert(prime.size() >= brnch.size());
	int diff = prime.size() - brnch.size();
	for (int i = 0; i < brnch.size(); ++i) {
		node grow = prime[i + diff] + brnch[i];
		prime[i + diff] = grow;
	}
}

//yes,no
vector<node> dp(int v) {
	if (child[v].empty()) {
		return vector<node>(1, { 1,1,1 });
	}
	/*
	vector<node>res = dp(child[v][0]);

	for (int i = 1; i < child[v].size(); ++i) {
	vector<node>tmp = dp(child[v][i]);
	if (tmp.size() > res.size()) {
	merge(tmp, res);
	//res = move(tmp);
	swap(res, tmp);
	}
	else {
	merge(res, tmp);
	}
	}
	*/
	vector<pair<int, int>>srt;
	vector<vector<node>>tame;
	for (int ch : child[v]) {
		tame.emplace_back(dp(ch));
		srt.push_back({ tame.back().size(),tame.size() - 1 });
	}
	sort(srt.begin(), srt.end());
	//vector<node>&res = tame[srt[0].second];
	int las = 0;
	for (int i = 1; i < srt.size(); ++i) {
		//vector<node>&tmp = tame[srt[i].second];
		/*
		if (tmp.size() > res.size()) {
		merge(tmp, res);
		res = move(tmp);
		//swap(res, tmp);
		}
		else {
		merge(res, tmp);
		}
		*/
		merge(tame[srt[i].second], tame[srt[i - 1].second]);
		las = tame[srt[i - 1].second].size();
	}
	vector<node>&res = tame[srt[srt.size() - 1].second];
	int cnt = 0;
	for (auto itr = res.rbegin(); itr != res.rend(); ++itr) {
		if (cnt >= las)break;
		LL zero = mpow(2, itr->sum) + MOD;
		zero = (zero - itr->one) % MOD;
		itr->nil = zero;
		cnt++;
	}
	res.push_back({ 1,1,1 });
	return move(res);
}

int main(void)
{
	cin >> N;
	for (int i = 0; i < N; ++i) {
		cin >> par[1 + i];
		child[par[1 + i]].push_back(i + 1);
	}
	dfs(0, 0);
	vector<node> ans = dp(0);
	for (int i = 0; i <= N; ++i) {
		cnt[dep[i]]++;
	}
	LL answer = 0;
	for (int i = 0; i < ans.size(); ++i) {
		LL kis = N + 1 - cnt[ans.size() - 1 - i];
		kis = mpow(2, kis);
		kis *= ans[i].one;
		kis %= MOD;
		answer += kis;
		answer %= MOD;
	}
	cout << answer << endl;
	return 0;
}


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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

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

  int n;
  cin >> n;
  string s;
  cin >> s;
  int ans = 1;
  for (int i = 0; i + 1 < n; i++) {
    if (s[i] != s[i + 1]) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <tuple>
#include <stack>
#include <bitset>
#include <utility>
#include<iomanip>
// #include <numeric>
using namespace std;



typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<ll> vint;
typedef vector<vector<ll>> vvint;
typedef vector<vector<vector<ll>>> vvvint;
typedef vector<string> vstring;
typedef vector<vector<string>> vvstring;
typedef vector<char> vchar;
typedef vector<vector<char>> vvchar;
typedef vector<long double> vdouble;
typedef vector<vector<long double>> vvdouble;
typedef vector<vector<vector<long double>>> vvvdouble;
typedef pair<ll,ll> pint;
typedef vector<pint> vpint;
typedef vector<bool> vbool;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define INT_MAX 2147483647
#define LLONG_MAX 9223372036854775807
#define vmax(vec) *max_element(vec.begin(), vec.end())
#define vmin(vec) *min_element(vec.begin(), vec.end())
#define vsort(vec) sort(vec.begin(), vec.end())
#define vsortgr(vec) sort(vec.begin(), vec.end(), greater<ll>())
#define DIVIDER 1000000007


//
// struct Node{
//   vint children;
//   ll index;
//   ll prop;
// };
// struct edge{ll to; ll cost;};



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

// ll X,Y,Z,K;
// ll pmax = 30000000000;
// vint A,B,C;




// struct UnionFind {
//     vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
//
//     UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
//         for(int i = 0; i < N; i++) par[i] = i;
//     }
//
//     int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
//         if (par[x] == x) return x;
//         return par[x] = root(par[x]);
//     }
//
//     void unite(int x, int y) { // xとyの木を併合
//         int rx = root(x); //xの根をrx
//         int ry = root(y); //yの根をry
//         if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
//         par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
//     }
//
//     bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
//         int rx = root(x);
//         int ry = root(y);
//         return rx == ry;
//     }
// };
//
vint divisor(ll n){ // nの約数
  vint ret;
  for(ll i=1;i*i<=n;i++){
    if(n%i == 0){
      ret.pb(i);
      if(i*i!=n) ret.pb(n/i);
    }
  }
  vsort(ret);
  return ret;
}

ll my_pow(ll x,ll y){
  ll rtn=1;
  rep(i,y) rtn*=x;
  return rtn;
}

ll get_digit_in(ll n, ll i){ // i桁目の数字を得る。
  for(ll j=0;j<i-1;j++){
    n/=10;
  }
  return n%10;
}

ll get_digit(ll n){
  ll rtn=0;
  while(n>0){
    n/=10;
    rtn++;
  }
  return rtn;
}



int main() {
  cout<<fixed<<setprecision(10);


  ll x,a;cin>>x>>a;
  if(x<a)cout<<0<<endl;
  else cout<<10<<endl;





}




//


Measured memory_bytes: 256
# coding: utf-8

II = lambda: int(input())
MI = lambda: map(int, input().split())


def check(N, A):
    if N % 2 == 0:
        for i in range(N):
            if A[i] != (i // 2) * 2 + 1: return False
    else:
        for i in range(N):
            if A[i] != ((i + 1) // 2) * 2: return False
    return True

def main():
    N = II()
    A = sorted(list(MI()))
    if not check(N, A):
        return 0
    ans = 1
    MOD = int(1e9 + 7)
    for i in range(N//2):
        ans = ans * 2 % MOD
    return ans


if __name__ == "__main__":
    print(main())


Measured memory_bytes: 14324
N, K = map(int, input().split())
p = list(map(int, input().split()))

summax = sum(p[0:K])
sumnow = sum(p[0:K])
maxi = 0

for i in range(1, N-K+1):
  sumnow = sumnow - p[i-1] + p[K+i-1]
  if sumnow > summax:
    summax = sumnow
    maxi = i

ans = 0
for i in range(maxi, maxi + K):
  ans = ans + (p[i]+1)/2
print(ans)

Measured memory_bytes: 25060
import java.io.IOException;
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	static int[][] map;
	static int[][] directions8= {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
	static int[][] directions4= {{-1,0},{1,0},{0,-1},{0,1}};
	static int ans;

	public static void main(String[] args) throws IOException {
//		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
//		String W	 = in.readLine();
//		int num = Integer.parseInt(W.split(" ")[0]);

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();

		int AC = 0;
		int WA = 0;
		int TLE =0;
		int RE = 0;

		for(int i = 0;i<N ; i++) {
			String str = sc.next();
			if(str.equals("AC")) {
			AC++;
			}else if(str.equals("WA")) {
				WA++;
			}else if(str.equals("TLE")) {
				TLE++;
			}else if(str.equals("RE")) {
				RE++;
			}
		}



		System.out.println("AC x "+AC);
		System.out.println("WA x "+WA);
		System.out.println("TLE x "+TLE);
		System.out.println("RE x "+RE);
	}

	//BFS用に二つの配列を足し算する
	static int[] addArrayElms(int[] a, int[] b) {
		int[] c = new int[a.length];
		for(int i = 0; i < a.length; i++) {
			c[i] = a[i] + b[i];
		}
		return c;
	}

	//	//二分探索
	//k <= num となる最小の配列要素kのインデックスを返す
	static private int binarySearch(long num, long[] orderedArray){
		int lowerBorder = -1;
		int upperBorder = orderedArray.length;
		int mid;

		while(upperBorder - lowerBorder >1) {
			mid = (upperBorder + lowerBorder)/2;
			if(orderedArray[mid]<=num) {
				lowerBorder = mid;
			}else {
				upperBorder = mid;
			}
		}
		return lowerBorder;
	}

	//二分探索
	//k <= num となる最小のList要素kのインデックスを返す
	static private int binarySearch(long num, ArrayList<Long> orderedList){
		int lowerBorder = -1;
		int upperBorder = orderedList.size();
		int mid;

		while(upperBorder - lowerBorder >1) {
			mid = (upperBorder + lowerBorder)/2;
			if(orderedList.get(mid)<=num) {
				lowerBorder = mid;
			}else {
				upperBorder = mid;
			}
		}
		return lowerBorder;
	}

	//aとbの最小公倍数を求める
	public static int gcd(int a, int b) {
        return b == 0 ? a: gcd(b, a % b);
	}
	public static long gcd(long a, long b) {
        return b == 0 ? a: gcd(b, a % b);
	}
}


Measured memory_bytes: 57996
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)
    

a = int(input())

ans = 0

for i in range(1,a+1):
    for j in range(1,i+1):
        for k in range(1,j+1):
            if i == j and i == k:
                ans += gcd(i,j,k)
            elif i == j or i == k or j == k:
                ans += gcd(i,j,k)*3
            else:
                ans += gcd(i,j,k)*6

print(ans)

Measured memory_bytes: 9624
#include <iostream>
#include <map>
#include <cctype>

using namespace std;

int main(void) {
  char line[1200];
  map<char, int> mp;
  int t;
  for(char c = 'a'; c <= 'z'; c++)
    mp[c] = 0;
  while(cin.getline(line, sizeof(line))) {
    for(int i = 0; line[i] != '\0'; i++)
      line[i] = tolower(line[i]);
    for(int i = 0; line[i] != '\0'; i++)
      if(mp.find(line[i]) != mp.end())
        mp[line[i]] += 1;
  }
  for(map<char, int>::iterator itr = mp.begin(); itr != mp.end(); ++itr)
    cout << itr->first << " : " << itr->second << endl;
  return 0;
}

Measured memory_bytes: 3084
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define lli long long int
#define ulli unsigned long long int
#define ld long double
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define loop(i,a,b) for(lli i=a;i<b;i++)
#define initialize(array,size,value) for(lli i=0;i<size;i++) array[i]=value
#define couta(array,size) for(lli i=0;i<size;i++) cout<<array[i]<<" "
#define vl vector<lli>
#define vp vector< pair <lli,lli> >
#define sl set<lli>
#define msp multiset < pair < long long , long long > > S;
#define pll pair<lli, lli>
#define mll map<lli, lli>              //for( map<lli, lli>::iterator i=result.begin();i!=result.end();i++)cout<<i->fi<<" "<<i->se<<endl;
#define mvl map<lli, vl>
#define umll unordered_map<lli, lli>
#define vt vector<pair<lli, pll >  >
#define vf vector<pair<pll,pll > >
#define qu queue<lli>
//#define pq priority_queue<lli>
#define dq deque <lli>
#define ptr vector<lli>::iterator
#define bs(array,x) binary_search(array.begin(),array.end(),x)
#define lb(array,x) lower_bound(array.begin(),array.end(),x)
#define ub(array,x) upper_bound(array.begin(),array.end(),x)
#define nobw(array,i,j) upper_bound(array.begin(), array.end(), j)-lower_bound(array.begin(), array.end(), i) //number of numbers between i & j
#define vc clear()
#define endl '\n'
#define sp system("pause");
#define INF 9223372036854775807
#define MINF -9223372036854775808
typedef tree<pll,null_type,less<pll>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;

int main()
{
	ios::sync_with_stdio(0);
    cin.tie(0);
    lli n;
    cin>>n;
    lli a[n+1];
    for(lli i=1;i<=n;i++)cin>>a[i];
    bool ans=true;
	lli b[n+1]={0},ans1[n+1]={0};
	for(lli i=n;i>0;i--){
		if(b[i]%2==a[i])continue;
		ans1[i]++;
		for(lli j=1;j<=sqrt(i);j++){
			if(i%j!=0)continue;
			if(j==sqrt(i)){b[j]++;continue;}
			b[j]++;b[i/j]++;
		}
	}
	//for(lli i=1;i<=n;i++)cout<<b[i]<<" ";
	lli ct=0;
	//cout<<endl;
	//for(lli i=1;i<=n;i++)cout<<ans1[i]<<" ";
	//cout<<endl;
	for(lli i=1;i<=n;i++)if(ans1[i])ct++;//<<" ";
	cout<<ct<<endl;
	for(lli i=1;i<=n;i++)if(ans1[i])cout<<i<<" ";



    return 0;
}


Measured memory_bytes: 5632
#include<bits/stdc++.h>
using namespace std;
#define me(a) memset(a,0,sizeof(a));
typedef long long ll;

int main(){
	double d,t,s;
    cin>>d>>t>>s;
    if(t * s >= d)cout<<"Yes";
    else cout<<"No";
	//system("PAUSE");
	return 0;
}


Measured memory_bytes: 3720
#include <stdio.h>

int main(int argc, const char * argv[]) {
    
    int x,h,m,s;
    
    scanf("%d",&x);
    
    h = x / 3600;
    x -= h*3600;
    
    m = x / 60;
    x -= m*60;
    
    s = x;
    
    printf("%d:%d:%d\n",h,m,s);
    return 0;
}

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

signed main(){
	int a,b;cin>>a>>b;
	if(a<b){puts("-1");return 0;}
	if(a==b){cout<<a+1<<endl;return 0;}
	for(int i=2;i*i<=a;i++){
		int sum=0;
		int c=a;
		while(c>0){
			sum+=c%i;
			c/=i;
			}
		if(sum==b){cout<<i<<endl;return 0;}	
		}
	 vector<int>V;
	 for(int i=1;i*i<a&&i<=b;i++){//ひと桁目
		 if((a-(b-i))%i)continue;
		 int e=(a-(b-i))/i;
		 if(a/e+a%e==b)V.push_back(e);
		 }	
		if(V.size()==0)puts("-1");
		else {
			sort(V.begin(),V.end());
			cout<<V[0]<<endl;
			} 
	}


Measured memory_bytes: 256
#pragma comment(linker, "/STACK:256000000")
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <map>
#include <set>
#include <array>
#include <unordered_set>
#include <deque>
#include <queue>
#include <iomanip>
#include <fstream>
#include <string>
#include <climits>
#include <sstream>

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

#define vi vector<ll>
#define pii pair<int, int>
#define fi(n) for(ll i = 0; i < (n); i++)
#define FOR(i, k, n) for(int i = (k); i < (n); i++)
#define RFOR(i, k, n) for(int i = (k); i >= (n); i--)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define umin(a, b) a = min(a, b)
#define umax(a, b) a = max((ll)a, (ll)b)

//const long long LINF = LLONG_MAX;
//const long long LINF = 1e14;
const int INF = 1e9 + 1;

using namespace std;

vector<vector<int>> g;
vector<int> lb;

void dfs(int v, int clb)
{
	lb[v] = clb;
	for (auto u : g[v])
		if (!lb[u])
			dfs(u, clb);
}

int main()
{
	std::ios::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	vector<int> p(n);
	fi(n)
		cin >> p[i];

	g.resize(n);
	lb.resize(n);

	fi(m)
	{
		int u, v;
		cin >> u >> v;
		u--, v--;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	fi(n)
		if (!lb[i])
			dfs(i, i + 1);
	int answ = 0;
	fi(n)
		if (lb[i] == lb[p[i] - 1])
			answ++;
	cout << answ << endl;
	return 0;
}

Measured memory_bytes: 8576
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
using namespace std;
int main(){
  int x1,y1,x2,y2;
  cin >> x1>>y1>>x2>>y2;
  int xx=x1-x2;int yy=y1-y2;
    cout <<x2+yy<<" "<<y2-xx<<" "<<x1+yy<<" "<<y1-xx<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
typedef long long int ll;
using namespace std;

bool primecheck(int n){
	if(n<2)return false;
	for(int i=2;i*i<=n;i++){
		if(n %i == 0)return false;
	}
	return true;
}


int main(){
	int n; cin >>n;
	ll mod=1e9+7;
	ll ans=1;
	for(int i=2;i<=n;i++){
		int cnt=0;
		for(int j=2;j<=n;j++){
          if(primecheck(i)){
			int num=j;
			while(num%i==0){
				cnt++;
				num/=i;
			}
          }
		}
		if(cnt!=0){ans*=(cnt+1);}
		ans%=mod;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int x,y,i,j;

    cin>>x>>y;
    char a[x][y];
    long long int ways[x][y],mod=1000000000+7;
    for(i=0;i<x;i++)
    for(j=0;j<y;j++)
    ways[i][j]=0;
    for(i=0;i<x;i++)
    for(j=0;j<y;j++)
    {cin>>a[i][j];
     if(i==0&&j==0)
     ways[i][j]=1;
     else if(i==0&&a[i][j]=='.')
     ways[i][j]=ways[i][j-1];
     else if(j==0&&a[i][j]=='.')
     ways[i][j]=ways[i-1][j];
     else if(a[i][j]=='.')
     ways[i][j]=(ways[i-1][j]%mod+ways[i][j-1]%mod)%mod;
    }
    cout<<ways[x-1][y-1]%mod;
}


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

using namespace std;
#define _overload3(_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(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

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

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

struct SegmentTree {
private:
    int n;
    vector<int> node;

public:
    // 元配列 v をセグメント木で表現する
    SegmentTree(vector<int> v) {
        // 最下段のノード数は元配列のサイズ以上になる最小の 2 冪 -> これを n とおく
        // セグメント木全体で必要なノード数は 2n-1 個である
        int sz = v.size();
        n = 1; while(n < sz) n *= 2;
        node.resize(2*n-1, -1);

        // 最下段に値を入れたあとに、下の段から順番に値を入れる
        // 値を入れるには、自分の子の 2 値を参照すれば良い
        for(int i=0; i<sz; i++) node[i+n-1] = v[i];
        for(int i=n-2; i>=0; i--) node[i] = max(node[2*i+1], node[2*i+2]);
    }

    void update(int x, int val) {
    // 最下段のノードにアクセスする
    x += (n - 1);

    // 最下段のノードを更新したら、あとは親に上って更新していく
    node[x] = val;
    while(x > 0) {
        x = (x - 1) / 2;
        node[x] = max(node[2*x+1], node[2*x+2]);
    }
}

int getmax(int a, int b, int k=0, int l=0, int r=-1) {
    // 最初に呼び出されたときの対象区間は [0, n)
    if(r < 0) r = n;

    // 要求区間と対象区間が交わらない -> 適当に返す
    if(r <= a || b <= l) return -1;

    // 要求区間が対象区間を完全に被覆 -> 対象区間を答えの計算に使う
    if(a <= l && r <= b) return node[k];

    // 要求区間が対象区間の一部を被覆 -> 子について探索を行う
    // 左側の子を vl ・ 右側の子を vr としている
    // 新しい対象区間は、現在の対象区間を半分に割ったもの
    int vl = getmax(a, b, 2*k+1, l, (l+r)/2);
    int vr = getmax(a, b, 2*k+2, (l+r)/2, r);
    return max(vl, vr);
}


};

ll dp[2][200100];

const ll MOD = 998244353;

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

  int N;
  cin >> N;

  vector<pair<ll, ll>> R(N);

  ll x, d;
  rep(i, N){
    cin >> x >> d;
    R[i] = make_pair(x, d);
  }

  R.push_back(make_pair(3*1e9, 1LL));

  sort(R.begin(), R.end());

  vector<int> BOOT(N+1);
  rep(i, N+1) BOOT[i] = -1;
  SegmentTree st(BOOT);

  for(int i = N-1; i >= 0; i--){

    int ind = upper_bound(R.begin(), R.end(), make_pair(R[i].first + R[i].second, 0LL)) - R.begin();
    st.update(i, i);
    int max_val = st.getmax(i, ind);
    st.update(i, max_val);
    BOOT[i] = max_val;

  }


  dp[0][N] = 1;
  dp[1][N] = 0;

  for(int i = N-1; i >= 0; i--){

    // ここのind取得を工夫する
    // int ind = upper_bound(R.begin(), R.end(), make_pair(R[i].first + R[i].second, 0LL)) - R.begin();

    dp[0][i] = (dp[0][i+1] + dp[1][i+1]) % MOD;

    dp[1][i] = (dp[0][BOOT[i]+1] + dp[1][BOOT[i]+1]) % MOD;

  }

  cout << (dp[0][0] + dp[1][0]) % MOD << endl;

  

  return 0;
}


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

int main(){
    int n;  cin >> n;
    vector<int> a(n+1);
    vector<int> b(n+1, 0);
    for(int i=1; i<=n; i++)  cin >> a.at(i);
    
    int cnt=0;
    for(int i=n; 1<=i; i--){
        ll tmp=i, sum=0;
        while(tmp+i<=n){
            tmp += i;
            sum += b.at(tmp);
        }
        if(sum%2!=a.at(i)){
            cnt += 1;    b.at(i) = 1;
        }
    }
    cout << cnt << endl;
    for(int i=1; i<=n; i++)
        if(b[i]==1) cout << i << ' ';
    
    
}




Measured memory_bytes: 2432
#include <stdio.h>

int main(){
	int n;
	scanf("%d", &n);
	int i;
	for(i=0;i<n;i++){
		int a,b,c;
		scanf("%d %d %d", &a, &b, &c);
		if(a <= 1000 || a >= 0 ||b <= 1000 || b >= 0 ||c <= 1000 || c >= 0){
			if(a*a == b*b + c*c || b*b == a*a + c*c ||c*c == b*b + a*a){
				printf("YES\n");			
			}else{
				printf("NO\n");
			}
		}
	}		
	return 0;
}

Measured memory_bytes: 580
var main = (input: string) => {
    let inputArray: bigint[] = input.split(" ").map(x => BigInt(x));
    let a: bigint = inputArray[0];
    let b: bigint = inputArray[1];
    let c: bigint = inputArray[2];
    let d: bigint = inputArray[3];

    let answerCandidate: bigint[] = Array.of(
        a * c, a * d, b * c, b * d
    );
    console.log(answerCandidate.sort((a, b) => a < b ? 1 : (a > b ? -1 : 0))[0].toString(10).replace('n', ''));
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

using namespace std;

typedef long long llint;

int main() {
  int n;
  cin >> n;
  llint T = 1, A = 1;
  llint t, a;
  for (int i = 0; i < n; i++) {
    cin >> t >> a;
    llint m = max((T + t - 1) / t, (A + a - 1) / a);
    T = m * t;
    A = m * a;
  }
  cout << T + A << endl;

  return 0;
}

Measured memory_bytes: 256
def p_d():
    n, k = map(int, input().split())
    *A, = map(int, input().split())
    size = (len(bin(max(A + [k]))) - 2)
    bits = [0] * size
    for a in A:
        for i in range(len(bin(a)) - 2):
            bits[i] += a >> i & 1

    now = 0
    ans = 0
    for i, bit_count in enumerate(reversed(bits)):
        b = 1 << size - i - 1
        if k < now | b or n - bit_count <= bit_count:
            ans += bit_count * b
            continue
        now |= b
        ans += (n - bit_count) * b

    print(ans)


if __name__ == '__main__':
    p_d()


Measured memory_bytes: 75408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    int H, W, C_h, C_w, D_h, D_w;
    cin >> H >> W >> C_h >> C_w >> D_h >> D_w;
    C_h--;
    C_w--;
    D_h--;
    D_w--;
    char S[H][W];
    for (int i = 0; i < H; i++) {
        string s;
        cin >> s;
        for (int j = 0; j < W; j++) {
            S[i][j] = s[j];
        }
    }
    int MAX = 100000000;
    int G[H][W];
    
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            G[i][j] = -1;
        }
    }
    
    int dx[] = {1, -1, 0, 0};
    int dy[] = {0, 0, -1, 1};
    deque<pair<int, int>> q;
    int idx = 0;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (G[i][j] == -1 && S[i][j] == '.') {
                G[i][j] = idx;
                vector<pair<int, int>> v;
                q.push_back(make_pair(i, j));
                while (!q.empty()) {
                    pair<int, int> p = q.front();
                    q.pop_front();
                    int x = p.second;
                    int y = p.first;
                    for (int k = 0; k < 4; k++) {
                        int nx = x + dx[k];
                        int ny = y + dy[k];
                        if (nx < 0 || ny < 0 || nx >= W || ny >= H) continue;
                        if (S[ny][nx] == '.' && G[ny][nx] == -1) {
                            G[ny][nx] = idx;
                            q.push_back(make_pair(ny, nx));
                        }
                    }
                }
                idx++;
            }
        }
    }
    
    int ex[] = {1, 1, -1, -1, 2, 2, 2, 2, 2, 1, 1, 0, 0, -1, -1, -2, -2, -2, -2, -2};
    int ey[] = {1, -1, 1, -1, -2, -1, 0, 1, 2, 2, -2, 2, -2, 2, -2, 2, 1, 0, 1, 2};
    set<int> adj[idx];
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (G[i][j] == -1) continue;
            for (int k = 0; k < 20; k++) {
                int nx = j + ex[k];
                int ny = i + ey[k];
                if (nx < 0 || ny < 0 || nx >= W || ny >= H) continue;
                if (S[ny][nx] == '.' && G[i][j] != G[ny][nx]) {
                    adj[G[i][j]].insert(G[ny][nx]);
                    adj[G[ny][nx]].insert(G[i][j]);
                }
            }
        }
    }

    int L[idx];
    for (int i = 0; i < idx; i++) {
        L[i] = MAX;
    }
    L[G[C_h][C_w]] = 0;
    deque<int> dq;
    dq.push_back(G[C_h][C_w]);
    while (!dq.empty()) {
        int p = dq.front();
        dq.pop_front();
        for (int i : adj[p]) {
            if (L[p] + 1 < L[i]) {
                L[i] = L[p] + 1;
                dq.push_back(i);
            }
        }
    }

    if (L[G[D_h][D_w]] != MAX) {
        cout << L[G[D_h][D_w]] << "\n";
    } else {
        cout << "-1\n";
    }
    return 0;
}

Measured memory_bytes: 33140
#include <bits/stdc++.h>
#define endl "\n"
#define ll long long int
#define pii pair<int,int>
#define pll pair<long long, long long>
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define f first
#define pb push_back
#define MAXN 10000057
#define mod 1000000007
#define fr(i, s, e, st) for(ll (i) = (s); (i) < (e); (i) += (st))
#define fre(i, s, e, st) for(ll (i) = (s); (i) <= (e); (i) += (st))
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(10);
using namespace std;

int main()
{
    fastio;
    ll T = 1;
    //cin >> T;
    while (T--)
    {       
        ll n, a, b, c; cin>>n;
        ll DP[n+1][3];
        mem(DP, 0);
        fr(i, 0, n, 1) {
            cin>>a>>b>>c;
            DP[i+1][0] = max(DP[i][1] + b, DP[i][2] + c); 
            DP[i+1][1] = max(DP[i][0] + a, DP[i][2] + c); 
            DP[i+1][2] = max(DP[i][0] + a, DP[i][1] + b); 
        }
        cout<<max({DP[n][0], DP[n][1], DP[n][2]})<<endl;
    }       
    return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h> 
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(vec) vec.begin(), vec.end()
#define tmax(x,y,z) max((x),max((y),(z)))
#define tmin(x,y,z) min((x),min((y),(z)))
typedef long long ll;ll MM = 1000000000;ll mod = MM + 7; ll MMM=9223372036854775807;//2^63 -1
ll GCD(ll x, ll y) {if (y == 0) return x;else return GCD(y, x % y);}
ll LCM(ll x, ll y) { return x / GCD(x, y) * y;}
//cout << fixed << setprecision(10);

int main(){
 ll h,n,t,a,ans;
  cin>>n>>t>>a;
  double dif=MMM;
  rep(i,n){
  cin>>h; if(dif>abs(a-t+0.006*h)){
    ans=i+1; dif=abs(a-t+0.006*h);
  }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
main()
{
	int n,l;
	cin>>n>>l;
	int ans=n*l+((n-1)*n)/2;
	// cout<<"ans="<<ans<<"\n";
	int mi=INT_MAX,index;
	for(int i=1;i<=n;i++){
		// cout<<ans-(l+i-1)<<" "<<ans<<" "<<l<<" "<<i<<"\n";
		if(abs(ans-(ans-(l+i-1)))<mi)
		{
			index=i,mi=min(mi,abs(ans-(ans-(l+i-1))));
			// cout<<mi<<" ";
		}
	}
	// cout<<"index-"<<index<<"\n";
	cout<<ans-(l+index-1);
}
	

Measured memory_bytes: 256
using System;
class ProgramC
{
    static void Main(string[] args)
    {
        //入力
        int n = int.Parse(Console.ReadLine());
        int[,] honest = new int[n,n];
        int ans = 0;

        //初期条件-1でリセット
        for(int i = 0; i < n;i++)
            for(int j = 0; j < n;j++)
                honest[i, j] = -1;

        //条件入力
        for(int i = 0; i < n;i++)
            {
                //何人言及しているか読む
                int ai = int.Parse(Console.ReadLine());

                for(int j = 0; j < ai;j++)
                {
                    //条件を見る
                    string[] input_1 = Console.ReadLine().Split();
                    int x = int.Parse(input_1[0]);
                    int y = int.Parse(input_1[1]);

                    //代入する
                    honest[i, x - 1] = y;
                         
                }
            }
        //ビットによる全検索
        for(int bit = 0; bit< (1 << n);bit++)
        {
            bool flag = true;
            for (int i = 0; i < n; i++)
            {
                //bitより大きい数のケースは飛ばす
                if((bit & (1 << i)) == 0)
                    continue;
                //証言をすべて照らし合わせてみる
                for(int j = 0;j < n;j++)
                {
                    if(honest[i, j] != -1 && honest[i, j] != (bit >> j & 1))
                        flag = false;
                }
            }

            if(flag == true)
                ans = Math.Max(ans, counter(bit));
        }

        //答え出力
        Console.WriteLine(ans);
    }

    //bit表記の時点灯している数を数える
    static int counter(int x)
    {
        if(x == 0)
            return 0;
        return counter(x >> 1) + (x & 1);
    }
}


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

using namespace std;

int main(){
 int a,b;
  cin >> a >> b;
  string s;
   cin >> s;
  
  bool res=true;
  
  for(int i=0;i<a;i++){
   if(s[i]<'0'||'9'<s[i]) res=false;
  }
  if(s[a]!='-') res=false;
  
  for(int i=a+1;i<a+b+1;i++){
  if(s[i]<'0'||'9'<s[i]) res=false;
  }

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

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<cstring>
#include<stdlib.h>
#include<time.h>
#include<math.h>
#include<algorithm>
#define ll long long
#define maxn 300005
#define p 1000000007
using namespace std;
char s[maxn];
int dp[maxn][5][5];

int main()
{
	scanf("%s",s+1);
	int len=strlen(s+1);
	dp[0][0][0]=1;
	for(register int i=0;i<len;++i)
	{
		if(s[i+1]!='1')
		{
			for(int j=0;j<3;++j)
				for(int k=0;k<3;++k)
				{
					if(k==2)
						dp[i+1][j][k-1]=(dp[i+1][j][k-1]+dp[i][j][k])%p;
					else
						dp[i+1][j][k+1]=(dp[i+1][j][k+1]+dp[i][j][k])%p;
				}
					
		}
		if(s[i+1]!='0')
		{
			for(int j=0;j<3;++j)
				for(int k=0;k<3;++k)
				{
					if(k==0)
						dp[i+1][j+(j!=2)][k]=(dp[i+1][j+(j!=2)][k]+dp[i][j][k])%p;
					else
						dp[i+1][j][k-1]=(dp[i+1][j][k-1]+dp[i][j][k])%p;
				}
		}
	}
	int ans=0;
	for(register int i=0;i<3;++i)
		for(register int j=0;j<=i;++j)
			ans=(ans+dp[len][i][j])%p;
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 29824
n = int(input())
a = list(map(int, input().split(' ')))
q = int(input())
M = list(map(int, input().split(' ')))
minA = min(a)
sumA = 0
for i in a:
    sumA += i


def solve(i, m):
    if m==0 :
        return True
    if i>=n:
        return False
    res = solve(i+1, m) or solve(i+1, m-a[i])
    return res

for j in M:
    if j < minA or j > sumA:
        print('no')
    else:
        if solve(0, j):
            print('yes')
        else:
            print('no')



Measured memory_bytes: 5624
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
signed main(){
	int a;cin >> a;
	cout << 3*a*a << endl;
	return 0;
}

Measured memory_bytes: 3588
n=int(input())
L=list(map(int,input().split()))
L.sort()#L[i]<=L[j]<=L[k]
ans=0
for i in range(n):
    for j in range(i+1,n):
        for k in range(j+1,n):
            if L[i] != L[j] != L[k]:
                if L[i] + L[j] >L[k]:#三角形を作る条件
                    ans+=1
print(ans)


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

int main() {
    string S;
    cin >> S;
    int a = 0;
    int b = 0;
    int c = 0;
    rep (i, S.size()) {
        switch(S[i]){
            case 'a':
                a += 1;
                break;
            case 'b':
                b += 1;
                break;
            case 'c':
                c += 1;
                break;
        }
    }
    if (max(a, max(b, c))-min(a, min(b, c)) <= 1) {
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
}


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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int mod = (int)1e9 + 7;
void dbg(){ cerr << "\n"; }  template <typename T,typename ...T2> 
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


int main(){
	int n,m;
	cin >>n >>m;
	VI p(m), ans(m), gno(n+4);
	vector<pii> vp(m);
	rep(i, m){
		cin >>p[i] >>vp[i].first;
		vp[i].second = i;
	}
	sort(all(vp));
	rep(i, m){
		ans[vp[i].second] = ++gno[p[vp[i].second]];
	}
	rep(i,m){
		printf("%06d%06d\n", p[i], ans[i]);
	}
}



Measured memory_bytes: 3456
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/math/common_factor_rt.hpp>

using namespace std;

int main()
{
    int64_t N, C, K;
    std::cin >> N >> C >> K;

    std::vector<int64_t> T;
    for (decltype(N) i = 0; i < N; ++i) {
        int64_t t;
        std::cin >> t;
        T.push_back(t);
    }

    std::sort(std::begin(T), std::end(T));

    int64_t bus = 0;
    int64_t waiting = 0;
    int64_t deadline = T[0] + K;
    for (auto t: T) {
        if (deadline < t || waiting == C) {
            bus++;
            waiting = 0;

            waiting++;
            deadline = t + K;
        }
        else {
            waiting++;
        }
    }

    bus++;

    std::cout << bus << std::endl;

    return 0;
}


Measured memory_bytes: 1400
#include<bits/stdc++.h>
#define lli long long
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define rep0(i,j) for(int i=0;i<j;i++)
#define rep1(i,j) for(int i=1;i<=j;i++)
#define rep0d(i,j) for(int i=j-1;i>=0;i--)
#define MOD 1000000007
 
using namespace std;
 
bool cmpf(const pair<lli, lli> left, const pair<lli, lli> right) {
  	return left.first< right.first;
}
bool cmps(const pair<lli, lli> left, const pair<lli, lli> right) {
  	return left.second < right.second;
}
 
void dfs(lli ed, lli num, vector<map<lli,lli>>& vec){
    lli n=1;
    for(auto e: vec[num]){
        if(n == ed)n++;
        if(e.second != -1)continue;
        vec[num][e.first] = n;
        vec[e.first][num] = n;   
        dfs(n, e.first, vec);
        n++;
    }
}
 
lli gcd(lli a, lli b){
    if(a < b)return gcd(b, a);
    lli temp;
    while((temp = a%b)){
        a=b;
        b=temp;
    }
    return b;
}

struct nCr{
  vector<lli> f, rf;
  lli count=0;
  nCr(lli num): f(num), rf(num){
      count = num;
      f[0] = 1;
      rep1(i, num) f[i] = (f[i - 1] * i) % MOD;
      rep0(i, num+1) rf[i] = inv(f[i]);
  }
    
  lli inv(lli x) {
      lli res = 1;
      lli k = MOD - 2;
      lli y = x;
      while (k) {
          if (k & 1) res = (res * y) % MOD;
          y = (y * y) % MOD;
          k /= 2;
      }
      return res;
  }
  lli C(lli n, lli k) {
      lli a = f[n];
      lli b = rf[n-k];
      lli c = rf[k];
   
      lli bc = (b * c) % MOD;
   
      return (a * bc) % MOD;
  }
};

struct UF{
    vector<int> par,size;

    UF(int N) : par(N), size(N, 1){
        rep0(i,N)par[i] = i;
    }

    int root(int x){
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y){
        int rx = root(x);
        int ry = root(y);
        if(rx == ry) return;
        par[rx] = ry;
        size[rx] += size[ry];
    }

    bool same(int x, int y){
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }

    int getSize(int x){
        return size[x];
    }
};
int main(){
  int x,y,a,b,c;
  cin >> x >> y >> a >> b >> c;
  vector<lli> p(a), sump(a+1,0), q(b), sumq(b+1,0), r(c), sumr(c+1,0);
  rep0(i,a){
    cin >> p[i];
  }
  rep0(i,b){
    cin >> q[i];
  }
  rep0(i,c){
    cin >> r[i];
  }

  sort(rall(p));
  sort(rall(q));
  sort(rall(r));

  if(x<a)p[x]=0;
  else p.push_back(0);
  if(y<b)q[y]=0;
  else q.push_back(0);
  if(x+y<c)r[x+y]=0;
  else q.push_back(0);

  lli s=0, t=0, u=0, sum=0;
  while(s+t+u < x+y){
    if(p[s] > q[t] & p[s] > r[u]){
      sum += p[s];
      s++;
    }else if (q[t] > r[u]){
      sum += q[t];
      t++;
    }else{
      sum += r[u];
      u++;
    }

  }
  cout << sum ;

}


Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
const int maxn = 234566;
struct splitted {
	multiset<int> p0, p1;
	long long cs;
	int sz;
	splitted(int n){
		sz = n;
		cs = 0;
	}
	void add(int x){
		p0.insert(x);
		cs += x;
		if(p0.size() > sz){
			int bad = *(--p0.end());
			p0.erase(--p0.end());
			cs -= bad;
			p1.insert(bad);
		}
	}
	void del(int x){
		if(p1.find(x) != p1.end()){
			p1.erase(p1.find(x));
		} else {
			p0.erase(p0.find(x));
			cs -= x;
			if(!p1.empty()){
				int good = *p1.begin();
				p1.erase(p1.begin());
				cs += good;
				p0.insert(good);
			}
		}
	}
};
int x[maxn], y[maxn], o[maxn];
int main(){
	int n; cin >> n;
	for(int i = 0; i < n; i++) cin >> x[i] >> y[i];
	long long ans = 0;
	for(int i = 0; i < n; i++) ans += x[i];
	for(int i = 0; i < n; i++) o[i] = x[i], o[i + n] = y[i];
	sort(o, o + n + n);
	long long sumy = 0;
	for(int i = 0; i < n; i++) sumy += y[i];
	ans = min(ans, sumy);
	splitted who(n);
	for(int i = 1; i < n; i++) who.add(x[i]), who.add(y[i]);
	ans = min(ans, who.cs);
	for(int i = 1; i < n; i++){
		who.add(x[i - 1]); who.add(y[i - 1]);
		who.del(x[i]); who.del(y[i]);
		ans = min(ans, who.cs);
	}
	cout << ans << endl;
	return 0;
}


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

#define printl(s) cout << s << endl;
#define print(s) cout << s << endl; return 0;
#define yes cout << "Yes" << endl; return 0;
#define no cout << "No" << endl; return 0;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep2(i,n) for (int i = 1; i < (n)+1; ++i)
using ll = long long;

const ll modseed = pow(10,9) + 7;

template <typename T>
vector<T> getValues(ll num){
    vector<T> values(num);
    for(ll i=0;i<num;i++){
        cin >> values.at(i);
    }
    return values;
}

string S;
int N, cnt;

int main(){
  cin >> N;
  rep2(i,N){
    int d = log10(i)+1;
    if(d%2!=0){
      cnt++;
    }
  }
  print(cnt);
}


Measured memory_bytes: 3968
// In the name of God

#include <bits/stdc++.h>

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	string s, t;
	cin >> s >> t;
	if(t.substr(0,s.length())==s) cout << "Yes";
	else cout << "No";
	return 0;
}


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

#define REP(i, x) REPI(i, 0, x)
#define REPI(i, a, b) for (int i = int(a); i < int(b); ++i)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
using namespace std;

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

  int N;
  cin >> N;

  vector<int> a(N);
  REP(i, N) { cin >> a.at(i); }

  int cur = 1;
  REP(i, N) {
    if (a[i] == cur) {
      cur++;
    }
  }

  int ans = N - (cur - 1);
  if (cur == 1) {
    cout << -1 << endl;
  } else {
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 1024
import sys
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt, ceil, floor
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
INF = float("inf")
sys.setrecursionlimit(10**7)

# 4近傍（右, 下, 左, 上）
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]


def inside(y: int, x: int, H: int, W: int) -> bool: return 0 <= y < H and 0 <= x < W


def solve(S):
    T = "AKIHABARA"
    if len(S) > len(T):
        return False
    if S.replace("A", "") != T.replace("A", ""):
        return False

    s, t = 0, 0
    while s < len(S) and t < len(T):
        if S[s] == T[t]:
            s, t = s + 1, t + 1
        elif S[s] != T[t] and T[t] == "A":
            t += 1
        else:
            return False

    if s == len(S):
        return True
    else:
        return False


def main():
    S = input()
    print("YES" if solve(S) else "NO")


if __name__ == '__main__':
    main()


Measured memory_bytes: 3884
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  for (int i = 0; i < N; i++){
      if(vec[i]%2 == 0){
          if (vec[i]%3 != 0 and vec[i]%5 != 0){
              cout << "DENIED" << endl;
              return 0;
          }
      }
  }
  cout << "APPROVED" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int x,y,tmp,result;
    
	scanf("%d %d", &x, &y);
	
	if(x < y)
	{
		tmp = x;
		x = y;
		y = tmp;
	}
	
	result = x % y;
	
	while(result != 0)
	{
		x = y;
		y = result;
		result = x % y;
	}
	
	printf("%d\n",y);
	
	return 0;
}



Measured memory_bytes: 2092
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>
#include <random>
#include <cstring>

#define rep(i,n) for(int i=0;i<int(n);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back

using namespace std;
using ll = long long;

const ll mod = 1000000007;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

int main(){
  ll N, K;
  cin >> N >> K;
  vector<ll> V(N);
  for(int i = 0; i < N; i++) cin >> V[i];
  
  ll ans = 0;
  for(int left = 0; left <= N; left++) {
    for(int right = N; right >= 0; right--) {
      // //cerr << left <<" " << right << endl;
      if(left > right) continue;
      int diff = left + (N - right);
      if(K < diff) continue;
      priority_queue<ll, vector<ll>, greater<ll> > que;
      for(int i = 0; i < left; i++) {
	que.push(V[i]);
      }
      for(int i = N - 1; i >= right; i--) {
	que.push(V[i]);
      }
      for(int i = 0; i < K - diff; i++) {
	if(que.size() == 0) break;
	ll top = que.top();
	if(0 < top) break;
	que.pop();
      }
      ll sum = 0;
      while(que.size()) { sum += que.top(); que.pop(); }
      ans = max(sum, ans);
    }
  }
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<string.h>
int main() {
	int sx,sy,tx,ty,i;
	scanf("%d %d %d %d",&sx,&sy,&tx,&ty);
	for(i=0;i<abs(tx-sx);i++){
		printf("R");	
	}
	for(i=0;i<abs(ty-sy);i++){
		printf("U");	
	}
	for(i=0;i<abs(tx-sx);i++){
		printf("L");	
	}
	for(i=0;i<abs(ty-sy);i++){
		printf("D");	
	}
	printf("D");
	for(i=0;i<abs(tx-sx+1);i++){
		printf("R");	
	}
	for(i=0;i<abs(ty-sy+1);i++){
		printf("U");	
	}
	printf("L");
	printf("U");
	for(i=0;i<abs(tx-sx+1);i++){
		printf("L");	
	}for(i=0;i<abs(ty-sy+1);i++){
		printf("D");	
	}
	printf("R");
	return 0;
}

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

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  int n;cin>>n;
  int res=0;
  for(int i=1;i<=n;i++){
    string str = to_string(i);
    if(str.size()%2==1)res++;
  }
  cout<<res<<endl;

  return 0;
}


Measured memory_bytes: 256