akhauriyash/Code-Regression huggingface dataset:
import sys
INF = 1 << 60
MOD = 998244353
sys.setrecursionlimit(2147483647)
input = lambda:sys.stdin.readline().rstrip()

prime = 998244353
root = 3
def _fmt(A, inverse = False):
    N = len(A)
    logN = (N - 1).bit_length()
    base = pow(root, (prime - 1) // N * (1 - 2 * inverse) % (prime - 1), prime)
    step = N
    for k in range(logN):
        step >>= 1
        w = pow(base, step, prime)
        wj = 1
        nA = [0] * N
        for j in range(1 << k):
            for i in range(1 << logN - k - 1):
                s, t = i + j * step, i + j * step + (N >> 1)
                ps, pt = i + j * step * 2, i + j * step * 2 + step
                nA[s], nA[t] = (A[ps] + A[pt] * wj) % prime, (A[ps] - A[pt] * wj) % prime
            wj = (wj * w) % prime
        A = nA
    return A

def convolution(f, g):
    N = 1 << (len(f) + len(g) - 2).bit_length()
    Ff, Fg = _fmt(f + [0] * (N - len(f))), _fmt(g + [0] * (N - len(g)))
    N_inv = pow(N, prime - 2, prime)
    fg = _fmt([a * b % prime * N_inv % prime for a, b in zip(Ff, Fg)], inverse = True)
    del fg[len(f) + len(g) - 1:]
    return fg

class modfact(object):
    def __init__(self, n):
        fact, invfact = [1] * (n + 1), [1] * (n + 1)
        for i in range(1, n + 1): fact[i] = i * fact[i - 1] % MOD
        invfact[n] = pow(fact[n], MOD - 2, MOD)
        for i in range(n - 1, -1, -1): invfact[i] = invfact[i + 1] * (i + 1) % MOD
        self._fact, self._invfact = fact, invfact

    def fact(self, n):
        return self._fact[n]

    def invfact(self, n):
        return self._invfact[n]

    def comb(self, n, k):
        return self._fact[n] * self._invfact[k] % MOD * self._invfact[n - k] % MOD if 0 <= k <= n else 0

    def perm(self, n, k):
        return self._fact[n] * self._invfact[n - k] % MOD if 0 <= k <= n else 0

from collections import Counter
def resolve():
    n = int(input())
    H = [int(input()) for _ in range(2 * n)]

    mf = modfact(n << 1)
    doublefact = [1] * (2 * n + 10)
    for i in range(2, 2 * n + 1):
        doublefact[i] = i * doublefact[i - 2] % MOD

    F = []
    for k in Counter(H).values():
        f = []
        for i in range(k // 2 + 1):
            f.append(mf.comb(k, 2 * i) * doublefact[2 * i - 1] % MOD)
        F.append(f)

    while len(F) > 1:
        nF = []
        for i in range(len(F) // 2):
            nF.append(convolution(F[2 * i], F[2 * i + 1]))
        if len(F) & 1:
            nF.append(F[-1])
        F = nF

    f = F[0]
    ans = 0
    for i in range(len(f)):
        f[i] = f[i] * doublefact[2 * n - 2 * i - 1] % MOD
        if i & 1:
            ans -= f[i]
        else:
            ans += f[i]
    ans %= MOD
    print(ans)
resolve()

Measured memory_bytes: 142012
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
const int MAXN = 100000;
ll x[MAXN + 5], v[MAXN + 5];
ll dp1[MAXN + 5], dp2[MAXN + 5];
int main() {
	int N; ll C;
	scanf("%d%lld", &N, &C);
	for(int i=1;i<=N;i++) {
		scanf("%lld%lld", &x[i], &v[i]);
		dp1[i] = dp1[i-1] - (x[i] - x[i-1]) + v[i];
	}
	for(int i=N;i>=1;i--) {
		x[i] = C - x[i];
		dp2[i] = dp2[i+1] - (x[i] - x[i+1]) + v[i];
	}
	ll Max1 = 0, Max2 = 0, ans = 0;
	x[0] = C;
	for(int i=N;i>=0;i--) {
		ans = max(ans, max(dp1[i] + Max1, dp1[i] + Max2 - (C - x[i])));
		Max1 = max(Max1, dp2[i] - x[i]);
		Max2 = max(Max2, dp2[i]);
	}
	printf("%lld\n", ans);
} 

Measured memory_bytes: 3328
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <numeric>
#include <string>
#include <cassert>

using namespace std;
typedef long long ll;

int main() {
  int N, K;
  cin >> N >> K;
  int cnt = 0;
  for (int i = 0; i < N; ++i) {
    int h;
    cin >> h;
    if (h >= K) ++cnt;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
from collections import defaultdict
import bisect
N,K = map(int,input().split())
A = list(map(int,input().split()))
S = [0]*N
for i in range(N):
    S[i] = S[i-1]+A[i]
    S[i] %= K
d = defaultdict(list)
for i in range(N):
    d[(S[i]-i)%K].append(i)

ans = 0
for k in d:
    l = d[k]
    for i in range(len(l)):
        n = l[i]
        j = bisect.bisect_left(l,n+K)
        ans += j-i-1
    if k==1:
        j = bisect.bisect_left(l,K-1)
        ans += j
            
print(ans)

Measured memory_bytes: 127560
// AOJ 1563: Array Update
// 2017.10.24 bal4u@uu

#include <stdio.h>

#define HASHSIZ 101
typedef struct { int id, v; } HASH;
HASH hash[HASHSIZ+2], *hashend = hash + HASHSIZ;

int lookup(int id)
{
	HASH *p = hash + id % HASHSIZ;
	while (p->id) {
		if (p->id == id) return p->v;
		if (++p == hashend) p = hash;
	}
	return -1;
}

void insert(int id, int v)
{
	HASH *p = hash + id % HASHSIZ;
	while (p->id) {
		if (p->id == id) { p->v = v; return; }
		if (++p == hashend) p = hash;
	}
	p->id = id, p->v = v;
}

int n, a, d;

int get(int id)
{
	int v;
	if ((v = lookup(id)) < 0) v = a + (id-1) * d;
	return v;
}

int main() 
{
	int m, x, y, z, k;
	int vy, vz;

	scanf("%d%d%d%d", &n, &a, &d, &m);
	while (m-- > 0) {
		scanf("%d%d%d", &x, &y, &z);
		if (x == 0) {
			vy = get(y), vz = get(z);
			insert(y, vz), insert(z, vy);
		} else {
			vz = get(z);
			insert(y, vz);
		}
	}
	scanf("%d", &k);
	printf("%d\n", get(k));
	return 0;
}

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

const long long INF = 1LL << 60;
const int MAX_N = 110;
const int MAX_V = 100100;

int N;
long long W, weight[MAX_N], value[MAX_V];
long long dp[MAX_N][MAX_V];

int main() {
  cin >> N >> W;
  for (int i = 0; i < N; i++) cin >> weight[i] >> value[i];

  for (int i = 0; i < MAX_N; i++) for (int j = 0; j < MAX_V; j++) dp[i][j] = INF;
  dp[0][0] = 0;
  for (int i = 0; i < N; i++) {
    for (int sum_v = 0; sum_v < MAX_V; sum_v++) {
      if (sum_v - value[i] >= 0) dp[i+1][sum_v] = min(dp[i][sum_v], dp[i][sum_v-value[i]] + weight[i]);
      else dp[i+1][sum_v] = dp[i][sum_v];
    }
  }

  long long res = 0;
  for (int sum_v = 0; sum_v < MAX_V; sum_v++) {
    if (dp[N][sum_v] <= W) res = sum_v;
  }
  cout << res << endl;
}

Measured memory_bytes: 86272
#include <iostream>
using namespace std;
int main(int argc, char* argv[])
{
	int A,B,C;
	cin>>A>>B>>C;
	int D=B/A;
	if (D>=C){
		cout<<C<<endl;
	}else{
		cout<<D<<endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#define MAXN 100006
using namespace std;
long long a[MAXN],x,sta[MAXN],s[MAXN],t[MAXN],ans;
int n,m,top;
int find(long long k,int r)
{
	if(r==0) return 0;
	int l=1;
	while(l<r)
	{
		int mid=(l+r+1)/2;
		if(a[mid]<=k) l=mid;
		else r=mid-1;
	}
	return l;
}
int main()
{
	//freopen("seq.in","r",stdin);
	//freopen("seq.out","w",stdout);
	scanf("%d%d",&n,&m);
	top=1;
	sta[top]=n;
	for(int i=1;i<=m;i++)
	{
		scanf("%lld",&x);
		while(x<=sta[top])
			top--;
		sta[++top]=x;
	}
	m=top;
	for(int i=1;i<=m;i++)
		a[i]=sta[i];
	t[m]=1;
	for(int i=m;i>=1;i--)
	{
		long long now=a[i];
		int p=find(now,i-1);
		while(p)
		{
			t[p]+=(now/a[p])*t[i];
			now%=a[p];
			p=find(now,p-1);
		}
		s[1]+=t[i];
		s[now+1]-=t[i];
	}
	for(int i=1;i<=n;i++)
	{
		ans+=s[i];
		printf("%lld\n",ans);
	}
}

Measured memory_bytes: 4864
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = s; i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
typedef long long ll;
const int MOD = 1000000007;
using namespace std;


int main(){
    int n, k, ans=0; cin >> n >> k;
    REP(i, n){
        int x; cin >> x;
        ans += min(x, k-x);
    }
    cout << 2*ans << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF 1e18L
#define INF 1e9L
#define EPS 1e-9
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define pb push_back
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
typedef long long ll;
typedef pair<int, int> pii;

int main(void)
{
    int n,k;
    cin >> n >> k;
    string s;
    cin >> s;
    vector<int> v; 
    if(s[0] == '0') v.pb(0);
    v.pb(0);
    Rep(i, 1, n){
       if(s[i-1] == s[i]) continue;
        v.pb(i);
    }
    v.pb(n);
    if(s[s.size()-1]=='0') v.pb(n);
    
    vector<int> ans;    
    for (int i = 1; i < n; i+=2) {
        int mid = i + k *2;
        if(mid >= v.size()) break; 
        ans.pb(v[mid] - v[i-1]);
    }

    if(ans.size() == 0){
        REP(i, v.size()){
            if(i%2) ans.pb(v[i]);
        }
    }
    RSORT(ans);
    pr(ans[0]);
}

Measured memory_bytes: 1272
#include <bits/stdc++.h>
 
#if DEBUG
    #include "debug.h"
#else
    #define debug(args...)
#endif    

using namespace std;

#define int long long

typedef vector<int> vi;
typedef pair<int,int> ii;


#define M 1000000 
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define fill(a,x) memset(a,x,sizeof(a))
#define F first
#define S second
#define FOR(i,a,b) for(int i = a; i<=b; ++i)
#define NFOR(i,a,b) for(int i = a; i>=b; --i)
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
const int INF = 1e18;
const int mod = 1e9+7;
const int N = 2e5 + 10;
inline int add(int x,int y){
  x += y;
  if(x >= mod) x -= mod;
  return x;
}
inline int mul(int x,int y){
  x = (1LL * x * y) % mod;
  return x;
}
// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());



int32_t main(){
  fast;

  string s;
  cin >> s;
  int n = s.length();
  string prev = "";
  int ans = 0;
  for(int i = 0; i < n; i++) {
    string curr1 = "";
    curr1 += s[i];
    if(curr1 != prev) {
      ans++;
      prev = curr1;
    } 
    else {
      if(i + 1 < n) {
        string curr2 = "";
        curr2 = curr2 + s[i] + s[i + 1];
        prev = curr2;
        ans++;
        i++;
      }
    }
  }

  cout << ans;
  

  return 0;
}

Measured memory_bytes: 720
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main(void){
    int n,m,a,b,i,j,fst,fnd,ans;
    bool friends[510];
    cin >> n >> m;
    while(n!=0 && m!=0){
        vector<int> list[510];
        fill(friends,friends+n,false);
        ans = 0;
        for(i=0; i<m; i++){
            cin >> a >> b;
            a--;
            b--;
            list[a].push_back(b);
            list[b].push_back(a);
        }
        for(i=(list[0].size()-1); i>=0; i--){
            fst = list[0][i];
            friends[fst] = true;
            for(j=(list[fst].size()-1); j>=0; j--){
                fnd = list[fst][j];
                friends[fnd] = true;
            }
        }
        
        for(i=1; i<n; i++){
            if(friends[i]){
                ans++;
            }
        }
        cout << ans <<endl;
        cin >> n >> m;
    }
    return 0;
}

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

int main() {

    bitset<3> s;
    cin >> s;
    int count = 0;

    for (int i = 0; i < 3; i++) {
        if (s.test(i)) {
            count++;
        }
    }

    cout << count << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		double height = Double.MIN_VALUE,min = Double.MAX_VALUE;
		while(scan.hasNext()) {
			double mount = scan.nextDouble();
			if(height < mount) {
				height = mount;
			}
			if(min > mount) {
				min = mount;
			}
		}
		System.out.println(height - min);
		scan.close();
	}
}


Measured memory_bytes: 27564
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    int a;
    cin>>a;
    if(a>=30)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;

    return 0;
}


Measured memory_bytes: 3632
import java.util.Scanner;

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

        //入力受付
        int n = scan.nextInt();
        long a = scan.nextLong();
        long b = scan.nextLong();
        long h[] = new long [n];

        for(int i=0;i < n;i++){
            h[i]= scan.nextLong();
        }

        //二分探索
        long l = 0;
        long r = (long)Math.pow(10,9)+1;
        while(l < r-1){
            long m = (l+r)/2;
            long temp[] = new long[n];
            for(int i = 0;i < n;i++){
                temp[i] = h[i];
            }
            for(int i = 0;i < n; i++){
                temp[i] -= b*m;
            }
            long x = 0;
            for(int i = 0;i < n;i++){
                if(temp[i] > 0){
                    if(temp[i] % (a - b)==0){
                        x += temp[i] / (a-b);
                    }else{
                        x += (temp[i] / (a-b))+1;
                    }
                }
            }
            if(x <= m){
                r = m;
            }else{
                l = m;
            }
        }
        System.out.println(r);
    }
}


Measured memory_bytes: 62916
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long int n;
	cin>>n;
	long long int arr[n+2],a;
	for(long int i=0;i<=n+1;i++){
		arr[i]=1;
	}
	arr[1]=1;
	long long ans=1;
	for(long int i=2;i<=n;i++){
			for(long int j=i;j<=n;j+=i){
					arr[j]+=1;
			}
		ans+=i*arr[i];
		}
	cout<<ans;
}

Measured memory_bytes: 81728
import argparse
import collections
import logging.config
import sys
import csv
import numpy as np

def tester(x, y):
    ans = "No"
    for i in range(x+1):
        if (y == x*4-2*i) : ans = "Yes"
    return (ans)

def main():
    s=input().split(" ")
    si = []
    for d in s:
        si.append(int(d))
    print (tester(si[0],si[1]))

if __name__ == '__main__':
    main()


Measured memory_bytes: 28792
# import bisect
# from collections import Counter, defaultdict, deque, namedtuple
# import copy
# from heapq import heappush, heappop, heapify
# from fractions import gcd
# import itertools
# from operator import attrgetter, itemgetter
# import math

import sys

# import numpy as np

ipti = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)

def main():
    h, w = list(map(int,ipti().split()))
    a = [[0] * w for _ in range(h)]

    for i in range(h):
        a[i] = list(map(int,ipti().split()))

    x_cur = 0
    y_cur = 0
    x_next = 0
    y_next = 0
    direction = 1 #1なら右、-1なら左
    mani_count = 0
    res = []

    while True:
        x_next += direction
        if x_next >= w:
            x_next -= 1
            direction *= -1
            y_next += 1
            if y_next >= h:
                break
        elif x_next < 0:
            x_next += 1
            direction *= -1
            y_next += 1
            if y_next >=h:
                break

        if a[y_cur][x_cur] % 2 == 1:
            mani_count += 1
            a[y_cur][x_cur] -= 1
            a[y_next][x_next] += 1
            res.append([y_cur + 1, x_cur + 1, y_next + 1, x_next + 1])

        x_cur, y_cur = x_next, y_next

    print(mani_count)
    for elem in res:
        print(*elem)

if __name__ == '__main__':
    main()

Measured memory_bytes: 73180
import sys
from bisect import bisect_left, bisect_right

N = int(sys.stdin.readline())
A = list(map(int, sys.stdin.readline().split(" ")))
B = list(map(int, sys.stdin.readline().split(" ")))
C = list(map(int, sys.stdin.readline().split(" ")))

A.sort()
B.sort() # ソートしなくても良い
C.sort()

ans = 0
for b_i in B:
    a_n = bisect_left(A, b_i)
    c_n = bisect_right(C, b_i)
    # print(a_n, c_n)
    ans += a_n * (N - c_n)

print(ans)

Measured memory_bytes: 94172
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int n;
vector<int> a;

int gcd(int x, int y){
    if(x%y == 0) return y;

    return gcd(y, x%y);
}

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


    int tmp = gcd(a[0], a[1]);
    for(int i = 2; i < n; i++){
        tmp = gcd(tmp,a[i]);
    }

    cout << tmp << endl;
}


Measured memory_bytes: 640
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

template < typename T >
void vprint(T &V){
	for(auto v : V){
        cout << v << " ";
    }
	cout << endl;
}

struct Edge{
    ll to;
    ll cost;
    Edge(ll to, ll cost): to(to), cost(cost) {}
};

vector<vector<Edge> > graph;

void printGraph(){
    FOR(i, 0, graph.size()){
        for(auto e : graph[i]){
            cout << i << "->" << e.to << " " << e.cost << endl;
        }
    }
}

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

    // input
    int K;
    cin >> K;

    graph.resize(K);
    // グラフデータ
    // graph[0].push_back(Edge(1, 1));
    // graph[1].push_back(Edge(2, 1));
    // graph[1].push_back(Edge(4, 0));
    // graph[2].push_back(Edge(3, 1));
    // graph[3].push_back(Edge(4, 1));
    // graph[3].push_back(Edge(0, 0));
    // graph[4].push_back(Edge(5, 1));
    // graph[5].push_back(Edge(0, 1));
    // graph[5].push_back(Edge(2, 0));
    
    // +1の分
    FOR(i, 0, K-1){
        graph[i].push_back(Edge(i+1, 1));
    }
    graph[K-1].push_back(Edge(0, 1));

    // +0の分
    FOR(i, 1, K){
        ll to = (10*i)%K;
        ll cost = 0;
        if(i!=to){
            graph[i].push_back(Edge(to, cost));        
        }
    }

    // 確認
    //printGraph();

    vector<ll> d(K);
    fill(ALL(d), inf);

    deque<ll> que;
    // 1からスタート
    d[1] = 0;
    que.push_front(1);

    while(!que.empty()){
        
        // 先頭の取り出し
        auto first = que.front(); 
        que.pop_front();

        // p("");
        // pn(first);

        auto lst = graph[first];
        for(Edge e : lst){
            ll dist = d[first] + e.cost;
            if(dist < d[e.to]){
                d[e.to] = dist;
                if(e.cost==0){
                    que.push_front(e.to);
                }else{
                    que.push_back(e.to);
                }                
            }
        }
    }

    p(d[0]+1);
    
    return 0;
}

Measured memory_bytes: 8448
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main(){
    ll n, k, ans = inf;
    cin >> n >> k;
    k--;
    vector<ll> x(n);
    rep(i, n)cin >> x.at(i);
    for(int i = 0; i < n-k; i++){
        if(x.at(i) <= 0 && 0 <= x.at(i+k)){
            ll mi = min(abs(x.at(i)), abs(x.at(i+k)));
            ll ma = max(abs(x.at(i)), abs(x.at(i+k)));
            ans = min(ans, 2*mi+ma);
        }
        else if(x.at(i+k) <= 0){
            ans = min(ans, abs(x.at(i)));
        }
        else{
            ans = min(ans, abs(x.at(i+k)));
        }
    }
    cout << ans;
}   


Measured memory_bytes: 1024
///Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>

#define                           ll                          long long
#define                           int                         ll
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<ll,ll>
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           show(x,y)                   cout<<x<<" : ";for(auto z:y)cout<<z<<" ";cout<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

const ll inf=1e18;
const int mod=1e9+7;
const int M=100009;

inline ll bigmod(ll B,ll P){ll R=1;while(P>0){if(P&1){R=(R*B)%mod;}P>>=1;B=(B*B)%mod;}return R;}
inline ll ad(ll x,ll y){ll ret=(x%mod+y%mod)%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}
inline ll sub(ll x,ll y){ll ret=((x%mod)-(y%mod)+mod)%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}
inline ll gun(ll x,ll y){ll ret=((x%mod)*(y%mod))%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}

string s;
int dp[M+3][13],sz;
int ten[M+4];
int n;
int solve(int pos,int rem)
{
    rem=rem%13;
    if(pos==sz)
    {
         if(rem==5)return 1;
         else return 0;
    }
    int &ret=dp[pos][rem];
    if(ret!=(-1))return ret;
    ret=0;
    if(s[pos]!='?')
    {
        int x=s[pos]-'0';
        int y=n-pos-1;
        int val=(ten[y]*x)%13;
        rem=(rem+val)%13;
        ret=ad(ret,solve(pos+1,rem));
    }
    else
    {
        for(int i=0;i<=9;i++)
        {
            int y=n-pos-1;
            int val=(ten[y]*i)%13;
            int nw=(rem+val)%13;
            ret=ad(ret,solve(pos+1,nw));
        }
    }
    return ret;
}
void init()
{
    ten[0]=1;
    int dos=10;
    dos=dos%13;
    for(int i=1;i<=M;i++)
    {
        ten[i]=(dos*ten[i-1])%13;

    }
}
 main()

{
    fast
    memset(dp,-1,sizeof dp);
    init();
    cin>>s;
    sz=s.size();n=sz;
    cout<<solve(0,0)<<endl;
    return 0;

}





































Measured memory_bytes: 19280
program hrn;
 var
  s:string;
  i,l,f:longint;
 begin
  read(s);l:=length(s);
  for i:=1 to l-1 do
   if(s[i]='A')and(s[i+1]='C')then f:=1;
  if f=1 then writeln('Yes')else writeln('No');
 end.

Measured memory_bytes: 128
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))

n,m,x=nii()
l=[lnii() for i in range(n)]

ans=10**9
for i in range(2**n):
  ml=[0 for j in range(m)]
  use=[0 for i in range(n)]

  for j in range(n):
    if (i>>j)&1:
      use[j]=1

  t_ans=0
  for j in range(n):
    if use[j]==1:
      use_book=l[j]
      t_ans+=use_book[0]
      for k in range(1,m+1):
        ml[k-1]+=use_book[k]

  if min(ml)>=x:
    ans=min(ans,t_ans)

if ans==10**9:
  print(-1)
else:
  print(ans)

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef tuple<int, int> duo;
const int dx[] = {0, 0, 1, -1, 1, 1, -1, -1};
const int dy[] = {1, -1, 0, 0, 1, -1, 1, -1};
const int Mod = 1000000000 + 0;
//{{{ templates
#define TT_ template<typename T>inline
#define TTF_ template<typename T,typename F>inline
TT_ T sq(T x){return x*x;}
TT_ T In(){T x;cin>>x;return x;}
TT_ void Out(T&x){cout<<x;}
TT_ void sort(T&v){sort(begin(v),end(v));}
TT_ void revs(T&v){reverse(begin(v),end(v));}
TT_ void uniq(T&v){sort(v);v.erase(unique(begin(v),end(v)),end(v));}
TT_ int ubnd(T&v,typename T::value_type&x){return upper_bound(begin(v),end(v),x)-begin(v);}
TT_ int lbnd(T&v,typename T::value_type&x){return lower_bound(begin(v),end(v),x)-begin(v);}
TTF_ void inpt(T&v,int n,F f){for(v.reserve(n);n--;v.emplace_back(f()));}
TTF_ void show(T&v,F f,string d=" ",string e="\n"){int i=0;for(auto&x:v)i++&&(cout<<d),f(x);cout<<e;}
TT_ typename T::iterator minel(T&v){return min_element(begin(v),end(v));}
TT_ typename T::iterator maxel(T&v){return max_element(begin(v),end(v));}

inline void fast_io(){ios::sync_with_stdio(0);cin.tie(0);}
inline int in(){int x;scanf("%d",&x);return x;}
inline ll pow_mod(ll a,ll k,ll m){ll r=1;for(;k>0;a=a*a%m,k>>=1)if(k&1)r=r*a%m;return r;}
inline ll mod_inv(ll a,ll p){return pow_mod(a,p-2,p);}
//}}} priority_queue queue deque front stringstream max_element min_element insert count make_tuple

//{{{ Z(s, &z)
void Z(const string& s, vector<int>& z)
{
  const int n = s.size();
  z.assign(n, 0);
  int R, L;
  R = L = 0;
  for (int i = 1; i < n; i++){
    if (i > R){
      L = R = i;
      while (R < n && s[R - L] == s[R]) R++;
      z[i] = R - L;
      R--;
    }
    else {
      int k = i - L;
      if (z[k] < R - i + 1) z[i] = z[k];
      else {
        L = i;
        while (R < n && s[R - L] == s[R]) R++;
        z[i] = R - L;
        R--;
      }
    }
  }
}
//}}}

int main()
{
  char S[4096], T[4096];
  while (~scanf("%s %s", S, T)){
    string s = S, t = T;
    string st = s + '$' + t;
    const int sl = s.size();
    int maxi = 0;
    for (int i = 0; i < sl - maxi - 1; i++){
      vector<int> z;
      Z(st.substr(i), z);
      maxi = max(maxi, *max_element(begin(z) + (sl - i), end(z)));
    }
    printf("%d\n", maxi);
  }
  return 0;
}

Measured memory_bytes: 1264
package main

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

type Query struct {
	Num, L, R int
}

func main() {
	N, Q := ReadInt(), ReadInt()
	c := ReadInts(N)
	for i := 0; i < N; i++ {
		c[i]--
	}
	queries := make([]*Query, Q)
	for i := 0; i < Q; i++ {
		queries[i] = &Query{
			Num: i,
			L:   ReadInt() - 1,
			R:   ReadInt() - 1,
		}
	}
	sort.Slice(queries, func(i, j int) bool {
		return queries[i].R < queries[j].R
	})

	seg := MakeSegTree(N)
	last := make([]int, N)
	for i := 0; i < N; i++ {
		last[i] = -1
	}
	i := 0
	ans := make([]int, Q)
	for j := 0; j < Q; j++ {
		q := queries[j]
		for ; i <= q.R; i++ {
			if last[c[i]] >= 0 {
				seg.Add(last[c[i]], -1)
			}
			seg.Add(i, 1)
			last[c[i]] = i
		}
		ans[q.Num] = seg.getSum(q.L, q.R+1)
	}
	for i := 0; i < Q; i++ {
		fmt.Println(ans[i])
	}
}

type SegTree []int

func MakeSegTree(n_ int) SegTree {
	n := 1
	for n < n_ {
		n <<= 1
	}
	return make([]int, n<<1)
}

func (t SegTree) Add(i, x int) {
	i += len(t) >> 1
	for i > 0 {
		t[i] += x
		i >>= 1
	}
}

func (t SegTree) getSum(a, b int) int {
	return t.getSumRecur(a, b, 1, 0, len(t)>>1)
}
func (t SegTree) getSumRecur(a, b, k, l, r int) int {
	if b <= l || r <= a {
		return 0
	}
	if a <= l && r <= b {
		return t[k]
	}
	sum := 0
	sum += t.getSumRecur(a, b, k<<1, l, (l+r)>>1)
	sum += t.getSumRecur(a, b, k<<1+1, (l+r)>>1, r)
	return sum
}

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

class UnionFind{
    vector<int> par;
    vector<long long> wei;
    int groupCount;

public:
    UnionFind(int n = 0){
        init(n);
    }

    void init(int n = 0){
        par.resize(n);
        fill(par.begin(), par.end(), -1);

        wei.resize(n);
        fill(wei.begin(), wei.end(), 0LL);

        groupCount = n;

        return;
    }

    int root(int x){
        if(par[x] < 0){
            return x;
        }
        int r = root(par[x]);
        wei[x] += wei[par[x]];
        return par[x] = r;
    }

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

    int size(int x){
        return -par[root(x)];
    }

    long long weight(int x){
        root(x);
        return wei[x];
    }

    long long diff(int x, int y){
        return weight(y) - weight(x);
    }

    bool unite(int x, int y, long long w = 0){
        w += weight(x) - weight(y);

        x = root(x);
        y = root(y);

        if(x == y){
            return false;
        }

        if(par[y] < par[x]){
            swap(x, y);
            w = -w;
        }

        par[x] += par[y];
        par[y] = x;
        wei[y] = w;
        --groupCount;

        return true;
    }

    int size(void){
        return groupCount;
    }
};

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

    int n, m;
    cin >> n >> m;

    UnionFind uf(n);
    for(int i = 0 ; i < m ; ++i){
        int l, r;
        long long d;
        cin >> l >> r >> d;
        if(uf.same(--l, --r) && uf.diff(l, r) != d){
            cout << "No" << endl;
            return 0;
        }
        uf.unite(l, r, d);
    }

    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 1536
#include <iostream>
#include <algorithm>
#include "math.h"


using namespace std;

int main()
{
	int a, b, c;
	cin >> a;
	cin >> b;
	cin >> c;
	if (c - b - a <= 0) {
		cout << b + c << endl;
	}
	else {
		cout << b + (b + a + 1) << endl;
	}
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//型に気を付けよう
//a=0x61=97
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long  ll;
typedef long double  ld;
typedef pair<int,int> pairii;
typedef vector<int> veci;
const double pi=3.1415926535;
const ll  mod=1000000007;
//桁数指定　cout << fixed << setprecision(2)
int main() {
  int n,k,cnt=0;
  cin>>n>>k;
  veci v(n);
  rep(i,n)cin>>v[i];
  sort(v.begin(),v.end());
  if(k<v[0])goto i;
  for(int i=0;(i<n)&&(k>0);i++){if(k<v[i])goto i;
    k-=v[i];
    cnt++;cerr<<i;
  }if(k>0)cnt--;
 i: cout<<cnt<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define forsn(i, s, n) for(int i=s;i<int(n);i++)
#define forn(i, n) forsn(i, 0, n)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
 
typedef long long tint;

const int INF = 1e6;
const long double PI = acos(-1);
 
int main() {
	int a, b, x; cin >> a >> b >> x;
	if(a > x) cout << "NO" << endl;
	else if(a+b >= x) cout << "YES" << endl;
	else cout << "NO" << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long [] height = new long[N];
		for(int i = 0; i < N ; i++) {
			height[i] = sc.nextLong();
		}
		long ans = 0;
		for(int i = 0; i < N-1; i++) {
			if(height[i] > height[i+1]) {
				long tmp = height[i]-height[i+1];
				ans += tmp;
				height[i+1]  += tmp;
			}
		}
		System.out.println(ans);

	}
}

Measured memory_bytes: 61492
#include<bits//stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int n, m, q, a[50], b[50], c[50], d[50], ans = 0, A[10];
void dfs(int p, int k) {
    if (p == n) {
        int sum = 0;
        rep(i,q) {
            if (A[b[i] - 1] - A[a[i] - 1] == c[i]) sum += d[i];
        }
        ans = max(ans, sum);
    }
    else {
        for (int i = k; i <= m; i++) {
            A[p] = i;
            dfs(p + 1, i);
        }
    }
}
int main() {
    cin >> n >> m >> q;A[0] = 1;
    rep(i,q) cin >> a[i] >> b[i] >> c[i] >> d[i];
    dfs(1, 1);
    cout << ans << endl;
}

Measured memory_bytes: 3564
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <numeric>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 100000001;
ll t[100010][50];
const ll mod = 1000000007;
void PictureFrame() {
	
	int h, w;
	cin >> h >> w;
	for (size_t i = 0; i <= h + 1; i++)
	{
		for (size_t j = 0; j <= w + 1; j++)
		{
			if (i == 0 || j == 0 || i == (h + 1) || j == (w + 1)) {
				cout << "#";
			}
			else
			{
				char c;
				cin >> c;
				cout << c;
			}
		}
		cout << endl;
	}
}

int main() {
	PictureFrame();

	return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <sstream>
#include <cmath>
#include <climits>
#include <set>
#include <iostream>
#include <map>
#include <functional>
#include <cstdlib>
#include <numeric>
#include <queue>

using namespace std;

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

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

int main()
{
	int x, y;
	while(scanf("%d%d", &x, &y), x&y){
		printf("%f\n", x*(x+sqrt(x*x+4*y*y)));
	}

	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main()
{
    std::ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n,m;
    cin>>n>>m;
    long long under = 0;
    long long last = 0;
    long long ans = 0;
    for(long long i=m;i<=n+1;i++)
    {
        under = (i-1)*i/2;
        last = (n+n-(i-1))*i/2;
        ans = (ans + (last-under)+1)%1000000007;
    }
    cout<<ans;




}


Measured memory_bytes: 3608
function myin(){return require("fs").readFileSync("/dev/stdin", "utf8").trim();}
function myout(text){console.log(text);}//standard output
//[no]param
//0:noConvert	1:singleNum	2:spaceList	3:newLineList	4:spaceNumList	5:newLineNumList
function myconv(i,no){switch(no){case 0:return i;case 1:return parseInt(i);case 2:return i.split(" ");case 3:return i.split("\n");case 4:return i.split(" ").map((a)=>Number(a));case 5:return i.split("\n").map((a)=>Number(a));}}

function Main(input) {
  input = myconv(input,1);
  var tmpInput = input.toString();
  var check = 0;
  for(var i = 0; i < tmpInput.length; i++){
    check += parseInt(tmpInput.slice(i,i+1));
  }
  if(input % check == 0){
     myout("Yes");
     }else{
     myout("No");
     }
  
}

Main(myin());


Measured memory_bytes: 7372
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <algorithm>

using namespace std;

void showIntArray(int a[], int n) {
  for (int i=0; i<n; i++) {
    cout << a[i] << ' ';
  } cout << endl;
}

int main() {
  int N, cr=0, cb=0;
  // char s[1000];
  char s;
  cin >> N;
  for (int i=0; i<N; i++) {
    cin >> s;
    if (s == 'R') {cr++;}
    else {cb++;}
  }
  if (cr > cb) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
carried = 1
uncarried = 0
gets.split("").each{ |n|
  n = n.to_i
  c = [carried + 9 - n, uncarried + n + 1].min
  u = [carried + 10 - n, uncarried + n].min
  carried = c
  uncarried = u
}
p uncarried

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

using namespace std;

int main(){
  int N, tmp;
  vector<int> A, B, C;
  cin >> N;
  for (int i=0; i<N; i++){
    cin >> tmp;
    A.push_back(tmp);
  }
  for (int i=0; i<N; i++){
    cin >> tmp;
    B.push_back(tmp);
  }
  for (int i=0; i<N - 1; i++){
    cin >> tmp;
    C.push_back(tmp);
  }
  int res = B[A[0] - 1];
  for (int i=1; i<N; i++){
    res += B[A[i] - 1];
    if (A[i] - A[i - 1] == 1){
      res += C[A[i - 1] - 1];
    }
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
import copy

N, K = map(int,input().split())
V = list(map(int, input().split()))

max_value=0
for i in range(min(N,K)+1):
  for j in range(min(N,K)-i+1):
    tmp_get=[]
    tmp_get.extend(V[:i])
    if j!=0:
      tmp_get.extend(V[-j:])
    tmp_get.sort()

    for _ in range(K-(i+j)):
      if tmp_get!=[] and tmp_get[0]<0:
        tmp_get.pop(0)

    if sum(tmp_get)>max_value:
      max_value=sum(tmp_get)
          
print(max_value)

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

using namespace std;
typedef long long ll;
typedef pair<int,int>pa;

const int N=2e5+100;
const int mod=1e9+7;
ll a[N];
int main()
{
   ios::sync_with_stdio(0);cin.tie(0);
   ll n;cin>>n;
   for(int i=1;i<=50;i++){
     a[i]=i-1;
   }
   ll k=n/50;
   int kk=n%50;
   for(int i=1;i<=50;i++){
    a[i]+=k;
   }
   for(int i=1;i<=kk;i++){
     for(int j=1;j<=50;j++){
        if(j==i) a[j]+=50;
        else a[j]--;
     }
   }
   cout<<50<<endl;
   for(int i=1;i<=50;i++)
     cout<<a[i]<<" ";
   return 0;
}



Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
using ll = long long;
using ull = unsigned long long;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
const ll md = 1000000007;
vector<ll> fact(1e6 + 7), invfact(1e6 + 7);

ll fn(ll a, ll r, ll n, ll mod = md) {
    ll res = 1, x = r%mod;
    ll ans = 0;
    while(n) {
        if(n&1) ans = (x*ans + res)%mod;
        res = ((res*x)%mod + res%mod)%mod;
        x = (x*x)%mod;
        n = n/2;
    }
    ans = (ans*a)%mod;
    return ans;
}

ll nCr(ll n, ll r) {
    if(r == 0) return 1;
    ll num = fact[n];
    ll den = (invfact[r] % md *invfact[n-r] % md)%md;
    return (num*den)%md;
}

ll mul(ll a, ll b, ll mod = md) {
    ll res = (a%mod * b%mod)%mod;
    return res;
}

ll mulm(ll a, ll b, ll mod = md) {
    ll r = 0;
    a %= mod;
    while (b) {
        if (b & 1) r = (r+a)%mod;
        a = (a+a)%mod;
        b = b/2;
    }
    r %= mod;
    return r;
}

ll power(ll x, ll n, ll mod = md) {
    ll res = 1;
    x %= mod;
    while (n) {
        if (n & 1)  res = (res*x)%mod;
        n = n/2;
        x = (x*x)%mod;
    }
    return res;
}

ll power2(ll x, ll n) {
    ll res = 1;
    while (n)  
    {  
        if (n & 1)  res = (res*x);  
        n = n/2; 
        x = (x*x);  
    }  
    return res;
}

bool is_prime(ll x) {
    if(x == 1 || x == 0) return false;
    for(int i=2; i*i <= x; i++) {
        if(x%i == 0) return false;
    }
    return true;
}

ll compgcd(ll n, vector<ll> const &primes) { 
    ll res = n; 
    for (ll i=0; primes[i]*primes[i] <= n; i++) {
        if (n % primes[i]== 0) { 
            res -= (res / primes[i]); 
            while (n%primes[i]== 0) {
               n/=primes[i]; 
            }
        } 
    } 
    if (n > 1) {
       res -= (res / n); 
    }
    return res; 
} 

void sieve(vector<bool> &prime, vector<ll> &primes, ll lim) {
    for(int i = 2; i*i <= lim; i++) {
        if(prime[i]) {
            for(int j = 2; j*i <= lim; j++) {
                prime[j*i] = false;
            }
        }
    }
    for(int i = 2; i <= lim; i++) {
        if(prime[i]) {
            primes.push_back(i);
        }
    }
}

void sieveGCD(ll lim, vector<ll> &tab, vector<ll> const &primes) {
    for(int  i = 1; i <= lim; i++) {
        tab[i] = i;
    }
    for(int i = 0; i<primes.size() && primes[i] <= lim; i++) {
        tab[primes[i]] = primes[i]-1;
        for(int j = 2; primes[i]*j <= lim; j++) {
            tab[primes[i]*j] = (tab[primes[i]*j]/primes[i])*(primes[i]-1);
        }
    }
}

ll calc(ll a, ll b, ll r) {
    ll total = r+1;
    ll tmp = a*b;
    ll count = (r/tmp)*max(a,b) + max(a,b);
    if((r/tmp)*tmp + max(a,b) > r) {
        count -= ((r/tmp)*tmp + max(a,b) - r - 1);
    }
    total -= count;
    return total;
}

int main() 
{ 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a, b;
    cin >> a >> b;
    cout << 6/(a*b) << "\n";
    return 0;
}

Measured memory_bytes: 15872
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 5e5+10;

ll a[maxn],b[maxn];

int main(){
	string s;
	cin >> s;
	
	int len = s.size();
	memset(a,0,sizeof(a));
	memset(b,0,sizeof(b));
	
	for(int i = 0;i < len;++i){
		if(s[i] == '<'){
			int j = 0;
			a[i] = j;
			while(s[i+1] == s[i] && i+1 < s.size()) a[++i] = ++j;
			a[i+1] = ++j;
		}
	}
	if(s[len-1] == '<') a[len] = a[len-1]+1;
	for(int i = len-1;i >= 0;--i){
		if(s[i] == '>'){
			int j = 0;
			b[i+1] = j;
			while(s[i-1] == s[i] && i-1 >= 0) b[i--] = ++j;
			b[i] = ++j;
		}
	}
	if(s[0] == '>') b[0] = b[1]+1;

	ll ans = 0;
	for(int i = 0;i <= len;++i) ans += max(a[i],b[i]);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 8708
package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Scan()
	line := strings.Split(sc.Text(), " ")
	a, _ := strconv.Atoi(line[0])
	b, _ := strconv.Atoi(line[1])
	fmt.Println(a * b)
}


Measured memory_bytes: 1760
#include <stdio.h>
#define min(x, y) ((x)>(y) ? (y) : (x))
#define max(x, y) ((x)<(y) ? (y) : (x))

int main(){
  int n;  scanf("%d", &n);
  int a[100005], b[100005];
  for(int i=0; i<n+1; i++)  scanf("%d", a+i);
  long ans = 0;
  for(int i=0; i<n; i++){
    scanf("%d", b+i);
    ans = ans + (long)min(a[i], b[i]);
    ans += (long)max(0, min(a[i+1], b[i]-a[i]));
    a[i+1] = max(0, a[i+1]-max(0, b[i]-a[i]));
  }
  printf("%ld\n", ans);
  return 0;
}


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

ans = 0
i = 0
for i in range(n-1):
    if a[i] == i + 1:
        ans += 1
        a[i+1] = 0

if a[n-1] == n:
    ans += 1

print(ans)



Measured memory_bytes: 14008
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int a = scanner.nextInt();
    int b = scanner.nextInt();
    int c = scanner.nextInt();
    int min = 30001;
    
    if (a+b < min) {
      min = a+b;
    }
    
    if (a+c < min) {
      min = a+c;
    }
    if (b+c < min) {
      min = b+c;
    }
    
    System.out.println(min);
}
}

Measured memory_bytes: 21844
#include<cstdio>
#include<iostream>
#include<algorithm>

#define MAX 1000001

using namespace std;

char prime[MAX];

void furui(int n)
{
  int i,j;
  prime[0]=prime[1]=1;
  for(i=2;i*i<=n;i++){
    if( prime[i] ) continue;
    for(j=i*2;j<=n;j+=i){
      prime[j]=1;
    }
  }
}

main(){
  int n;
  int i,j;
  int ans;
  furui(MAX-1);
  while(1){
    ans=j=0;
    cin >> n;
    if(!n) break;
    for(i=0;i<MAX-1;i++){
      if(j>=n) break;
      if(prime[i]==0){
	ans+=i;
	j++;
      }
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 0
import bisect
import cmath
import heapq
import itertools
import math
import operator
import os
import random
import re
import string
import sys
from collections import Counter, defaultdict, deque
from copy import deepcopy
from decimal import Decimal
from functools import lru_cache, reduce
from math import gcd
from operator import add, itemgetter, mul, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353

N, K = list(map(int, sys.stdin.buffer.readline().split()))
A = list(map(int, sys.stdin.buffer.readline().split()))

for i in range(K, N):
    j = i - K
    ok = A[j] < A[i]
    if ok:
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 46216
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; }
template <class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b; }
void print() { cout << "\n"; }
template <class T, class... Args>
void print(const T &x, const Args &... args) { cout << x << " "; print(args...);}
void debug_out() { cout << "\n"; }
template <class T, class... Args>
void debug_out(const T &x, const Args &... args) { cout << x << " "; debug_out(args...);}
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

ll f(ll a, ll b) {
  return a*a*a*a*a - b*b*b*b*b;
} 

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  ll x;
  cin >> x;
  for (ll a = 1; ; ++a) {
    for (ll b = a; ; --b) {
      if (f(a,b) == x) {
        debug(f(a,b));
        cout << a << " " << b << endl;
        return 0;
      }
      else if (f(a,b) > x) break;
      debug(a,b);
    }
  }
  return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <stdio.h>
#include <stdlib.h>

using namespace std;

int main() {
  long x, y, diff;
  cin >> x >> y;
  if(x == y) {
    cout << 0 << endl;
  } else if (y > x) {
    diff = y - x;
    if(diff < x) {
      cout << diff << endl;
    } else {
      cout << x << endl;
    }
  } else if (x > y) {
    diff = x % y;
    y = labs(diff - y);
    if(diff < y) {
      cout << diff << endl;
    } else {
      cout << y << endl;
    }
  }
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    ll n,ans=0; cin>>n;
    vector<pair<ll,ll>> q(n);
    rep(i,n){
        ll a,b; cin>>a>>b;
        q[i]=mk(a+b,b);
    }
    sort(al(q)); reverse(al(q));
    rep(i,n){
        ans-=q[i].second;
        if(i%2==0) ans+=q[i].first;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1792
n = int(input())
t,a = map(float, input().split( ))
h = list(map(float, input().split( )))
ans= float(0)
c1 = float(0)
c2 = float(100000000000000)
for i in range(n):
    c1 = a-(t-(h[i]*0.006))
    c1 = abs(c1)
    if c1 <= c2:
        ans = i+1
        c2 = c1
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<bitset>
#include<deque>
#include<functional>
#include<iterator>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<utility>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep1(i,n) for(ll i=1;i<=(n);i++)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(n);i>=1;i--)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
const ll MOD=1000000007;
const ll INF=1000000000000000;
template<class T> inline bool chmin(T& a, T b){if(a>b){a=b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a=b;return true;}return false;}
ll maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll digsz(ll x){if(x==0) return 1;else{ll ans=0;while(x){x/=10;ans++;}return ans;}}
ll digsum(ll x){ll sum=0;while(x){sum+=x%10;x/=10;}return sum;}
vector<ll> pw2(62,1);vector<ll> pw10(19,1);


int main(){
    {rep1(i,61) pw2[i]=2*pw2[i-1];}
    {rep1(i,18) pw10[i]=10*pw10[i-1];}
    
    ll L,R,d; cin>>L>>R>>d;
    cout<<(R/d)-(L-1)/d<<endl;
    
}



Measured memory_bytes: 3676
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <cassert>
#include <cinttypes>

using namespace std;

typedef int64_t ll;
typedef uint64_t ull;

typedef pair<int, int> P;
inline P operator+(const P& p1, const P& p2) {
  return P(p1.first + p2.first, p1.second + p2.second);
}


int main(){
  int n, k;
  cin >> n >> k;
  vector<int> cnt(200001);

  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    cnt[a]++;
  }

  sort(cnt.begin(), cnt.end(), greater<int>());

  int ans = 0;
  for (int i = k; i < n; i++) {
    ans += cnt[i];
  }

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

/* */

Measured memory_bytes: 1024