akhauriyash/Code-Regression huggingface dataset:
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
    static int[] h = new int[100010];
    static int[] dp = new int[100010];
    static int k;

    static int chmin(int a, int b) {
        if (a > b) {
            a = b;
            return b;
        }
        return a;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        k = sc.nextInt();
        Arrays.fill(dp, Integer.MAX_VALUE);
        int res = Integer.MAX_VALUE;
        dp[0] = 0;
        for (int i = 0; i < n; i++) {
            h[i] = sc.nextInt();
        }

        for (int i = 0; i < n; i++) {
            for (int j = 1; i + j < n && j <= k; j++) {
                dp[i + j] = chmin(dp[i + j], dp[i] + Math.abs(h[i] - h[i + j]));
            }
        }
        System.out.println(dp[n - 1]);
    }
}


Measured memory_bytes: 59216
N=int(input())
TXY=[list(map(int,input().split())) for _ in range(N)]

txy=[]
Current_t,Current_x,Current_y=0,0,0
for i in range(N):
    txy=TXY[i]
    t,x,y=txy[0],txy[1],txy[-1]
    sa_t=t-Current_t
    sa_x=x-Current_x
    sa_y=y-Current_y

    if sa_t<sa_x+sa_y or sa_t%2!=(sa_x+sa_y)%2:
        print('No')
        exit()  
        
    Current_t=t
    Current_x=x
    Current_y=y

print('Yes')


Measured memory_bytes: 27380
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll ; 
typedef long double ld ;
typedef pair<ll , ll> pll ;

const ll N = 2e5 + 30 , Mod = 1e9 + 7 ;
const ll SQ = 330 ;

string to(ll x) {
	string s = "" ;
	while (x) {
		s += '0' + (x % 10) ;
		x /= 10 ;
	}
	while (s.size() < 3) s += "0" ;
	reverse(all(s)) ;
	return s ;
}
int main () {
    ios::sync_with_stdio(0), cin.tie(0) ;
    ll n ;
    cin >> n ;
    string s ;
    cin >> s; 
    ll ans = 0 ;
    for (int i = 0 ; i < 1000 ; i ++) {
    	string t = to(i) ;
    	ll po1= 0 , po2 = n - 1 ;
    	while (po1 < n && s[po1] != t[0]) po1 ++ ;
    	while (po2 && s[po2] != t[2]) po2 -- ;
    	ll ok = 0 ;
    	for (int j = po1 + 1 ;  j < po2 ; j ++) if (s[j] == t[1]) ok = 1 ;
    	ans += ok ;
	}
	cout << ans ;
    return (0) ;
}

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

using namespace std;

#define int long long
#define ar array
#define vt vector
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define sz(x) (int)(x).size()

#define F_OR(i, a, b, s) for (int i=(a); (s)>0?i<(b):i>(b); i+=(s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define FOR(...) F_ORC(__VA_ARGS__)(__VA_ARGS__)
#define EACH(x, a) for (auto& x: a)

template<class T>
bool umin(T &a, const T &b) {
    return b < a ? a = b, 1 : 0;
}

template<class T>
bool umax(T &a, const T &b) {
    return a < b ? a = b, 1 : 0;
}

template<class A>
void read(vt<A> &v);

template<class A, size_t S>
void read(ar<A, S> &a);

template<class T>
void read(T &x) {
    cin >> x;
}

void read(double &d) {
    string t;
    read(t);
    d = stod(t);
}

void read(long double &d) {
    string t;
    read(t);
    d = stold(t);
}

template<class H, class... T>
void read(H &h, T &... t) {
    read(h);
    read(t...);
}

template<class A>
void read(vt<A> &x) {
    EACH(a, x)read(a);
}

template<class A, size_t S>
void read(array<A, S> &x) {
    EACH(a, x)read(a);
}

string to_string(char c) {
    return string(1, c);
}

string to_string(bool b) {
    return b ? "true" : "false";
}

string to_string(const char *s) {
    return string(s);
}

string to_string(string s) {
    return s;
}

string to_string(vt<bool> v) {
    string res;
    FOR(sz(v))res += char('0' + v[i]);
    return res;
}

template<size_t S>
string to_string(bitset<S> b) {
    string res;
    FOR(S)res += char('0' + b[i]);
    return res;
}

template<class T>
string to_string(T v) {
    bool f = 1;
    string res;
    EACH(x, v) {
        if (!f)
            res += ' ';
        f = 0;
        res += to_string(x);
    }
    return res;
}

template<class A>
void write(A x) {
    cout << to_string(x);
}

template<class H, class... T>
void write(const H &h, const T &... t) {
    write(h);
    write(t...);
}

void print() {
    write("\n");
}

template<class H, class... T>
void print(const H &h, const T &... t) {
    write(h);
    if (sizeof...(t))
        write(' ');
    print(t...);
}

template<class T, class U>
void vti(vt<T> &v, U x, size_t n) {
    v = vt<T>(n, x);
}

template<class T, class U>
void vti(vt<T> &v, U x, size_t n, size_t m...) {
    v = vt<T>(n);
    EACH(a, v)vti(a, x, m);
}

int cmp(int a, int b) {
    if (a == b) {
        return 0;
    }
    return a < b ? -1 : 1;
}

void solve() {
    int n, l;
    read(n, l);
    vt<string> a(n);
    read(a);
    sort(all(a));
    EACH(x, a) {
        write(x);
    }
}

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

    int tt = 1;
//    read(tt);
    FOR(tt) {
//        write("Case #", i + 1, ": ");
        solve();
    }

}



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

bool judge(int a,int b,int c){
    if(a*a+b*b==c*c||a*a==b*b+c*c||b*b==a*a+c*c){
        return true;
    }
    return false;
}
int main(){
    int N;
    cin>>N;
    int a,b,c;
    for(int i=0;i<N;i++){
        cin>>a>>b>>c;
        if(judge(a,b,c)){
            cout<<"YES"<<endl;
        }else{
            cout<<"NO"<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long int n,a,b;
	cin>>n>>a>>b;
    long long int h[n];
	for(int i=0;i<n;++i){
		cin>>h[i];
	}
    long long int l = -1, r = (long long int)1e9;
    while(r-l>1){
    	long long int m=(l+r)/2;
    	long long int req=0;
    	for(int i=0;i<n;++i){
    		if(h[i]>m*b){
    			if((h[i]-m*b) < a-b)req++;
    			else if(((h[i]-m*b) % (a-b) )==0)req+=(h[i]-m*b)/(a-b);
    			else
    			req+=(h[i]-m*b)/(a-b) + 1;
    		}
    	}
    	if(req<=m){
    		r=m;
    	} else {
    		l=m;
    	}
    }
    cout<<r<<endl;
    return 0;
}

Measured memory_bytes: 1024
import sys
stdin = sys.stdin

ni = lambda: int(ns)
ns = lambda: stdin.readline().rstrip()
na = lambda: map(int, stdin.readline().split())

def solve():
  s = ns()
  ans = 0
  t = p = ''

  for i in range(len(s)):
    t += s[i]
    if t == p:
      continue
    p = t
    t = ''
    ans += 1

  print(ans)


if __name__ == '__main__':
  solve()

Measured memory_bytes: 3500
N, M = map(int,input().split())
ans = [-1 for i in range(N)]
flag = 0
for i in range(M):
    s, c = map(int,input().split())
    if N != 1 and s == 1 and c == 0:
        flag = 1
        break
    if ans[s-1] != -1 and ans[s-1] != c:
        flag = 1
        break
    ans[s-1] = c
for i in range(N):
    if ans[i] == -1:
        if i == 0 and N != 1:
            ans[i] = 1
        else:
            ans[i] = 0
SUM = 0
for i in range(N):
    SUM += ans[i] * (10 ** (N - 1 - i))
if flag:
    print(-1)
else:
    print(SUM)

Measured memory_bytes: 3064
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
using namespace std;
typedef long long ll;

int N;
string W[100];

int main(){
    cin>>N;
    rep(i,N) cin>>W[i];

    repn(i,N-1){
        if(W[i][0]==W[i-1][W[i-1].size()-1]){
            rep(j,i){
                if(W[i]==W[j]){
                    cout<<"No"<<endl;
                    return 0;
                }
            }
        }else{
            cout<<"No"<<endl;
            return 0;
        }
    }

    cout<<"Yes"<<endl;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using edge = pair<ll, P>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
using Graph = vector<vector<ll>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    int N;
    cin >> N;
    vector<int> H(N);
    rep(i, N) cin >> H[i];
    vector<ll> dp(N + 2, INF);
    dp[0] = 0;
    rep(i, N) {
        dp[i + 1] = min(dp[i] + abs(H[i + 1] - H[i]), dp[i + 1]);
        dp[i + 2] = min(dp[i] + abs(H[i + 2] - H[i]), dp[i + 2]);
    }
    cout << dp[N-1] << endl;
}

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


Measured memory_bytes: 1408
#include <bits/stdc++.h>
    //#define int long long
    typedef long long ll;
    #define fore(i, l, r) for(int i = int(l); i < int(r); ++i)
    #define forn(i, n) fore(i, 0, n)
    #define fori(i, l, r) fore(i, l, (r) + 1)
    #define sz(v) int((v).size())
    #define all(v) (v).begin(), (v).end()
    #define pb push_back
    #define mp make_pair
    #define ff first
    #define ss second
    using namespace std; 
     
    const double PI = atan(1)*4;

    int dx[8]={1,0,-1,0,1,-1,-1,1};
    int dy[8]={0,1,0,-1,1,1,-1,-1};
     
     
    bool isprime(int n)
    {
        for(int i=2;i*i<=n;i++)
            if(n%i==0)
                return false;
        return true;
    }

    const int mod = 998244353;
     
    bool comp(pair<int,int> a, pair<int,int> b)
    {
        return b.ff < a.ff ;
    }
     
    ll pw(ll b, ll e)
    {
        ll ans = 1;
        while(e)
        {
            if(e & 1)
                ans = (ans * b) % mod;
            b = (b * b) % mod;
            e >>= 1;
        }
        return ans;
    }

    ll fact[200002], inv[200002];
    
    ll C(ll n, ll k)
    {
        return ((((fact[n] * inv[k]) % mod) * inv[n-k]) % mod);
    }
     
    /*void bsearch(int max,int min)   //  for function 
    //void bsearch(int a,int n, int x)     // for array
    {
        int k=min;
     
        //  for array
     
    /*    for(int b=n/2; b>=1; b/=2)
        {
            while(k+b<n && arr[k+b]<=x) k+=b; 
        }
     
        if(arr[k]==x)
            cout<<"found at "<<k+1;
        else
            cout<<"not found";
    */
     
        //  for function 
     
    /*    for(int b=max; b>=1; b/=2)
        {
            while( !fn(b+k) ) k+=b;
        }
        cout<<k+1;
     
    }*/
     
    int vis[200005];
     
    int main()
    {
     
        #ifndef ONLINE_JUDGE
        freopen("input.txt","r", stdin);
        freopen("output.txt", "w", stdout);
        #endif
     
        int t=1;
        //cin>>t;
     
        while(t--)
        {
            ll n,m,k,ans=0;
            cin >> n >> m >> k;

            fact[0] = inv[0] = 1;
            for(int i = 1; i <= n; ++i)
            {
                fact[i] = (fact[i-1] * i) % mod;
                inv[i] = pw(fact[i], mod - 2);
            }

            for(int i = 0; i <= k; ++i)
            {
                int cc = n - i;
                ll coef = 1LL * m * pw(m-1, cc-1);
                coef %= mod;
                coef = coef * C(n-1, i);
                ans = (ans + coef) % mod;
            }
            cout << ans;
        }
        return 0;
    }

Measured memory_bytes: 6696
#include<stdio.h>
#define MAX 2000000
#define INF (1<<30)
int h=0;
void maxHeapify(int *Heap,int i){
  int l=2*i;
  int r=2*i+1;
  int largest;
  int tmp;
  if(l<=h && Heap[l]>Heap[i]) largest=l;
  else largest=i;
  if(r<=h && Heap[r]>Heap[largest]) largest = r;
  if(largest!=i){
    tmp=Heap[i];
    Heap[i]=Heap[largest];
    Heap[largest]=tmp;
    maxHeapify(Heap,largest);
  }
}
int insert(int x,int *Heap){
  int i,tmp;
  h++;
  Heap[h] =-INF;
  if(x<Heap[h]) return -1;
  Heap[h]=x;
  i=h;
  while(i>1&&Heap[i/2]<Heap[i]){
    tmp=Heap[i/2];
    Heap[i/2]=Heap[i];
    Heap[i]=tmp;
    i/=2;
  }
  return 0;
}
int extract(int *Heap){
  int maxv = Heap[1];
  if(h < 1) return -INF;
  Heap[1] = Heap[h];
  h--;
  maxHeapify(Heap,1);
  return maxv;
}    
int main(){
  int n;
  char s[20];
  int Heap[MAX+2];
  while(1){
    scanf("%s",s);
    if(s[0]=='e'&&s[1]=='n') break;
    if(s[0]=='i'){
      scanf("%d",&n);
      insert(n,Heap);
    }else{
      printf("%d\n",extract(Heap));
    }
  }
  return 0;
}

Measured memory_bytes: 5128
n, q = map(int, input().split())
s = input()
a = [list(map(int, input().split())) for i in range(q)]
S = [0]*(n+1)
for i in range(n):
    if s[i:i+2] == 'AC':
        S[i] = 1
A = [0]
for i in range(n):
    c = A[i] + S[i] 
    A.append(c)
for i in range(q):
    print(A[a[i][1]-1] - A[a[i][0]-1])

Measured memory_bytes: 70104
import std.stdio, std.algorithm, std.conv, std.array, std.string;

void main()
{
    auto xab = readln.split.to!(long[]);
    writeln( xab[1] - xab[2] >= 0 ? "delicious" : xab[1] + xab[0] >= xab[2] ? "safe" : "dangerous" );
}

Measured memory_bytes: 256
def main():
    N = input()
    N_l = list(N)
    m = int(N_l[-1])
    if m == 0 or m == 1 or m==6 or m==8:
        print("pon")
    elif m == 2 or m== 4 or m == 5 or m == 7 or m==9:
        print("hon")
    elif m == 3:
        print("bon")
if __name__ == "__main__":
    main()


Measured memory_bytes: 9184
package main

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

func main() {
	K := ReadInt()
	if K%2 == 0 {
		fmt.Println((K / 2) * (K / 2))
	} else {
		fmt.Println((K + 1) / 2 * (K / 2))
	}
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 1840
#include<cstdio>
#include<string>
#include<iostream>
#include<algorithm>

using namespace std;

int main(void){
	int n;
	while(scanf("%d", &n) && n){
		int count = 0;
		
		while(n != 1){
			count++;
			if(n%2){
				n=n*3+1;
			}else {
				n/=2;
			}
		}
		printf("%d\n",count);
	}
	
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;

LL dp[31][100000];
map<int,LL> ma;

LL dfs(int a,int b,LL sum){
    for(int k=0;k<31;k++){
        if(b<=dp[k][a]){
            if(k==0) return sum+1;
            return dfs(dp[k-1][a],b,sum+(1<<(k-1)));
        }
    }
}

int main(){
    int N;
    cin >> N;
    vector<LL> X;
    for(int i=0;i<N;i++){
        LL x;
        cin >> x;
        X.eb(-x);
        ma[i]=x;
    }
    sort(ALL(X));
    LL L,Q;
    cin >> L >> Q;
    for(int i=0;i<N;i++){
        dp[0][i]=X.end()-lower_bound(X.begin(),X.end(),-(ma[i]+L))-1;
    }
    for(int k=1;k<31;k++){
        for(int i=0;i<N;i++){
            dp[k][i]=dp[k-1][dp[k-1][i]];
        }
    }
    while(Q--){
        int a,b;
        cin >> a >> b;
        a--,b--;
        if(a>b) swap(a,b);
        cout << dfs(a,b,0) << endl;
    }
    return 0;
}

Measured memory_bytes: 32116
#include<stdio.h>
#include<algorithm>
using namespace std;
typedef unsigned long long wolf;
int mod=1000000009;
int c[110][110];
wolf s[2600][42];
wolf u=1;
int main(){
	int a,b;
	scanf("%d%d",&a,&b);
	for(int i=0;i<a;i++)for(int j=0;j<b;j++){
		scanf("%d",&c[i][j]);
		s[i*b+j][40]=c[i][j];
	}
	for(int i=0;i<a;i++)for(int j=0;j<b;j++){
		for(int k=0;k<a;k++)for(int l=0;l<b;l++){
			if(i==k||j==l||(i+j)==(k+l)||(i-j)==(k-l)){
				int L=i*b+j;
				int R=k*b+l;
				s[L][R/64]^=(u<<(R%64));
			}
		}
	}
	int rank=0;
	for(int i=0;i<a*b;i++){
		int at=-1;
		for(int j=rank;j<a*b;j++){
			if(s[j][i/64]&(u<<(i%64))){at=j;break;}
		}
		if(!~at)continue;
		for(int j=0;j<42;j++)swap(s[at][j],s[rank][j]);
		for(int j=rank+1;j<a*b;j++){
			if(s[j][i/64]&(u<<(i%64))){
				for(int k=0;k<42;k++)s[j][k]^=s[rank][k];
			}
		}
		rank++;
	}
	
	bool ok=true;
	for(int i=0;i<a*b;i++){
		bool OK=false;
		for(int j=0;j<40;j++)if(s[i][j])OK=true;
		if(!OK&&s[i][40])ok=false;
	}
	if(!ok){
		printf("0\n");return 0;
	}
	int ret=1;
	for(int i=0;i<a*b-rank;i++){
		ret=ret*2%mod;
	}
	printf("%d\n",ret);
}

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

int main(){
    int n;
    int a,b,c;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> a >> b >> c;
        if(a*a+b*b==c*c||b*b+c*c==a*a||c*c+a*a==b*b){
            cout << "YES" << endl;
        }else{
             cout << "NO" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 2992
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int a,b;
    scanf("%d %d",&a,&b);
    if(b<a)
    {
        for(int i=0; i<a; i++)
            printf("%d",b);
    }
    else
         for(int i=0; i<b; i++)
            printf("%d",a);
    return 0;
}


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

using namespace std;

int N, M;
int A[10];
int num[] = {-1, 2, 5, 5, 4, 5, 6, 3, 7, 6};
string dp[10010];


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

  for(int i=0; i<=N; ++i) {
    for(int j=0; j<M; ++j) {
      int n = num[A[j]];
      string tmp;
      stringstream ss;

      if(i < n) continue;
      if(i == n) ss << A[j];
      else if(dp[i-n] != "") ss << A[j] << dp[i-n];
      else continue;
      ss >> tmp;
      if(tmp.size() > dp[i].size() || (tmp.size() == dp[i].size() && tmp > dp[i])) {
        dp[i] = tmp;
      }
    }
  }
  cout << dp[N] << endl;
}

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

int main() {
    vector<int> a{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};

    int k;
    cin >> k;
    cout << a[k-1] << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/rope>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#define int long long
#define pb push_back
#define x first
#define y second
#define mk(a,b) make_pair(a,b)
#define rr return 0
#define sqr(a) ((a)*(a))
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class value, class cmp = less<value> >
using ordered_set = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class value, class cmp = less_equal<value> >
using ordered_multiset = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class key, class value, class cmp = less<key> >
using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;

/// find_by_order()
/// order_of_key()
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
inline int randll(int l = INT_MIN, int r = INT_MAX) {
    return uniform_int_distribution<int>(l, r)(rng);
}
const int INF = 1e9, MOD = 1e9 + 7; /// think
const ll LINF = 1e18;


const int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0};
inline bool inside (int x, int y, int n, int m) {
    return 0 <= x && 0 <= y && x < n && y < m;
}

template<class T> bool umin (T &a, T b) {return a > b ? (a = b, true) : false; }
template<class T> bool umax (T &a, T b) {return a < b ? (a = b, true) : false; }

main()
{
    ios::sync_with_stdio(0);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, k, c;
    cin >> n >> k >> c;
    string s;
    cin >> s;
    vector <int> ans;
    vector <int> pref(n + 1);
    for (int i = 0; i < n; i++) {
        if (i) umax(pref[i], pref[i - 1]);
        if (s[i] == 'o') {
            umax(pref[i], i - c - 1 >= 0 ? pref[i - c - 1] + 1 : 1);
        }
//        cout << pref[i] << ' ';
    }
//    cout << '\n';
    vector <int> suff(n + 1);
    for (int i = n - 1; i >= 0; i--) {
        umax(suff[i], suff[i + 1]);
        if (s[i] == 'o') {
            umax(suff[i], suff[min(n, i + c + 1)] + 1);
        }
    }
    vector <int> cnt(n);
    for (int i = n - 1, j = n; i >= 0; i--) {
        while (j - 1 > i + c && pref[i] + suff[j] < k) {
            --j;
        }
        if (pref[i] + suff[j] >= k) {
            if (i + 1 <= j - 1) {
                ++cnt[i + 1];
                --cnt[j];
            }
        }
    }
    if (suff[1] < k) ans.pb(0);
    int cur = cnt[0];
    for (int i = 1; i < n; i++) {
        cur += cnt[i];
        if (cur == 0 && s[i] == 'o') {
            ans.pb(i);
        }
    }
    for (auto &i : ans) cout << i + 1 << '\n';
}


Measured memory_bytes: 6712
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = 5;
	 int[] menu = new int[n];
	 int[] nextTime  = new int[n];
	for(int i = 0; i < n; i++) {
		menu[i] = sc.nextInt();
	}
	for(int i = 0; i < n; i++) {
		if(menu[i]%10==0) {
			nextTime[i] = menu[i];
		}
		else {
		nextTime[i] = menu[i] - menu[i]%10+10;
		}
	}
	int bestTime = Integer.MAX_VALUE;
	for(int i = 0; i < n; i++) {
		int nowTime = 0;
		for(int j = 0; j < n; j++) {
			if(i == j) {
				nowTime+=menu[j];
			}
			else {
				nowTime+=nextTime[j];
			}
		}
		bestTime = Math.min(nowTime, bestTime);
	}
	System.out.println(bestTime);
	}

}


Measured memory_bytes: 21204
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = (ll)1e9;
const ll mod = (ll)1e9 + 7;

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

#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s, f) cout << fixed << setprecision(f) << s << endl;


int main()
{
	vector<pair<int, bool>> p(9);
	for (int i = 0; i < 9; i++)
	{
		int x;
		cin >> x;

		p[i].first = x;
		p[i].second = false;
	}

	int n;
	cin >> n;

	for (int i = 0; i < n; i++)
	{
		int x;
		cin >> x;
		for (int j = 0; j < 9; j++)
		{
			if (p[j].first == x)
			{
				p[j].second = true;
				break;
			}
		}
	}

	string res = "No";

	for (int i = 0; i < 3; i++)
	{
		int j = 3 * i;
		if (p[j].second && p[j + 1].second && p[j + 2].second)
		{
			res = "Yes";
		}

		if (p[i].second && p[i + 3].second && p[i + 6].second)
		{
			res = "Yes";
		}
	}

	if (p[0].second && p[4].second && p[8].second)
	{
		res = "Yes";
	}

	if (p[2].second && p[4].second && p[6].second)
	{
		res = "Yes";
	}

	println(res);
}


Measured memory_bytes: 256
def f(X):
    digitsum=0
    while(True):
        if X<1:
            break
        digitsum+=X%10
        X=int(X/10)
    return digitsum

if __name__=="__main__":
    N=int(input())
    if(N%f(N)==0):
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 3060
#include <stdio.h>
int main()
{

	long long int a,b,c=0,d,e,f,i,j,k,l,m,n;
	scanf("%lld",&n);
	long long int x[n+1];
	memset(x, 0, sizeof x);
	for(i=0;i<n-1;i++)
    {
        scanf("%lld",&a);
        x[a]++;
    }
    for(i=1;i<n+1;i++)
    {
        printf("%lld\n",x[i]);
    }

}


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

using namespace std;

#define pii pair<int , int>

int n , m , k;
char a[301][301];
int ans[301][301];

bool f(int l , int r , int x)
{
    if(x < 1 || x > n)
        return 0;
    for(; l <= r; l ++)
    {
        if(ans[x][l] != 0)
            return 0;
    }
    return 1;
}
signed main()
{
    cin >> n >> m >> k;
    queue<pii> q;
    int cnt = 0;
    for(int i = 1; i <= n; i ++)
    {
        for(int j = 1; j <= m; j ++)
        {
            cin >> a[i][j];
            if(a[i][j] == '#')
            {
                q.push({i , j});
                ans[i][j] = ++cnt;
            }
        }
    }
    while(!q.empty())
    {
        int x = q.front().first , y = q.front().second;

        q.pop();

        int num = ans[x][y];

        int ly = y , ry = y;

        while(ly - 1 > 0 && ans[x][ly - 1] == 0)
            ly --;

        while(ry + 1 <= m && ans[x][ry + 1] == 0)
            ry ++;
        int lx = x , rx = x;
        while(f(ly , ry , lx - 1))
            lx --;
        while(f(ly , ry , rx + 1))
            rx ++;
        for(int i = lx; i <= rx; i ++)
            for(int j = ly; j <= ry; j ++)
            {
                ans[i][j] = num;
            }
    }
    for(int i = 1; i <= n; i ++)
    {
        for(int j = 1; j <= m; j ++)
        {
            cout << ans[i][j] << ' ';
        }
        cout << endl;
    }
    return 0;
}


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

int main() {

    int N;
    cin >> N;
	set<int> s;
	for(int i=1;i<10;i++){
		for(int j=1;j<10;j++){
			s.insert(i*j);
		}
	}
	if(s.count(N) != 0){
		cout << "Yes";
	}else{
		cout << "No";
	}
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

using namespace std;

int main() {

	int n, k;
	scanf("%d%d",&n,&k);
	if(k == 1){
	  printf("0\n");
	}else{
	  n -= k;
	  printf("%d\n",n);
	}
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <string>
#include <cstring>
using namespace std;

int main()
{
    int a,b,x;
    cin>>a>>b>>x;
    if(a<=x&&a+b>=x)cout<<"YES";
    else cout<<"NO";
    return 0;
}


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

int main() {
    int N; cin >> N;
    int a = N / 111;
    int b = N % 111;
    int ans;
    if (b == 0) {
        ans = a * 111;
    } else {
        ans = (a + 1) * 111;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        solve(System.in, System.out);
    }

    static void solve(InputStream is, PrintStream os) {
        // Your code here!
        Scanner scan = new Scanner(is);
        int N = scan.nextInt();

        switch (N%10) {
            case 0:
            case 1:
            case 6:
            case 8:
                os.println("pon");
                break;
            case 2:
            case 4:
            case 5:
            case 7:
            case 9:
                os.println("hon");
                break;
            case 3:
                os.println("bon");
        }

    }
}

Measured memory_bytes: 27080
#include <bits/stdc++.h>
using namespace std;
// #include <atcoder/all>
// using namespace atcoder;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vb = vector<bool>;
using vs = vector<string>;
using vvi = vector<vi>;
using vp = vector<pii>;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()
#define each(a, x) for (auto&& a : (x))
#define _overload3(_1, _2, _3, name, ...) name
#define rep1(n) rep2(_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, n) for (int i = (a); i < (n); ++i)
#define rep(...) _overload3(__VA_ARGS__, rep3, rep2, rep1)(__VA_ARGS__)
constexpr int inf = (1 << 30) - 1;
constexpr int mod = 1e9 + 7;
constexpr double eps = 1e-10;
constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
template<typename T> constexpr void print(const T& t) {cout << t << "\n";}
template<typename T, typename U> constexpr bool chmax(T& a, const U& b) {if (a < b) a = b; return a < b;}
template<typename T, typename U> constexpr bool chmin(T& a, const U& b) {if (a > b) a = b; return a > b;}
template<typename T, typename U> istream& operator>>(istream& is, pair<T, U>& p) {is >> p.fi >> p.se; return is;}
template<typename T, typename U> ostream& operator<<(ostream& os, const pair<T, U>& p) {os << p.fi << " " << p.se; return os;}
template<typename T> istream& operator>>(istream& is, vector<T>& v) {rep(i, sz(v)) is >> v[i]; return is;}
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {rep(i, sz(v)) os << v[i] << (i + 1 != sz(v) ? " " : ""); return os;}
struct Init {Init() {cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(10);}} init;


int main() {
    int n; cin >> n;
    vp p(n); cin >> p;
    int ans = 0;
    int ma0 = -inf, mi0 = inf;

    rep(i,n) {
        int f0 = p[i].fi - p[i].se;
        chmax(ma0, f0);
        chmin(mi0, f0);
    }

    ans = ma0 - mi0;

    int ma1 = -inf, mi1 = inf;
    rep(i,n) {
        int f1 = p[i].fi + p[i].se;
        chmax(ma1, f1);
        chmin(mi1, f1);
    }
    ans = max(ans, ma1 - mi1);
    print(ans);



}

Measured memory_bytes: 4760
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _20191021
{
    class Program
    {
        static void Main(string[] args)
        {
            int a = int.Parse(Console.ReadLine());
            string s = Console.ReadLine();

            if (a >= 3200)
                Console.WriteLine(s);

            else
                Console.WriteLine("red");

            Console.ReadKey();
            
        }
    }
}


Measured memory_bytes: 11092
N=int(input())
A=[input() for i in range(N)]
d=[[0]*50 for i in range(50)]
div=[]
for a in A:
    if '.' in a:
        i=a.index('.')
        n=int(a[:i])*10**9+int(a[i+1:]+'0'*(10-len(a)+i))
    else:
        n=int(a)*10**9
    t,f=0,0
    while n%2==0:
        n//=2
        t+=1
    while n%5==0:
        n//=5
        f+=1
    d[t+1][f+1]+=1
    div.append((t,f))
for i in range(49):
    for j in range(49):
        d[i+1][j+1]+=d[i+1][j]+d[i][j+1]-d[i][j]
r=0
for t,f in div:
    r+=d[-1][-1]-d[-1][max(0,18-f)]-d[max(0,18-t)][-1]+d[max(0,18-t)][max(0,18-f)]
    if max(0,18-t)<=t and max(0,18-f)<=f:
        r-=1
print(r//2)

Measured memory_bytes: 37356
package main

import "fmt"

func pow(b, n uint64) uint64 {
	ret := uint64(1)
	for i := uint64(1); i <= n; i++ {
		ret *= b
	}
	return ret
}

func nCr(n, r uint64) uint64 {
	if n < 0 || r < 0 || r > n {
		return 0
	}

	k := r
	if k > n/2 {
		k = n - r
	}

	ret := uint64(1)
	for i := uint64(1); i <= k; i++ {
		ret *= n - i + 1
		ret /= i
	}
	return ret
}

func main() {
	var N, P, odds, evens uint64
	fmt.Scan(&N, &P)
	for i := uint64(0); i < N; i++ {
		var v int
		fmt.Scan(&v)
		if v%2 == 0 {
			evens++
		} else {
			odds++
		}
	}
	ans := uint64(0)
	// 偶数を加えても全体の偶奇は変わらない <= 核心
	// P = 0の場合は、奇数を偶数個選ぶ選び方 x 偶数の選び方 (2^0 ~ 2^even)
	// P = 1の場合は、奇数を奇数個選ぶ選び方 x 偶数の選び方 (2^0 ~ 2^even)
	if P == 1 {
		for i := uint64(1); i <= N; i += 2 {
			ans += nCr(odds, i)
		}
	} else {
		for i := uint64(0); i <= N; i += 2 {
			ans += nCr(odds, i)
		}
	}
	fmt.Println(ans * pow(2, evens))
}


Measured memory_bytes: 512
A,B,K = map(int,input().split())
L = 0
ans = 0
for i in reversed(range(1,2000)):
  if A%i == 0:
    if B%i == 0:
      L += 1
    else:
      L += 0
  else:
    L += 0
  if L == K:
    ans = i
    break
print(ans)


Measured memory_bytes: 2940
N,M = map(int,input().split())
XY = [tuple(map(int,input().split())) for i in range(M)]

may_red = [0] * N
may_red[0] = 1
balls = [1] * N

for x,y in XY:
    x,y = x-1,y-1
    if may_red[x]:
        may_red[y] = 1
        if balls[x] == 1:
            may_red[x] = 0
    balls[x] -= 1
    balls[y] += 1
print(sum(may_red))

Measured memory_bytes: 24060
# -*- coding: utf-8 -*-
"""
@author: H_Hoshigi
"""
def main():
    S = input()
    T = input()
    answer = ""
    if S == T[:-1]:
        answer = "Yes"
    else:
        answer = "No"
    print(answer)

if __name__ == "__main__":
    main()




Measured memory_bytes: 9104
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>

using namespace std;

typedef pair<long long, int> PII;

const int DIR_W = 0;
const int DIR_H = 1;

int main() {
	int w, h, pq;
	cin >> w >> h;

	priority_queue<PII, vector<PII>, greater<PII>> que;

	for (int i = 0; i < w; i++) {
		cin >> pq;
		que.push(make_pair(pq, DIR_W));
	}
	for (int i = 0; i < h; i++) {
		cin >> pq;
		que.push(make_pair(pq, DIR_H));
	}

	w++;
	h++;
	int connected_w = 0;
	int connected_h = 0;
	long long ans = 0;

	while (!que.empty()) {
		auto p = que.top();
		que.pop();

		if (p.second == 0) {
			ans += p.first * (h - connected_h);
			connected_w++;
		} else {
			ans += p.first * (w - connected_w);
			connected_h++;
		}
	}

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


Measured memory_bytes: 4464
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;
    
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 
#define U_MAP unordered_map<ll,ll>
#define pq priority_queue<ll>
#define rpq priority_queue<ll,vector<ll>,greater<ll>>
#define p_b push_back
    
ll n,cnt,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};
char ans;
    
//-------------------------↓↓↓↓↓↓------------------------
    
//------ 自分を天才だと信じる ------
    
int main(void){
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>s>>k;
    ll kokomade=-1;
    rep(i,Size(s)){
        if(s[i]!='1'){
            ans=s[i];
            break;
        }
        kokomade=i;
    }
    if(kokomade+1>=k)Cout(1);
    else Cout(ans);
    return 0;
}

Measured memory_bytes: 764
#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
typedef long long LL; 
const LL inf=1e18;
int n;
int a[20];
LL f[20][20][1<<18];
LL F(int l,int r,int xl,int xr,int s)
{
	if(l+1==r)
	{
		return 0;
	}
	if(f[l][r][s]!=-1)
	{
		return f[l][r][s];
	}
	LL &re=f[l][r][s]=inf;
	for(int i=l+1;i<r;++i)
	{
		re=min(re,F(l,i,xl,xl+xr,s<<1)+F(i,r,xl+xr,xr,s<<1|1)+(LL)(xl+xr)*a[i]);
	}
	return re;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
	{
		scanf("%d",&a[i]);
	}
	memset(f,-1,sizeof(f));
	printf("%lld\n",F(1,n,1,1,1)+a[1]+a[n]);
	return 0;
}

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

int main()
{
   ios_base::sync_with_stdio(0);
  cin.tie(0);cout.tie(0);
    int n,ans=0;
    cin>>n;
    if(n%1000==0){cout<<n%1000<<endl;}
    else{
       ans=n%1000;
       cout<<1000-ans<<endl;
    }
    return 0;
}


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

#define INCANT cin.tie(0), ios::sync_with_stdio(false), cout << fixed << setprecision(20)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define all(x) (x).begin(),(x).end()
#define out(a) cout << a << endl
#define PRINT(V) for (auto v : (V)) cout << v << " "

const int MOD = 1000000007;
const double PI = acos(-1.0);

ll N,M,Q;
vector<int> a, b, c, d;
ll check(vector<int> A){
    ll score=0;
    rep(i, Q){
        if(A.at(b.at(i)-1) - A.at(a.at(i)-1) == c.at(i))
            score += d.at(i);
    }
    return score;
}

ll dfs(vector<int> A, int depth, ll max_score){
    if(depth == N){
        ll score = check(A);
        if(max_score < score) return score;
        else return max_score;
    }
    if(depth == 0){
        FOR(i, 1, M+1){
            A.at(depth) = i;
            ll score = dfs(A, depth+1, max_score);
            max_score = max(max_score, score);
        }
        return max_score;
    }else{
        FOR(i, A.at(depth-1), M+1){
            A.at(depth) = i;
            ll score = dfs(A, depth+1, max_score);
            max_score = max(max_score, score);
        }
        return max_score;
    }
}


void solve() {
    cin >> N >> M >> Q;
    rep(i, Q){
        int aa, bb, cc, dd;
        cin >> aa >> bb >> cc >> dd;
        a.push_back(aa);
        b.push_back(bb);
        c.push_back(cc);
        d.push_back(dd);
    }
    vector<int> A(N);
    out(dfs(A, 0, 0));
}
int main() {
    INCANT;
    solve();
    return 0;
}




Measured memory_bytes: 3624
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            new Program().Solve(new MyInputStream(Console.In, ' '));
            Console.Out.Flush();
        }

        public void Solve(MyInputStream cin)
        {
            var N = cin.ReadInt();
            var a = cin.ReadIntArray(N);
            WriteLine(a.Max() - a.Min());
        }
    }

    public class MyInputStream
    {
        private readonly System.IO.TextReader _stream;
        private char separator = ' ';
        private Queue<string> inputStream;
        public MyInputStream(System.IO.TextReader s, char separator = ' ')
        {
            this.separator = separator;
            this._stream = s;
            inputStream = new Queue<string>();
        }
        public string Read()
        {
            if (inputStream.Count != 0) return inputStream.Dequeue();
            string[] tmp = _stream.ReadLine().Split(separator);
            for (int i = 0; i < tmp.Length; ++i)
                inputStream.Enqueue(tmp[i]);
            return inputStream.Dequeue();
        }
        public string ReadLine() { return _stream.ReadLine(); }
        public int ReadInt() { return int.Parse(Read()); }
        public long ReadLong() { return long.Parse(Read()); }
        public double ReadDouble() { return double.Parse(Read()); }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read(); return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt(); return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong(); return ret;}
    }
}

Measured memory_bytes: 13396
from collections import deque
n,m=map(int,input().split())
ans=0


group = [set() for _ in range(n)]

for i in range(m):
    a,b = map(int,input().split())
    a-=1
    b-=1
    group[a].add(b)
    group[b].add(a)


kisyutu = set()
deque = deque()

for i in range(n):
    if i not in kisyutu:
        kisyutu.add(i)
        friend_set=group[i]

        deque.extend(group[i])

        while deque:
            a1 = deque.pop()
            if a1 not in kisyutu:
                kisyutu.add(a1)
                friend_set.add(a1)
                deque.extend(group[a1])
        ans = max(ans, len(friend_set)+1)

if m!=0:
    print(ans)
else:
    print(1)

Measured memory_bytes: 97308
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 2e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n, m;
    cin >> n >> m;
    ll x[n], y[n], z[n];
    rep(i, 0, n ) cin >> x[i] >> y[i] >> z[i];

    ll ans = 0;
    for (int i = 0; i < (1 << 3); i++) {
        ll sum[n] = {};
        for (int j = 0; j < n; j++) {
            if (i & (1 << 0)) sum[j] += x[j];
            else sum[j] += -x[j];
            if (i & (1 << 1)) sum[j] += y[j];
            else sum[j] += -y[j];
            if (i & (1 << 2)) sum[j] += z[j];
            else sum[j] += -z[j];
        }
        sort(sum, sum + n, greater<ll>());
        ll tmp = 0;
        for (int j = 0; j < m; j++) {
            tmp += sum[j];
        }
        ans = max(ans, tmp);
    }

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


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

int main() {

    int N;
    cin>>N;
    vector<int> A(N);
    for(int i=0;i<N;i++){
        cin>>A.at(i);
    }
    int count=0;
    for(int i=0;i<N;i++){
        int minj=i;
        for(int j=i;j<N;j++){
            if(A.at(j)<A.at(minj)){
                minj=j;
            }
        }
        if(i!=minj){
            swap(A.at(i),A.at(minj));
            count++;
        }
    }
    for(int i=0;i<N;i++){
        if(i) cout<<" ";
        cout<<A.at(i);
    }
    cout<<endl<<count<<endl;
}



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

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using ld = long double;

template <typename T>
int sz(T &x) {
  return (int)(x.size());
}

int power(int x, int y, int mod) {
  if (y == 0) {
    return 1;
  }
  int z = power(x, y >> 1, mod);
  z = z * 1ll * z % mod;
  if (y & 1) {
    z = z * 1ll * x % mod;
  }
  return z;
}

const int mod = 998244353;
const int inf = 1'000'000'007;

void solve() {
  int n, m, k;
  cin >> n >> m >> k;
  vector<vector<char> > a(n + 2, vector<char>(m + 2, '#'));

  int si(0), sj(0);

  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      cin >> a[i][j];
      if (a[i][j] == 'S') {
        si = i;
        sj = j;
      }
    }
  }

  vector<vector<int> >dist(n + 2, vector<int> (m + 2, inf));

  queue<pii> f;
  f.push(make_pair(si, sj));
  dist[si][sj] = 0;
  while (!f.empty()) {
    pii v = f.front();
    f.pop();
    for (int dx : {-1, 0, 1}) {
      for (int dy : {-1, 0, 1}) {
        if ((dx == 0) + (dy == 0) != 1) {
          continue;
        }
        int cx = v.first + dx;
        int cy = v.second + dy;
        if (dist[cx][cy] != inf || a[cx][cy] == '#') {
          continue;
        }
        dist[cx][cy] = dist[v.first][v.second] + 1;
        f.push(make_pair(cx, cy));
      }
    }
  }
  int ans = inf;
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      if (dist[i][j] <= k) {
        ans = min(ans, 1 + (min({i - 1, j - 1, n - i, m - j}) + k - 1) / k);
      }
    }
  }
  cout << ans << "\n";
}

int main() {
  #ifndef LOCAL58
    // don't forget to remove if interactive
    ios_base :: sync_with_stdio(false);
    cin.tie(nullptr);
  #endif

  int t;
  t = 1;
  while (t--) {
    solve();
  }

  return 0;
}


Measured memory_bytes: 6812
#include <iostream>
#include<vector>
using namespace std;
int main() {
	int n, highest = 0, ans = 0;
	cin >> n;
	vector<int> h(n);
	for (int i = 1; i <= n; i++) {
		cin >> h[i];
		if (highest <= h[i]) {
			ans++;
			highest = h[i];
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
   int x,y,a,b;
   cin>>x>>y>>a>>b;
   if(x+y <a+b)cout<<"Right"<<endl;
   if(x+y >a+b)cout<<"Left"<<endl;
   if(x+y == a+b)cout<<"Balanced"<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <vector>
#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 n, x;
  vector<int> v;
  while (1) {
    cin >> n >> x;
    if (n == 0)
      break;
    int ans = 0;
    for (int i = 1; i < n - 1; ++i)
      for (int j = i + 1; j < n; ++j)
        for (int k = j + 1; k <= n; ++k) {
          if (i + j + k == x)
            ++ans;
        }
    v.push_back(ans);
  }

  rep(i, v.size()) cout << v[i] << endl;
  return 0;
}


Measured memory_bytes: 3152
package main

import "fmt"

func main() {
	var s string
	fmt.Scan(&s)

	l, r := len(s)/2, len(s)/2
	if len(s)%2 == 0 {
		l--
	}
	ans := len(s) / 2
	for (0 <= l && r <= len(s)-1) && (s[l] == s[r] && s[l] == s[len(s)/2]) {
		ans++
		l--
		r++
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define LL long long
using namespace std;
vector<vector<int> >g(200050);
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n,m,u,v; cin>>n>>m;
    for(int i=0;i<m;i++)
    {
        cin>>u>>v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    for(auto i:g[1])
        for(auto j:g[i])
            if(j==n)return cout<<"POSSIBLE",0;
    cout<<"IMPOSSIBLE";
}


Measured memory_bytes: 12016
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;

int main(){
    int n; cin >> n;
    int ans = 0;
    for(int i = 1; i <= n; i++){
        int tmp = i;
        int keta = 0;
        while(tmp) {
            keta++;
            tmp/=10;
        }
        if(keta%2==1) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
<?php

	fscanf(STDIN, "%d %d", $N, $M);
	$input_array = explode(' ',trim(fgets(STDIN)));
	
	$obj = new SplMaxHeap();
	for ($i = 0; $i < $N; $i++) {
		$obj->insert((int)$input_array[$i]);
    }

	for ($i = 0; $i < $M; $i++) {
      $a = floor($obj->extract() / 2);
      $obj->insert($a);
    }

	$result = 0;
	for ($i = 0; $i < $N; $i++) {
      $a = $obj->extract();
      $result += $a;
    }

	echo ($result);
?>

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

const int MX = 100005;

vector<int> neigh[MX];
bool debt[MX];
int depth[MX];

vector<pair<int, int>> ans;
void addAns(int a, int b, int c) {
	ans.emplace_back(b, a);
	ans.emplace_back(b, c);
}

void dfs(int v, int p, int d)
{
	depth[v] = d;
	int with = 0;
	
	for (int u : neigh[v]) {
		if (u == p) continue;
		
		else if (depth[u] == 0) {
			// front edge forward
			dfs(u, v, d + 1);
			
			if (debt[u]) {
				if (with) {
					addAns(with, v, u);
					with = 0;
				}
				else {
					with = u;
				}
			}
		}
		else if (depth[u] > depth[v]) {
			continue;
		}
		else {
			if (with) {
				addAns(with, v, u);
				with = 0;
			}
			else {
				with = u;
			}
		}
	}
	
	if (with) {
		addAns(with, v, p);
	}
	else {
		debt[v] = true;
	}
}

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

	if (m % 2 == 1) {
		printf("-1\n");
		return 0;
	}
	
	for (int i = 0; i < m; i++) {
		int u, v;
		ignore = scanf("%d %d", &u, &v);
		neigh[u].push_back(v);
		neigh[v].push_back(u);
	}
	
	dfs(1, -1, 1);
	
	for (auto p : ans) {
		printf("%d %d\n", p.first, p.second);
	}
}


Measured memory_bytes: 20724
squares = []
for i in range(0, 16001):
	squares.append(i*i)
N, D = map(int, input().split())
X = []
for i in range(0, N):
	X.append(list(map(int, input().split())))
cnt = 0
for i in range(0, N):
	for j in range(i+1, N):
		sqdist = 0
		for k in range(0, D):
			sqdist += (X[i][k]-X[j][k])**2
		if sqdist in squares:
			cnt += 1
print(cnt)

Measured memory_bytes: 38768
s=list(input())
s1=len(s)
c=[]
k=[]
c1=0
k1=0
for i in range(s1):
    if i%2==0:
        c.append('1')
        k.append('0')
        if s[i]==c[i]:k1+=1
        else:c1+=1
    else:
        c.append('0')
        k.append('1')
        if s[i]==c[i]:k1+=1
        else:c1+=1
print(min(c1,k1))

Measured memory_bytes: 5512
#include<bits/stdc++.h>
#define endl '\n'
#define INF (1 << 21)
const int MOD = 1000000007;
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  int h[105];

  cin >> n;
  while(n != 0){
    for(int i = 0;i <= n;i++){
      cin >> h[i];
    }

    int diff = h[1] - h[0];
    int cnt = 0;
    int p;
    int ans;
    
    for(int i = 0;i < n;i++){
      if(h[i + 1] - h[i] != diff){
	ans = h[i + 1];
	p = i;
	cnt ++;
      }
    }

    if(cnt > 2){
      diff = h[n] - h[n - 1];
      if(h[2] - h[1] == diff){
	ans = h[0];
      }else{
	ans = h[1];
      }
    }else{
      if(p < n){
	if(diff != h[p] - h[p - 1]){
	  ans = h[p];
	}else{
	  ans = h[p + 1];
	}
      }else{
	if(diff != h[p - 1] - h[p - 2]){
	  ans = h[p - 1];
	}else{
	  ans = h[p];
	}
      }
    }

    cout << ans << endl;
    cin >> n;
  }
  
  return 0;
}



Measured memory_bytes: 3136