akhauriyash/Code-Regression huggingface dataset:
/*
 * atcoder/abc124_2nd/d.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> ostream & operator << (ostream & out, vector<T> const & v) {
  for (auto &&a: v) out << a << " "; out << endl; return out;
}
template <class T> void dump(T &a) { cout << a << endl; }
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }

/*
 * 操作を行う区間として、互いに重ならないものだけを選択しても結果（最大値）が変わらないか.
 * 同じ座標に２回以上操作を行っても0回、または1回と同様の結果に帰着されるので変わらない.
 * 以降区間は重ならないものとみなす.
 *
 * 文字列を, 連続した1と連続した0の塊としてみた場合必ず01010101...と0と1が交互に並んだ形になる
 * 01010101... の代わりに連続する個数としてやると、
 * 後の簡単のために必ず1で始まり1で終わるとする.
 * 例2の場合
 * 11101010110011
 * が
 * (3) 1 (1) 1 (1) 1 (2) 2 (2)
 * と符号化出来る. (x) が1の個数.
 * 1はフリップしても連続した1の最大数には寄与しないのでK個の0をフリップすることを考える.
 * 連続した1の最大数なのでK個の0を挟む3個の1と合わせて長さ5(2K+1)の区間の要素の最大値を全探索したものが答えとなる.
 * 1のカウントには累積和を使用する.
 * N=10^5なので十分間に合う.
 */

template <class T, class T2>
void group(T &xs, vector<pair<T2, int> > &result) {
  int i=0, j;
  while (i<xs.size()) {
    j=i;
    while (j < xs.size() and xs[j] == xs[i]) j++;
    result.push_back({ xs[i], j-i });
    if (j==i) i++;
    i=j;
  }
}

int N, K;
string S;
vector<int> acc;
void solve() {
  cin >> N >> K >> S;
  int prev = -1;
  int count = 0;
  vector<pair<int, int> > G;
  if (S[0] != '1') G.push_back({ 1, 0 });
  group(S, G);
  if (S[N-1] != '1') G.push_back({ 1, 0 });

  int M = G.size();
  acc.assign(M+1, 0);
  for (int i=0; i<M; i++) acc[i+1] = acc[i] + G[i].second;

  int len = 2 * K + 1;
  int max_ = 0;
  // dump(acc);
  for (int l=0; l<M; l += 2) {
    int r = min(l+len, (int)acc.size()-1);
    // cout << l << " " << r << " " << acc[r] - acc[l] << endl;
    chmax(max_, acc[r] - acc[l]);
  }
  cout << max_ << endl;
}
int main() {
  // cout.precision(15); cout << fixed;

  solve();

  return 0;
}


Measured memory_bytes: 1652
n = int(raw_input())
arr = map(int, raw_input().split())
dp =[0]* n
dp[1] = abs(arr[1]-arr[0])
for i in xrange(2, n):
    dp[i] = min(dp[i-1] + abs(arr[i]-arr[i-1]), dp[i-2] + abs(arr[i]-arr[i-2]))
print dp[-1]


Measured memory_bytes: 11144
// C++ 14
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <math.h>

#define ll long long
#define Int ll
#define loop(__x, __start, __end) for(Int __x = __start; __x < __end; __x++)
#define loopdown(__x, __start, __end) for(Int __x = __start; __x > __end; __x--)
#define rep(__n) for(Int __x = 0; __x < __n; __x++)
#define span(__a,__x,__y) __a.begin()+__x,__a.begin()+__y
#define span_all(__a) __a.begin(),__a.end()
#define len(__x) (__x.size())
#define last(__x) (__x[__x.size()-1])

using namespace std;

struct Point {
  Int x, y;
  Point(Int x, Int y): x(x), y(y) {}
  Point(): x(0), y(0) {}

  bool operator< (const Point &p1) {
    return x < p1.x && y < p1.y;
  }
};
ostream & operator << (ostream & out, Point const & v) {
  out << "Point(" << v.x << ", " << v.y << ')';
  return out;
}

istream & operator >> (istream & in, Point & v) {
  Int x, y;
  in >> x; in >> y; v.x = x; v.y = y;
  return in;
}

// Geometry

#define EPS 0.0000000001

class Vector2 {
public:
  double x, y;
  
  Vector2(double x = 0, double y = 0): x(x), y(y) {}
  
  Vector2 operator + (Vector2 v) { return Vector2(x + v.x, y + v.y); }
  Vector2 operator - (Vector2 v) { return Vector2(x - v.x, y - v.y); }
  Vector2 operator * (double k) { return Vector2(x * k, y * k); }
  Vector2 operator / (double k) { return Vector2(x / k, y / k); }
  
  double length() { return sqrt(norm()); }
  double norm() { return x * x + y * y; }
  double dot (Vector2 v) { return x * v.x + y * v.y; }
  double cross (Vector2 v) { return x * v.y - y * v.x; }
  
  bool operator < (const Vector2 &v) const {
    return x != v.x ? x < v.x : y < v.y;
  }
  
  bool operator == (const Vector2 &v) const {
    return fabs(x - v.x) < EPS && fabs(y - v.y) < EPS;
  }
};

ostream & operator << (ostream & out, Vector2 const & v) { 
  out<< "Vector2(" << v.x << ", " << v.y << ')';
  return out;
}

istream & operator >> (istream & in, Vector2 & v) { 
  double x, y;
  in >> x;
  in >> y;
  v.x = x;
  v.y = y;
  return in;
}

Int N;
string S;
vector<int> D;
vector<bool> done1(100, false);
vector<bool> done2(1000, false);

int toInt(char c) {
  return c - '0';
}

void input() {
  cin >> N >> S;

  for (auto x: S) {
    D.push_back(toInt(x));
  }
}


void solve() {
  int count = 0, num1, num2;
  for (int i=0; i<N-2; i++) {
    for (int j=i+1; j<N-1; j++) {
      num1 = D.at(i) * 10 + D.at(j);
      if (done1.at(num1)) continue;
      for (int k=j+1; k<N; k++) {
        num2 = num1*10 + D.at(k);
        if (done2.at(num2)) continue;
        count++;
        done2.at(num2) = true;
      }
      done1.at(num1) = true;
    }
  }
  cout << count << endl;
}

int main() {
  input();
  solve();
  return 0;
}


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

int main() {
	long long n,i,j,k,t,tt,ans,mod=1000000007;
	cin >> n >> t;
	vector<pair<long long,long long>> a(n);
	
	tt=0; ans=0;
	for(i=0; i<n; i++){
		cin >> a[i].first >> a[i].second;
		a[i].second=-a[i].second;
		tt+=a[i].first;
	}
	sort(a.begin(),a.end());
	for(i=0; i<n; i++){
		a[i].second=-a[i].second;
	}
	/*
	if(tt-a[n-1].first<t){
		for(i=0; i<n; i++){
			ans+=a[i].second;
		}
		cout << ans; return 0;
	}
	*/
	
	vector<long long> dp1(t),dp2(t);
	
	for(i=0; i<t; i++){
		dp1[i]=0; dp2[i]=0;
	}
	ans=a[0].second;
	for(i=0; i<n-1; i++){
		for(j=a[i].first; j<t; j++){
			dp2[j]=max(dp1[j],dp1[j-a[i].first]+a[i].second);
		}
		for(j=0; j<t; j++){
			dp1[j]=dp2[j];
		}
		ans=max(ans,dp2[t-1]+a[i+1].second);
	}
	
	cout << ans;
	return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
int main(void){
    int K, a, x = 0;
    scanf("%d", &K);
    a = K / 2;
    int aa, bb, cc, mij = 0, z = 0, aaa, bbb, ccc, ma = 0, zz = 0;
    for(int i = 1; i <= K; i++){
        for(int j = 1; j <= K; j++){
            for(int k = 1; k <= K; k++){
                z = 0; zz = 0;
                aa = (i < j)? j : i;
                bb = (i < j)? i : j;
                while(z != 1){
                    cc = aa % bb;
                    if(cc == 0){
                        mij = bb;
                        z += 1;
                    }
                    else {
                        aa = bb;
                        bb = cc;
                    }
                }
                
                aaa = (mij < k)? k : mij;
                bbb = (mij < k)? mij : k;
                while(zz != 1){
                    ccc = aaa % bbb;
                    if(ccc == 0){
                        ma = bbb;
                        zz += 1;
                    }
                    else {
                        aaa = bbb;
                        bbb = ccc;
                    }
                }
                x += ma;
                
            }
        }
    }
    printf("%d\n", x);
  return 0;
}

Measured memory_bytes: 1652
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iomanip>
#include <map>
#include <set>
#include <tuple>
#include <unordered_map>
#include <iterator>
#include <string>
#include <limits>

using namespace std;

using i64 = int64_t;
using P = pair<i64, i64>;
i64 mod = 1000000007;
int int_max = 2147483647;
i64 INF = 1e12;
int max_n = 1e5;


int main(int argc, char **argv) {
    string st;
    cin >> st;

    char c = st.back() - '0';

    if (c == 2 || c == 4 || c==5 || c==7 || c==9)
        cout << "hon" << endl;
    else if (c==0 || c==1 || c== 6 || c==8)
        cout << "pon" << endl;
    else
        cout << "bon" << endl;

    return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
 
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)      //repeat n times
#define REP2(i,s,n) for(int (i)=(s);(i)<(n);(i)++) //repeat from s to n 
#define REPD(i,n) for(int (i)=(n);(i)>=0;(i)--)    //repeat from n to 0
#define REPD2(i,s,e) for(int (i)=(s);(i)>=(e);(i)--) //repeat from s to e
#define ASIZE(a) (sizeof(a) / sizeof(a[0]))        //array size
#define SORTD(a) sort(a,a+ASIZE(a),greater<int>()) //sort in descending order for array
#define SORTA(a) sort(a,a+ASIZE(a))                //sort in ascending order for array
#define SORTS(a) sort(a.begin(),a.end())           //sort in ascending order for string type
typedef long long LL;
typedef unsigned int UINT;
typedef pair<int, int> P;
typedef vector<int> Vi;
typedef vector< Vi > VVi;
 
void SCAN(int *a){scanf("%d",a);}                             //scan for type int
void SCAN(int *a,int n){int i;REP(i,n){scanf("%d",&a[i]);}}   //scan for type int array
void SCAN(UINT *a){scanf("%u",a);}                            //scan for type unsigned int
void SCAN(UINT *a,int n){int i;REP(i,n){scanf("%u",&a[i]);}}  //scan for type unsigned int array
void SCAN(LL *a){scanf("%lld",a);}                            //scan for type long long int
void SCAN(LL *a,int n){int i;REP(i,n){scanf("%lld",&a[i]);}}  //scan for type long long int array
void SCAN(char *c){scanf(" %c",c);}                           //scan for type char
void SCAN(char *c,int n){int i;REP(i,n){scanf(" %c",&c[i]);}} //scan for type char array
 
const int MOD = 1000000007;
const int INF = 1999999999;
const LL INFLL = 999999999999999;
 
const int DX4[4]= {-1,0,1,0};
const int DY4[4]= {0,-1,0,1};
 
//fill an N-dimensional array with val
template<typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val){
	fill((T*)array,(T*)(array+N),val);
}
 
long double pascalTri(int n,int r){
	long double tri[n+1][n+1];
	int i,j;
	REP(i,n+1){REP(j,n+1){tri[i][j]=0;}}
	REP(i,n+1){
		REP(j,n+1){
			if(j>i){break;}
			if(j==0||j==i){tri[i][j]=1;}else{tri[i][j]=(tri[i-1][j-1]+tri[i-1][j]);}
		}
	}
	return tri[n][r];
}
 
 
int main(){
	// cin.tie(0);
	// ios::sync_with_stdio(false);
	int h,w;
	int cost[10][10];

	int i,j,k;
	SCAN(&h);SCAN(&w);
	int a[h][w];

	REP(i,10){
		SCAN(cost[i],10);
	}

	REP(i,h){
		SCAN(a[i],w);
	}
 

	REP(k,10){
		REP(i,10){
			REP(j,10){
				cost[i][j]=min(cost[i][j],cost[i][k]+cost[k][j]);
			}
		}
	}



	int ans=0;

	REP(i,h){
		REP(j,w){
			if(a[i][j]==1||a[i][j]==-1){continue;}
			ans+=cost[a[i][j]][1];
		}
	}

	printf("%d\n",ans);
	return 0;
}

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

const double PI=3.141592653589793238;

double ac(double r) {
    double area = r * r * PI;
    return area;
}

double ar(double r) {
    double circle = 2 * PI * r;
    return circle;
}

int main() {
    double r;
    cin >> r;
    
    double area = ac(r);
    double circle = ar(r);
    cout << fixed << setprecision(10);
    cout << area << ' ' << circle << endl;
}


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

#define loop(n) for(int i = 0;i < (int)(n);++i)
#define rep(i,n) for(int i = 0;i < (int)(n);++i)
#define all(vec) (vec).begin(),(vec).end()
#define Sort(vec) sort(all(vec))
#define Rev(vec) reverse(all(vec))

namespace Input
{
                
    void input(){return;}
    template<typename First,typename... Rest> void input(First &first,Rest&... rest){
    std::cin >> first;
    input(rest...);
}
    
    void inputVec(){return;}
    template<typename First,typename... Rest> void inputVec(vector<First> &first,Rest&... rest){
        int N = first.size();
        for(int i = 0;i < N;i++){
            cin >> first[i];
        }
        inputVec(rest...);
    }
    
    template<typename First,typename Second> void inputTwoVec(vector<First> &first,vector<Second>& second){
        int N = first.size();
        for(int i = 0;i < N;i++){
            cin >> first[i] >> second[i];
        }
    }
}

void calculate(){
    int n,have;
    Input::input(n,have);
    vector<int> child(n);
    Input::inputVec(child);
    Sort(child);
    int res = 0;
    rep(i,n){
        have -= child[i];
        if(have < 0) break;
        res++;
    }

    //余ったときの処理
    if(have > 0) res--;

    cout << res << '\n';
}

int main(int,char**){
    calculate();    
}




Measured memory_bytes: 256
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n = I()
A = sorted(readInts(),reverse=True)
ans = 0
dic = defaultdict(int)
dq = deque()
for i in range(n):
    #print(dq)
    if i == 0:
        dq.append(A[i])
    else:
        ans += dq.popleft()
        for j in range(2):
            dq.append(A[i])
print(ans)


Measured memory_bytes: 32948
import java.util.*;
import java.util.Map.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        List<Long> sum = new ArrayList<>();
        long bTotal = 0;
        for (int i = 0; i < n; i++) {
            long a = sc.nextLong();
            long b = sc.nextLong();
            bTotal += b;
            sum.add(a + b);
        }
        Collections.sort(sum, Comparator.reverseOrder());
        long ans = 0;
        for (int i = 0; i < n; i++) {
            if (i % 2 == 1) {
                continue;
            }
            ans += sum.get(i);
        }
        ans -= bTotal;
        System.out.println(ans);
    }
}


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

using namespace std;

int main()
{
	string S, T;
	cin >> S >> T;
	int A, B;
	cin >> A >> B;
	string U;
	cin >> U;
	if (S == U) {
		A--;
	} else {
		B--;
	}
	cout << A << " " << B << endl;
	return 0;
}


Measured memory_bytes: 256
import sys

def hantei(array,n):
  s = str(n)
  for i in range(len(s)):
    if int(s[i]) in array:
      return False
  
  return True

n,k = map(int,input().split())
d = list(map(int,input().split()))

while True:
  if hantei(d,n):
    print(n)
    sys.exit()
    
  n += 1

Measured memory_bytes: 2940
n,x,y = map(int, input().split())

ANS = [0]*(n-1)
for i in range(1, n):
    for j in range(i+1, n+1):
        d = min(j-i, abs(i-x)+abs(y-j)+1)
        ANS[d-1] += 1
print(*ANS, sep='\n')



Measured memory_bytes: 45404
n = gets.chomp.to_i
(d, x) = gets.chomp.split(' ').map(&:to_i)

s = x

n.times do |i|
  a = gets.chomp.to_i
  s += (d / a) + (d % a == 0 ? 0 : 1)
end

puts s.to_s

Measured memory_bytes: 1788
from itertools import combinations_with_replacement


def sol(A):
    tmp_ans = 0
    for row in B:
        a, b, c, d = row
        a -= 1
        b -= 1
        if A[b] == A[a] + c:
            tmp_ans += d
    return tmp_ans


if __name__ == '__main__':
    N, M, Q = map(int, input().split())
    A = [1 for _ in range(N)]
    used = [False for _ in range(N)]

    B = [list(map(int, input().split())) for _ in range(Q)]

    cnt = 0
    ans = 0
    for A in combinations_with_replacement([i for i in range(1, M + 1)], N):
        ans = max(ans, sol(A))

    print(ans)


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

int main()
{

    while (true)
    {
        int x, y;
        scanf("%d%d", &x, &y);
        if (x == 0 && y == 0)
            break;
        if (x < y)
            printf("%d %d\n", x, y);
        else
            printf("%d %d\n", y, x);
        }
}


Measured memory_bytes: 3132
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

namespace
{
	ll ModPow(ll a, ll p, ll mod)
	{
		if (p == 0)
			return 1;
		if (p % 2 == 0)
		{
			ll halfp = p / 2;
			ll half = ModPow(a, halfp, mod);
			return (half * half) % mod;
		}
		else
		{
			return (a * ModPow(a, p - 1, mod)) % mod;
		}
	}
	void Combination(int n, int r, ll mod, vl& out)
	{
		ll num = 1;
		ll den = 1;
		out[0] = 1;
		for (int i = 0; i < r; ++i)
		{
			num *= (n - i);
			num %= mod;
			den *= (i + 1);
			den %= mod;
			ll r = (num * ModPow(den, mod - 2, mod)) % mod;
			out[i + 1] = r;
		}
	}
}
void ABC167E()
{
	int MOD = 998244353;
	int N, M, K;
	cin >> N >> M >> K;
	if (N == 1)
	{
		cout << M << endl;
		return;
	}

	vl comb(K + 1);
	Combination (N - 1, K, MOD, comb);
	ll ans = 0;
	ll x = 1;
	for (int i = 0; i < N - 1 - K; ++i)
	{
		x *= M - 1;
		x %= MOD;
	}
	for (int i = K; i > -1; --i)
	{
		ans += x * comb[i];
		ans %= MOD;
		x *= M - 1;
		x %= MOD;
	}
	ans *= M;
	ans %= MOD;
	cout << ans << endl;
}
int main()
{
	ABC167E();
	return 0;
}


Measured memory_bytes: 4752
#include <iostream>

using namespace std;

int main(){
    int n, x, y;
    cin >> n >> x >> y;
    x--; y--;
    int d[n + 1];
    for (int i = 0; i <= n; i++)
        d[i] = 0;
    for (int i = 0; i < n; i++){
        for (int j = i + 1; j < n; j++){
            int dist = j - i;
            
            if (i <= x && j >= x && j <= y)
                dist = min(y - j + 1 + x - i, dist);
            if (i <= x && j >= y)
                dist = min(dist, x - i + j - y + 1);
            if (i >= x && j >= y)
                dist = min(dist, i - x + 1 + j - y);
            if (i >= x && j <= y)
                dist = min(dist, i - x + 1 + y - j);
            d[dist]++;
        }
    }
    for (int i = 1; i < n; i++)
        cout << d[i] << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#define rep(i, n)   for(int i = 0; i < (n); i++)
using namespace std;

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


Measured memory_bytes: 256
import os

import itertools
import sys
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, M, X = list(map(int, sys.stdin.buffer.readline().split()))
A = [list(map(int, sys.stdin.buffer.readline().split())) for _ in range(N)]

A = np.array(A, dtype=int)
mat = A[:, 1:]
C = A[:, 0]

ans = INF
for choices in itertools.product((True, False), repeat=N):
    choices = np.array(list(choices), dtype=bool)
    if np.all(mat[choices, :].sum(axis=0) >= X):
        ans = min(ans, C[choices].sum())
if ans == INF:
    print(-1)
else:
    print(ans)


Measured memory_bytes: 27408
#include<stdio.h>
#define MAX 200000
#define SENTINEL 2000000000
typedef long long llong;

int L[MAX / 2 + 2], R[MAX / 2 + 2];

llong merge(int A[], int n, int left, int mid, int right){
  int i, j, k;
  llong cnt = 0;
  int n1 = mid - left;
  int n2 = right - mid;
  for(i = 0; i < n1; i++) L[i] = A[left + i];
  for(i = 0; i < n2; i++) R[i] = A[mid + i];
  L[n1] = R[n2] = SENTINEL;
  i = j = 0;
  for(k = left; k < right; k++){
    if(L[i] <= R[j]) A[k] = L[i++];
    else{
      A[k] = R[j++];
      cnt += n1 - i;
    }
  }
  return cnt;
}

llong mergeSort(int A[], int n, int left, int right){
  int mid;
  llong v1, v2, v3;
  if(left + 1 < right){
    mid = (left + right) / 2;
    v1 = mergeSort(A, n, left, mid);
    v2 = mergeSort(A, n, mid, right);
    v3 = merge(A, n, left, mid, right);
    return v1 + v2 + v3;
  }
  else return 0;
}

int main(){
  int A[MAX], n, i;

  scanf("%d",&n);
  for(i = 0; i < n; i++){
    scanf("%d",&A[i]);
  }

  llong ans = mergeSort(A, n, 0, n);
  printf("%lld\n",ans);

  return 0;
}

Measured memory_bytes: 2156
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<string>
#include<functional>
#include<queue>
#include<stack>
#include<math.h>
#define INF 1000000000
#define EPS 1.0e-10

using namespace std;

typedef long long ll;

int n;

int main()
{
	while (cin >> n) {
		if (n == 0)return 0;
		ll d[5250];
		
		d[0] = 0;
		int a;
		for (int i = 1; i <= n; i++) {
			cin >> a;
			d[i] = d[i - 1] + a;
		}
		ll max = -INF;
		for (int i = 1; i <= n; i++) {
			for (int j = 0; j < i; j++) {
				if (d[i] - d[j] > max)max = d[i] - d[j];
			}
		}
		cout << max << endl;
	}

}

Measured memory_bytes: 3112
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.List;
import java.util.StringTokenizer;
import java.util.HashMap;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyScanner in = new MyScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        C solver = new C();
        solver.solve(1, in, out);
        out.close();
    }

    static class C {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            int N = in.nextInt();
            HashMap<String, C.Item> col = new HashMap<>();
            for (int i = 0; i < N; i++) {
                String S = in.next();
                if (!col.containsKey(S)) {
                    col.put(S, new C.Item(S));
                }
                col.get(S).count++;
            }
            List<String> items = new ArrayList<>();
            int max = 0;
            for (C.Item item : col.values()) {
                if (max < item.count) {
                    max = item.count;
                    items.clear();
                    items.add(item.S);
                } else if (max == item.count) {
                    items.add(item.S);
                }
            }
            items.sort(String::compareTo);
            for (String S : items) {
                out.println(S);
            }
        }

        static class Item {
            String S;
            int count;

            Item(String S) {
                this.S = S;
            }

        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 67068
#include <bits/stdc++.h>
#define mp make_pair
#define eb emplace_back
#define fi first
#define se second
#define int long long
using namespace std;
using cd = complex <double>;

typedef pair <int, int> pii;
typedef vector <int> vi;
typedef vector <pair <int, int> > vii;
typedef map <int, int> mii;

const int Inf = 100000;
const int mod = 1234567;
const double Pi = acos(-1);

void Fastio()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}

int a, b, c, k;
int ans;

void Solve()
{
	cin >> a >> b >> c >> k;
	if(k < a)
	{
		cout << k;
		return;
	}
	ans = a;
	k -= a;
	if(k < b)
	{
		cout << a;
		return;
	}
	k -= b;
	cout << a - k;
}

signed main()
{
	Fastio();
	Solve();
}

Measured memory_bytes: 3652
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int a[] = new int[n];
		for(int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}

		float ans = 0;
		for(int i = 0; i < n; i++) {
			ans += 1.0 / a[i];
//			System.out.println(ans);
		}
		
//		System.out.println(Arrays.toString(a));
		System.out.println(1 / ans);
	}
}


Measured memory_bytes: 25172
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))
res = 10 ** 6
idx = 0
for i, h in enumerate(H):
    tmp = abs(A - T + h * 0.006)
    if tmp < res:
        res = tmp
        idx = i + 1
print(idx)

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

using namespace std;
int h,w;
int sum[250005],mp[250005];
int abs(int x){
	if(x>0) return x;
	else return -x;
}
void solve(int x,int d){
	int y,a,b,pa,pb;
	y=mp[x];
	pa=y/500;
	pb=y%500;
	for(int i=x;i<=h*w;i+=d){
		y=mp[i];
	    a=y/500;
	    b=y%500;
	    sum[i]=sum[i-d]+abs(pa-a)+abs(pb-b);
	    pa=a;
	    pb=b;
	}
}
int main()
{
	int d,x;
	scanf("%d%d%d",&h,&w,&d);
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			scanf("%d",&x);
			mp[x]=i*500+j;
		}
	}
	memset(sum,0,sizeof(sum));
	for(int i=1;i<=d;i++){
		solve(i,d);
	}
	int q,l,r;
	scanf("%d",&q);
	while(q--){
		scanf("%d%d",&l,&r);
		//cout<<sum[r]<<" "<<sum[l]<<endl;
		printf("%d\n",sum[r]-sum[l]);
	}
	return 0;
}

Measured memory_bytes: 2432
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::io::{BufWriter, Write};

// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn solve() {
    input!(
        x: usize,
        _y: usize,
        _z: usize,
        k: usize,
        a: [[usize; x]; 3],
    );

    let mut ans = Vec::new();
    ans.push(0);



    for idx in 0..3 {
        let mut tmp: Vec<usize> = vec![];
        for i in ans {
            for j in &a[idx] {
                tmp.push(i + j);
            }
        }
        tmp.sort();
        tmp.reverse();
        ans = tmp[0..min(k, tmp.len())].to_vec();
    }

    for i in ans {
        println!("{}", i);
    }
}

fn main() {
    let stack_size = 1 << 28;
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 40308
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main {
	public static void main (String[] args) throws java.lang.Exception
	{
		ArrayList<String> x = new ArrayList<String>();
		ArrayList<Integer> intAry = new ArrayList<Integer>();
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		int i = 0;
		while(true) {
			x.add(br.readLine());
			String s = x.get(i);
			if(s.equals("0 0")) {
				break;
			}else {
				i++;
			}
		}

		
		for(int j = 0; j < x.size() - 1; j++) {
			String s = x.get(j);
			String[] strAry = s.split(" ");
			int a = Integer.parseInt(strAry[0]);
			int b = Integer.parseInt(strAry[1]);
			if(a > b) {
				int r = a;
				a = b;
				b = r;
			}
			intAry.add(a);
			intAry.add(b);
		}
		
		for(int j = 0; j < intAry.size(); j++) {
			if(j % 2 == 1) {
				System.out.println(intAry.get(j));
			}else {
				System.out.print(intAry.get(j) + " ");
			}
			
		}


	}
}

Measured memory_bytes: 27964
n = int(input())
arr = [[1] * n for _ in range(4)]
t = list(map(int, input().split()))
a = list(map(int, input().split()))[::-1]

MOD = 10**9 + 7

max_t = 0
max_a = 0

for i in range(n):
    if max_t < t[i]:
        arr[0][i] = t[i]
        arr[1][i] = t[i]
        max_t = t[i]
    else:
        arr[1][i] = t[i]
    if max_a < a[i]:
        arr[2][i] = a[i]
        arr[3][i] = a[i]
        max_a = a[i]
    else:
        arr[3][i] = a[i]

arr[2] = arr[2][::-1]
arr[3] = arr[3][::-1]

ans = 1
for i in range(n):
    ans *= max(min(arr[1][i], arr[3][i]) - max(arr[0][i], arr[2][i]) + 1, 0)
    ans %= MOD

print(ans)

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

int main(){
    int sum = 0;
    for(int i = 0; i < 2; i++){
        int tmp1, tmp2;
        cin >> tmp1 >> tmp2;
        if(tmp1 > tmp2){
            sum += tmp2;
        }
        else{
            sum += tmp1;
        }
    }

    cout << sum << endl;

    return 0;
}

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

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

    vector<int> ans(n, 0);
    for(int i = 0; i < n - 1; i++) {
        int a;
        cin >> a;
        a--;
        ans[a]++;
    }

    for(int i = 0; i < n - 1; i++) {
        cout << ans[i] << endl;
    }
    cout << 0 << endl;

    return 0;
}

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

typedef pair<int, int> pii;
typedef long long ll;
const ll mod = 1000000007LL;

int main()
{
    int n;
    cin>>n;
    vector<int> v(n);
    for(auto &i:v)
        cin>>i;
    sort(v.begin(),v.end(),[](int a, int b){
        return a>b;
    });
    vector<int> alice, bob;
    for(int i=1;i<n+1;i++)
    {
        if(i&1)
            alice.push_back(v[i-1]);
        else
            bob.push_back(v[i-1]);
    }
    int a=0,b=0;
    for(auto i:alice)
        a+=i;
    for(auto i:bob)
        b+=i;
    cout<<a-b<<endl;
    return 0;
}

Measured memory_bytes: 256
export class Main {
  static main(input): string {
    const s: string = input.split("\n")[0].split(" ")[0];
    const len: number = s.length;
    const zeroLength: number = s.split("").filter(m => m === "0").length;
    const oneLnegth: number = len - zeroLength;
    return `${Math.min(zeroLength, oneLnegth) * 2}`;
  }
}

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

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

/* 
 * g++ -std=c++17 main.cpp -o main
 */
int main() {
  ios::sync_with_stdio(false);
  int n, m;
  cin>>n>>m;
  int sum = 0;
  for(int i = 0; i < m; i++) {
    int a;
    cin>>a;
    sum+=a;
  }

  cout << max(-1, n - sum);
  cout<<endl;
}


Measured memory_bytes: 3644
/*
ID: varunra2
LANG: C++
TASK: buffet
*/
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <limits.h>
#include <limits>
#include <list>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <utility>
#include <vector>

using namespace std;

#define EPS 1e-9
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define IN(A, B, C) assert(B <= A && A <= C)
#define INF (int)1e9
#define MEM(a, b) memset(a, (b), sizeof(a))
#define MOD 1000000007
#define MP make_pair
#define PB push_back
#define PI 3.1415926535897932384626433832795
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()

typedef pair<int, int> PII;
typedef vector<int> VI;

const double pi = acos(-1.0);
typedef long int int32;
typedef long long int int64;
typedef map<int, int> MPII;
typedef multiset<int> MSETI;
typedef set<int> SETI;
typedef set<string> SETS;
typedef unsigned long int uint32;
typedef unsigned long long int uint64;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef vector<string> VS;

#define watch(x) cerr << (#x) << " is " << (x) << endl
#define printvii(v)                                    \
  cerr << (#v) << "=";                                 \
  for_each(v.begin(), v.end(), [](PII i) -> void {     \
    cerr << "(" << i.first << "," << i.second << "),"; \
  });                                                  \
  cerr << endl;
#define printvi(v)                                                       \
  cerr << (#v) << "=";                                                   \
  for_each(v.begin(), v.end(), [](int i) -> void { cerr << i << ","; }); \
  cerr << endl;

int main(int argc, char const *argv[]) {

  int n;
  cin >> n;

  VI a(n), b(n), c(n - 1);

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

  for(int i = 0; i < n; i++) {
    cin >> b[i];
  }
  for (int i = 0; i < n - 1; i++) {
    cin >> c[i];
  }

  int ret = accumulate(b.begin(), b.end(), 0);

  for(int i = 0; i < n - 1; i++) {
    if(a[i] + 1 == a[i + 1]) {
      ret += c[a[i]];
    }
  }

  cout << ret << endl;

  return 0;
}


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

using namespace std;

typedef long long LL;

const int N = 1100, MOD = 1e9 + 7;
int c[N][N], g[N][N], inv[N];
int dp[N][N];

int mypow(LL a, LL b) {
    LL ret = 1;
    while (b) {
        if (b & 1) ret = ret * a % MOD;
        a = a * a % MOD;
        b >>= 1;
    }
    return ret;
}

int main() {
    for (int i = 0; i < N; i++) {
        c[i][0] = 1;
        for (int j = 1; j <= i; j++) c[i][j] = (c[i-1][j] + c[i-1][j-1]) % MOD;
    }
    for (int i = 1; i < N; i++) inv[i] = mypow(i, MOD - 2);
    for (int i = 1; i < N; i++) {
        g[i][0] = 1;
        for (int j = 1; j < N; j++) if (i * j < N) {
            g[i][j] = 1ll * g[i][j-1] * c[i*j][i] % MOD * inv[j] % MOD;
        }
    }
    int n, a, b, C, d;
    scanf("%d%d%d%d%d", &n, &a, &b, &C, &d);
    dp[a-1][0] = 1;
    for (int i = a; i <= b; i++) {
        dp[i][0] = 1;
        for (int j = 1; j <= n; j++) {
            dp[i][j] = dp[i-1][j];
            for (int k = C; k <= d; k++) {
                if (k * i > j) break;
                dp[i][j] = (dp[i][j] + 1ll * dp[i-1][j-k*i] * g[i][k] % MOD * c[j][k*i] % MOD) % MOD;
            }
        }
    }
    printf("%d\n", dp[b][n]);
    return 0;
}


Measured memory_bytes: 13696
n = gets.chomp.to_i
value = gets.chomp.split(" ").map(&:to_i)
cost = gets.chomp.split(" ").map(&:to_i)
ans = 0
n.times do |i|
    tmp = value[i] - cost[i]
    if tmp >= 0 then
        ans += tmp
    end
end
puts ans

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

int main() {
	vector<int> a(3);
	for (int i = 0; i < 3; i++) cin >> a.at(i);
	sort(a.begin(), a.end());
	for (int i = 0; i < 3; i++) {
		if (i == 2)cout << a.at(i) << endl;
		else cout << a.at(i) << " ";
	} 
}


Measured memory_bytes: 3144
/*K - Stones*/
#include <bits/stdc++.h>
using namespace std;

int main(){

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	int stones;
	int tam;

	cin >> tam >> stones;
	vector <int> jugada(tam);

	for (int i = 0; i < tam; ++i)
		cin >> jugada[i];

	bool ans;
	sort(jugada.begin(), jugada.end());

	vector<bool> memo(stones + 10);

	memo[0] = false;

	for (int piedras = 1; piedras <= stones; ++piedras)
	{

		memo[piedras] = false;

		for (int i = 0; i < jugada.size(); ++i)
		{
			if(piedras < jugada[i])
				break;

			if (memo[piedras - jugada[i]] == false){
				memo[piedras] = true;
			}
		}
	}

	ans = memo[stones];

	if(ans == true)
		cout << "First";
	else
		cout << "Second";

	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define ALL(x) x.begin(),x.end()
#define PB push_back
#define LL long long
 
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {
    _for(i,0,v.size()) os << v[i] << " ";
    return os;
}
 
template<typename T>
ostream& operator<<(ostream& os,const set<T>& v){
    for(typename set<T>::iterator it = v.begin();it != v.end();it++)
    os << *it <<" ";
    return os;
}
 
int main()
{
    int k;cin >> k;
    int odd = (k+1)/2;
    int even = k/2;
    cout << odd*even << endl;
    return 0;
}

Measured memory_bytes: 256
(defun split (str delim)
  (let ((res (make-array 1 :element-type 'string
                           :fill-pointer 0
                           :adjustable t)))
    (loop for i from 0 below (length str)
          with start = 0
          when (eq (char str i) delim)
          do (vector-push-extend (subseq str start i) res)
             (setf start (1+ i))
          finally (let ((tail (subseq str start)))
                    (when tail
                      (vector-push-extend tail res))))
    res))

(let* ((in (map 'vector #'parse-integer (split (read-line) #\Space)))
       (x (aref in 0))
       (y (aref in 1))
       (xplus (plusp x))
       (yplus (plusp y)))
  (if (= x y)
      (format t "~A~%" 0)
      (if (= x 0)
          (if yplus
              (format t "~A~%" (abs y))
              (format t "~A~%" (1+ (abs y))))
          (if (= y 0)
              (if xplus
                  (format t "~A~%" (1+ x))
                  (format t "~A~%" (abs x)))
              (if (eq xplus yplus)
                  (if (> x y)
                      (format t "~A~%" (+ (- x y) 2))
                      (format t "~A~%" (- y x)))
                  (if xplus
                      (if (> (abs x) (abs y))
                          (format t "~A~%" (1+ (+ x y)))
                          (format t "~A~%" (1+ (-(+ x y)))))
                      (if (> (abs x) (abs y))
                          (format t "~A~%" (1+ (- (+ x y))))
                          (format t "~A~%" (1+ (+ x y))))))))))

Measured memory_bytes: 15588
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
using P = pair<int, int>;
const int inf =1e9;

struct edge{
    int to;
    int cost;
};
using graph = vector<vector<edge>>;

int main(){
    int a, b; cin >> a >> b;
    int i=0;
    while((a-1)*i+1 < b){
        i++;
    }
    cout << i << endl;
    return 0; 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);++i)
#define fi first
#define se second
#define INF 1000000009
#define lINF 1000000000000000009
typedef long long ll;

int main(){
  int m=3;
  int a[10][10];
  rep(i,m)rep(j,m){
    cin>>a[i][j];
  }
  int n;
  cin>>n;
  rep(i,n){
    int b;
    cin>>b;
    rep(j,m)rep(k,m){
      if(a[j][k]==b)a[j][k]=-1;
    }
  }
  string ans="No";
  rep(i,m){
    int cnt=0;
    rep(j,m){
      if(a[i][j]==-1)cnt++;
    }
    if(cnt==3)ans="Yes";
  }
  rep(i,m){
    int cnt=0;
    rep(j,m){
      if(a[j][i]==-1)cnt++;
    }
    if(cnt==3)ans="Yes";
  }
  if(a[0][0]==-1&&a[1][1]==-1&&a[2][2]==-1||a[0][2]==-1&&a[1][1]==-1&&a[2][0]==-1)ans="Yes";
  cout<<ans<<endl;
  return(0);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for((i)=1;(i)<=(n);(i)++)
using namespace std;
int n,i,j,t;
long long a[65],b[205];
string s;
bool ins(long long x){
	int i;
	for(i=63;i>=0;i--)if((x>>i)&1){
		if(a[i]){
			x^=a[i];
			continue;
		}
		a[i]=x;
		return 1;
	}
	return 0;
}
int main(){
	cin>>t;
	while(t--){
		memset(a,0,sizeof(a));
		cin>>n;
		rep(i,n)cin>>b[i];
		cin>>s;
		for(i=n;i>=1;i--){
			if(ins(b[i])&&s[i-1]=='1') break;
		}
		cout<<(!!i)<<endl;
	}
	return 0;
}

Measured memory_bytes: 3604
#include <cstdio>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <iostream>
#include <queue>
#include <stack>
#include <sstream>
#include <cctype>
using namespace std;

#define PQ priority_queue
#define P pair<int,int>
#define CLA(array) memset(array,0,sizeof array)
#define CLINF(array) memset(array,0x3f,sizeof array)
#define CLF(array) memset(array,-1,sizeof array)
#define DB(a) cout << "DEBUG " << a << endl;
#define lowbit(x) (x)&(-x)
#define fi first
#define se second
typedef long long LL;
typedef unsigned long long ULL;
const int MAXN = 100000 + 10;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9+7;

int n;
char s1[60], s2[60];
int main(){
    //ios_base::sync_with_stdio(false);
	scanf("%d", &n);
	scanf("%s%s", s1, s2);
	std::vector<int> v;
	LL sum = 1;
	int t1 = 0, t2 = 0;
	for(int i = 0; i < n; i++){
		if( i-2 >= 0 && s1[i] == s1[i+1] && s1[i-2] == s1[i-1] && i + 1 < n){
			if(!t1 && !t2) {
				t1 = 3, t2 = 2;
				sum = sum*(t1*t2)%MOD;
			}
			else if(!t2){
				t1 = 2; t2 = 1;
				sum = sum*2ll%MOD;
			}
			else{
				t1 = 2; t2 = 1;
				sum = sum*(3ll)%MOD;
			}
			i ++;
		}
		else if(s1[i] == s2[i] && s1[i+1] == s2[i+1] && i+1 < n){
			if(!t1 && !t2) {
				t1 = 3, t2 = 0;
				sum = 3ll*sum%MOD;
			}
			else if(t1 && t2) {
				t1 = 3, t2 = 0;
			}
			else {
				t1 = 3, t2 = 0;
				sum = 2ll*sum%MOD;
			}
		}
		else if(s1[i] == s2[i]){
			if(!t1 && !t2){
				t1 = 3; t2 = 0;
				sum = t1*sum%MOD;
			}
			else if(!t2){
				t1 = 3; t2 = 0;
				sum = 2ll*sum%MOD;
			}
			else {
				t1 = 3, t2 = 0;
			}
		}
		else if(s1[i] == s1[i+1] && i+1 < n){
			if(!t1 && !t2){
				t1 = 3; t2 = 2;
				sum = sum*t1*t2%MOD;
			}
			else if(!t2){
				sum = 2ll*sum%MOD;
				t1 = 2, t2 = 1;
			}
			else{
				sum = 2ll*sum%MOD;
			}
			i++;
		}
		// cout << i << " " << sum%MOD << endl;
	}
	printf("%lld\n", sum%MOD);

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,a,b) for (int i=a; i<b; ++i)
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a,b,c;
    cin >> a >> b >> c;
    if (c-a-b < 0)
    {
        cout << "No\n"; return 0;
    }
    if ((c-a-b)*(c-a-b) <= 4*a*b)
    {
        cout << "No\n"; return 0;
    }
    cout << "Yes\n";
    return 0;
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;

void Main(){
    auto dsum = [&](ll x){
        int res = 0;
        while(x){
            res += x % 10;
            x /= 10;
        }
        return res;
    };
    
    auto ratio = [&](ll x){
        return double(x)/double(dsum(x));    
    };

    vll ans;
    rep3(i, 1, 8) ans.pb(i);
    ll now = 9, power = 10;    
    while(now < 1e15 + 5){
        if(ratio(now) <= ratio(now + power)){
            ans.pb(now);
            // cout << now << endl;
            now += power;
        }
        else{
            now -= power;
            power *= 10;
            now += power;
        }
    }
    
    ll k; cin >> k; 
    rep(i, k){
        cout << ans[i] << endl;
    }
    return;
}

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

Measured memory_bytes: 3592
/* tempate
 *
 *
 */

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int (i)=(n); (i)>=(0); (i)--)
#define SIZE(x) ((int)(x).size())
#define GCD(a, b) int gcd(int a,int b){return b?gcd(b,a%b):a;}
#define QP(a, b) int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define all(v) (v).begin(),(v).end()


template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
template<typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

typedef vector<int, int> vint;
typedef pair<int,int> pint;
typedef vector<pint>vpint;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1LL << 60;
const ll MOD = 1000000007LL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    ll res = 0;
    for(ll i = 1; i <= n; i++){
        if(10 <= i && i <= 99 || 1000 <= i && i <= 9999 || i == 100000) continue;
        res++;
    }
    cout << res;
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
import numpy as np

a, b, x = map(int, input().split())

v = a * a * b

if x <= v / 2:
    theta = np.arctan(a * b**2 / (2 * x))
    print(np.rad2deg(theta))

else:
    theta = np.arctan(2 * (v - x) / (a**3))
    print(np.rad2deg(theta))

Measured memory_bytes: 12496
#include <bits/stdc++.h>
//#define DEBUG
#define REP(i, nn ) for(int i = 0 ; i < (int) nn; i++)
#define deb(x) std::cout << #x << " " << x << endl;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
template<typename... T>
void read(T& ... a){
    ((cin >> a),...);
}
template<typename... T>
void write(T... a){
    ((cout << a << "\n"),...);
}

template<typename... T>
void write_space(T... a){
    ((cout << a << " "),...);
}
constexpr int mxK = 1e6;
int k;
int mod_pow[mxK];

void compute_mod(){
    mod_pow[0] = 1;
    for(int i = 1 ; i < k ; i++){
        mod_pow[i] = mod_pow[i-1] * 10 + 1;
        if(mod_pow[i] > k){
            mod_pow[i] = (mod_pow[i] % k);
        }
    }
}

void solve(){
    read(k);
    compute_mod();
    for(int i = 0 ; i < k ; i++){
        if( (7 * mod_pow[i]) % k == 0){
            cout << i + 1 << endl;
            return;
        }
    } 
    cout << "-1\n";
} 

int main()
{
    //making data IO Fast
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);

    solve();

    return 0;
}


Measured memory_bytes: 7508
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
const int mod=1000000007;
const int mod1=998244353;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a,b;cin >> a >> b;
	b+=a*3;
	cout << b/2 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;

using namespace std;


int main()
{
    int n;
    cin >> n;
    if (n <= 9)
    {
        cout << "Yes";
        return 0;
    }
    for (int q = 2; q <=9; q++)
    {
        if (n%q == 0 && n/q <= 9)
        {
            cout << "Yes";
            return 0;
        }
    }
    cout << "No";
    return 0;
}


Measured memory_bytes: 256