akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define rep(i,x,y) for(ll i=(x);i<(y);i++)
#define rrep(i,x,y) for(ll i=(ll)(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
#ifdef LOCAL
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#define itrdebug(x) cerr << #x << " "; for (auto & el : (x)) {cerr << (el) << " ";} cerr << endl
#define dassert(...) assert(__VA_ARGS__)
#else
#define debug(x)
#define itrdebug(x)
#define dassert(...)
#endif
//#define int long long

typedef long long ll;
const ll MOD = 1e9 + 7;
const long double EPS = 1e-8;

void solve(long long N, std::vector<long long> V, std::vector<long long> W, long long Q, std::vector<long long> v, std::vector<long long> L){
    vector<vector<int>> dp(min<int>(pow(2, 10)+1, N+1), vector<int>(1e5+1, 0));
    rep(i,1,dp.size()) {
        int parent = i/2;
        rep(j,0,dp.front().size()) {
            dp[i][j] = dp[parent][j];
            if (j-W[i] >= 0) dp[i][j] = max<int>(dp[i][j], dp[parent][j-W[i]] + V[i]);
            if (j>0) dp[i][j] = max(dp[i][j], dp[i][j-1]);
        }
    }
    rep(ti,0,Q) {
        if (v[ti] < dp.size()) {
            cout << dp[v[ti]][L[ti]] << endl;
            continue;
        }
        vector<pair<int, int>> items;
        int current = v[ti];
        while (current >= dp.size()) {
            items.emplace_back(W[current], V[current]);
            current /= 2;
        }
        int answer = 0;
        rep(i,0,1 << items.size()) {
            int weightSum = 0, valueSum = 0;
            rep(j,0,items.size()) {
                if (i & (1 << j)) {
                    weightSum += items[j].first;
                    valueSum += items[j].second;
                }
                if (weightSum > L[ti]) break;
            }
            if (weightSum <= L[ti]) {
                answer = max(answer, valueSum + dp[current][L[ti]-weightSum]);
            }
        }

        cout << answer << endl;
    }
}

signed main(){
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    long long N;
    scanf("%lld",&N);
    std::vector<long long> V(N+1);
    std::vector<long long> W(N+1);
    for(int i = 1 ; i <= N ; i++){
        scanf("%lld",&V[i]);
        scanf("%lld",&W[i]);
    }
    long long Q;
    scanf("%lld",&Q);
    std::vector<long long> v(Q);
    std::vector<long long> L(Q);
    for(int i = 0 ; i < Q ; i++){
        scanf("%lld",&v[i]);
        scanf("%lld",&L[i]);
    }
    solve(N, std::move(V), std::move(W), Q, std::move(v), std::move(L));
    return 0;
}


Measured memory_bytes: 411052
# -*- coding:utf-8 -*-

def solve():
    A, B = input().split()

    # 2進浮動小数点数(float)にしたら誤差が発生するので、整数のまま計算する
    A = int(A)
    B = int(B.replace(".", ""))

    ans = A*B//100
    print(ans)


def solve2():
    A, B = input().split()

    # 10進小数が扱えるdecimalモジュールを使う
    from decimal import Decimal
    A = int(A)
    B = Decimal(B)

    ans = (A*B)//1
    print(ans)


if __name__ == "__main__":
    solve()


Measured memory_bytes: 9184
even = "#." * 151
odd = ".#" * 151
while 1:
    h,w = map(int,input().split())
    if h == w ==0:
        break
    for i in range(h//2):
        print(even[:w])
        print(odd[:w])
    if h%2 != 0:
        print(even[:w])
    print()

Measured memory_bytes: 7664
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

const int MOD = 1000000007;

int main()
{
    int n;
    string s;
    cin >> n >> s;
    int len = s.size();

    vector<vector<int> > dp(2, vector<int>(n+1, 0));
    dp[1][len] = 1;
    for(int i=0; i<n; ++i){
        vector<vector<int> > nextDp(2, vector<int>(n+1, 0));
        for(int j=0; j<2; ++j){
            for(int k=0; k<=n; ++k){
                if(k < n){
                    nextDp[j][k+1] += dp[j][k] * 2;
                    nextDp[j][k+1] %= MOD;
                }

                if(k == len){
                    nextDp[0][k-1] += dp[j][k];
                    nextDp[0][k-1] %= MOD;
                    if(j == 1){
                        nextDp[1][k] += dp[1][k];
                        nextDp[1][k] %= MOD;
                    }
                }
                else if(k > 0){
                    nextDp[j][k-1] += dp[j][k];
                    nextDp[j][k-1] %= MOD;
                }
            }
        }
        dp.swap(nextDp);
    }

    cout << dp[0][0] << endl;

    return 0;
}

Measured memory_bytes: 384
#include<map>
#include<queue>
#include<time.h>
#include<limits.h>
#include<cmath>
#include<ostream>
#include<iterator>
#include<set>
#include<stack>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define rep_1(i,m,n) for(int i=m;i<=n;i++)
#define mem(st) memset(st,0,sizeof st)
int read()
{
	int res=0,ch,flag=0;
	if((ch=getchar())=='-')             //判断正负
		flag=1;
	else if(ch>='0'&&ch<='9')           //得到完整的数
		res=ch-'0';
	while((ch=getchar())>='0'&&ch<='9')
		res=res*10+ch-'0';
	return flag?-res:res;
}
typedef long long ll;
typedef pair<int,int> pii;
typedef unsigned long long ull;
typedef pair<double,double> pdd;
const int inf = 0x3f3f3f3f;
#define int long long
signed main()
{
	int h1,m1,h2,m2,k;
	cin>>h1>>m1>>h2>>m2>>k;
	if(h2<h1)
		h2+=24;
	if(m2<m1)
		m2+=60,h2-=1;
	int ans=(h2-h1)*60+m2-m1;
	ans-=k;
	cout<<ans<<endl; 
	return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (int)(m); i < (int)(n); ++i)


int main()
{
    int N;
    cin >> N;
    vector<int> P(N*N);
    REP(i, N*N) cin >> P[i];

    vector<vector<int>> num_pairs(N, vector<int>(N));
    REP(i, N){
        REP(j, N) num_pairs[i][j] = min({i, j, N-i-1, N-j-1});
    }

    int ans = 0;
    vector<vector<bool>> is_empty(N, vector<bool>(N, false));
    REP(n, N*N){
        int i = (P[n]-1)/N;
        int j = (P[n]-1)%N;
        ans += num_pairs[i][j];
        is_empty[i][j] = true;

        //
        queue<pair<int,int>> q;
        q.push({i, j});
        while(!q.empty()){
            auto top = q.front(); q.pop();
            i = top.first;
            j = top.second;
            vector<int> di = {1, 0, -1, 0};
            vector<int> dj = {0, 1, 0, -1};
            REP(k, 4){
                int ni = i + di[k];
                int nj = j + dj[k];
                if(0 <= ni and ni < N and 0 <= nj and nj < N){
                    int cand = num_pairs[i][j] + !is_empty[i][j];
                    if(num_pairs[ni][nj] > cand){
                        num_pairs[ni][nj] = cand;
                        q.push({ni, nj});
                    }
                }
            }
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 5316
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt();
        int W = sc.nextInt();
        int h = sc.nextInt();
        int w = sc.nextInt();
        System.out.println((H-h)*(W-w));


    }
}

Measured memory_bytes: 21588
#include <iostream>

using namespace std;

int main()
{
    int a,b;
    int n =0;
    cin>>a>>b;
    for(int i =0;i < 2;i ++)
    {
        if(a>b)
        {
            n+=a;
            a--;
        }
        else
        {
            n+=b;
            b--;
        }
    }
    cout<<n;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
input = sys.stdin.readline
from collections import defaultdict

def empty_list():
    return [0] * 26

class RollingHash():
    def __init__(self, s):
        length = len(s)
        base = 1009
        # self.mod = (1 << 61) - 1
        self.mod = 67280421310721
        self.hash = [0] * (length + 2)
        self.pow = [1] * (length + 2)

        for i in range(length):
            self.hash[i+1] = (self.hash[i] + s[i]) * base % self.mod
            self.pow[i+1] = self.pow[i] * base % self.mod
        self.pow[length+1] = self.pow[length] * base % self.mod 

    def get(self, l, r):
        t = self.hash[r] - self.hash[l] * self.pow[r-l] % self.mod
        return t % self.mod

ss = []
n = int(input())
for _ in range(n):
    ss.append([ord(item) for item in input().rstrip()])
ss.sort(key=lambda x: len(x), reverse=True)

orda = ord("a")
words = defaultdict(empty_list)
ans = 0
for s in ss:
    word_len = len(s)
    s_rev = s[::-1]
    RH = RollingHash(s_rev)
    rh = RH.get(0, word_len-1)
    ans += words[rh][s_rev[-1] - orda]
    initial = [0] * 26 
    for i, ch in enumerate(s):
        initial[ch - orda] = 1
        for j, is_initial in enumerate(initial):
            if is_initial:
                rh = RH.get(0, word_len-i-1)
                words[rh][j] += 1
print(ans)

Measured memory_bytes: 445908
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  string s,t,r;
  int a,b;
  cin >> s >> t >> a >> b >> r;
  if(s==r) a--;
  else b--;
  pr(a,b);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


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

int main() {
  int n,k,q;
  cin >> n >> k >> q;
  vector<long long> a(q),ans(n);
  for(int i=0;i<q;i++){
    cin >> a.at(i);
  }
  for(int i=0;i<q;i++){
    ans.at(a.at(i)-1)++;
  }
  
  for(int i=0;i<n;i++){
    if(ans.at(i)> q-k){
      cout << "Yes" << endl;
    }
    else {
      cout << "No" << endl;
    }
  }
  
  return 0;
}


Measured memory_bytes: 2176
import sys
def main():
    input = sys.stdin.readline
    N, K = map(int, input().split())
    A = map(int, input().split())

    neg, pos, zero = list(), list(), 0
    for a in A:
        if a < 0: neg.append(a)
        elif a > 0: pos.append(a)
        else: zero += 1
    neg.sort()
    pos.sort()

    #x未満になる組み合わせの個数
    def calc(x):
        result = 0
        if x < 0:
            #負になるのは 正*負, 負*正
            i, j = len(pos)-1, len(neg)-1
            while i >= 0:
                while j >= 0 and pos[i]*neg[j] >= x: j -= 1
                if j < 0: break
                result += j + 1
                i -= 1
        elif x == 0:
            result += len(neg) * len(pos) #負
        else:
            #正*正
            i, j = 0, len(pos)-1
            while i < len(pos):
                while j >= 0 and pos[i]*pos[j] >= x: j -= 1
                if j < 0: break
                result += j + 1
                if pos[i]*pos[i] < x: result -= 1 #同じもの同士を除外
                i += 1
            #負*負
            i, j = len(neg)-1, 0
            while i >= 0:
                while j < len(neg) and neg[i]*neg[j] >= x: j += 1
                if j >= len(neg): break
                result += len(neg) - j
                if neg[i]*neg[i] < x: result -= 1 #同じもの同士を除外
                i -= 1
            result //= 2 #ペアの入れ替え分
            result += len(neg) * len(pos) #負
            result += (len(neg) + len(pos)) * zero + (zero)*(zero-1)//2 #0
        return result
    
    #二分探索
    l, over = -10**18, 10**20+1
    while over - l > 1:
        m = (l+over)//2
        if calc(m) < K: l = m
        else: over = m
    print(l)

if __name__ == '__main__':
    main()

Measured memory_bytes: 79828
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int maxn=1e6+5;
vector<ll> V;
int pre[maxn];
int main() {
    int n;cin>>n;
    for(int i=1;i<=n;i++) cin>>pre[i];
    sort(pre+1,pre+1+n);
    ll ans=pre[n];
    for(int i=2;i<n;i++) {
        ans+=pre[n-i/2];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 4420
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<list>
#include<bitset>
#include<stack>
#include<memory>
#include<numeric>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define REP(i, n) for(int64 i = 0;i < (n);i++)
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const int mod=998244353 ;
const llint inf=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-10;
template <class T,class U>bool chmin(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool chmax(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(const vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(const vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
//13:14~

int main(void){
	cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);
	llint n,i;cin>>n;
	llint At=0,ans=0;
	vector<pair<llint,llint>>hei(n);//通常move,ずらしmove
	for(i=0;i<n;i++){
		llint A,B;cin>>A>>B;
		if(A<=B){At+=B-A;hei[i]=mp(B,B);}
		else{hei[i]=mp(A,B);}
	}
	SO(hei);
	while(At>=hei[ans].fir){At-=hei[ans].fir;ans++;}
	//2パターン
	
	llint bbb=0;
	for(i=0;i<=ans;i++){chmax(bbb,hei[i].sec);}
	llint P=max(bbb+At-hei[ans].fir,0LL),Q=bbb;
	//At/aaa
	for(i=ans;i<n;i++){
		llint nP=At-hei[i].fir+hei[i].sec;
		llint nQ=hei[i].sec;
		if(P*nQ<Q*nP){P=nP,Q=nQ;}//1- At/bbbが大きい
		
	}
	
	P+=ans*Q;
	Q*=n;
	llint G=gcd(P,Q);
	cout<<P/G<<" "<<Q/G<<endl;
	return 0;
}
/*
s---r---|---
  A   B   C
Aゾーン すぬけ早い
Bゾーン すぬけ有利
Cゾーン

B-A 
*/


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <map>
#include <bitset>
#include <cmath>
#include <set>
#include <utility>

#define INF 1000000000000
#define MOD 1000000007 //10^9+7:合同式の法

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

int main(){
    ll N,K,sum=0;
    cin >> N >> K;
    vector<ll> H(N);

    for(ll i = 0;i < N;i++)
        cin >> H.at(i);
    
    sort(H.begin(),H.end());
    reverse(H.begin(),H.end());

    for(ll i = 0;i < N;i++){
        if(K > 0){
            K--;
        }else{
            sum += H.at(i);
        }
    }

    cout << sum << endl;
    
}

Measured memory_bytes: 4792
import sys
import math
from collections import defaultdict
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

s = list(input())
alphabets = [chr(ord('a')+i) for i in range(26)]

ans = float('inf')
for a in alphabets:
    t = s[:]
    count = 0
    while True:
        b = []
        if t == [a]*len(t):
            ans = min(ans,count)
            break
        else:
            for i in range(len(t)-1):
                if t[i] == a or t[i+1] == a:
                    b.append(a)
                else:
                    b.append('A')
            count += 1
            t = b[:]

print(ans)

Measured memory_bytes: 41328
n, m = map(int, input().split())
count = [0 for i in range(m)]
ans = 0
for i in range(n):
    s = list(map(int, input().split()))
    k = s[1:s[0] + 1]
    for j in k:
        count[j - 1] += 1
for i in range(len(count)):
    if count[i] == n:
        ans += 1
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ldb = long double;
using pa = pair < ll, ll >;
using vec = vector < ll >;
#define pb push_back
#define F  first
#define S  second
#define f(i,x,n) for(ll i=x;i<n;i++) 
#define all(c) c.begin(),c.end()
#define edl "\n"
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)
const int MOD = 1e9 + 7, N = 1e5 + 10;
const ll LINF = LLONG_MAX;
int main() 
{

  fast();
  
    // #ifndef ONLINE_JUDGE
    //   freopen("input.txt", "r", stdin);
    //   freopen("output.txt","w",stdout);
    // #endif
    ll a,b,c;
    cin >> a >> b >> c;
    cout<<min({a+b,a+c,b+c});
    cerr << "Time taken: " << int((clock() * 1000.) / CLOCKS_PER_SEC) << "ms\n";
    return 0;
}
 

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String s = sc.next();
        String t = sc.next();
        StringBuilder sb = new StringBuilder();
        
        for(int i=0; i<n; i++){
            sb.append(s.charAt(i));
            sb.append(t.charAt(i));
        }
        
        System.out.println(sb.toString());
    }
}

Measured memory_bytes: 21588
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	long long int H,N,Ans,i;
  	cin >> H;
  	N = 0;
  	Ans = 1;
  while(H>0){
  N++;
  H /= 2;
  }
  
  for(i = 0;i < N;i++){
  	Ans *= 2;
  }
  
  cout << Ans-1 <<endl;
}


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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define REPD(i,n) for(ll i = (ll)n - 1;i >= 0;i--)
#define ALL(x) (x).begin(),(x).end()
#define FILLl(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define FILL(n,first_dimension_size,value) fill((int*)n,(int*)(n+first_dimension_size),value)
#define INF (1 << 30)
#define MOD 1000000007
//int dy[4] = {-1,0,0,1};
//int dx[4] = {0,1,-1,0};



int main(){

  int n,d,x;
  cin >> n >> d >> x;
  vector<int> v(n);
  REP(i,n)cin >> v[i];
  ll res = x;
  REP(i,n){
    int k = 1;
    while(k <= d){
      k += v[i];
      res++;
    }
  }
  cout << res << endl;


  

  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
char t[100005];
//0, 1, 2
//r, s, p
long long d[100005][3];

long long max(long long a,long long b){ return a>b?a:b; }

long long getAns(int mod,int n,int k,long long r,long long s,long long p){
    long long ans = 0;
    for(int i = mod; i < n; i += k){
        d[i][0] = d[i][1] = d[i][2] = 0;
        if(i!=mod){
            d[i][0] = max(d[i-k][1],d[i-k][2]);
            d[i][1] = max(d[i-k][0],d[i-k][2]);
            d[i][2] = max(d[i-k][0],d[i-k][1]);
        }
        if(t[i]=='r') d[i][2] += p;
        else if(t[i]=='s') d[i][0] += r;
        else d[i][1] += s;
        ans = max(ans,d[i][0]);
        ans = max(ans,d[i][1]);
        ans = max(ans,d[i][2]);
    }
    //printf("mod = %d, ans = %lld\n",mod,ans);
    return ans;
}

int main(){
    int n,k;
    long long r,s,p;
    scanf("%d%d%lld%lld%lld",&n,&k,&r,&s,&p);
    scanf("%s",t);
    long long ans = 0;
    for(int i = 0; i < k; i++){
        ans += getAns(i,n,k,r,s,p);
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 2560
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;


namespace AtC
{
    class Program
    {
        static void Main(string[] args)
        {
            var nk = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            int N = nk[0], K = nk[1];
            var S = Console.ReadLine();
            int count = 0;
            var list = new List<int>();
            char buf;
            if ((buf = S[0]) == '0') list.Add(0); //左端は逆立ち固定
            foreach (var c in S)
            {
                if (c == buf) count++;
                else
                {
                    buf = c;
                    list.Add(count);
                    count = 1;
                }
            }

            list.Add(count);
            if (buf == '0') list.Add(0); //右端も逆立ち固定
            //この時点でlist.Countは奇数確定

            if (list.Count == 1)
            {
                Console.WriteLine(list.Sum());
                return;
            }

            var scores = new List<int>();
            var sum = list[0];
            for (int r = 0, l = 0; r < (list.Count >> 1); r++)
            {
                if (r - l >= K)
                {
                    scores.Add(sum);
                    sum -= list[2 * l];
                    sum -= list[2 * l + 1];
                    l++;
                }

                sum += list[2 * r + 1];
                sum += list[2 * r + 2];
            }

            scores.Add(sum);
            Console.WriteLine(scores.Max());
        }
    }
}

Measured memory_bytes: 13536
/*I MAY NOT GET THE SUCCESS IMMEDIATELY BUT I WILL GET IT FOR SURE*/
#include<bits/stdc++.h>
#define opt std::ios_base::sync_with_stdio(false)
#define lli		long long
#define ulli unsigned long long

#define pn			 printf("\n")
#define nl			 cout<<'\n'
#define sf(N)        scanf("%lld",&N)
#define pf(N)        printf("%lld",N)
#define sf1(N1,N2)    scanf("%lld %lld",&N1,&N2)
#define pf1(N1,N2)    printf("%lld %lld",N1,N2)
#define sf2(N1,N2,N3) scanf("%lld %lld %lld",&N1,&N2,&N3)
#define pf2(N1,N2,N3) printf("%lld %lld %lld",N1,N2,N3)

#define rep(i,a,b)	for(i=a;i<b;i++)
#define repr(i,a,b)	for(i=a;i>b;i--)
#define elif		else if

#define pb		push_back
#define pob		pop_back
#define itr		iterator
#define sz()	size()
#define szof    sizeof
#define mp		make_pair
#define vlli    vector<lli>
#define plli	pair<lli,lli>
#define vplli	vector<plli >
#define F   	first
#define S		second

#define ALL(V)  V.begin(),V.end()

#define MX1     100000LL
#define MX2     1000000LL
#define Inf     1000000000000000
#define mod		1000000007
using namespace std;

lli Power(lli a,lli b)
{
    lli result=1;

    while(b)
    {
        if(b%2)
        {
            result=(result*a)%mod;
        }

        b=b>>1;
        a=(a*a)%mod;
    }

 return result;
}

int main()
{
    opt;

    /*#ifndef ONLINE_JUDGE
    freopen("double_squares.txt","r",stdin);
    freopen("double_squares_out.txt","w",stdout);
    #endif // ONLINE_JUDGE*/

    lli X,Y;
    cin>>X>>Y;

    lli cnt=0;

    while(X<=Y)
    {
        X*=2;
        cnt++;
    }

    cout<<cnt;





 return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s1;
    string s2="";
    string s3="";
    string s4;
    string s5;
    string s6;

    cin>>s1;
    int n=s1.length();
    s4 = s1;
    int x,y,count=0;
    reverse(s1.begin(),s1.end());
    if(s1!=s4){
        cout<<"No"<<endl;
    }
    else{
        count++;
        x = (n-1)/2;
        for(int i=0; i<x; i++){
            s2 += s4[i];
        }
        s5 = s2;
        reverse(s2.begin(),s2.end());
        if(s5==s2)count++;

        y = (n+3)/2;
        for(int i=y-1; i<n; i++){
            s3 += s4[i];
        }
        s6 = s3;
        reverse(s3.begin(),s3.end());
        if(s3==s6)count++;

        if(count==3)cout<<"Yes\n";
        else cout<<"No\n";
    }


    return 0;
}

Measured memory_bytes: 256
"""
B - Power Socket
"""


import sys
sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline
from itertools import permutations,  combinations, accumulate
from functools import *
from collections import deque, defaultdict, Counter
from heapq import heapify, heappop, heappush, heappushpop

INF = float('inf')
NIL = - 1

A, B = map(int, input().split())

total = 1
number = 0

while total < B:
    number += 1
    total = (total - 1) + A

print(number)


Measured memory_bytes: 38384
import sys
from itertools import accumulate

def Main():
    n,m,k = map(int,sys.stdin.readline().rstrip().split())
    a = [0] + list(accumulate(map(int,sys.stdin.readline().rstrip().split())))
    b = [0] + list(accumulate(map(int,sys.stdin.readline().rstrip().split())))

    ans = 0
    j = m
    for i,item in enumerate(a):
        if k<item:  break
        while k<item+b[j]:
            j -= 1
        ans = max(ans,i+j)
    print(ans)
    return

if __name__=='__main__':
    Main()

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

#ifdef _DEBUG
inline void dump() { cerr << endl; }
template<typename Head> void dump(Head&& head) { cerr << head; dump(); }
template<typename Head, typename... Tail> void dump(Head&& head, Tail&&... tail) { cerr << head << ", "; dump(forward<Tail>(tail)...); }
#define debug(...) do {cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; dump(__VA_ARGS__); } while (false)
#else
#define dump(...)
#define debug(...)
#endif

template<typename T>
struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template<typename T>
using Edges = vector<edge<T>>;
template<typename T>
using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template<typename T>
using Matrix = vector<vector<T>>;

/////////////////////////////////////////////////////////////////////
const ll inf = 1LL<<60;

int main()
{
  vector<int> a(3);
  rep(i, 3) cin>>a[i];
  sort(a.begin(),a.end());
  cout << a[0]*a[1]/2 << endl;

  return 0;
}


Measured memory_bytes: 3632
N = int(input())
SP = []
name = []
for i in range(N):
    x = list(input().split())
    x = [x[0], int(x[1]), int(i)]
    name.append(x[0])
    SP.append(x)


s = sorted(SP, key=lambda x: (x[0], -x[1]))

for i in range(N):
    print(s[i][2] + 1)


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int n;
  cin >> n;
  cout << n*n*n << endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python

from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(1000000)

INF = 10 ** 18
MOD = 10 ** 9 + 7

N, K = map(int, raw_input().split())
S = raw_input()
ls = []
cc = '1'
num = 0
for c in S:
    if cc == c:
        num += 1
    else:
        ls += [num]
        num = 1
        cc = c
ls += [num]
if cc == '0':
    ls += [0]
S = 0
for i in range(min(len(ls), 2 * K + 1)):
    S += ls[i]
ans = S
for i in range(2 * K + 1, len(ls), 2):
    S += ls[i]
    S += ls[i + 1]
    S -= ls[i - (2 * K + 1)]
    S -= ls[i - (2 * K)]
    ans = max(ans, S)
print ans

Measured memory_bytes: 5332
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    String ans = "No";
    int p = 0;
    if((n % 10) == 9) p++;
    n /= 10;
    if((n % 10) == 9) p++;
    if(p > 0) ans = "Yes";
    System.out.println(ans);
  }
}

Measured memory_bytes: 21844
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        if (N%1000 == 0){
            System.out.println(0);
        }else{
            System.out.println(1000 - N%1000);
        }
    }
}

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

struct rout{
	int t,x,y;
}a[100005];

int i,j,n;
int main(){
	cin>>n;
	
	for(i=1;i<=n;i++)
		cin>>a[i].t>>a[i].x>>a[i].y;
	a[0].t=0;a[0].x=0;a[0].y=0;
	
	int s,f=1;
	for(i=1;i<=n;i++){
		s=fabs(a[i].x-a[i-1].x)+fabs(a[i].y-a[i-1].y);
		
		if( s>(a[i].t-a[i-1].t) || ( (a[i].t-a[i-1].t-s)%2==1 ) ){
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 1408
import itertools
import sys
import math
import numpy as np
from collections import deque
from itertools import combinations
from functools import reduce
from functools import lru_cache
sys.setrecursionlimit(10**9)

def main():
    N = int(input())

    counter = [[0] * 10 for _ in range(10)]
    for i in range(N+1):
        i_str = str(i)
        counter[int(i_str[0])][int(i_str[-1])] += 1

    ans = 0
    for i in range(1,10):
        for j in range(1,10):
            ans += counter[j][i] * counter[i][j]

    print(ans)

if __name__ == "__main__":
  main()


Measured memory_bytes: 12448
#include <stdio.h>
#define PI 3.141592653589
 
int main( )
{
  double r,s,l;
 
  scanf("%lf",&r);
 
  s = r * r * PI;
  l = 2 * PI * r;
 
  printf("%f %f\n",s,l);
 
  return 0;
}

Measured memory_bytes: 648
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define sz(c) ((int)(c).size())
#define mp make_pair

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
//typedef pair<int, int> P;
//typedef pair<int, pair<int, int> > PP;
//const int MAX=;



int main(){
	int N,K;
	cin>>N>>K;
	ll s[1005];
	s[0]=0;
	rep1(i,N){
		ll a;
		cin>>a;
		s[i]=s[i-1]+a;
	}
	vll v;
	rep1(i,N+1)rep1(j,N+1)if(i<j)v.push_back(s[j-1]-s[i-1]);
	
  	ll ans=0;
	for(ll k=40; k>=0; k--){
      	ll tmp=1ull<<k;
		ans=ans^tmp;
		int ct=0;
		rep(i,sz(v))if((v[i] & ans)==ans)ct++;
		if(ct>=K) continue;
		else ans=ans^tmp;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 6384
#include <bits/stdc++.h>
using namespace std;
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    long n,ans,a,r,c,h,m;
    a = r = c = h = m = 0;
    string b;
    vector <string> vec;
    cin >> n;
    for(int i = 0;i < n;i ++){
        cin >> b;
        if(b[0] == 'A')a ++;
        else if(b[0]=='R')r ++;
        else if(b[0]=='C')c ++;
        else if(b[0]=='M')m ++;
        else if(b[0]=='H')h ++;
    }
    cout << a*r*c + a*r*m + a*r*h + a*c*m + a*c*h + a*m*h + r*c*m +r*c*h + r*m*h + c*m*h << endl;
}

Measured memory_bytes: 256
import math
a,b,c=map(int,input().split())
S=a*b*math.sin(math.radians(c))/2
L=(a**2+b**2-2*a*b*math.cos(math.radians(c)))**0.5+a+b
h=2*S/a
print(S)
print(L)
print(h)


Measured memory_bytes: 5716
/*
Hey there stalker....

█▀▀▄░░░░░░░░░░░▄▀▀█
░█░░░▀▄░▄▄▄▄▄░▄▀░░░█
░░▀▄░░░▀░░░░░▀░░░▄▀
░░░░▌░▄▄░░░▄▄░▐▀▀
░░░▐░░█▄░░░▄█░░▌▄▄▀▀▀▀█
░░░▌▄▄▀▀░▄░▀▀▄▄▐░░░░░░█
▄▀▀▐▀▀░▄▄▄▄▄░▀▀▌▄▄▄░░░█
█░░░▀▄░█░░░█░▄▀░░░░█▀▀▀
░▀▄░░▀░░▀▀▀░░▀░░░▄█▀
░░░█░░░░░░░░░░░▄▀▄░▀▄
░░░█░░░░░░░░░▄▀█░░█░░█
░░░█░░░░░░░░░░░█▄█░░▄▀
░░░█░░░░░░░░░░░████▀
░░░▀▄▄▀▀▄▄▀▀▄▄▄█▀

Like what you see?
*/
#include <bits/stdc++.h>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define pii         pair<ll ,ll>
#define vi          vector<ll>
#define present(container, element) (container.find(element) != container.end()) /* For set n maps */
#define cpresent(container, element) (find(all(container),element) != container.end()) /* For vectors */
#define all(a)      (a).begin(),(a).end()
#define invect(data,n,commands) for(int i = 0;i<n;i++){int tmp;cin>>tmp;data.pb(tmp);commands}
#define inset(data,n,commands) for(int i = 0;i<n;i++){int tmp;cin>>tmp;data.I(tmp);commands}
#define F           first
#define S           second
#define I           insert
#define sz(x)       (ll)x.size()
#define rep(i,a,b)    for(ll  i=a;i<b;i++)
#define repr(i,a,b) for(ll  i=a;i>b;i--)
#define trav(a, x) 	for(auto& a : x)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define lcase(a) (char)tolower(a)
#define ll long long int
#define lld long double
#define endl "\n"
#define PI 3.14159265358979323844
#define MOD 1000000007
#define max(a, b) (a < b ? b : a)
#define min(a, b) ((a > b) ? b : a)
#define mod 1e9 + 7
const int N = 1e5 + 5;
/*	For Debugging	*/
#define DEBUG 		cerr<<"\n>>>I'm Here<<<\n"<<endl;
#define display(x) trav(a,x) cout<<a<<" ";cout<<endl;
#define what_is(x)  cerr << #x << " is " << x << endl;

int32_t main()
{
   IOS

    int TESTS=1;
    //cin >> TESTS;
    while (TESTS--)
    {
        ll x,y,temp;
        cin >> x >> y;
        bool flag=false;
        if(y%2!=0)
        {
            cout<< "No"<<endl;
            continue;
        }
        for(int i=0;i<=x;i++)
        {
            ll b=x-i;
            if((2*i+4*b)==y)
            {
                flag=true;
                break;
            }

        }

        if(flag)
        {
          cout<< "Yes"<< endl;
        }
        else
        {
            cout<< "No"<< endl;
        }

    }
    return 0;
}


Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();

		System.out.println(6-a-b);

	}

}

Measured memory_bytes: 21716
#include<bits/stdc++.h>
#define ll long long
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define repn(i,n) for(ll i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define bac(i,a,b) for(ll i=a;i>=b;i--)
#define sz(v) (ll)v.size()
using namespace std;

ll MOD=1e9+7;
ll g,h,l;
const ll N=100005;

ll add(ll a,ll b); ll mul(ll a,ll b); ll binpo(ll a,ll b);

int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    ll k;cin>>k;
    vector<string> v;
    queue<string> q;
    for(int i=1;i<10;i++){
        q.push(to_string(i));
        // v.push_back(to_string(i));
    }
    while(v.size()+q.size()<2*100000){
        auto top = q.front();
        q.pop();
        v.push_back(top);
        char last = top[sz(top)-1];
        
        if(last!='0'){
            q.push(top+char(last-1));
        }
        q.push(top+last);
        if(last!='9'){
            q.push(top+char(last+1));
        }
    }
    while(!q.empty()){
        auto top = q.front();
        q.pop();
        v.push_back(top);
    }
    cout<<v[k-1];
}

ll add(ll a,ll b)
{
    return (a%MOD+b%MOD)%MOD ;
}
ll mul(ll a,ll b)
{
    return (a* 1ll *b)%MOD ;
}
ll binpo(ll a,ll b)
{
    int ans = 1 ;
    while(b)
    {
        if( b % 2 != 0)
        {
            ans = mul(ans,a);
        }
        a = mul(a,a);
        b = b/2;
    }
    return ans;
}

Measured memory_bytes: 15604
#include <bits/stdc++.h>
#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 per(i,a,b) for(int i=a;i>=b;--i)
#define rvc(i,S) for(int i=0;i<(int)S.size();++i)

#define pb push_back
#define fi first
#define se second
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define maxn 1000020
#define ll long long 
#define int long long
#define N 8000020
using namespace std;

int n,k;
int a[maxn];
int sum[maxn];
int cnt=0;
int num[maxn];
bool tmp[maxn];
bool used[maxn];
char s[maxn];
int T; 
void solve()
{ll ans=0ll; 
 ll dui=0,D=0,M=0,C=0; 
 rep(i,1,k)
   {if(s[i]=='D') D++;
    if(s[i]=='M'){M++;dui+=D;}
	if(s[i]=='C') {ans+=dui;} 
   }
 rep(i,k+1,n)
   { int Era=i-k;
     if(s[Era]=='D') {dui-=M; D--;}
     if(s[Era]=='M') {M--;}
   ///////////
     if(s[i]=='D') D++;
	 if(s[i]=='M'){M++;dui+=D;}
	 if(s[i]=='C') {ans+=dui;} 
   } 
   cout<<ans<<endl;
}

signed main()
{ cin>>n;
   scanf("%s",s+1); 
   cin>>T;
   while(T--)
   {cin>>k;
    solve();
	} 
  
return 0;
} 

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(a);i>(b);--i)
#define eper(i,a,b) for(int i=(a);i>=b;--i)
#define fore(i, x, a) for(auto &&x:a) 
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define ALL(x) begin(x),end(x)
#define F first
#define S second
const int inf=1001001001;
const long long INF=1001001001001001001;
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using vii = vector<int>;
using vll = vector<ll>;
using priority_queue_small = priority_queue<int, vector<int>, greater<int> >;
template<class T>using vv = vector<T>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T>T gcd(T a, T b){ return b ? gcd(b, a % b) : a; }
template<class T>T lcm(T a, T b){ return a / gcd(a, b) * b; }
int dy[]={0, 1, -1, 0};
int dx[]={1, 0, 0, -1};

ll n, k;
int main() {
 cin.tie(0);
 ios::sync_with_stdio(false);
  cin >> n >> k;
  ll t = n / k;
  if (k % 2) {
    cout << t * t * t << endl;
  } else {
    ll b = (n + (k/2)) / k;
    cout << t * t * t + b * b * b << endl;
  }
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a) for(int i = 0; i < a; i++)
#define all(v) v.begin(), v.end()
#define dcout cout << fixed << setprecision(15)
#define arep(i, a) for(auto i : a)
#define F first
#define S second
#define VE vector<int>
#define pb(x) push_back(x)
#define MOD 1000000007
#define INF 10000000000
#define int long long
#define KETA(n) floor(log10(n) + 1)
using namespace std;
signed main() {
    int a, b;
    cin >> a >> b;
    rep(i, a + 1) {
        if(i * 2 + (a - i) * 4 == b) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3628
#include<cstdio>
#include<cstring>
using namespace std;
char s[105];
int n,K,L,R;
long long ans;
int main(){
	scanf("%s%d",s+1,&K);
	L=1,R=n=strlen(s+1);
	if(s[L]==s[R]){
		while(s[1]==s[L]) L++;
		while(s[1]==s[R]) R--;
		if(L>n) return printf("%lld\n",1ll*K*n>>1)&0;
	}
	ans+=(1ll*(K-1)*(L-1+n-R>>1))+(L-1>>1)+(n-R>>1);
	for (int i=L,j;i<=R;i=j){
		for (j=i;s[i]==s[j]&&j<=R;j++);
		ans+=1ll*K*(j-i>>1);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include<string>
#include<string.h>
#include<map>
#include<set>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
int x,y;
int main(){
cin>>x>>y;
int i=2;
if (x==y || x%y==0) {
                cout<<"-1"<<endl;
                return 0; 
          }
long long a=0;
while(true)
{
  a=i*x;
  if (a%y!=0) {
                cout<<a<<endl;
                return 0; 
                }
  else i++;
}
}

Measured memory_bytes: 256
N = int(input())

F = []
for _ in range(N):
	F.append([int(x) for x in input().split()])

P = []
for _ in range(N):
	P.append([int(x) for x in input().split()])


ans = -float('inf')
for i in range(1, 2 ** 10):
	selfF = []
	for j in range(10):
		selfF.append((i >> j) & 1)
	
	benefit = 0
	for j in range(N):
		both = 0
		for k in range(10):
			if F[j][k] == 1 and selfF[k] == 1:
				both += 1
		benefit += P[j][both]
	ans = max(ans, benefit)

print(ans)

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

int main()
{
    int A, B, C, K;
    cin >> A >> B >> C >> K;
    int res = 0;
    if     (K <= A)         res = K;
    else if(K <= A + B)     res = A;
    else if(K <= A + B + C) res = A - (K - A - B);
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <cmath>
#include <string>
#include <stack>
#include <algorithm>
#include <vector>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <queue>

using namespace std;

#define echo(A) cout << A << endl;

typedef long long llong;

int main() {
	string A;
	cin >> A ;
	int c = 0, longest = 0;
	for (int i = 0; i < A.size(); ++i) {
		if(A[i] == 'A' or A[i] == 'C' or A[i] == 'G' or A[i] == 'T' ) {
			c++;
			longest = max(c, longest);
		}else{
			c=0;
		}
	}

	echo(longest);

	return 0;
}



Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 16;
const int MAX_BITS = 1 << MAX_N;

const int INF = 1 << 30;

/* typedef */

struct Stat {
  int d, bits, pos;

  Stat() {}
  Stat(int _d, int _bits, int _pos) { d = _d, bits = _bits, pos = _pos; }
  bool operator<(const Stat& st0) const { return d > st0.d; }
};

/* global variables */

int n;
int dists[MAX_BITS][MAX_N];

/* subroutines */

int str2bits(string str, int n) {
  int bits = 0;
  for (int i = 0; i < n; i++) {
    bits <<= 1;
    if (str[i] == 'B') bits |= 1;
  }
  return bits;
}

/* main */

int main() {
  for (;;) {
    cin >> n;
    if (n == 0) break;

    string sstr, gstr;
    cin >> sstr >> gstr;

    int sbits = str2bits(sstr, n);
    int gbits = str2bits(gstr, n);
    //printf("%x -> %x\n", sbits, gbits);

    int maxbits = 1 << n;
    for (int i = 0; i < maxbits; i++)
      for (int j = 0; j < n; j++)
	dists[i][j] = INF;
    
    priority_queue<Stat> q;

    for (int i = 0; i < n; i++) {
      dists[sbits][i] = 0;
      q.push(Stat(0, sbits, i));
    }

    int mind = INF;
    
    while (! q.empty()) {
      Stat u = q.top();
      q.pop();

      if (u.d != dists[u.bits][u.pos]) continue;
      if (u.bits == gbits) {
	mind = u.d;
	break;
      }

      for (int i0 = 0; i0 < n; i0++) {
	int b0 = (u.bits >> i0) & 1;
	int vc0 = (u.pos > i0) ? u.pos - i0 : i0 - u.pos;
	for (int i1 = 0; i1 < n; i1++) {
	  if (i0 == i1) continue;
	  int b1 = (u.bits >> i1) & 1;
	  if (b0 == b1) continue;

	  int vc1 = (i0 > i1) ? i0 - i1 : i1 - i0;
	  int vbits = (u.bits ^ (1 << i0)) ^ (1 << i1);
	  int vd = u.d + vc0 + vc1;
	  if (dists[vbits][i1] > vd) {
	    dists[vbits][i1] = vd;
	    q.push(Stat(vd, vbits, i1));
	  }
	}
      }
    }

    cout << mind << endl;
  }

  return 0;
}

Measured memory_bytes: 15856
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, M;
  cin >> N >> M;

  int l,r;
  int max = 100000;
  int min = 0;
  int ans=1;

  for(int i=0;i<M;i++){
    cin >> l >> r;
    if(l>r) swap(l,r);

    if(l>max || r<min) ans = 0;
    else if(l<=min && r<=max) max = r;
    else if(l>=min && r>=max) min = l;
    else if(l>=min && r<=max){
      max = r;
      min = l;
    }

    //if(l<min && max<r)

  }

  if(ans != 0) ans = max - min+1; 
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#define i_7 (ll)(1E9+7)
//#define i_5 (ll)(1E9+5)
#define i_7 998244353
#define i_5 998244351
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
ll inf=(ll)1E17;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
long double EPS=1E-8;
////////////////////////////////////////


int main(){
    ll n,m,q;cin>>n>>m>>q;
    ll a[n+1][n+1];memset(a,0,sizeof(a));
    while(m--){
        ll b,c;cin>>b>>c;
        a[b][c]++;
    }
    rep(i,1,n){
        rep(j,1,n){
            a[i][j]+=a[i][j-1];
        }
    }
    rep(j,1,n){
        for(ll i=n;i>=1;i--){
            a[i-1][j]+=a[i][j];
        }
    }
    /*rep(i,0,n){
        rep(j,0,n){
            cout<<a[i][j]<<" ";
        }cout<<endl;
    }*/
    while(q--){
        ll l,r;cin>>l>>r;
        cout<<a[l][r]<<endl;
    }
    return 0;
}


Measured memory_bytes: 2944
/*Read the problem carefully before starting to work on it*/
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;

typedef long long ll;

//ll ncr(ll n,ll r){ll ans=1;r=min(r,n-r);for (int i=1;i<=r;i++){ans*=(n-r+i);ans/=i;}return ans;}

#define pb push_back
#define eb emplace_back
#define mp(x,y) make_pair(x,y)
#define mod 1000000007

double PI=3.1415926535897932384626;

//template<typename T> T power(T x,T y,ll m=mod){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1LL;x=(x*x)%m;}return ans%m;}

//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ost;

#define fi first
#define se second

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll r;
	cin>>r;
	cout<<(r*r);
    return 0;
}


//252908XL

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

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pl;

const int INT_INF = 2147483646;
const ll LL_INF = 9223372036854775807;

bool SecondCompare(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second<b.second;
}
 
bool SecondCompareDes(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second>b.second;
}

ll minll(ll a, ll b){
    if(a >= b)  return b;
    else    return a;
}

ll maxll(ll a, ll b){
    if(a >= b)  return a;
    else    return b;
}

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

const ll SIZE = 1e5+10;

ll n,m;

int main(){
    cin >> n >> m;
    if(n == m)  cout << "Yes\n";
    else{
        cout << "No\n";
    }
}

Measured memory_bytes: 256
n = int(input())
h = list(map(int, input().split()))

for i in range(n-1):
    if h[i+1] - h[i] == -1:
        h[i+1] += 1
    elif h[i+1] - h[i] < -1:
        print("No")
        quit()

print("Yes")

Measured memory_bytes: 85008