akhauriyash/Code-Regression huggingface dataset:
// #include <bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>
#include<queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define exf(x)	 for(auto&& tmp : x) { cout << tmp << endl; }	// 拡張for
#define PI 3.14159265358979323846264338327950288
#define testP	 cout << "------------------ test ------------------" << endl;	// 動作確認テスト
#define testX(x) cout << "testout : " << x << endl;	// テストアウト
const int MOD{ int(1e9 + 7) };	// = 1000000007
const int inf{ 2100000000 };	// = 2100000000 (MAX:2147483647)
typedef long long ll;
using namespace std;

// ------------------ ベクター表示 ------------------ //
void printVec(vector<int>& vec) {
	cout << "";
	for (auto it = vec.begin(); it != vec.end(); it++) cout << *it << " ";
	cout << endl;
}

// ------------------ ベクター合計 ------------------ //
int sumVec(vector<int> v) {
	int sum = 0;
	for (size_t i = 0; i < v.size(); i++) sum += v[i];
	return sum;
}

// -------------------------------------------------- //
// ------------------ ここから本編 ------------------ //
// -------------------------------------------------- //

int main(void) {

	int a, b, c, d, N, H, W;

	cin >> a;
	cout << a + a * a + a * a * a << endl;

	return 0;
}


Measured memory_bytes: 3668
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int V = Integer.parseInt(sc.next());
        int E = Integer.parseInt(sc.next());
        int r = Integer.parseInt(sc.next()); // root
        long INF = 200_000_000_000_000_000L;
        ArrayList<int[]> edge = new ArrayList<int[]>();
        for (int i=0;i<E;i++) {
            int s = Integer.parseInt(sc.next());
            int t = Integer.parseInt(sc.next());
            int d = Integer.parseInt(sc.next());
            int[] add = {s, t, d};
            edge.add(add);
        }

        long[] values = new long[V];
        for (int i=0;i<V;i++) {
            if (i!=r) {
                values[i]=INF;
            }
        }
        int flag = 0;
        for (int k=0;k<V;k++) {
            for (int i=0;i<E;i++) {
                    int[] tmp = edge.get(i);
                    if ((values[tmp[0]] != INF) && (values[tmp[1]] > values[tmp[0]]+tmp[2])) {
                        values[tmp[1]] = values[tmp[0]]+tmp[2];
                        if (k==V-1) {
                            flag=1;
                        }
                    }
            }
        }

        if (flag==1) {
            System.out.println("NEGATIVE CYCLE");
        } else {
            for (int i=0;i<V;i++) {
                if (values[i]==INF) {
                    System.out.println("INF");
                } else {
                    System.out.println(values[i]);
                }
            }
        }
    }
}


Measured memory_bytes: 38580
#include<iostream>
#include<string>
using namespace std;
int main(){
	int H,W;cin>>H>>W;
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			string S;cin>>S;
			if(S=="snuke"){cout<<(char)('A'+j)<<i+1<<endl;}
		}
	}
	return 0;
}

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

using namespace std;

int Erase(vector<int> a){
  for(int i=0,j=0;j<a.size();){
    if(a[j]==a[j+1])j++;
    else {
      if(j-i>2){
	a.erase(a.begin()+i,a.begin()+j+1);
	i=j=0;
      }
      else j++,i=j;
    }
  }
  return a.size();
}

int main(void){
  int n,m;
  vector<int>a;

  while(cin >> n,n){
    a.clear();
    for(int i=0;i<n;i++){
      cin >> m;
      a.push_back(m);
    }

    int ans=100000000;
    for(int i=0;i<a.size();i++){
      int temp=a[i];
      for(int j=1;j<4;j++){
	if(temp!=j){
	  a[i]=j;
	  ans=min(ans,Erase(a));
	}
      }
      a[i]=temp;
    }
    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 1328
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<string>
#include<functional>
#include<queue>
#include<math.h>
#define INF 999999

using namespace std;

typedef long long ll;

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

int main()
{
	ll a, b;
	while (cin >> a >> b) {

		ll c = gcd(a, b);
		ll d = a*b / c;

		printf("%lld %lld\n", c, d);
	}

	return 0;
}

Measured memory_bytes: 3200
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
 
class UnionFind{
public:vector<int>Parent;
  UnionFind(int N){
    Parent=vector<int>(N,-1);
  }
  int root(int A){
    if(Parent[A]<0)return A;
    return Parent[A]=root(Parent[A]);
  }
  int size(int A){
    return -Parent[root(A)];
  }
  bool connect(int A,int B){
    A=root(A);
    B=root(B);
    if(A==B){
      return false;
    }
    if(size(A)<size(B))swap(A,B);
    Parent[A]+=Parent[B];
    Parent[B]=A;
    return true;
  }
};
 
int main(){
  int N,M;
  cin >> N >> M;
  vector<int>A(M),B(M);
  for(int i=0;i<M;i++){
    cin >> A[i] >> B[i];
    A[i]--;
    B[i]--;
  }
  vector<long long>ans(M);
  ans[M-1]=(long long)N*(N-1)/2;
  
  UnionFind Uni(N);
  
  for(int i=M-1;i>0;i--)
  {
    ans[i - 1] = ans[i];
 
		
		if (Uni.root(A[i]) != Uni.root(B[i])) {
			ans[i - 1] -= (long long)Uni.size(A[i]) * Uni.size(B[i]);
			Uni.connect(A[i], B[i]);
		}
	}
 
	for (int i = 0; i < M; i++)
	{
		cout << ans[i] << endl;
	}
  
}

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

// int/long:		-2,147,483,648 - 2,147,483,648 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

#define	INF (1<<29)
//536,870,912

// lower_bound(A.begin(), A.end(), N)
// upper_bound(...

// A.erase(unique(A.begin(), A.end()), A.end())

// bit: &/and, |/or, ^/xor, ~/not

// getline(cin, String)

#define	MOD 1000000007

struct	ITEM {
	long	wei;
	long	val;
};

int	main() {
	long N, K;
	cin >>N >>K;
	vector<long> A(N);
	long AMax=K;
	for (long i=0; i<N; i++) {
		cin >>A.at(i);
		AMax=max(AMax, A.at(i));
	}
	vector<ITEM>	p;
	long I=1;
	while (AMax>=I) {
		p.push_back({I, 0});
		I *=2;
	}
	for (long i=0; i<N; i++) {
		long AA=A.at(i);
		for (long j=0; j<p.size(); j++)
			if (0!=(AA&p.at(j).wei))
				p.at(j).val++;
	}
	long f=0;
	for (long i=0; i<p.size(); i++) {
		f += p.at(i).wei*p.at(i).val;
	}
	for (long i=0; i<p.size(); i++) {
		long NN=N-p.at(i).val*2;
		if (NN <= 0)
			p.at(i).val=0;
		else
			p.at(i).val=NN*p.at(i).wei;
	}
	vector<vector<long>> VL;
	long V=0;
	long KK=0;
	VL.push_back({V, KK});
	for (long i=p.size()-1; i>=0; i--) {
		if (K>=KK+p.at(i).wei) {
			KK +=p.at(i).wei;
			if (p.at(i).val>0) {
				V +=p.at(i).val;
				VL.push_back({V, KK});
			}
		}
	}
	vector<vector<long>> VR;
	V=0;
	KK=0;
	VR.push_back({V, KK});
	for (long i=0; i<p.size(); i++) {
		if (K>=KK+p.at(i).wei) 
			if (p.at(i).val>0) {
				V +=p.at(i).val;
				KK +=p.at(i).wei;
				VR.push_back({V, KK});
			}
	}
	long S=0;
	long ir=0;
	long il=VL.size()-1;
	while (ir<VR.size()) {
		while(K<VL.at(il).at(1)+VR.at(ir).at(1))
			il--;
		S=max(S, VL.at(il).at(0)+VR.at(ir).at(0));
		ir++;
	}
	cout <<f+S <<endl;
	return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		S = S.replaceAll("eraser", "");
		S = S.replaceAll("erase", "");
		S = S.replaceAll("dreamer", "");
		S = S.replaceAll("dream", "");
		if (S.length() == 0){
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
		sc.close();
	}
}


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

int main() {
  int A, B;
  char op;
  cin >> A >> op >> B;
  
  if (op == '+') { 
    cout << A + B << endl;
  }
  if (op == '-') {
    cout << A - B << endl;
  }
}

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

using namespace std;
const int N = 2000;
const int mod = 1e9+7;
char maze[N][N];
long long dp[N][N];
int main(){
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++) cin>>maze[i][j];
	}
	dp[1][1]=1;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(i==1&&j==1) dp[i][j]=1;
			else{
				if(maze[i][j]=='#'){
					dp[i][j]=0;
				}else{
					dp[i][j]=(dp[i-1][j]%mod+dp[i][j-1]%mod);
					dp[i][j]%=mod;
				}
			}
		}
	}
	cout<<dp[n][m]<<endl;
	return 0;
}

Measured memory_bytes: 20224
#!/usr/local/gnu/bin/bash
read h w
al=(- {A..Z})
for i in `seq $h`
do
    read -a a
    for j in `seq $w`
    do
        if [ ${a[j-1]} = "snuke" ]
        then
            echo ${al[j]}$i
            exit
        fi
    done
done


Measured memory_bytes: 612
#include <stdio.h>

int main(){
	int n,s;
	s = 100000;
	scanf("%d",&n);
	for(;n>0;n--){
		s *= 1.05;
		if(s%1000)s+=1000-s%1000;
	}
	printf("%d\n",s);
	return 0;
}

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

typedef long long ll;

#define pb push_back
#define mp make_pair
#define f first
#define s second
#define all(a) a.begin(), a.end()

const int maxn = 200010;
const int MOD = 1e9+7;
const int INF = 1e9;
const ll LINF = 1e18;
int n, m, a[maxn];
map<int, int> M, N;
set<int> S;
string s;

void solve()
{
    cin >> n;
    if(n%7==0) n/=7;
    if(n%2==0 or n%5==0) { cout << -1; return; }
    ll x = 1%n;
    int cnt=1;
    while(x) x*=10, x++, x%=n, cnt++;
    cout << cnt << "\n";
}

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    int t=1; //cin >> t;
    while(t--) solve();
}


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

typedef long long int Long;
typedef long double Double;
const int MAXN = 1e5 + 4;

int n, a, ans = 64;

int main() {
	scanf("%d", &n);
	while(n--) {
		scanf("%d", &a);
		int cnt = 0;
		while(!(a & 1)) a >>= 1, ++cnt;
		ans = min(ans, cnt);
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7

N, M = MAP()
a = [INT() for _ in range(M)]

fib_list = [0]*(N+1)
fib_list[0] = 1
fib_list[1] = 1

def fib(n):
	if n < 2:
		return fib_list[n]
	elif fib_list[n] != 0:
		return fib_list[n]
	else:
		fib_list[n] = fib(n-1) + fib(n-2)
		return fib_list[n]

tmp = -1
ans = 1

for x in a:
	#print(tmp, x)
	if x == tmp+1:
		print(0)
		exit()
	else:
		ans = ans*fib(x-tmp-2)%mod
		tmp = x

ans = ans*fib(N-tmp-1)%mod
print(ans) 






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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

::std::pair<::std::int64_t, ::std::int64_t> extgcd(::std::int64_t a, ::std::int64_t b) {
	::std::pair<::std::int64_t, ::std::int64_t> pa(1, 0), pb(0, 1);
	while (b != 0) {
		::std::swap(a, b); ::std::swap(pa, pb);
		pb = ::std::make_pair(pb.first - pa.first * (b / a), pb.second - pa.second * (b / a));
		b = b % a;
	}
	return pa;
}

::std::int64_t modinv(::std::int64_t a, ::std::int64_t mod) {
	::std::int64_t x = extgcd(a, mod).first;
	if (x < 0) x += mod;
	return x;
}

::std::int64_t modpow(::std::int64_t a, ::std::int64_t b, ::std::int64_t mod) {
	::std::int64_t res = 1;
	while (b > 0) {
		if (b & 1) res = res * a % mod;
		a = a * a % mod;
		b >>= 1;
	}
	return res;
}

int64 N, mod;
vector<int64> fact, inv;

void init() {
	fact.resize(11234, 1); inv.resize(11234, 1);
	REP(i, 11234) {
		fact[i+1] = fact[i] * (i+1) % mod;
		inv[i+1] = modinv(fact[i+1], mod);
	}
}

int64 comb(int64 a, int64 b) {
	return fact[a] * inv[b] % mod * inv[a-b] % mod;
}

int main(void) {
	cin >> N >> mod;
	init();
	int64 res = 0;
	FOR(i, 1, N) {
		int64 ret = comb(N, i);
		ret = ret * modpow(2, i*(i-1)/2, mod) % mod;
		ret = ret * modpow(2, (N-i)*(N-i-1)/2, mod) % mod;
		int64 sum = 0;
		REP(j, i+1) {
			sum += (j%2 ? -1 : 1) * comb(i, j) * modpow(modpow(2, i-j, mod)-1, N-i, mod) % mod;
			sum %= mod;
			if (sum < 0) sum += mod;
		}
		res += ret * sum % mod;
		res %= mod;
	}
	cout << res << endl;
}




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

using namespace std;
int main(){
	string s;
	cin >> s;
	int i,k,a[100010];
	cin >> k;
	for(i=0;i<s.size();i++){
		a[i] = ('z'- s[i] + 1)%26;
	}
	
	for(i=0;i<s.size()-1;i++){
		if(k>=a[i]){
			k -= a[i];
			s[i] = 'a';
		}
	}
	if(k>0){
		s[s.size()-1] = (k%26 + s[s.size()-1] - 'a')%26 + 'a';
	}
	cout << s << endl;
}

Measured memory_bytes: 896
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <complex>
using namespace std;

#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define pi 3.14159265359
#define shosu(X) fixed << setprecision(X)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int cur;
int solve(string str){
	cur++;
    if(str[cur] != '[' && str[cur] != ']'){
        string t;
        while(str[cur] != '[' && str[cur] != ']')
            t += str[cur++];
        cur++;
        return stoi(t)/2+1;
    }
    vi vote;
    while(str[cur] != ']'){
        vote.pb(solve(str));
    }
    sort(All(vote));
    int ret = 0;
    REP(i,vote.size()/2+1) ret += vote[i];
    cur++;
    return ret;
}

int main(){
	int n;
	cin >> n;
	REP(i,n){
		string str;
		cin >> str;
		cur = 0;
		cout << solve(str) << endl;
	}
}

Measured memory_bytes: 1332
//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=2e9;
const ll INF=5e18;
typedef pair<int,int> P;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  string s;
  int d;
  cin >> s >> d;
  ll dp[10005][2][105]={},ans=0;
  dp[0][0][0]=1;
  for(int i=0; i<s.size(); i++) {
    for(int j=0; j<2; j++) {
      for(int k=0; k<d; k++) {
        int lim=j?9:s[i]-'0';
        for(int l=0; l<=lim; l++) {
          (dp[i+1][j||l<lim][(k+l)%d]+=dp[i][j][k])%=MOD;
        }
      }
    }
  }
  cout << (dp[s.size()][0][0]+dp[s.size()][1][0]-1+MOD)%MOD << "\n";
}


Measured memory_bytes: 16640
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
int main()
{
    int a[30],l;
    while(cin>>a[0]>>l)
    {if(a[0]==0&&l==0)break;
        char q[10];
        for(int k=1;k<=20;k++)
        {
            for(int i=0;i<l;i++)
            {
                int r=1,u=0;
                while((u++)!=i)r*=10;
                q[i]=(a[k-1]/r)%10+'0';
            }
            sort(q,q+l);
            int x=0,y=0;
            for(int i=0;i<l;i++)
            {
                x+=(q[i]-'0')*(int )(pow((double)10,(double)(l-i-1)));
                y+=(q[i]-'0')*(int )(pow((double )10,(double )i));
            }
            a[k]=y-x;
        }
        int flag=1,w,e;
        for(int i=0;flag&&i<=20;i++)
        {
            for(int j=i+1;flag&&j<=20;j++)
            {
                if(a[i]==a[j])
                {
                    flag=0;
                    w=i;e=j-w;
                }
            }
        }
        cout<<w<<" "<<a[w]<<" "<<e<<endl;
    }
    return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<algorithm>
#define INF (1 << 29)
using namespace std;

int town[201][201];

int main() {
    int N, M, R, A, B, C, min_dist = INF;
    int target_town[9], perm[9];
    cin >> N >> M >> R;
    for (int i = 1; i <= R; i++) {
        cin >> target_town[i];
        perm[i] = i;
    }
    for (int i = 1; i <= N; i++) {
        for (int j = 1; j <= N; j++) town[i][j] = INF;
    }
    for (int i = 0; i < M; i++) {
        cin >> A >> B >> C;
        town[A][B] = town[B][A] = C;
    }
    for (int k = 1; k <= N; k++) {
        for (int i = 1; i <= N; i++) {
            for (int j = 1; j <= N; j++) {
                if (town[i][j] > town[i][k] + town[k][j]) town[i][j] = town[i][k] + town[k][j];
            }
        }
    }
    do {
        int dist = 0;
        for (int i = 1; i <= R - 1; i++) {
            dist += town[target_town[perm[i]]][target_town[perm[i + 1]]];
        }
        if (dist < min_dist) min_dist = dist;
    } while (next_permutation(perm + 1, perm + R + 1));
    cout << min_dist << endl;
    return 0;
}

Measured memory_bytes: 384
#include "bits/stdc++.h"
#include <random>
using namespace std; typedef unsigned long long _ulong; typedef long long int lint; typedef pair<lint, lint> plint; typedef pair<double long, double long> pld;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(lint i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define endk '\n'
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
const lint mod = 1e9 + 7, INF = 1e18;
lint dx[8] = { 0, -1, 1, 0, 1, -1, 1, -1 }, dy[8] = { 1, 0, 0, -1, -1, -1, 1, 1 };
typedef pair<double, lint> Pa;

lint N, K, Q, arr[2000];
set<lint> st;
int main() {
	cin >> N >> K >> Q;
	REP(i, N) {
		cin >> arr[i];
		st.insert(arr[i]);
	}
	lint minv = INF;
	for (auto itr : st) {
		lint border = itr, cnt = 0, _cnt = 0;
		priority_queue<lint, vector<lint>, greater<lint>> que;
		REP(i, N) {
			if (arr[i] >= border) {
				cnt++;
			}
			else {
				if (cnt >= K) {
					priority_queue<lint, vector<lint>, greater<lint>> _que;
					REP(j, cnt) {
						_que.push(arr[i - j - 1]);
					}
					REP(j, cnt - K + 1) {
						que.push(_que.top()); _que.pop();
					}
				}
				cnt = 0;
			}
		}
		if (cnt >= K) {
			priority_queue<lint, vector<lint>, greater<lint>> _que;
			REP(j, cnt) {
				_que.push(arr[N - 1 - j]);
			}
			REP(j, cnt - K + 1) {
				que.push(_que.top()); _que.pop();
			}
		}
		if (SZ(que) < Q) continue;
		lint _min = que.top();
		REP(i, Q - 1) {
			que.pop();
		}
		chmin(minv, que.top() - _min);
	}
	cout << minv << endk;
}	

Measured memory_bytes: 3752
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#include <map>



int main() {
    int A,B;
    cin >> A >> B;
    if(1<=A && A<=9){
        if(1<=B && B<=9){
            cout << A*B << endl;
        }
        else{
            cout << -1 << endl;
        }
    }
    else{
        cout << -1 << endl;
    }
} 

Measured memory_bytes: 256
#include <stdio.h>


typedef struct test
 {
    int n1;
    int n2;
 }test;

int main()
{
  int count=0;
  int n=0;
  int temp = 0;
  test t1[3000];

  scanf("%d%d", &t1[count].n1, &t1[count].n2);
  
  while(t1[count].n1!=0 || t1[count].n2!=0)
    {
      count++;
      scanf("%d%d", &t1[count].n1, &t1[count].n2);
    }
  while(n != count)
    {
      if(t1[n].n1>t1[n].n2)
        {
          temp = t1[n].n1;
	  t1[n].n1 = t1[n].n2;
          t1[n].n2 = temp;
        }
      printf("%d %d\n", t1[n].n1, t1[n].n2);
      n++;
    }
  return 0;
}


Measured memory_bytes: 2044
using System;

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

            var line = Console.ReadLine().Split();
            var lineInt = new int[n];
            for (int i = 0; i < n; i++)
            {
                lineInt[i] = int.Parse(line[i]);
            }

            int now = 0, count = 0, max = 0;

            for (int i = 0; i < n - 1; i++)
            {
                if (lineInt[i] >= lineInt[i+1])
                    count++;
                else
                    count = 0;
                if (count > max)
                    max = count;
            }

            Console.WriteLine(max);
        }
    }
}

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

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

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

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

const int nmax=20010;
bool infected[nmax];


int main(void){
	int n,m;
	while(cin >> n >> m){
		if(n==0)
			break;
		rep(i,nmax) infected[i]=false;
		infected[1]=true;
		vector<tuple<int,int,int>> data;

		rep(i,m){
			int t,s,d;
			cin >> t >> s >> d;
			data.push_back(make_tuple(t,s,d));
		}
		sort(data.begin(),data.end());
		rep(i,data.size()){
			int t,s,d;
			tie(t,s,d)=data[i];
			if(infected[s])
				infected[d]=true;
		}
		int ans=0;
		range(i,1,n+1) ans+=infected[i];
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1700
def is_9(arr):
    s = []
    for i in range(len(arr)):
        if arr[i] != '9':
            return False
        s.append(arr[i])
    return True


n = list(input())
fd = int(n.pop(0))
if is_9(n):
    print(fd + int(9 * len(n)))
else:
    print(fd - 1 + int(9 * len(n)))


Measured memory_bytes: 2940
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

A, B = MAP()
print(ceil((B-1)/(A-1)))

Measured memory_bytes: 3888
#include <bits/stdc++.h>
using namespace std;
long a,b,k;
int main(void){
    cin>>a>>b>>k;
    for(int i=a;i<=min((a+b)/2,a+k-1);i++) cout<<i<<endl;
    for(int i=1+max((a+b)/2,b-k);i<=b;i++) cout<<i<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
#include<complex>
#include <cassert>

using namespace std;

#define ll long long
#define ld long double
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

const double PI=acos(-1);
const double EPS=1e-9; //うまくいかなかったらゆるめる

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;
typedef vector<pii> vp;
typedef vector<vi> vvi;

int gcd(int a, int b){if(b==0) return a;return gcd(b,a%b);}
int lcm(int a, int b){return a/gcd(a,b)*b;}


signed main(void) {
    int n,x;
    cin >> x >> n;
    map<int,int> ma;
    rep(i,n){
        int in;
        cin >> in;
        ma[in]++;
    }
    rep(i,1000){
        int lo = x - i;
        int hi = x + i;
        if(ma[lo] == 0){
            cout << lo << endl;
            return 0;
        }
        if(ma[hi] == 0){
            cout << hi << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
//~ #include <ext/pb_ds/assoc_container.hpp>
//~ #include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//~ using namespace __gnu_pbds; 
#define mp make_pair
#define endl '\n'
typedef long long ll;
 
const int INF=1e9+5;
const ll lim=(ll)3e16;
const int N=4e5+5;
const int mod=1e9+7;	
const ll oo=1e18+5;

//~ typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

ll mul(int a,int b){
	return 1ll*a*b%mod;
}

ll inv[N],f1[N],f2[N];

ll poww(int a,int b){
	ll r=1;
	while(b){
		if(b%2) r=mul(r,a);
		a=mul(a,a);
		b/=2;
	}
	return r;
}

void init(){
	inv[1]=1;
	for(int i=2;i<N;++i){
		inv[i]=mod-mod/i*inv[mod%i]%mod;
	}
	f1[0]=f2[0]=1;
	for(int i=1;i<N;++i){
		f1[i]=f1[i-1]*i%mod;
		f2[i]=f2[i-1]*inv[i]%mod;
	}
}

ll binomial(int n,int k){
	return f1[n]*f2[n-k]%mod*f2[k]%mod;
}

ll my_inv(ll a){
	return poww(a,mod-2);
}

int main(){
	ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
	init();
	int n,a,b;
	cin>>n>>a>>b;
	vector<ll> nCk(2*100000+1,1);
	for(int i=1;i<2*100000+1;++i){
		nCk[i]=nCk[i-1]*(n-i+1)%mod;
		nCk[i]=nCk[i]*my_inv(i)%mod;
	}
	ll ans=poww(2,n)-1;
	ans%=mod;
	cout<<((ans-nCk[a]+mod)%mod-nCk[b]+mod)%mod;
	return 0;	
}


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

const int MAX_V = 1e5 + 10;

int main()
{
    ll N, K;
    cin >> N >> K;
    
    vector<ll> A(MAX_V);
    int a, b;
    int m = 0;
    rep(i, N) {
        cin >> a >> b;
        A.at(a) += b;
        m = max(m, a);
    }

    int ans;
    for (int i = 1; i <= m; i++) {
        K -= A.at(i);
        if (K <= 0) {
            ans = i;
            break;
        }
    }

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

Measured memory_bytes: 1024
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;
typedef vector<P> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<ll,vector<ll>,greater<ll>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;
const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
constexpr int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30); // 1073741824
const int INF = (1LL << 60); // 1152921504606846976
const double EPS = (1 >> 30);
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; }
int nmax=200000;
vvec g(nmax);



signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    int n;
    cin>>n;
    int ans=0;
    for(int i=1;i<=n;i+=2){
        int cnt=0;
        for(int j=1;j<=i;j++){
            if(i%j==0) cnt++;
        }
        if(cnt==8) ans++;
    }
    cout<<ans<<endl;
    
}

Measured memory_bytes: 4992
#include"bits/stdc++.h"
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=1;i<=n;i++)
const long long mod = 1000000007;
const long long inf = 11451419198109130;
typedef pair<int, int> P;
typedef pair<P, int> PP;
typedef pair<int, PP> PPP;
struct edge { int to; int to2; int cost; };

signed main() {
	int a, b, c, d, e, k; cin >> a >> b >> c >> d >> e >> k;
	if (e - a > k)puts(":(");
	else puts("Yay!");
}

Measured memory_bytes: 256
x,y = list(map(int, input().split()))
a = [1,3,5,7,8,10,12]
b = [4,6,9,11]
c = [2]
if (x in a and y in a) or (x in b and y in b) or (x in c and y in c):
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef map<int, int> mi;
typedef set<int> si;
#define VV(T) vector<vector< T > >
#define dump(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl

#define rep(i, n) REP(i, 0, n)                              // 0, 1, ..., n-1
#define REP(i, x, n) for(int i = x; i < n; i++)             // x, x + 1, ..., n-1
#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(v) (v).begin() , (v).end()
#define RALL(v) (v).rbegin(), (v).rend()

#define pb push_back
#define pu push
#define mp make_pair
#define fi first
#define sc second

#define COUT(x) cout << (x) << endl
#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECCOUT(x) for(auto&youso_: (x) )cout<<youso_<<" ";cout<<endl

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


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

    double a, b, c; cin >> a >> b >> c;
    int ans = 0;
    for(double i = a; i < c + 0.5; i = i + a) {
        ans += b;
    }
    COUT(ans);
}

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

existence = [0] * M
a = []
A = X
for i in range(N):
    if existence[A] != 0:
        break
    existence[A] = 1
    a.append(A)
    A = A * A % M

for i in range(len(a)):
    if a[i] == A:
        break
j = i

result = sum(a[:j])
a = a[j:]
N -= j
x = N // len(a)
y = N % len(a)
result += sum(a) * x + sum(a[:y])
print(result)


Measured memory_bytes: 69160
#include<iostream>
#include<algorithm>

using namespace std;

int q, n, a, b, c;

int solve(int c, int a, int n){
	int res = 0;
	for(int i = 0;i <= 1080;i++){
		for(int j = 0;j <= 1080;j++){
			int tc = c - i - 2 * j;
			int ta = a - i - j;
			int tn = n - i;
			if(tc >= 0 && ta >= 0 && tn >= 0){
				res = max(res, i + j + tc / 3);
			}
		}
	}
	return res;
}

int main(){
	cin >> q;
	for(int i = 0;i < q;i++){
		cin >> c >> a >> n;
		cout << solve(c, a, n) << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>

int main(int argc, char *argv[]){
  char a[3];
  scanf("%s", &a);
  
  int count = 0;
  for(int i=0; i<3; i++){
    if (a[i] == '1'){
      count++;
    }
  }
  printf("%d", count);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
 
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define sll set<long long>
#define si set<int>
#define stk stack<int>
#define que queue<int>
#define pb push_back
#define ff first
#define ss second
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
 
using namespace std;

int main(){
	IOS;
	int q=1,c=1;
	//cin>>q;
	while(q--){
		int n,k;
		cin>>n>>k;
		si a;
		for(int i=0;i<k;i++){
			int d;
			cin>>d;
			for(int i=0;i<d;i++){
				int x;cin>>x;
				a.insert(x);
			}
		}

		cout<<n-a.size()<<endl;
		
	}
}

Measured memory_bytes: 3664
get_number(Number) :-
    get_string(String),
    number_string(Number, String).

get_number(A, B) :-
    get_number(A),
    get_number(B).

get_number(A, B, C) :-
    get_number(A, B),
    get_number(C).

get_string(String) :-
    current_input(Input),
    read_string(Input, ' \n', '', _, String).

/* memo
    code(int)
    string_code(1, S, C), (C: code)
    char_code(X, Y) (X: char, Y: code)
    string_chars(S, S2) (S: string, S2: [char])
    to_lower(C, C2) (C: char? C2: code?)
    sub_string

    f(0, [], []).
    f(Z, [X|Xs], [Y|Ys]) :- X = Y, f(Z1, Xs, Ys), Z is Z1 + 1.
    f(Z, [_|Xs], [_|Ys]) :- f(Z, Xs, Ys).

    match: =, \=

    numeric: <,=<, >, >= (eval)
    lexicographically: @<. @=<, @>, @>=
    value?: =:=, =\= (eval)
    identical: ==, \==
*/

f("error", A, B) :- A + B >= 10.
f(X, A, B) :- X is A + B.

main :-
    get_number(A, B),
    f(X, A, B),
    writeln(X).


Measured memory_bytes: 8196
S = [[int(i) for i in input().split()] for i in range(3)]
N = int(input())
b = [int(input()) for i in range(N)]
check = 0

for num in b:
    for i in range(3):
        for j in range(3):
            if S[i][j] == num:
                S[i][j] = '*'

if len(set(S[0])) == 1 or len(set(S[1])) == 1 or len(set(S[2])) == 1:
    check = 1

for i in range(3):
    cnt = 0
    for j in range(3):
        if S[j][i] == '*':
            cnt += 1
    if cnt == 3:
        check = 1

if S[0][0] == S[1][1] == S[2][2] == '*' or S[0][2] == S[1][1] == S[2][0] == '*':
    check = 1

if check == 1:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE ScopedTypeVariables #-}
import Data.Int
import qualified Data.ByteString.Char8 as BS

main = do
  [m,k] :: [Int] <- map (read . BS.unpack) . BS.words <$> BS.getLine
  -- 0 <= m <= 16, 0 <= k <= 10^9
  case m of
    0 | k == 0 -> putStrLn "0 0"
      | otherwise -> putStrLn "-1"
    1 | k == 0 -> putStrLn "0 0 1 1"
      | otherwise -> putStrLn "-1"
    _ | k < 2^m -> do let l = [0..2^m-1]
                          l' = filter (/= k) l
                      BS.putStrLn $ BS.unwords $ map (BS.pack . show) $ l' ++ [k] ++ reverse l' ++ [k]
      | otherwise -> putStrLn "-1"


Measured memory_bytes: 60284
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0;i < n;i++)
#define rev(i, n) for(int i = n;i >= 0;i--)
#define Rep(i, m, n) for(int i = m;i < n;i++)
#define repeatrev(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define itn int

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
typedef priority_queue<int> Pr;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
ll a[10000];
ll gcd(ll a, ll b){
    if(b == 0) return a;
    return gcd(b, a % b);
}

ll lcm(ll a, ll b){
    ll g = gcd(a, b);
    ll kkkk = a / g;
    return kkkk * b;
    //return a / g * b;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n;
    cin >> n;
    //ll a[n];
    rep(i, n) cin >> a[i];
    unsigned ll ans = 0;
    ans = lcm(a[0], a[1]);
    for(int i = 2; i < n; i ++){
        ans = lcm(ans, a[i]);
        //cout << ans << endl;
    }
    if(n == 1) cout << a[0] << endl;
    else cout << ans << endl;


}


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

int main()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
 /* int n,k;
  cin>>n>>k;
  vector<int>x(n),dp(n,INT_MAX);
  int i=0;
  for(;i<n;i++)
    cin>>x[i];
  dp[0]=0;  
  for(i=0;i<n;i++)
  {
    for(int j=1;i<=k;j++)
    {
      if(i+j<n)
        dp[i+j]=min(dp[i+j],dp[i]+abs(x[i]-x[i+j]));
    }
  }
  cout<<dp[n-1]<<"\n";*/
   int n;
    cin>>n;
    int k;
    cin>>k;
    vector<int> h(n);
    for(int& x : h) {
			cin>>x;
    	}
    vector<int> dp(n, 1000000009);
    dp[0] = 0;
    for(int i = 0; i < n; ++i) {
        for(int j = i + 1; j <= i + k; ++j) 
            if(j < n) 
                dp[j] = min(dp[j], dp[i] + abs(h[i] - h[j])); 
    }
	cout<<dp[n-1];
  return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
//#include<bits/stdc++.h>
using ll = long long;
using ld = long double;
using namespace std;
const ll INF = 1000000000000000000;
const ll mod = 1000000007;
const ld pi = 3.141592653589793238;
//printf("%.10f\n", n);

ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (a % b == 0)return b;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
ll modpow(ll x, ll y) {
	ll res = 1;
	while (y) {
		if (y % 2) { res *= x; res %= mod; }
		x = x * x % mod; y /= 2;
	}
	return res;
}

ll test[12345678];
signed main() {
	ll n, m, k, q, a = 0, b = 0, c = 0, cnt = 0, ans = 0; string s, t;
	cin >> n;
	cout << n + pow(n, 2) + pow(n, 3) << endl;
	return 0;
}

Measured memory_bytes: 4140
#include <iostream>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
using namespace std;
typedef long long ll;
const int INF = 1<<30;
const ll MOD = 1e9+7;
const double EPS = 1e-9;


int main(int argc, const char * argv[]) {
  int a, b; cin >> a >> b;
  int ans;
  if (a<= 5){
    ans = 0;
  }else if (a<=12)
    ans = b/2;
  else
    ans = b;
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
from sys import stdin

N, K = [int(x) for x in stdin.readline().rstrip().split()]
S = stdin.readline().rstrip()
cnt = 1
run = []
if len(S) == 1:
    run.append(1)
else:
    for i in range(1, len(S)):
        if S[i - 1] == S[i]:
            cnt += 1
        else:
            run.append(cnt)
            cnt = 1
        if i == len(S) - 1:
            run.append(cnt)
if S[0] == '0':
    run = [0] + run
if S[N - 1] == '0':
    run = run + [0]
if len(run) < 2 * K + 1:
    print(sum(run))
    exit()
ans = sum(run[0: 2 * K + 1])
sb = ans
for j in range(2, len(run) - 2 * K):
    if j % 2 == 1:
        continue
    else:
        sb = sb - run[j - 1] - run[j - 2] + run[j + 2 * K] + run[j + 2 * K - 1]
        if sb > ans:
            ans = sb
print(ans)


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

int main()
{
    long long int n,k;
    cin >> n >> k;
    vector<long long int> v;
    for(long long int i=0;i<n;i++)
    {
        long long int k;
        cin >> k;
        v.push_back(k);
    }
    long long int dp[n+1];
    dp[0]=0;
    dp[1]=0;
    for(long long int i=2;i<=n;i++)
    {
        dp[i]=INT_MAX;
        for(long long int j=k;j>0;j--)
        {
            if(i-j>=1)
            {
                dp[i]=min(dp[i],dp[i-j]+abs(v[i-1]-v[i-j-1]));
            }
        }
    }
    cout << dp[n] << endl;
}
    

Measured memory_bytes: 1908
with Ada.Text_IO;
with Ada.Integer_Text_IO;
with Ada.Float_Text_IO;
use Ada.Text_IO;
use Ada.Integer_Text_IO;
use Ada.Float_Text_IO;

procedure hoge is
 a: integer;
 b: integer;
begin
 get(a);
 get(b);
 put(6-a-b);
end hoge;

Measured memory_bytes: 3696
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define INF 1e14
#define dd double
#define MOD 1000000007
#define my_sizeof(type) ((char *)(&type+1)-(char*)(&type)) 
#define nl cout<<endl
#define fill(a,val) memset(a,val,sizeof(a))
#define mp make_pair
#define endl "\n"
#define pb push_back
#define ff first    
#define ss second
#define all(v) v.begin(),v.end()
#define s(ar,n) sort(ar,ar+n)
#define rs(ar,n) sort(ar, ar+n, greater<ll>()) 
#define oa(a,n) for(ll i=0;i<n;i++)cout<<a[i]<<" ";nl
#define cn(a,n) for(ll i=0;i<n;i++)cin>>a[i];
#define maxa(ar,N) *max_element(ar,ar+N)
#define mina(ar,N) *min_element(ar,ar+N)
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define printclock cerr<<"Time : "<<1000*(long double)clock()/(long double)CLOCKS_PER_SEC<<"ms\n";
ll power(ll x, ll y){ll res=1;x=x%MOD;while(y>0){if(y&1)res = (res*x)%MOD;y = y>>1;x = (x*x)%MOD;}return res%MOD;}  
ll logtwo(ll n){if(n==1)return 0;return logtwo(n/2)+1;}
void ceilsearch(ll ar[],ll low,ll high,ll x,ll &y){if(low>high)return;ll mid=(low+high)/2;if(ar[mid]>=x){y=mid;ceilsearch(ar,low,mid-1,x,y);}else{ceilsearch(ar,mid+1,high,x,y);}}
signed main()
{
    fastio(); 
    ll K;
    cin>>K;
    ll a=K%10;
    ll b=(K%100)/10;
    ll c=K/100;
    if(a==7||b==7||c==7)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}   

Measured memory_bytes: 3652
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;

int main(){
    int n;cin>>n;
    int a[100];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a,a+n,greater<int>());
    int A=0,B=0;
    for(int i=0;i*2<n;i++){
        A+=a[i*2];
    }
    for(int i=0;i*2+1<n;i++){
        B+=a[i*2+1];
    }
    int ans=A-B;
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
int main(){
	int n;
	int a=0;
	int count=0;
	cin>>n;
	vector<int> v(n);
	rep(i, n){cin>>v[i];v[i]=(v[i]<400)?1:(v[i]<800)?2:(v[i]<1200)?4:(v[i]<1600)?8:(v[i]<2000)?16:(v[i]<2400)?32:(v[i]<2800)?64:(v[i]<3200)?128:(count++&&0);}
	rep(i,n)a=a|v[i];
	int c=0;
	for(;a;a&=a-1)++c;
	int s=c;
    int p=count;
	cout<<(((p>=1)&&(c==0))?1:c)<<' '<<s+count<<endl;
	return 0;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}

func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}

func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n, m := iScan(), iScan()
	a, b := make([]int, n), make([]int, n)
	c, d := make([]int, m), make([]int, m)
	for i := 0; i < n; i++ {
		a[i] = iScan()
		b[i] = iScan()
	}
	for i := 0; i < m; i++ {
		c[i] = iScan()
		d[i] = iScan()
	}
	for i := 0; i < n; i++ {
		ans := -1
		dist := mod
		for j := 0; j < m; j++ {
			x := abs(a[i]-c[j]) + abs(b[i]-d[j])
			if dist > x {
				dist = x
				ans = j + 1
			}
		}
		fmt.Println(ans)
	}
}


Measured memory_bytes: 1776
if isfile("mystdin.txt");mystdin=open("mystdin.txt","r");redirect_stdin(mystdin);end
pI(x)=parse(Int,x)
pM(x::Array{SubString{String},1})=map(pI,x)
function main()
  l=chomp(readline())
  a,b,c,d=[pI(i) for i=l]
  if a+b+c+d==7
    println(a,"+",b,"+",c,"+",d,"=7")
  elseif a+b+c-d==7
    println(a,"+",b,"+",c,"-",d,"=7")
  elseif a+b-c+d==7
    println(a,"+",b,"-",c,"+",d,"=7")
  elseif a+b-c-d==7
    println(a,"+",b,"-",c,"-",d,"=7")
  elseif a-b+c+d==7
    println(a,"-",b,"+",c,"+",d,"=7")
  elseif a-b+c-d==7
    println(a,"-",b,"+",c,"-",d,"=7")
  elseif a-b-c+d==7
    println(a,"-",b,"-",c,"+",d,"=7")
  elseif a-b-c-d==7
    println(a,"-",b,"-",c,"-",d,"=7")
  end
end
main()
if isdefined(Base, :mystdin);close(mystdin);end

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

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

int main() {
    int N,W;
    cin >> N >> W;
    vector<int> w(N),u(N);
    rep(i,N)cin >> w[i] >> u[i];
    vector<vector<ll>> dp(N+1,vector<ll>(W+1));
    rep(i,N){
        rep(j,W+1){
            chmax(dp[i + 1][j], dp[i][j]);
            if(j-w[i]>=0)chmax(dp[i + 1][j], dp[i][j-w[i]] + u[i]);
        }
    }
    ll ans = 0;
    rep(j,W+1){
        ans = max(ans, dp[N][j]);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 80256
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<iostream>
#include<cstring>
#include<vector>
#include<string> 
#include<queue>
#include<algorithm>
using namespace std;
int main()
{
	int i,a,b,k;
	cin>>a>>b>>k;
	int A=min(a+k,b);
	for(i=a;i<A;i++)
	printf("%d\n",i);
	int B=max(i,b-k+1);
	for(i=B;i<=b;i++)
	printf("%d\n",i);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
	ll n, k;
	cin >> n >> k;
	vi a(n), b(n);
	rep(i, n) cin >> a[i] >> b[i];
	vl c(1e6);
	rep(i, n) c[a[i]] += b[i];
	ll sum = 0LL;
	rep(i, 1e6) {
		sum += c[i];
		if(sum >= k) {
			cout << i << endl;
			return 0;
		}
	}
	// cout << sum << endl;
	// rep(i, 4) cout << c[i] <<" ";
	// cout << endl;
}


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

int main(){
  int A,B;
  cin >> A >> B;
  if(A==1 && B!=1){
    cout << "Alice" << endl;
  }
  else if(B==1 && A!=1){
    cout << "Bob" << endl;
  }
  else if(A==1 && B==1){
    cout << "Draw" << endl;
  }
  else if(A>B){
    cout << "Alice" << endl;
  }
  else if(A==B){
    cout << "Draw" << endl;
  }
  else if(A<B){
    cout << "Bob" << endl;
  }
}

Measured memory_bytes: 256
S = input()
val = 10**9
 
voc = set(S)
for c in voc:
    cnt = 0
    tmp = list(S)
 
    while True:
        if all([w == c for w in tmp]):
            val = min(cnt, val)
            break
        cnt += 1
        for u in range(len(tmp)-1):
            tmp[u] = c if tmp[u] == c or tmp[u+1] == c else tmp[u]    
        tmp.pop()
 
 
print(val)

Measured memory_bytes: 9132