akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <set>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
 
int main(void){
    while(1){
        int n, k, ans = 0;
        cin >> n >> k;
        if(n == 0 && k == 0) break;//00???????????????????????????
        bool flag = false;//?????¨???????????????0??????????????????????????????????????°
        vector<bool> num(n + 1, false);//?????±??????????????????????????????
        rep(i, k){
            int tmp; scanf("%d", &tmp);
            if(tmp == 0){
                flag = true;
                continue;
            }
            num[tmp] = true;//?????±????????????
        }
        int pre = 0;//???????????£?¶??¢????????????°???????????°?????\????????????
        int cnt = 0;//?????????????????£?¶??¢????????????°???????????°????????????????????????????????¨
        int now;
        int end = 0;//???????????£?¶???¨????¢?????????????????????°????????\????????????
        bool rennketukanouseiflag = false;//??£??\????????£?¶??¢????????????????1?????¨?????????true
        reps(i, 1, n + 1){
            //??°???i????????????
            if(num[i] == true){
                if(i == end + 2) rennketukanouseiflag = true;//???????????£?¶??¢?????????¨?????????1
                cnt++;
            //??°???i???????????¨???
            }else{
                now = cnt;//?????¨??????????????£?¶???¨????¢????????????°???????????°
                //?????¨?????????0????????????????????????????????£??\????????£?¶???¨??????????????°???1???????????¨?????????????????£?¶???¨???????????????????????£????????????
                if(flag == true && rennketukanouseiflag == true) ans = max(ans, pre + now + 1);
                //???????????¶????????????????????¨?????????????????£?¶???¨????¢???????????????§?????§??????????????¢?????°??????
                else ans = max(ans, now);
                
                // ?????????
                cnt = 0;
                rennketukanouseiflag = false;
                pre = now;//?????¢??£?????????
                end = i;
            }
        }
        printf("%d\n", ans);
    }
    return 0;
}

Measured memory_bytes: 3124
import sys
readline = sys.stdin.readline


def solve():
    N = int(input())
    brackets_generator = (readline().strip() for _ in range(N))

    grads_positive = list()
    grads_negative = list()

    total = 0
    for brackets in brackets_generator:

        elevation, bottom = 0, 0

        for bk in brackets:

            elevation += 1 if bk == '(' else -1
            bottom = min(bottom, elevation)

        if elevation >= 0:
            grads_positive.append((bottom, elevation))
        elif elevation < 0:
            grads_negative.append((bottom - elevation, -elevation))

        total += elevation

    if total != 0:
        return False

    grads_positive.sort(reverse=True)
    grads_negative.sort(reverse=True)

    def is_good(grads):
        elevation, bottom = 0, 0
        for grad in grads:
            bottom = elevation + grad[0]
            if bottom < 0:
                return False
            elevation += grad[1]

        return True

    return is_good(grads_positive) and is_good(grads_negative)


def main():
    ok = solve()
    if ok:
        print('Yes')
    else:
        print('No')


if __name__ == "__main__":
    main()


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

#define int long long
#define rep(i,a,n) for(int i = a; i < n; i++)
#define pb push_back
#define eb emplace_back
#define dump(x) cout << #x << " = " << (x) << endl
#define chk() cout << "now" << endl;
#define SORT(c) sort((c).begin(), (c).end())
#define SORTG(c) sort((c).begin(), (c).end(), greater<int>());
#define fi first
#define se second
  
typedef pair<int,int> P;
typedef vector<int> vi;

int N,T;
vi A;

signed main() {
    cin>>N>>T;
    rep(i,0,N) {
        int a; cin>>a; A.pb(a);
    }

    int min=A[0],ret=0,ans;
    map<int,int> mp;
    rep(i,1,N) {
        if(A[i]-min>ret) {
            ret=A[i]-min;
            mp[ret]=1;
        }else if(A[i]-min==ret) {
            mp[ret]++;
        }

        if(A[i]<min) {
            min=A[i];
        }
    }
    cout<<mp[ret]<<endl;
    return 0;
}




Measured memory_bytes: 7284
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#define INF 1000000000;

using namespace std;

int main() {
    string s;
    cin >> s;

    int n = s.size(), a_index, z_index, diff;
    bool a_flg=false, z_flg=false;
    for (int i=0; i<n; ++i){
        if (a_flg==false){
            if (s[i] == 'A'){
                a_index = i;
                a_flg = true;
            }
        }

        if (s[i] == 'Z') z_index = i;

    }
    diff = z_index-a_index+1;
    cout << diff << endl;
    
}


Measured memory_bytes: 644
import sys
input = sys.stdin.readline

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
iA = [(i, A[i]) for i in range(N)]
iB = [(i, B[i]) for i in range(N)]
iA.sort(key=lambda t: t[1])
iB.sort(key=lambda t: t[1])

for i in range(N):
    if iA[i][1]>iB[i][1]:
        print('No')
        exit()

to = [-1]*N

for i in range(N):
    to[iB[i][0]] = iA[i][0]

s = {0}
now = 0

while True:
    now = to[now]
    
    if now in s:
        break
    
    s.add(now)

if len(s)<N:
    print('Yes')
    exit()

for i in range(N-1):
    if iA[i+1][1]<=iB[i][1]:
        print('Yes')
        exit()

print('No')

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

#define maxn 2500
#define INF 0x3f3f3f3f
#define mod 1000000007
typedef long long ll;
using namespace std;

int a[201] = { 0,1,9,30,76,141,267,400,624,885,1249,1590,2208,2689,3411,4248,5248,6081,7485,8530,10248,11889,13687,15228,17988,20053,22569,25242,28588,31053,35463,38284,42540,46581,50893,55362,61824,65857,71247,76884,84388,89349,97881,103342,111528,120141,128047,134580,146316,154177,164817,174438,185836,194157,207927,218812,233268,245277,257857,268182,288216,299257,313635,330204,347836,362973,383709,397042,416448,434025,456967,471948,499740,515581,536073,559758,583960,604833,633651,652216,683712,709065,734233,754734,793188,818917,846603,874512,909496,933081,977145,1006126,1041504,1073385,1106467,1138536,1187112,1215145,1255101,1295142,1342852,1373253,1422195,1453816,1502376,1553361,1595437,1629570,1691292,1726717,1782111,1827492,1887772,1925853,1986837,2033674,2089776,2145333,2197483,2246640,2332104,2379085,2434833,2490534,2554600,2609625,2693919,2742052,2813988,2875245,2952085,3003306,3096024,3157249,3224511,3306240,3388576,3444609,3533637,3591322,3693924,3767085,3842623,3912324,4027884,4102093,4181949,4270422,4361548,4427853,4548003,4616104,4718640,4812789,4918561,5003286,5131848,5205481,5299011,5392008,5521384,5610705,5739009,5818390,5930196,6052893,6156139,6239472,6402720,6493681,6623853,6741078,6864016,6953457,7094451,7215016,7359936,7475145,7593865,7689630,7886244,7984165,8130747,8253888,8403448,8523897,8684853,8802826,8949612,9105537,9267595,9376656,9574704,9686065,9827097,9997134,10174780,10290813,10493367,10611772,10813692 };

void slove()
{
	int n; cin >> n; cout << a[n];
}

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

	slove();

	return 0;
}

Measured memory_bytes: 3636
/*{{{*/
//#define HOME
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;

#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define F first
#define S second

template<class T> void _R(T &_x) { cin >> _x; }
void _R(int &_x) { scanf("%d", &_x); }
void _R(int64_t &_x) { scanf("%" SCNd64, &_x); }
void _R(double &_x) { scanf("%lf", &_x); }
void _R(char &_x) { scanf(" %c", &_x); }
void _R(char *_x) { scanf("%s", _x); }
template<class T, class U> void _R(pair<T, U> &_x) {_R(_x.F); _R(_x.S);}
void R() {}
template<class T, class... U> void R(T &_head, U &... _tail) { _R(_head); R(_tail...); }

template<class T> void _W(const T &_x) { cout << _x; }
void _W(const int &_x) { printf("%d", _x); }
void _W(const int64_t &_x) { printf("%" PRId64, _x); }
void _W(const double &_x) { printf("%.16f", _x); }
void _W(const char &_x) { putchar(_x); }
void _W(const char *_x) { printf("%s", _x); }
template<class T, class U> void _W(const pair<T, U> &_x) {_W(_x.F); putchar(' '); _W(_x.S);}
template<class T> void _W(const vector<T> &_x) { for (auto i = _x.begin(); i != _x.end(); _W(*i++)) if (i != _x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &_head, const U &... _tail) { _W(_head); putchar(sizeof...(_tail) ? ' ' : '\n'); W(_tail...); }
template<class T, class... U> void DB(const T &_head, const U &... _tail) {
#ifdef HOME
    W('#', _head, _tail...);
#endif
}

#define SZ(x) (int)((x).size())
#define ALL(x) (x).begin(), (x).end()
#define RAN(x,n) (x).begin(), (x).begin()+(n)
#define UNIQUE(x) {sort(ALL(x)); (x).erase(unique(ALL(x)), (x).end());}

#define REP(i,a,b) for (int i = (a); i <= (b); ++i)
#define REPD(i,a,b) for (int i = (a); i >= (b); --i)
#define FORI(i,n) REP(i,1,n)
#define FOR(i,n) REP(i,0,int(n)-1)
//#define ITER(i,t) for (auto i = t.begin(); i != t.end(); ++i)
#define IT3(i,st,ed) for (auto i = st; i != ed; ++i)
#define IT2(i,range) IT3(i,range)

#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define MS(X, v) memset((X), (v), sizeof((X)))

template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

typedef int64_t ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

inline int LG (const unsigned int &_x) { return 31-__builtin_clz(_x); }  // floor: LG(x), ceil: LG(x-1)+1
/*}}}*/

int n;

int main(){
    R(n);
    int x = (double)n / 1.08 - 10;
    for(; (int)(x * 1.08) <= n; ++x)
        if((int)(x*1.08) == n){
            W(x);
            return 0;
        }
    W(":(");
    return 0;
}


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

int main() {
  int n;cin>>n;
  int an[n];rep(i,n) cin>>an[i];
  ll bn[n];rep(i,n) bn[i]=0;
  rep(i,n) {
    bn[an[i]-1] ++;
  }
  ll sn = 0;
  rep(i,n) sn += bn[i] * (bn[i]-1) / 2;
  
  rep(i,n) {
    int a = an[i];
    cout << sn - (bn[a-1] - 1) << endl;
  }
}


Measured memory_bytes: 4992
#include <iostream>
#include <ios>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cstdio>
using namespace std;

int times[16][17];
int N;

map<vector<int>, int> memo;

int dp(const vector<int>& state) {
    auto it = memo.find(state);
    if(it != memo.end()) {
        return it->second;
    }

    const int L = state.size();
    if(L == 1) {
        return times[*state.begin()][0];
    } else {
        int min_route = 10000000;
        for(int i : state) {
            vector<int> copy = state;
            copy.erase(remove(copy.begin(), copy.end(), i));
            int min_time = times[i][0];
            for(int j = 0; j < N; ++j) {
                if(find(copy.begin(), copy.end(), j) != copy.end()) {
                    min_time = min(min_time, times[i][j + 1]);
                }
            }
            min_route = min(min_route, dp(copy) + min_time);
        }
        memo[state] = min_route;
        return min_route;
    }
}

int main(void) {
    ios::sync_with_stdio(false);

    while(true) {
        cin >> N;
        if(N == 0) {
            break;
        }
        for(int i = 0; i < N; ++ i) {
            for(int j = 0; j < N + 1; ++j) {
                int x;
                cin >> x;
                times[i][j] = x;
            }
        }
        vector<int> state;
        for(int i = 0; i < N; ++ i) {
            state.emplace_back(i);
        }
        memo.clear();
        cout << dp(state) << endl;
    }

    return 0;
}

Measured memory_bytes: 9292
#include<iostream>
using namespace std;
int main(){
    int n,x;
    while(true){
    cin>>n>>x;
        int y=0;
        if(n ==0&&x==0){
            break;
        }
        for(int i=1;i<=n;i++){
            for(int j=i+1;j<=n;j++){
                for(int k=j+1;k<=n;k++){
                    if(i+j+k==x){
                        y++;
                    }
                }
            }
        }
        cout<<y<<endl;
    }
    return 0;
}


Measured memory_bytes: 3084
from itertools import accumulate

N, Q = map(int, input().split())
S = input()
A = [list(map(int, input().split())) for i in range(Q)]
# リストに入れておく
#print(A)

flg = []
for i in range(N-1):
    tmp_S = S[i:i+2]
    if tmp_S == 'AC':
        flg.append(1)
    else:
        flg.append(0)
# print(len(flg)) #N-1になっていることを確認

ans = []
ans = [0] + flg #繋げて
ans = list(accumulate(ans)) #累積和にする
#print(ans)

for li in A:
    print(ans[li[1]-1] - ans[li[0]-1] )

Measured memory_bytes: 33172
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

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);
    return a / g * b;
}

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

ll ceil(ll a, ll b)
{
    return (a + b - 1) / b;
}

const string YES = "POSSIBLE";
const string NO = "IMPOSSIBLE";

void solve(long long N, long long K, std::vector<long long> A)
{
    SORT(A);

    if (A[N - 1] < K)
    {
        cout << NO << endl;
        return;
    }
    ll gcd_ans = A[0];

    for (int i = 0; i < N; i++)
    {
        gcd_ans = gcd(gcd_ans,A[i]);
    }

    if( K % gcd_ans == 0){
        cout << YES << endl;
    }else{
        cout << NO << endl;
    }
}

int main()
{
    long long N;
    scanf("%lld", &N);
    long long K;
    scanf("%lld", &K);
    std::vector<long long> A(N);
    for (int i = 0; i < N; i++)
    {
        scanf("%lld", &A[i]);
    }
    solve(N, K, std::move(A));
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <string>
#include <string.h>
using namespace std;

const int MAX_N=10000;
int w,h,c;

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

int main(){
	cin >> w >> h >> c;
	int g = gcd(w,h);
	
	cout << ((w*h)/(g*g))*c << endl;
	return 0;
}

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

int main() {
int A;
  int B;
  cin>>A>>B;
  if(A>=13){
    cout<<B<<endl;
  }
  else if(6<=A&&A<=12){
    cout<<B/2<<endl;
  }
  else if(0<=A&&A<=5){
    cout<<"0"<<endl;
  }
}

Measured memory_bytes: 256
import java.io.*
import java.util.*

fun solve(N: Int, K: Int, x: LongArray, y: LongArray){
    var ans = Long.MAX_VALUE
    val xy = (0 until N).map{ x[it] to y[it] }.sortedBy{ it.first }
    for (i in 0 until N){
        for(j in i+1 until N){
            val ys = xy.filter{ xy[i].first <= it.first && it.first <= xy[j].first }.map{ it.second }.sorted()
            if(ys.size < K) continue
            val height = (0..ys.size - K).map{ ys[it + K - 1] - ys[it] }.min()!!
            ans = Math.min(ans, height * (xy[j].first - xy[i].first))
        }
    }
    println(ans)
    return
}

fun <T> Collection<T>.powerSet(): Set<Set<T>> = powerSet(this, setOf(setOf()))

private tailrec fun <T> powerSet(left: Collection<T>, acc: Set<Set<T>>): Set<Set<T>> = when {
    left.isEmpty() -> acc
    else -> powerSet(left.drop(1), acc + acc.map { it + left.first() })
}

fun <T> Set<T>.combinations(n: Int): Set<Set<T>> = when {
    n < 0 -> throw Error("n must be positive, but got $n")
    n == 0 -> setOf(setOf())
    n >= size -> setOf(toSet())
    else -> powerSet()
            .filter { it.size == n }
            .toSet()
}

fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    class Scanner(stream: InputStream) {
        private val reader = BufferedInputStream(stream).bufferedReader()
        private var st: StringTokenizer? = null
        fun next(): String {
            while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
            return st!!.nextToken()
        }
    }
    val sc = Scanner(System.`in`)
    val N = sc.next().toInt()
    val K = sc.next().toInt()
    val x = LongArray(N)
    val y = LongArray(N)
    for (i in 0 until N) {
        x[i] = sc.next().toLong()
        y[i] = sc.next().toLong()
    }
    solve(N, K, x, y)
}



Measured memory_bytes: 40992
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;
using msi=map<string,int>;
using mii=map<int,int>;
using psi=pair<string,int>;
using pii=pair<int,int>;
using vlai=valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1e9
#define EPS 1e-9
#define MOD (1e9+7)
void get(){}template<class H,class...T>void get(H&h,T&...t){cin>>h;get(t...);}
template<class T>void geti(T&a){for(auto&_:a)cin>>_;}
template<class T>void getii(T&a){for(auto&_:a)geti(_);}
void put(string d){}template<class H,class...T>void put(string d,H&h,T&...t){cout<<h;if(sizeof...(t))cout<<d;put(d,t...);}
template<class T>void puti(T&a,string d=" "){bool f=1;for(auto&_:a)cout<<(exchange(f,0)?"":d)<<_;cout<<endl;}
template<class T>void putii(T&a,string d=" "){for(auto&_:a)puti(_,d);}
#define dcl(...) ll __VA_ARGS__;get(__VA_ARGS__)
#define dclt(t,...) t __VA_ARGS__;get(__VA_ARGS__)

int main(){
	int r,c;
	while(cin>>r>>c, r){
	    int ans=0;
		vector<vlai> f(r,vlai(c));
		rep(i,r)rep(j,c)cin>>f[i][j];
		rep(i,1<<r){
			auto cp=f;
			int n=i;
			while(n){
				cp[__builtin_ctz(n)]^=1;
				n&=(n-1);
			}
			vlai res(c);
			for(auto d:cp){
				res+=d;
			}
			for(auto &d:res)d=min(d,r-d);
			ans=max(ans,r*c-res.sum());
		}
		cout<<ans<<endl;

	}
	
	return 0;
}



Measured memory_bytes: 3888
#include <iostream>
#include <math.h>
#include <algorithm>
using namespace std;
int main(){
  int X;
  cin>>X;
  for(int i=2;i<=360;i++){
    if((X*i)%360==0){
      cout<<i<<endl;
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 3592
a=gets.to_i
nums={}
a.times do |d|
  c=gets.to_s.chomp
  if nums[c].nil?
    nums[c]=1
  else
    nums[c]=nums[c]+1
  end  
end
max_num= nums.max{ |x,y| x[1] <=> y[1] }[1]
puts Hash[nums.find_all {|k,v| v == max_num}.sort].keys

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

int main() {
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if( a+b == c+d){
        cout << "Balanced";
    }
    else if( a+b > c+d){
        cout << "Left";
    }
    else{
        cout << "Right";
    }
   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define M 1000000007
#define ll long long 
#define pb push_back
#define fo(i,N) for(int i = 0 ; i < N ; i++)
#define foo(i,x,N) for (int i = x; i < N ; i++)
#define fill(a,val) memset(a,val,sizeof(a))
#define fastio()  ios_base::sync_with_stdio(false); cin.tie(NULL);
#define endl '\n'
#define ff first
#define ss second
#define MAX 1234567
#define pii pair<int,int> 
#define pll pair<ll,ll> 
#define inf 1e14+1
#define all(a) a.begin(),a.end()
int n;
vector <int> h(200005);
vector <int> a(200005);
ll dp[200005];

ll solve()
{
   dp[1] = a[1];
   ll ans = a[1];

   map <ll,ll> mp;
   mp[h[1]] = a[1];

   foo(i,2,n+1)
   {
     dp[i] = a[i];
     auto it = mp.lower_bound(h[i]);
     if ( it != mp.begin())
     {
      it--;
      dp[i] += it->second;
     }
       mp[h[i]] = dp[i];
    it = mp.upper_bound(h[i]);
     while ( it != mp.end() && it->second <= dp[i])
   {
    auto temp = it;
    temp++;
    mp.erase(it);
    it = temp;
    }
      ans = max(ans,dp[i]);  
    }
   
   return ans;


}

int main()
{ 
  cin >> n;
  foo(i,1,n+1)
  cin >> h[i];
  foo(i,1,n+1)
  cin >> a[i];

  cout << solve() << endl;

}

Measured memory_bytes: 15872
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = numeric_limits<int>::max() /4;
const ll linf = numeric_limits<ll>::max() /4;
const ull ulinf = numeric_limits<ull>::max()/4;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
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; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////

ll n,x;
ll a[3000] = {};
ll b[3000][3000] = {};
    

int main(){
    
    cin >> n>> x;
   
    
    rep(i,0,n)cin >> a[i];

	
    
    rep(i,0,n){
    	b[i][0] = a[i];
		rep(k,1,n){
			int m = i-k;
			if(m < 0)m = n+m;

			b[i][k] = min(b[i][k-1],a[m]);
		}
    }


	ll ans = linf;
    rep(k,0,n){
		ll t = x * k;
		ll sum = 0;
		rep(i,0,n)sum += b[i][k];
		ans = min(ans,t+sum);
    }
    P(ans);

 
	
	return  0;
}

Measured memory_bytes: 46976
#include <stdio.h>

int main(){

	char S[4+1];
	int a=0,b=0;

	scanf("%s",S);

  a+=((S[0]-'0')*10+(S[1]-'0'));
	b+=((S[2]-'0')*10+(S[3]-'0'));

	if(1<=a && a<=12){
		if(1<=b && b<=12)printf("AMBIGUOUS");
		else printf("MMYY");
	}else if(1<=b && b<=12)printf("YYMM");
	else printf("NA");

	printf("\n");

	return 0;
}


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

typedef long long ll;

#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define FORR(i,a,b) for(ll i=b-1;i>=a;i--)

#define vl vector<ll>
#define pll pair<ll,ll>

#define DEBUG(x) cout<<#x<<": "<<x<<endl

using namespace std;
/*}}}*/

int main() {
  ll n,k;
  cin >> n >> k;
  vl a(n);
  REP(i,n) cin >> a[i];
  REP(i,n-k){
    if(a[i]<a[i+k]) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  return 0;
}


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

#define all(s) s.begin(), s.end()
#define vi vector<int>
#define pb push_back
#define ii pair<int, int>
#define x first
#define y second
#define bit(x, y) (x>>y)&1

vi solve(int n, int fr, int to) {
    vi res;
    if (n == 1) {
        return {fr, to};
    }
    bool bitfr, bitto;
    int pos;
    for (int i = 0; i < n; i++) {
        if ((bit(fr, i)) != (bit(to, i))) {
            bitfr = bit(fr, i);
            bitto = !bitfr;
            pos = i;
            break;
        }
    }
    int l = ((fr>>(pos + 1))<<pos) + (fr&((1<<pos) - 1));
    int r = ((to>>(pos + 1))<<pos) + (to&((1<<pos) - 1));
    int too = 0;                               
    for (int i = 0; i < (1 << (n - 1)); i++) {
        if (i != l && i != r && __builtin_popcount(l) % 2 != __builtin_popcount(i) % 2) {
            too = i;
            break;
        }
    }
    vi vl = solve(n - 1, l, too);
    vi vr = solve(n - 1, too, r);
    for (auto u : vl) {
        int foo = u&((1 << pos) - 1);
        int bar = (u - foo) * 2;
        res.pb(foo + bar + (bitfr << pos));
    }
    for (auto u : vr) {
        int foo = u&((1 << pos) - 1);
        int bar = (u - foo) * 2;
        res.pb(foo + bar + (bitto << pos));
    }
    return res;
}

int main() {
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int n, a, b;
    cin >> n >> a >> b; 
    if (__builtin_popcount(a) % 2 == __builtin_popcount(b) % 2) {
        return cout << "NO", 0;
    }
    cout << "YES\n";
    vi ans = solve(n, a, b);
    for (auto u : ans) {
        cout << u << ' ';
    }
    return 0;
}

Measured memory_bytes: 1756
from itertools import combinations, chain
n = int(input())
A = list(map(int, input().split()))
q = int(input())
m = list(map(int, input().split()))
S = list(map(sum, chain.from_iterable(combinations(A, r) for r in range(n))))
ans = map(lambda y: 'yes' if y else 'no', map(lambda x: x in S, m))
print('\n'.join(ans))


Measured memory_bytes: 43140
#include <bits/stdc++.h>
 #define ll long long
 #define int long long
 #define MOD  1000000007
 #define MAX 500005
 #include<iomanip>
 #define Need_for_speed(activated) ios_base :: sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
 #define satisfy ll t; cin>> t; while(t--)
 #define inp(n) int n;cin >> n
 #define mp make_pair
 #define pb push_back
 #define fore(i,a,b) for(ll i=a;i<b;i++)
 #define x first
 #define y second
using namespace std;
int gcd(int a, int b);
  
int power(int x, unsigned int y, unsigned int m)
{
    if (y == 0)
        return 1;
    int p = power(x, y/2, m) % m;
    p = (p * p) % m;
  
    return (y%2 == 0)? p : (x * p) % m;
}
ll modInverse(int a, int m)
{
    int g = gcd(a, m);
   
    {
        // If a and m are relatively prime, then modulo inverse
        // is a^(m-2) mode m
      
             return power(a, m-2, m);
    }
}
int gcd(int a, int b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);

}
//void spf(ll num)
//{
//    fore(i,0,num+1)arr[i]=i;
//    for(ll i=2;i<=num;i+=2)
//    {
//        arr[i]=2;
//    }
//    for(ll i=3;i<=num;i+=2)
//    {
//        if(arr[i]==i)
//        for(ll j=i;j<=num;j+=i)
//        {
//           if(arr[j]==j) arr[j]=i;
//        }
//    }
//}
 
 int32_t main()
{
    Need_for_speed(activated);
//    satisfy
//    {}
    ll a,b;
    cin>>a>>b;
    ll d=a^b;
    cout<<d<<endl;
   
    return 0;
    }


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

using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
const ll mod = 1e9 + 7;
const ll INF = 10000000000;
const int MAX_N = 100000;

int main() {
	cin.sync_with_stdio(false);
	int N, M;
	cin >> N >> M;
	if (M == 0) {
		cout << "Yes" << endl;
		return 0;
	}
	map<int, ll>mp;
	map<pair<int, int>, int>mp2;
	vector<pair<int, int>>P(M);
	vector<ll>R(M), L(M), D(M);
	set<int>st;
	vector<vector<int>>path(N);
	vector<int>Node;
	rep(i, M) {
		int d;
		cin >> P[i].first >> P[i].second >> d;
		P[i].first--;
		P[i].second--;
		if (P[i].first > P[i].second) {
			swap(P[i].first, P[i].second);
			d = -d;
		}
		st.insert(P[i].first);
		st.insert(P[i].second);
		Node.push_back(P[i].first);
		Node.push_back(P[i].second);
		mp2[P[i]] = d;
		path[P[i].first].push_back(P[i].second);
		path[P[i].second].push_back(P[i].first);
	}
	int cnt = st.size();
	sort(P.begin(), P.end());
	ll start = 100000000000;
	sort(Node.begin(), Node.end());
	Node.erase(unique(Node.begin(), Node.end()), Node.end());
	rep(x, Node.size()) {
		int i = Node[x];
		if (mp[i] == 0) {
			mp[i] = start;
			stack<pair<int,int>>st;
			rep(j, path[i].size()) {
				if (mp[path[i][j]] == 0)st.push({ i,path[i][j] });
			}
			while (st.size()) {
				pair<int,int> K = st.top();
				st.pop();
				int k = K.second;

				rep(l, path[k].size()) {
					if (mp[path[k][l]] == 0)st.push({ k,path[k][l] });
				}
				int d = mp2[{min(k, K.first), max(k, K.first)}];
				mp[k] = (k > K.first ? mp[K.first] + d : mp[K.first] - d);
			}
		}
	}
	rep(i, M) {
		int R = P[i].second, L = P[i].first, D = mp2[P[i]];
		if (mp[R] - mp[L] != D) {
		//	cout << mp[R] << mp[L] << D << endl;
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	
	return 0;
}


Measured memory_bytes: 39924
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <iostream>
#include <fstream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstring>
#include <chrono>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = int64_t;
using pii = pair<int, int>;
using pll = pair<int64_t, int64_t>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
// variadic template
template<typename T> inline void chmin(T &a, T b) {if (a > b) a = b; return;}
template<typename T> inline void chmax(T &a, T b) {if (a < b) a = b; return;}

struct bridge{
  int64 cost;
  int from, to;
};

struct UnionFind {
  std::vector<int> par, rank;

  UnionFind(int n) : par(n , -1), rank(n, 0) {}

  void init(int n) {
    par.assign(n, -1); rank.assign(n, 0);
  }

  int root(int x) {
    if (par[x] == -1) return x;
    else return par[x] = root(par[x]);
  }

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

  void unite(int x, int y) {
    x = root(x); y = root(y);
    if (x == y) return;
    if (rank[x] < rank[y]) std::swap(x, y);
    if (rank[x] == rank[y]) ++rank[x];
    par[y] = x;
    return;
  }
};

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

  int n; cin >> n;
  vector<int64> x(n), y(n);
  for (int i = 0; i < n; ++i) {
    cin >> x[i] >> y[i];
  }

  vector<pair<int64, int>> vx, vy;
  for (int i = 0; i < n; ++i) {
    vx.emplace_back(x[i], i);
    vy.emplace_back(y[i], i);
  }

  sort(vx.begin(), vx.end()); sort(vy.begin(), vy.end());

  vector<bridge> v;
  UnionFind uf(n);

  for (int i = 0; i < n - 1; ++i) {
    v.push_back({vx[i + 1].first - vx[i].first, vx[i].second, vx[i + 1].second});
    v.push_back({vy[i + 1].first - vy[i].first, vy[i].second, vy[i + 1].second});    
  }

  sort(v.begin(), v.end(), [](const bridge& x, const bridge& y){return x.cost < y.cost;});

  int64 ans = 0;

  for (int i = 0; i < 2 * (n - 1); ++i) {
    if (uf.issame(v[i].from, v[i].to)) continue;
    uf.unite(v[i].from, v[i].to);
    ans += v[i].cost;
  }
  print(ans);

  return 0;
}

Measured memory_bytes: 11748
import math
from functools import reduce
import itertools

def resolve():
  K = int(input())
  gcd = sum([ reduce(math.gcd,x) for x in itertools.product(range(1, K+1), range(1, K+1), range(1, K+1)) ])
  print(gcd)

if __name__ == "__main__":
    resolve()

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

int main(){
    int w,h,x,y,r;
    int a=0;
    
    cin >> w >> h >> x >> y >> r;
    
    if (x >= r && y >= r && (w-x) >= r && (h-y) >= r)a=1;

    if (a == 0) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
    
    return 0;
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for (int i = a; i < (int)b; ++i)
#define rrep(i, n) for (int i = ((int)n - 1); i >= 0; --i)

using ll = long long;
using ld = long double;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
	int n;
	cin >> n;
	ll sum = 0;
	vector<ll> a(n);
	rep (i, n) {
	  cin >> a[i];
	  sum += a[i];
	}
	ll res = 0;
	rep (i, n) {
	  sum -= a[i];
	  res += (sum % MOD) * a[i] % MOD;
	  res %= MOD;
	}
	cout << res << endl;
    
    return 0;
}


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

int main() {
  int N, M, X, A[105];
  cin >> N >> M >> X;
  rep(i, M) cin >> A[i];

  if (X < A[0] || X > A[M - 1]) {
    cout << 0 << endl;
    return 0;
  }
  
  int *pos;
  int idx;
  pos = lower_bound(A, A+M, X);
  idx = distance(A, pos);

  int ans;
  ans = min(idx, M - idx);

  cout << ans << endl;


  return 0;

}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args)
	{
		Scanner in = new Scanner(System.in);
		int length = in.nextInt();
		int[] string = new int[length];
		for(int i = 0; i < length; i++)
		{
			string[i] = in.nextInt();
		}
		
		length = in.nextInt();
		int[] search = new int[length];
		for(int i = 0; i < length; i++)
		{
			search[i] = in.nextInt();
		}
		
		int counter = 0;
		for(int i = 0; i < length; i++)
		{
			if(Search(string, search[i]))
			{
				counter++;
			}
		}
		System.out.println(counter);
	}
	
	public static boolean Search(int[] list, int n)
	{
		for(int i = 0; i < list.length; i++)
		{
			if(list[i] == n)
			{
				return true;
			}
		}
		return false;
	}
}



Measured memory_bytes: 40476
def main():
    import heapq
    n, m, *a = map(lambda x: -int(x), open(0).read().split())
    heapq.heapify(a)
    for _ in range(-m):
        x = heapq.heappop(a)
        heapq.heappush(a, x / 2)

    ans = -sum(map(lambda x: int(x), a))
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 14180
#include <iostream>

int main(void)
{
    int a, b;
    std::cin >> a >> b;
    int total = a + b;
    if (total >= 10)
    {
        std::cout << "error";
    }
    else
    {
        std::cout << total;
    }
    std::cout << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i = a; i<n; i++)
#define per(i,a,n) for (int i = n-1; i>=a; i--)
#define pb push_back
#define mp make_pair
#define all(now) (now).begin(),(now).end()
#define fi first
#define se second
#define SZ(now) ((int)(now).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod = 1000000007;
inline int read(int &n){char c=getchar();int x=0,f=1;while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}while(c>='0'&&c<='9'){x=x*10+(c-'0');c=getchar();}return n = x*f;}
ll powmod(ll a,ll b,ll mod) {ll res = 1; a%=mod; assert(b>=0); for(;b; b>>=1){if(b&1)res = res*a%mod; a = a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head
const int N = 1e2+7;
int T,n,m;
int x[N],y[N],d[N];
int main()
{
    //ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    int L;
    scanf("%d", &L);
    if(L<=2){
        printf("2 %d\n",L);
        for(int i=0;i<L;i++)
            printf("1 2 %d\n",i);
        return 0;
    }
    // if(L<=2){
    //     printf("2 %d\n", L);
    //     rep(i,0,L){
    //         printf("1 2 %d\n", i);
    //         return 0;
    //     }
    // }

    int len = 0;
    while(1<<len <= L)
        ++len;

    n = len, m = 0;
    rep(i,0,len-1){
        x[++m] = i + 1;
        y[m] = i + 2;
        d[m] = 0;
        x[++m] = i + 1;
        y[m] = i + 2;
        d[m] = 1<<i;        
    }

    per(i,0,len-1){
        if(L&(1<<i)){
            x[++m] = i + 1;
            y[m] = n;
            d[m] = L >> (i + 1) << (i + 1);
        }
    }

    printf("%d %d\n", n, m);
    rep(i,1,m+1){
        printf("%d %d %d\n", x[i], y[i], d[i]);
    }
    return 0;
}

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

int main() {
  int a, b;
  cin >> a >> b;
  if(a >= 13)
    cout << b << endl;
  else if(a <= 5)
    cout << 0 << endl;
  else
    cout << b/2 << endl;
}

Measured memory_bytes: 256
S=input()
T=input()
s=dict()
for i in range(len(S)):
    a=S[i]
    if a in s:
        s[a]+=1
    else:
        s[a]=1

t=dict()
for i in range(len(T)):
    a=T[i]
    if a in t:
        t[a]+=1
    else:
        t[a]=1

l=[]
r=[]
for idx in s:
    a=s[idx]
    l.append(a)
for idx in t:
    a=t[idx]
    r.append(a)

l.sort()
r.sort()
if len(l)!=len(r):
    print("No")
    exit()
for i in range(len(l)):
    if l[i]==r[i]:
        pass
    else:
        print("No")
        exit()

print("Yes")

Measured memory_bytes: 42524
W,H,x,y,r = map(int,input().split())

if -100 <= x <= 100 and -100 <= y <= 100 and 0 < W <= 100 and 0 < H <= 100 and 0 < r <= 100:
    if 0 <= (x - r) and (x + r) <= W and 0 <= (y - r) and (y + r) <= H:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 5596
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+7; bool fl[N];
int n,m,q,pos[N],que[N]; long long k,w[N],val[N];
inline long long read(){
	long long num=0; char t='+',g=getchar(); while(g<48||57<g) t=g,g=getchar();
	while(47<g&&g<58) num=(num<<1)+(num<<3)+g-48,g=getchar(); if(t=='-') return 0-num; return num;
}
inline void find(int u){
	que[++que[0]]=u,fl[u]=1; if(!fl[pos[u]]) find(pos[u]);
}
inline void getans(){
	int z=k%que[0]; for(int i=1;i<=que[0];i++) pos[que[i]]=que[(i+z-1)%que[0]+1];
}
int main(){
	n=read(); for(int i=1;i<=n;i++) w[i]=read(),pos[i]=i;
	m=read(),k=read(); for(int i=1;i<=m;i++) q=read(),swap(pos[q],pos[q+1]);
	for(int i=2;i<=n;i++) if(!fl[i]) que[0]=0,find(i),getans();
	for(int i=2;i<=n;i++) val[i]=w[i]-w[i-1]; long long vt=w[1]; printf("%lld\n",vt);
	for(int i=2;i<=n;i++) vt=vt+val[pos[i]],printf("%lld\n",vt);
	return 0;
}

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

#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1e18;
long long mod=1e9+7;

//status unsolved

int main(){
    int s,w;
    cin>>s>>w;
    if(s<=w){
        cout<<"unsafe"<<endl;
    }
    else{
        cout<<"safe"<<endl;
    }
    return 0;

}
/*


*/


Measured memory_bytes: 3580
N = int(input())
amari = N%10

if amari == 2 or amari == 4 or amari == 5 or amari == 7 or amari == 9:
  print('hon')
elif amari == 0 or amari == 1 or amari == 6 or amari == 8:
  print('pon')
else:
  print('bon')

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

int main() {
	int a,b,c,d,e,f;
	cin>>a>>b>>c>>d;
	e=(a+b+c+d)/60;
	f=(a+b+c+d)%60;
	cout<<e<<"\n"<<f<<endl;
	
	return 0;
}


Measured memory_bytes: 3060
import java.util.ArrayList;
import java.util.Scanner;
class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力



		int n = sc.nextInt();
		int[] w = new int[n];
		for(int i = 0;i < n;i++){
			w[i] = sc.nextInt();
		}
		int[] sum = new int[n];
		sum[0] = w[0];
		for(int i = 1;i < n;i++){
			sum[i] = sum[i-1] + w[i];
		}
		int ans = Integer.MAX_VALUE;
		for(int i = 0;i < n;i++){
			if(Math.abs(sum[n-1] - sum[i] - sum[i]) < ans){
				ans = Math.abs(sum[n-1] - sum[i] - sum[i]);
			}
		}
		System.out.print(ans);
		


	}


	static boolean checkswitch(int bit,int[] k,ArrayList<ArrayList<Integer>> list,int[] p,int m){
		
//		System.out.println("bit " + bit);
			
		for(int i = 0;i < m;i++){
			
			ArrayList<Integer> sub = list.get(i);
			int onnum = 0;						//onの数
			for(int j = 0;j < sub.size();j++){
//				System.out.println("sub "+ sub.get(j));
				if((bit & (1 << sub.get(j))) != 0){				//目的のスイッチがついているか
					onnum++;
//					System.out.println("on  ");
				}
				
			}
			if(onnum % 2 != p[i]){				//一個でも電球がつかなかったらout
				return false;
			}
			
		}
		

		return true;

	}

	static int gcd(int a,int b){				//最大公約数を返す
		if(b == 0){
			return a;
		}else{
			return gcd(b, a%b);
		}
	}





}



class Pair implements Comparable{
	int from;
	int end;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return  otherpair.end - end;
	}
}




Measured memory_bytes: 23764
///cREATED bY BERNARB.01
#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;
typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
typedef priority_queue<int,vector<int>,greater<int>> pqil;
typedef priority_queue<int> pqig;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef priority_queue<pii> pqiig;
typedef vector<pii> vii;
typedef vector<piii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef map<int, int> mii;
#define mid ((l+r)/2)
#define PB push_back
#define PP pop_back
#define PF push_front
#define DF pop_front
#define F first
#define S second
#define MP make_pair
#define C continue
#define B break
#define R return
#define sz(v) (int)(v).size()
#define len(s) (int)(s).length()
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define clr(arr, x) memset((arr), (x), sizeof (arr))
#define loop(n) for(int i=0; i<(n); i++)
#define lop(a, n) for(int i=(a); i<(n); i++)
#define jloop(n) for(ll j=0; j<(n); j++)
#define kloop(n) for(ll k=0; k<(n); k++)
#define gloop(n) for(ll g=0; g<(n); g++)
#define rloop(n) for(ll i=(n)-1; i>=0; i--)
#define sgm(y) (((y)*((y)+1))/2)
const ll LINF = 2e17+423;
const int INF = 2e9 + 69;
const ll mod = 1e9+7; //998244353;
const ld pi = acos(-1.0);
const ld cmpf = 1e-9;
//__int128_t
//      -ASCII-
//a -> z | A -> Z | 0 -> 9
//97 122 | 65  90 | 48  57
#define endl '\n'
ll po(ll,ll);



































int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    vi a(n);
    mii mp;
    bool bl = 1;
    loop(n) {
        int x;
        cin >> x;
        mp[x]++;
        if(mp[x]>=2) bl = 0;
    }
    if(bl) cout << "YES";
    else cout << "NO";
    R 0;
}
/*

*/



























































ll po(ll x, ll n){
  if(n==0) R 1%mod;
  ll y = po(x, n/2)%mod;
  y = ((y%mod)*(y%mod));
  if(n%2) y = (y*(x%mod))%mod;
  R y%mod;
}


Measured memory_bytes: 10368
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    int d;
    cin >> d;
    vec c(26);
    rep(i, 26) cin >> c[i];
    int s[365][26] = {};
    rep(i, d) rep(j, 26) cin >> s[i][j];
    vec t(d);
    rep(i, d) {
        cin >> t[i];
        t[i]--;
    }
    int last[365][26] = {};

    lint res = 0;

    rep(i, d) {
        res += s[i][t[i]];
        for (int j = i; j < d; j++) last[j][t[i]] = i+1;
        rep(j, 26) {
            res -= c[j] * (i+1 - last[i][j]);
        }
        cout << res << endl;
    }
    return 0;
}

Measured memory_bytes: 3668
#include <bits/stdc++.h>
using intl = long long;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define repd(i, n) for(intl i = (intl)((n) - 1); i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define INF = 1e9;
#define debug(x) cout << #x << ":" << x << endl
using namespace std;
int main(){
    intl a;
    cin >> a;
    intl b;
    cin >> b;
    intl cnt = 0;
    while(a != 0){
        a /= b;
        cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    int n,sum=0;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        int l,r;
        cin>>l>>r;
        sum+=(r-l+1);
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
use std::io::*;
use std::str::*;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let mut count: i32 = 0;
    let s: String = read();

    for c in s.chars() {
        if c == '1' {
            count += 1;
        }
    }

    println!("{}", count);
}

Measured memory_bytes: 4352
n = int(input())

a = list(map(int,input().split()))

b1 = []

b2 = []

for i in range(0,len(a),2):
    b1.append(a[i])
    
for i in range(1,len(a),2):
    b2.append(a[i])
    
if n%2 == 0:
    b2.reverse()
    b2.extend(b1)
    for i in b2:
        print(i,end = " ")
        
else:
    b1.reverse()
    b1.extend(b2)
    for i in b1:
        print(i,end = " ")

Measured memory_bytes: 30948
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define N 666666
int a[N],b[N],c[N],str[N];
map<int,int> mp1,mp2,mp3;
int n;
int sum1[N],sum2[N];
int sum[N];
int slove1(int num,int n){
	int ans=-1;
	int l=0;
	int r=n-1;
	while(l<=r){
		int mid=(l+r)>>1;
		if(c[mid]>num){
			ans=mid;
			r=mid-1;
		}else{
			l=mid+1;
		}
	}
	return ans;
}
int slove2(int num,int n){
	int ans=-1;
	int l=0;
	int r=n-1;
	while(l<=r){
		int mid=(l+r)>>1;
		if(b[mid]>num){
			ans=mid;
			r=mid-1;
		}else{
			l=mid+1;
		}
	}
	return ans;
}
signed main(){
	cin>>n;
	int t;
	int cnt1=0,cnt2=0,cnt3=0;
	
	for(int i=1;i<=n;i++){
		cin>>t;
		if(!mp1[t]) a[cnt1++]=t;
		mp1[t]++;
	}
	
	for(int i=1;i<=n;i++){
		cin>>t;
		if(!mp2[t]) b[cnt2++]=t;
		mp2[t]++;
	}
	for(int i=1;i<=n;i++){
		cin>>t;
		c[cnt3++]=t;
	}
	sort(a,a+cnt1);
	sort(b,b+cnt2);
	sort(c,c+cnt3);

	for(int i=0;i<cnt2;i++){
		int pos=slove1(b[i],cnt3);
		if(pos==-1) sum1[i]=0;
		else {
			sum1[i]=mp2[b[i]]*(cnt3-pos);
		}
	}
	for(int i=cnt2-1;i>=0;i--) sum2[i]=sum2[i+1]+sum1[i];
	int ans=0;
	for(int i=0;i<cnt1;i++){
		int pos=slove2(a[i],cnt2);
		if(pos!=-1){
			ans+=sum2[pos]*mp1[a[i]];
		}
	}
	cout<<ans;
	return 0;
} 

Measured memory_bytes: 27136