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

long long n,a[DIM],res;

int main()
{
    cin>>n;
    for(int i = 1; i <= n; ++i)
        cin>>a[i];


    long long ptr1 = 1,ptr2 = 1,s = 0,x = 0;

    for(ptr2 = 1;ptr2<=n;ptr2++)
    {
        s+=a[ptr2];
        x^=a[ptr2];
        while(s!=x)
        {
            s-=a[ptr1];
            x^=a[ptr1];
            ptr1++;
        }
        res += ptr2-ptr1+1;
    }

    cout<<res;

    return 0;
}


Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;

#define ll long long int
#define str string
#define sec .second

ll MOD = 1000000007, INFL = 1ll << 60, INF = 1 << 30;
ll A[1000000] = {}, X[1000] = {}, coun[60] = {}, bcou[60] = {};
ll dp[100000] = {};
int dy[] = { 0, 0, 1, -1 }, dx[] = { 1, -1, 0, 0 };
vector <ll> v;
ll a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, n = 0, su = 0, ma = INF, mi = -1;
double ans;
pair<str, ll> S[1000];
bool an = false, bn = false;



int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//Code Line
	for (int i = 1; i < 100000; i++)dp[i] = INF;
	cin >> n >> a;
	for (int i = 0; i < n; i++)cin >> A[i];
	for (int i = 0; i < n; i++) {
		for (int j = 1; j <= a; j++) {
			dp[i + j] = min(dp[i + j], abs(A[i] - A[i + j]) + dp[i]);
		}
	}

	cout << dp[n - 1] << endl;
	cin >> n;
	//Code Line
	return 0;
}


Measured memory_bytes: 1792
N = int(input())
abc = []
for i in range(N):
    abc.append(list(map(int, input().split())))
    
happy = [abc[0]]
for i in range(1,N):
    tmp = happy[i-1]
    max_happy = max(tmp)
    max_happy_index = tmp.index(max_happy)
    
    #最大値が2つある場合
    tmp.remove(max_happy)
    if max(tmp)==max_happy:
        max_happy_index = -1
        
    happy_i = [0,0,0]
    for j in range(3):
        if j==max_happy_index:
            happy_i[j] = max(tmp) + abc[i][j]
        else:
            happy_i[j] = max_happy + abc[i][j]
    happy.append(happy_i)

print(max(happy[-1]))

Measured memory_bytes: 75864
/*  -*- coding: utf-8 -*-
 *
 * c.cc: C - Marks
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

const int MAX_N = 200000;

/* typedef */

/* global variables */

int as[MAX_N];

/* subroutines */

/* main */

int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  for (int i = 0; i < n; i++) scanf("%d", as + i);

  for (int i = 0; i + k < n; i++) {
    if (as[i] < as[i + k]) puts("Yes");
    else puts("No");
  }
  return 0;
}


Measured memory_bytes: 3940
s = input()
ans = 'Yes'
for i in range(len(s)):
    if i % 2 == 0 and s[i] == 'L':
        ans = 'No'
        break
    elif i % 2 == 1 and s[i] == 'R':
        ans = 'No'
        break
print(ans)


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

const int MAX = 510000;
 const int MOD = 1000000007;
 
 long long fac[MAX], finv[MAX], inv[MAX];
 
 // テーブルを作る前処理
 void COMinit() {
     fac[0] = fac[1] = 1;
     finv[0] = finv[1] = 1;
     inv[1] = 1;
     for (int i = 2; i < MAX; i++){
         fac[i] = fac[i - 1] * i % MOD;
         inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
         finv[i] = finv[i - 1] * inv[i] % MOD;
     }
 }
 
 // 二項係数計算
 long long COM(int n, int k){
     if (n < k) return 0;
     if (n < 0 || k < 0) return 0;
     return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
 }
 
  long long modpow(long long a, long long n) {
      long long res = 1;
      while (n > 0) {
          if (n & 1) res = res * a % MOD;
          a = a * a % MOD;
          n >>= 1;
      }
      return res;
  }

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string s;
    std::cin >> s;
    if(s[2]==s[3]&&s[4]==s[5]){
        std::cout << "Yes" << std::endl;
    }else{
        std::cout << "No" << std::endl;
    }
}



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

struct Node{ int l=-1,r=-1,p=-1; int d=-1,h=-1; };

UL N;
Node V[100];
int R;

void DFS(UL p){
 int h=0;
 if(V[p].l != -1){
  V[V[p].l].d=V[p].d+1;
  DFS(V[p].l);
  h=max(h,V[V[p].l].h+1);
 }
 if(V[p].r != -1){
  V[V[p].r].d=V[p].d+1;
  DFS(V[p].r);
  h=max(h,V[V[p].r].h+1);
 }
 V[p].h=h;
}

int main() {
 scanf("%u",&N);
 rep(i,N){
  UL v,l,r; scanf("%u%u%u",&v,&l,&r);
  V[v].l=l; V[v].r=r;
  if(l!=-1) V[l].p=v;
  if(r!=-1) V[r].p=v;
 }
 rep(i,N) if(V[i].p==-1) R=i;
 V[R].d=0;
 DFS(R);
 rep(i,N){
  printf("node %u: ",i);
  printf("parent = %d",V[i].p);
  if(V[i].p==-1) printf(", sibling = -1");
  else printf(", sibling = %d",V[V[i].p].l+V[V[i].p].r-i);
  if(V[i].h==0) printf(", degree = 0");
  else if(V[i].l==-1 || V[i].r==-1) printf(", degree = 1");
  else printf(", degree = 2");
  printf(", depth = %d",V[i].d);
  printf(", height = %d",V[i].h);
  if(R==i) printf(", root");
  else if(V[i].h==0) printf(", leaf");
  else printf(", internal node");
  printf("\n");
 }
}



Measured memory_bytes: 3212
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using VS = vector<string>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "-----------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T>inline istream& operator>>(istream& is, deque<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    string a, b; cin >> a >> b;
    if (a.length() > b.length())cout << "GREATER\n";
    else if (a.length() < b.length())cout << "LESS\n";
    else {
        FOR(i, 0, a.length()) {
            if (a[i] > b[i])cout << "GREATER\n";
            else if (a[i] < b[i])cout << "LESS\n";
            else continue;
            return 0;
        }
        cout << "EQUAL\n";
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
constexpr long long MOD = 1000000007;
using ll = long long;
int main() {
string s;
cin>>s;
string word[4] = {"remaerd", "maerd", "esare", "resare"};
reverse(s.begin(), s.end());
ll cnt = 0;
bool flag = true;
while (cnt < s.size()){
    if (s.substr(cnt, 5) == word[1]) cnt += 5;
    else if(s.substr(cnt,5)==word[2])
        cnt += 5;
    else if(s.substr(cnt,7)==word[0])
        cnt += 7;
    else if(s.substr(cnt,6)==word[3])
        cnt += 6;
    else {
        flag=false;
        break;
    }
}
cout << (flag ? "YES" : "NO") << endl;
}


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

typedef long long LL;
const int M=1e5+5;
struct Event
{
	int w,k;
	void read(int k_)
	{
		k=k_;
		scanf("%d",&w);
	}
	bool operator<(const Event &B) const
	{
		return w<B.w;
	}
}e[M*2];
vector<Event> vec;

int main()
{
	int n,m; scanf("%d%d",&n,&m);
	int k=0;
	for(int i=0;i<n;i++)
		e[k++].read(0);
	for(int i=0;i<m;i++)
		e[k++].read(1);
	n++; m++;
	int c=0,r=0;
	LL ans=0;
	sort(e,e+k);
	for(int i=0;i<k;i++)
	{
		if(e[i].k) ans+=1LL*e[i].w*(n-r),c++;
		else ans+=1LL*e[i].w*(m-c),r++;
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 5344
// Copyright 2019 yaito3014
#include "bits/stdc++.h"
using namespace std;
using namespace literals;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<int> P(N);
  for (auto& v : P)cin >> v;
  set<int> s;
  int ans = 0;
  for (int i = 0; i < N; ++i) {
    if (s.lower_bound(P[i]) == s.begin())
      ++ans;
    s.insert(P[i]);
  }
  cout << ans << endl;
}


Measured memory_bytes: 10368
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

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

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(os.Stdout)

	n := getNextInt(scanner)
	a := getNextInt(scanner)
	b := getNextInt(scanner)
	vv := make(Values, n)
	var sum int64
	sum = 0
	for i := 0; i < n; i++ {
		vv[i] = getNextInt64(scanner)
	}

	sort.Sort(vv)

	for i := 0; i < a; i++ {
		sum += vv[i]
	}

	avg := float64(sum) / float64(a)
	var ans int64

	var cm [51][51]int64

	cm[0][0] = 1
	for i := 1; i < 51; i++ {
		for ii := 0; ii <= i; ii++ {
			if ii == 0 || i == ii {
				cm[i][ii] = 1
				continue
			}
			cm[i][ii] = cm[i-1][ii-1] + cm[i-1][ii]
		}
	}

	r := 0
	l := 1
	if vv[a-1] != vv[0] {
		for ii := a - 2; ii >= 0 && vv[ii] == vv[ii+1]; ii-- {
			l++
		}
		for ii := a; ii < n && vv[ii] == vv[ii-1]; ii++ {
			r++
		}
		ans += cm[l+r][l]
	} else {
		for ii := 0; ii < n && vv[ii] == vv[0]; ii++ {
			r++
		}
		for i := a; i < b+1; i++ {
			ans += cm[r][i]
		}
	}

	fmt.Fprintln(writer, fmt.Sprintf("%f", avg))
	fmt.Fprintln(writer, ans)
	writer.Flush()
}

type Values []int64

func (a Values) Len() int           { return len(a) }
func (a Values) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a Values) Less(i, j int) bool { return a[i] > a[j] }


Measured memory_bytes: 640
#include<stdio.h>

int binarySearch(int,int *,int);

int main(){
  int a,S[100000],b,T[50000],i,j,k=0;
  scanf("%d",&a);
  for(i=0;i<a;i++){
    scanf("%d",&S[i]);
  }
  scanf("%d",&b);
  for(j=0;j<b;j++){
    scanf("%d",&T[j]);
    if(binarySearch(a,S,T[j])==1)
      k++;
    else if(binarySearch(a,S,T[j])==0)
      continue;
  }
  printf("%d\n",k);
  return 0;
}
int binarySearch(int n,int *A,int key){
  int left,right,mid;
  left = 0;
  right = n;
  while(left<right){
    mid = (left+right)/2;
    if(A[mid]==key)
      return 1;
    else if(key<A[mid])
      right = mid;
    else
      left = mid+1;
  }
  return 0;
}
      
	      



Measured memory_bytes: 3320
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int main() {
   ll n;cin>>n;
   vector<ll>p,q,a;
   for(ll i=0;i<n;i++){ll x;cin>>x;p.push_back(x);}
   for(ll i=0;i<n;i++){ll x;cin>>x;q.push_back(x);}
   for(ll i=0;i<n;i++){a.push_back(i+1);}
   ll cnt=1,idx1=0,idx2=0;
    do{bool ok1=0,ok2=0;
       for(ll i=0;i<n;i++){if(a[i]!=p[i]){ok1=1;break;}}
        for(ll i=0;i<n;i++){if(a[i]!=q[i]){ok2=1;break;}}
       if(!ok1)idx1=cnt;
       if(!ok2)idx2=cnt;
       cnt++;
    }while(next_permutation(a.begin(),a.end()));
    
    cout<<abs(idx1-idx2);
}

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

public class Main {
    public static void main(String[] args) throws IOException {
        try (PrintWriter writer = new PrintWriter(System.out); InputReader reader = new InputReader(System.in)) {
            char[] inputs = reader.readLine().toCharArray();
            int ans = 700;
            for (char a : inputs) {
                if (a == 'o') {
                    ans += 100;
                }
            }

            System.out.println(ans);
        }
    }
}

class InputReader implements Closeable, AutoCloseable {
    private final BufferedReader br;

    InputReader(InputStream inputStream) {
        this.br = new BufferedReader(new InputStreamReader(inputStream));
    }

    String readLine() throws IOException {
        return this.br.readLine();
    }

    int readInt() throws IOException {
        return Integer.parseInt(this.br.readLine());
    }

    long readLong() throws IOException {
        return Long.parseLong(this.br.readLine());
    }

    String[] readStringsSplitByDelimiter(String delimiter) throws IOException {
        return this.br.readLine().split(delimiter);
    }

    int[] readIntsSplitByDelimiter(String delimiter) throws IOException {
        String[] strings = this.br.readLine().split(delimiter);

        int stringsLength = strings.length;
        int[] ints = new int[stringsLength];
        for (int i = 0; i < stringsLength; i++) {
            ints[i] = Integer.parseInt(strings[i]);
        }

        return ints;
    }

    long[] readLongsSplitByDelimiter(String delimiter) throws IOException {
        String[] strings = this.br.readLine().split(delimiter);

        int stringsLength = strings.length;
        long[] longs = new long[stringsLength];
        for (int i = 0; i < stringsLength; i++) {
            longs[i] = Long.parseLong(strings[i]);
        }

        return longs;
    }

    @Override
    public void close() throws IOException {
        br.close();
    }
}

Measured memory_bytes: 22740
#include <iostream>
#include <string>
#include <set>
using namespace std;
int main(){
    string s; cin >> s;
    set<char> st;
    for(int i = 0; i < s.size(); i++){
        st.insert(s[i]);
    }
    for(int i = 0; i < 26; i++){
        char c = 'a';
        char now = (char)(c + i);
        if(st.count(now) == 0){
            cout << now << endl;
            return 0;
        }
    }
    cout << "None" << endl;
    return 0;
}

Measured memory_bytes: 512
//inlclude前用define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<cstdio>
#include<type_traits>
#include<numeric>
#include<limits>
#include<iomanip>
#include<set>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;

//define
#define INF 100000000
#define NUM 1000000007

int main() {
	int n;
	cin >> n;
	VI x1(n), x2(n);
	for (int i = 0; i < n; i++) cin >> x1[i];
	for (int i = 0; i < n; i++) cin >> x2[i];

	int sum,maxv=-1;
	for (int i = 0; i < n; i++) {
		sum = 0;
		for (int j = 0; j <= i; j++) {
			sum += x1[j];
		}

		for (int j = i; j < n; j++) {
			sum += x2[j];
		}
		if (max(maxv, sum) == sum) maxv = sum;
	}
	cout << maxv << endl;
	return 0;
}

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

string s[100000];

signed main(){
    int n;
    map<string,int>mp;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>s[i];
        sort(s[i].begin(),s[i].end());
        mp[s[i]]++;
    }
    int ans=0;
    for(auto x:mp)
        ans+=(x.second-1)*x.second/2;
    cout<<ans<<endl;
}


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

void solve(std::istream& ist, std::ostream& ost)
{
    /* ------- 宣言と入力 ------- */

int K;
    ist >> K;


    /* ------- 計算 ------- */

        int N[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};


ost << N[K-1] << endl;

}

#ifndef WOMAIN
int main()
{
    solve(std::cin, std::cout);
    return 0;
}
#endif



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define pb push_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
typedef long long ll;
#define se second
#define fi first
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef multiset<ll> S;
typedef priority_queue<ll> PQ;
typedef priority_queue<P,vector<P>,greater<P>> SPQ;
using vi=vector<ll>;
using vvi=vector<vector<ll>>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double pi=3.14159265358979323846;
bool chmin(auto &a,auto b){if(a>b){a=b;return true;}return false;}
bool chmax(auto &a,auto b){if(a<b){a=b;return true;}return false;}
void outvi(vi v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<endl;}
void outvvi(vvi v){rep(i,v.size()){rep(j,v[i].size()){if(j)cout<<' ';cout<<v[i][j];}cout<<endl;}}

int main(){
    ll sx,sy,gx,gy,n;cin>>sx>>sy>>gx>>gy>>n;
    if(sy>gy){
        swap(sx,gx);
        swap(sy,gy);
    }
    vector<P> v;
    rep(i,n){
        ll a,b;cin>>a>>b;
        if(((sx<=a&&a<=gx)||(gx<=a&&a<=sx))&&sy<=b&&b<=gy)v.eb(a,b);
    }
    n=v.size();
    if(sx>gx){
        sx=2*gx-sx;
        rep(i,n)v[i].fi=2*gx-v[i].fi;
    }
    sort(all(v));
    vi dp(n+1,inf);
    rep(i,n){
        ll u=lb(dp,v[i].se);
        dp[u]=v[i].se;
    }
    ll ans;
    rep(i,n+1){
        if(dp[i]==inf){
            ans=i;
            break;
        }
    }
    cout<<fixed<<setprecision(15);
    if(ans==min(gx-sx,gy-sy)+1)cout<<((gx-sx)+(gy-sy))*100+5*pi*(ans+1)-20*ans<<endl;
    else cout<<((gx-sx)+(gy-sy))*100+5*pi*ans-20*ans<<endl;
}

Measured memory_bytes: 6512
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
   
using namespace std;
typedef long long int ll;
  
int main()
{
	string s;
	cin>>s;
	string ans;
	for(int i=0; i<s.length(); i++){
		if(s[i]!='B'){
			ans+=s[i];
		}else if(ans.length()){
			ans.pop_back();
		}
	}
	cout<<ans<<endl;
    return 0;
}

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

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

    ll count = 0;
    // ll dp[11];

    // dp[0] = 0;  // 0桁
    // dp[1] = 9;  // 1桁
    // for (int i = 2; i <= 10; i++) {
    //     dp[i] = dp[i-1] * 3 - 1;
    //     printf("dp[%d] = %d\n", i, dp[i]);
    // }

    if (K < 10) {
        cout << K << endl;
        return 0;
    }

    vector<ll> a = {1, 2, 3, 4, 5, 6, 7, 8, 9};
    count = 9;

    for (int digit = 1; digit <= 11; digit++) {
        vector<ll> b;

        for (auto x : a) {
            ll last = x % 10;

            if (last != 0) {
                b.push_back(x * 10 + last - 1);
                count++;
                if (count == K) {
                    cout << b.back() << endl;
                    return 0;
                }
            }
            
            b.push_back(x * 10 + last);
            count++;
            if (count == K) {
                cout << b.back() << endl;
                return 0;
            }            

            if (last != 9) {
                b.push_back(x * 10 + last + 1);
                count++;
                if (count == K) {
                    cout << b.back() << endl;
                    return 0;
                }
            }
        }

        swap(a, b);
    }
}


Measured memory_bytes: 4132
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <sstream>
#include <string>
#include <map>
#include <set>
using namespace std;

#define rep(i, n) for (int i=0; i<int(n); i++)


//ABC111_b
int main() {
	int N;
	cin >> N;
	int a, b, c;
	a = N/100;
	b = (N/10)%10;
	c = N - 100*a - 10*b;
	int res;
	if (a >= b and a >= c) res = a * 111;
	else res = (a+1) * 111;
	cout << res << endl;
}

Measured memory_bytes: 256
# AGC010A - Addition
def main():
    # all evens and pairs of odds become a single number
    # -> check an odd (not pair) remains or not <-> parity of A
    N, *A = map(int, open(0).read().split())
    flg = sum(A) % 2 == 0
    print("YES" if flg else "NO")


if __name__ == "__main__":
    main()

Measured memory_bytes: 14060
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

typedef boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>> cpp_dec_float_1000;

constexpr char CRLF = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }

void solve(void)
{
  int H, W; cin >> H >> W;
  int A, B; cin >> A >> B;

  char res{'0'};
  constexpr char ICHI = 0x01;
  for (int row = 0; row < H; ++row){
    res ^= ICHI;
    if(row == B) res ^= ICHI;
    for (int column = 0; column < W; ++column){
      if(column == A) res ^= ICHI;
      cout << res;
    }
    cout << CRLF;
  }

  return;
}

int main(void)
{
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);

  solve();

  return 0;
}


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

int main() {
    int h, w, n;
    cin >> h >> w >> n;
    int a[n];
    int ans[h][w] = {};
    rep(i,n) cin >> a[i];
    int p = 0;
    rep(i,n) {
        rep(j,a[i]) {
            ans[p/w][p%w] = i+1;
            p++;
        }
    }
    rep(i,h) {
        rep(j,w) {
            if (i % 2 == 0) cout << ans[i][j];
            else cout << ans[i][w-j-1];
            if (j < w-1) cout << " ";
        }
        cout << endl;
    }
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
//#include <atcoder/all>
#define rep(i, n) for (int i=0; i < (n); i++)
using namespace std;
//using namespace atcoder;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> P;
const int INF = 1 << 30;
const ll LINF = 1LL << 61;
const int NIL = -1;
const int MAX = 10000;
const int MOD = 1000000007;
const double pi = 3.141592653589;

int main() {
    int d, n;
    cin >> d >> n;
    if (n == 100) n += 1;
    rep(i,d) n *= 100;
    cout << n << endl;
    return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
#define FAST_IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

int main(int argc, char const *argv[])
{
	FAST_IO
	
	int a, b, c, k;
	cin >> a >> b >> c >> k;
	int sum = 0;

	if(a <= k && k > 0) { sum += a; k -= a; } 
	else { sum += k; k = 0; } 
	
	if(b <= k && k > 0) k -= b; 
	else k = 0; 

	if(c <= k && k > 0) { sum -= c; k -= c; }
	else { sum -= k; k = 0; }
	
	cout << sum;
	return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <cstdio>
#include <string>

#define MAX 100001
#define NIL -1

using namespace std;

//left-child,right-sibling representation
struct Node{int parent,left,right;};

struct Node T[MAX];

int getDepth(int idx){
  int dep=0;
  while(T[idx].parent!=NIL){
    idx=T[idx].parent;
    dep++;
  }
  return dep;
}

string getState(int idx){
  if(T[idx].parent==NIL){
    return "root";
  }else if(T[idx].left==NIL){
    return "leaf";
  }else{
    return "internal node";
  }
}

int main(){
  int n; cin >> n;
  for(int i=0;i<n;i++){
    T[i].parent=NIL;
    T[i].left=NIL;
    T[i].right=NIL;
  }
  for(int i=0;i<n;i++){
    int id,k; scanf("%d %d",&id,&k);
    if(k==0) continue;
    int x; cin >> x;
    T[x].parent=id; T[id].left=x;
    for(int i=1;i<k;i++){
      int c; scanf("%d",&c);
      T[c].parent=id;
      T[x].right=c;
      x=T[x].right;
    }
  }
  for(int i=0;i<n;i++){
    printf("node %d: parent = %d, depth = %d, ",i, T[i].parent, getDepth(i));
    cout << getState(i) << ", ";
    cout << "[";
    if(T[i].left!=NIL){
      printf("%d",T[i].left);
      int sib=T[T[i].left].right;
      while(sib!=NIL){
        printf(", %d",sib);
        sib=T[sib].right;
      }
    }
    cout << "]" << endl;
  }
}

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

int main() {
	int A, B;
  	cin >> A >> B;
  
  if (A > B*2){
  	cout << A - B*2 << endl;
  }
  else if (A <= B*2){
  	cout << "0" << endl;
  }
}

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

int main() {
	int n,m;cin>>n>>m;
	vector<int> v(n);
	int tot=0;
	for(int i=0;i<n;++i){
		cin >> v[i];
		tot += v[i];
	}
	sort(v.begin(),v.end(),greater<int>());
	bool isok = true;
	for(int j=0;j<m;++j){
		if(4*m*v[j]<tot) {
			isok =false;
		}
	}
	if(isok){
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 3640
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<unordered_map>
#include<set>
#include<cstring>
#include<iomanip> //cout << fixed << setprecision(15) << x << endl;

using namespace std;
typedef long long ll;
const ll INF = 1e9 + 6;
const ll MOD = 1e9 + 7;
const ll LLINF = 1e18;
#define Pint pair<int, int>
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rnr(i,a,b) for(int i=int(a);i>=int(b);i--)
#define rep(i,b) rng(i,0,b)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
/* -- template -- */

int solve(int x) {

}

int main() {
    int n; cin >> n;
    vector<int> ans(n + 1, 0);
    //全探索し，ans[x]をインクリメント
    for(int x = 1; x * x <= n; ++x) {
        for(int y = 1; y * y <= n; ++y) {
            for(int z = 1; z <= n; ++z) {
                int num = x * x + y * y + z * z + x * y + y * z + x * z;
                if(num > n) break;
                ans[num]++;
            }
        }
    }
    rep(i, n) {
        cout << ans[i + 1] << endl;
    }
}


Measured memory_bytes: 3468
k,n = map(int,input().split())
a_ = list(map(int,input().split()))

#N個の区間の中で最大距離の区間以外の和を取ると良い
disList = []
for i in range(n):
    if i == n-1:
        dis = k - a_[i] + a_[0]
        disList.append(dis)
    else:
        dis = a_[i+1] - a_[i]
        disList.append(dis)
max = max(disList)
disList.remove(max)

print(sum(disList))


Measured memory_bytes: 25840
/**
 *    Author: "Robin Singh" !!
 *    rob_in_1
**/

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

#define dbg( args...) { vector<string> _v = split( #args, ','); err( _v.begin(), args); cerr << '\n'; }
vector<string> split( const string& s, char c) { vector<string> v; stringstream ss( s); string x; 
while ( getline( ss, x, c)) v.emplace_back(x); return move(v); }
void err( vector<string>::iterator it) { } 
template<typename T, typename... Args>
void err( vector<string>::iterator it, T a, Args... args) {
cerr << it -> substr( ( *it)[0] == ' ', it -> length()) << " = " << a << '\t'; err( ++it, args...); }

#define int long long
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())
#define ff first
#define ss second
#define MP make_pair
#define szz(v) ((int)(v).size())  
#define fr(i, j, k) for(int i = j; i < k; i++)     
#define bk(i, j, k) for(int i = j-1; i >= k; i--)
#define mem(ptr, val)  memset(ptr, val, sizeof ptr)
#define sbit(n)  __builtin_popcount(n)
#define nl "\n"

typedef long double ld;
typedef pair<int, int> pii;
typedef vector <int> vi;
typedef vector < pair<int,int> > vpii;
const long double eps = 1e-9;
const int mod = 1e9+7;

pii dir[8] = { {-1, 0}, {1, 0}, {0, -1}, {0, 1}, {1, 1}, {-1, -1} , {-1, 1}, {1, -1} };

//*********************************!Template Ends Here!**********************************//

const int nn = 2e5+5;
vi g[5];

void robin(){
	fr(i, 0, 3){
		int u, v;
		cin >> u >> v;
		g[u].pb(v);
		g[v].pb(u);
	}

	fr(i, 1, 5){
		// dbg(i, szz(g[i]));
		if(szz(g[i]) == 3){
			cout << "NO";
			return;
		}
	}
	cout << "YES";
}

int32_t main(){
    // freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int T = 1;
    // cin >> T;
    for(int tc = 1; tc <= T; tc++){
    	// cout << "Case #" << tc << ": ";
    	robin();
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
#define pb push_back
#define pii pair < int , int >
#define F first
#define S second
#define endl '\n'
#define int long long
#define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#define kill(x) return cout<<x<<'\n', 0;
using namespace std;
const int N=2e5+100;
vector <int> g[N];
ll vis[N];
void dfs(ll v,ll p){
    for (auto u : g[v]){
        if (u==p) continue;
        dfs(u,v);
        if (vis[u]==0 && vis[v]==0){
            vis[u]=1;
            vis[v]=1;
        }
    }
}
int32_t main(){
    sync;
    ll n;
    cin >> n;
    for (int i=0;i<n-1;i++){
        ll u,v;
        cin >> u >> v;
        g[u].pb(v);
        g[v].pb(u);
    }
    dfs(1,1);
    for (int i=1;i<=n;i++) if (vis[i]==0) kill("First");
    kill("Second");
}


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

int main(){
	lint a,b,c,k;//a = 1 b = 0 c = -1
	cin >> a >> b >> c >> k;
	lint total = 0;

	if (a >= k)
		total = k;
	else{
		total = a;
		if (a + b < k){
			rep(i,k-a-b)
				total -= 1;
		}
	}
	cout << total;
	return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
template<typename T = int> vector<T> create(size_t n){ return vector<T>(n); }
template<typename T, typename... Args> auto create(size_t n, Args... args){ return vector<decltype(create<T>(args...))>(n, create<T>(args...)); }
const int maxn = 1'000'001, mod = 1'000'000'007;
int add(int a, int b){
	a += b;
	if(a >= mod) a -= mod;
	return a;
}
int sub(int a, int b){
	return add(a, (mod - b) % mod);
}
int mul(long long a, long long b){
	return (a * b) % mod;
}
int pwr(int a, int b){
	int r = 1;
	for(; b; b >>= 1, a = mul(a, a))
		if(b&1)
			r = mul(r, a);
	return r;
}
int fact[maxn], ifact[maxn];
void init(){
	fact[0] = 1;
	for(int i = 1; i < maxn; i++)
		fact[i] = mul(fact[i - 1], i);
	ifact[maxn - 1] = pwr(fact[maxn - 1], mod - 2);
	for(int i = maxn - 2; i >= 0; i--)
		ifact[i] = mul(ifact[i + 1], i + 1);
}
int ncr(int n, int r){
	if(n < r) return 0;
	return mul(fact[n], mul(ifact[r], ifact[n - r]));
}
int comb(int n, int r){
	if(n < r) return 0;
	return mul(fact[n], ifact[n - r]);
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	init();
	int n, m;
	cin >> n >> m;
	int ans = 0;
	for(int i = 0; i <= n; i++){
		int rest = pwr(comb(m - i, n - i), 2);
		int use = ncr(n, i);
		use = mul(use, comb(m, i));
		int t = mul(use, rest);
		if(i % 2) ans = sub(ans, t);
		else ans = add(ans, t);
	}
	cout << ans << '\n';
	return 0;
}


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

int n;

int main(){
  cin >> n;
  set<int> d;
  rep(i, n){
    int tmp; cin >> tmp;
    d.insert(tmp);
  }
  cout << d.size() << endl;
}


Measured memory_bytes: 256
def judge(s)
    n = s.size/2
    n.times do |i|
        return false if s[i] != s[i + n]
    end
    return true
end

s=gets.chomp
n=s.size/2
(n-1).downto(1) do |i|
    if judge(s[0...(2*i)])
        p 2*i
        break
    end
end

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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

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

    int64_t ans = 0;
    for (int64_t i = 2; i * i <= n; ++i) {
        if (n % i == 0) {
            int64_t t = 0;
            while (n % i == 0) {
                n /= i;
                ++t;
            }

            // cerr << i << "," << t << endl;
            int64_t j = 1;
            while (t - j >= 0) {
                t -= j;
                ++j;
                ++ans;
            }
        }
    }

    if (n != 1) {
        ++ans;
    }

    cout << ans << endl;
}

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

int main(){
  int n;cin >> n;
  int l[n];rep(i,n)cin >> l[i];
  int ans = 0;
  for(int i=0;i<n;++i){
    for(int j=i+1;j<n;++j){
      for(int k=j+1;k<n;++k){
        if(max({l[i],l[j],l[k]}) < l[i]+l[j]+l[k] - max({l[i],l[j],l[k]})){
          if(l[i] != l[j] && l[j] != l[k] && l[i] != l[k])ans += 1;
        } 
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3564
/*
	Name:
	Author: xiaruize
	Date:
*/
#pragma GCC optimize(2)
#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define MOD 1000000007
#define ALL(a) (a).begin(), (a).end()
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define ll long long
#define form(i,j,n) for(int i=int(j);i<=int(n);i++)
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define pis pair<int,string>
#define sec second
#define sz(a) int((a).size())

inline int read()
{
    char ch=getchar();
    int x=0,f=1;
    while(ch<'0'||ch>'9'){if(ch=='-') f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9') x=x*10+(ch^48),ch=getchar();
    return x*f;
}

int main()
{
 	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
 	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
 	int n,m;
    cin>>n>>m;
    ll dp[n+1];
    ll ans=m-n+1;
    dp[0]=1;
    dp[1]=m-n;
    for(int i=2;i<=n;i++)
    {
        dp[i]=((m-n+i-1)*dp[i-1]+(i-1)*dp[i-2])%MOD;
        ans=ans*(m-i+2)%MOD;
    }
    cout<<ans*dp[n]%MOD<<endl;
}


Measured memory_bytes: 7512
#include <bits/stdc++.h>
  
using namespace std;
  
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
  
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
  
#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update> 
  
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
  
const int inf = int(1e9);
const int mod = inf + 7;
const int N = 1e6 + 555; // TL MB
const double PI = acos(-1.0);
 
void mul(ll &x, ll y){
	x *= y;
	if(x >= mod) x %= mod;
}
 
void add(ll &x, ll y){
	x += y;
	if(x >= mod) x -= mod;
	if(x < 0) x += mod;
}
ll bp(ll a, ll n){
	ll r = 1;
	while(n){
		if(n & 1) mul(r, a);
		mul(a, a);
		n >>= 1;
	}
	return r;
}
 
 
ll a[N], res;
void solve(){
	int n, k;
	cin >> n >> k;
	for(int i = k; i >= 1; --i){
		ll tmp = bp(k / i, n);
		for(ll j = i * 2; j <= k; j += i){
			tmp -= a[j];
			tmp += mod;
			tmp %= mod;
		}
		a[i] = tmp;
		res += tmp * i % mod;
		res %= mod;
	}
	cout << res;
}
 
 
 
 
int main()
{
    Red;
  	// int T; cin >> T; while(T--)
    solve();
    return 0;
}

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<tuple<int, int, string>> a(m);
  vector<bool> pp(n);
  rep(i,m) {
    int p;
    string s;
    cin >> p >> s;
    a.at(i) = make_tuple(p, i, s);
    if(s=="AC") pp.at(p-1)=true;
  }
  sort(a.begin(),a.end());
  int AC=0, WA=0, k=0;

  rep(i,m) {
    while(k<n&&!pp.at(k)) k++;
    if(get<0>(a[i])==k+1&&get<2>(a[i])=="WA") {
        WA++;
        continue;
    }
    else if(get<0>(a[i])==k+1&&get<2>(a[i])=="AC") {
        AC++;
        k++;
    }
  }
  cout <<AC <<" " << WA << endl;  
}


Measured memory_bytes: 6528
# include<iostream>
# include<cmath>
using namespace std;
const int INF = pow(10,9)+7;
int main ()
{
	
	int H,N;
	cin>>H>>N;
	int A[N],B[N];
	int dp[H+1];
	for(int i=0;i<H+1;i++)
	{
		dp[i]=INF;
	}
	for(int i=0;i<N;i++)
	{
		cin>>A[i]>>B[i];
	}
	dp[0] =0;
	for(int i=0;i<N;i++)
	{
		 for(int j=1;j<=H;j++)
		 {
		 	  dp[j] = min(dp[j],dp[max(0,j-A[i])]+B[i]);
		 }
		 
	 
		 
	}

	
	
	
	cout<<dp[H]<<endl;
	
	
	
}

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

int main(){
  int x, y;
  while(1){
    cin>>x>>y;
    if(x==0&&y==0) break;
    if(x>y) cout<<y<<" "<<x<<endl;
    else cout<<x<<" "<<y<<endl;
  }
  return 0;
}

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

unsigned int euclid(unsigned int a,unsigned int b){
  if(b==0) return a;
  return euclid(b,a%b);
}

int main(void){
  unsigned int a,b;
  while(fscanf(stdin,"%u %u",&a,&b)!=EOF) cout<<euclid(a,b)<<endl;
  return 0;
}

Measured memory_bytes: 0
import java.util.*;

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

      String s = sc.next();
      int lng = s.length();
      char[] c = new char[lng];
      String[] ccc = new String[lng];
      String[] cc = new String[lng];



      int cnt = 0;

      for(int i=0;i<lng;i++){
        c[i] = s.charAt(i);
        ccc[i] = String.valueOf(c[i]);
      }

      int flag = 0;

      for(int i=0;i<lng-1;i++){
        if(i==0){
          cc[cnt] = ccc[i];
        }
        else{
          if(cc[cnt-1].equals(ccc[i])){
            cc[cnt] = ccc[i] + ccc[i+1];
            if(i==lng-2){flag = 1;}
            i++;
          }
          else{
            cc[cnt] = ccc[i];
          }
        }
        cnt++;
      }

      int ans = 0;

      if(!(cc[cnt-1].equals(ccc[lng-1])) && flag == 0){
        ans++;
      }

      for(int i=0;i<lng;i++){
        if(cc[i] != null){
          ans++;
        }
      }

      System.out.println(ans);
    }
}


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

#define int long long
#define reps(i,s,n) for(ll (i)=(s);(i)<(ll)(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) reps(i,0,n+1)
#define repst(i,s,n) reps(i,s,n+1)
#define reprt(i,n,t) for(ll (i)=(n);(i)>=t;--(i))
#define repr(i,n) reprt(i,n,0)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb emplace_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define dbg(x) cout<<#x" = "<<(x)<<ln
#define dbga(x,n) for(int (i)=0;i<n;++i){cout<<x[i]<<(i==n-1?'\n':' ');}

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<ld> vld;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

// a[l], a[l+1], ..., a[r-1]の平均がk以上 というのは↓のように言い換えられる
// https://drive.google.com/open?id=1TXSdOrUMMpPNGxPieiC2hORo8_wAEIJi
// 配列bをO(n)で作ってからbの値を[0,n-1]に圧縮して、
// あとはBITで各iについてb[0], b[1], ..., b[i-1]のうちb[i]以下のものだけカウントして答えに加算していく感じで
// 式変形がポイント

int n, k, a[200200], b[200200], r;
pii c[200200];
int bit[200200];

int sum(int i) {
	int s = 0;
	while (i>0) {
		s += bit[i];
		i -= i & -i;
	}
	return s;
}

void add(int i, int x) {
	while (i<=n+2) {
		bit[i] += x;
		i += i & -i;
	}
}

signed main() {
	cin >> n >> k;
	rep(i,n) cin >> a[i];
	repst(i,1,n) {
		a[i] += a[i-1];
		b[i] = a[i-1] - i*k;
		c[i].fi = b[i], c[i].se = i;
	}
	sort(c, c+1+n);
	// 同じ値があるときに注意
	int s = 1;
	rept(i,n) {
		if (i>0 && c[i].fi!=c[i-1].fi) s++;
		b[c[i].se] = s;
	}
	rept(i,n) {
		r += sum(b[i]);
		add(b[i],1);
	}
	cout << r << ln;
}

Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> lP;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}

bool cmp(const lP &a, const lP &b){
    return (a.first+a.second)>(b.first+b.second);
}

int main()
{
    int n;
    cin >> n;
    vector<lP> ab;
    vector<ll> food;
    rep(i, n){
        ll tmp1, tmp2;
        cin >> tmp1 >> tmp2;
        ab.push_back({tmp1, tmp2});
    }
    sort(ab.begin(), ab.end(), cmp);
    
    ll taka = 0;
    ll aok = 0;

    rep(i, n){
        if ((i%2)==0){
            taka+=ab[i].first;
        }else{
            aok+=ab[i].second;
        }
    }
    printf("%lld\n", taka-aok);
}



Measured memory_bytes: 2420
#include<stdio.h>

int main(void){
    int n, r;
    scanf("%d""%d", &n, &r);
    if(n >= 10){
        printf("%d\n", r);
    }else{
        printf("%d\n", 100 * (10 - n) + r);
    }
    return 0;
    
}

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

using namespace std;

#define endl '\n'

const int MOD = 1e9 + 7;
vector<vector<char> > grid;
int dp[1001][1001];

int solve(int i, int j, int h, int w) {
  if (i < 0 || i >= h || j < 0 || j >= w || grid[i][j] == '#')
    return 0;
  if (dp[i][j] != -1) return dp[i][j];
  return dp[i][j] = (solve(i - 1, j, h, w) + solve(i, j - 1, h, w)) % MOD;
}

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

  int h, w;
  cin >> h >> w;
  for (int i = 0; i < h; i++) {
    vector<char> aux(w);
    grid.push_back(aux);
  }
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      cin >> grid[i][j];
      dp[i][j] = -1;
    }
  }
  dp[0][0] = 1;
  solve(h - 1, w - 1,h,w);
  cout << dp[h - 1][w - 1] << endl;

	return 0;
}


Measured memory_bytes: 8192
#include <bits/stdc++.h>
using namespace std;
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; }

 
int main() {
  string S;
  cin >> S;
  int number=0;
  number=S.size();
  for(int i=0;i<number;i++){
    cout << "x";
  }
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main {
    static long MOD = 1000*1000*1000 + 7;
    public static void main(String args[]) {
        int n = 0;
        
        int[][] met = null;
        try (Scanner scanner = new Scanner(System.in)) {
            n = scanner.nextInt();
            met = new int[n][n];
            for(int i = 0; i < n ;i++) {
                for(int j = 0; j < n ;j++) {
                    met[i][j] = scanner.nextInt();
                }
            }
        }
        
        // we can go away from dp[men][1<<n] to dp[1<<n] because we are using men to get to met[men][w]
        // we are remove that loop and count number of bit set in wmask to give number of men already mapped.
        // we can do so because if a bit is 1 in wmask it mush be matching to anyone man. 
        long[] dp = new long[1<<n];
        dp[0] = 1;
        // for(int m = 0; m < n; m++) {
            for(int wmask = 0; wmask < (1<<n) ; wmask++) {
                int m = Integer.bitCount(wmask);
                for(int w = 0; w < n; w++) {
                    if((wmask & (1<<w)) ==0 && met[m][w] == 1){
                        int newWMask = wmask | (1<<w);
                        dp[newWMask] += dp[wmask]; 
                        // System.out.println(dp[m][newWMask] + " " + newWMask + " " + wmask);
                        if(dp[newWMask] >= MOD)
                            dp[newWMask] -= MOD;
                    }
                }
            }
        // }
        // System.out.println(Arrays.toString(dp));
        System.out.println(dp[(1<<n) - 1]);
        
    }
    
}

Measured memory_bytes: 40532
###template###
import sys
def input(): return sys.stdin.readline().rstrip()
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
import heapq
INF = float("inf")
MOD = 10**9 + 7
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 mi(): return map(int, input().split())
def ii(): return int(input())
###template###

N, K = mi()
As = list(mi())

c_m = [] # cumsum_minus
c_p = [] # cumsum_plus

#番兵的に0を追加しておく
c_m.append(0)
c_p.append(0)

for a in As:
  if a <= 0:
    c_m.append(c_m[-1] + a)
    c_p.append(c_p[-1])
  else:
    c_p.append(c_p[-1] + a)
    c_m.append(c_m[-1])


ans = -INF
for i in range(N-K+1): #0 ~ N-K までループ
  # [i, i+K) を all or nothing にする
  tmpans = 0
  tmpans += max(0, c_m[i+K] - c_m[i] + c_p[i+K] - c_p[i])
  tmpans += c_p[i] + c_p[N] - c_p[i+K]#左端からi-1までの累積和([i-1+1]) + i+kから右端までの累積和 [i+k, N)
  ans = max(ans, tmpans)

print(ans)






Measured memory_bytes: 67344