akhauriyash/Code-Regression huggingface dataset:
def incre():
    n = int(input())
    s = input()
    x = 0
    m = [0,]
    for i in range(len(s)):
        if s[i] == 'I':
            x += 1
            m.append(x)
        elif s[i] == 'D':
            x -= 1
            m.append(x)
    else:
        print(max(m))

if __name__ == "__main__":
    incre()

Measured memory_bytes: 3064
import java.util.Scanner;
 
public class Main {
    static Scanner stdIn = new Scanner(System.in);
    public static void main(String[] args){
        int n = stdIn.nextInt();
        int[] a = new int[n+1];
        for(int i=0; i<n+1; i++){
            a[i] = stdIn.nextInt();
        }
        int[] b = new int[n];
        for(int i=0; i<n; i++){
            b[i] = stdIn.nextInt();
        }

        long cnt = 0;
        for(int i=0; i<n; i++){
            if(a[i] >= b[i]){
                cnt += b[i];
                b[i] = 0;
            }else{
                cnt += a[i];
                b[i] -= a[i];

                if(a[i+1] >= b[i]){
                    cnt += b[i];
                    a[i+1] -= b[i];
                }else{
                    cnt += a[i+1];
                    a[i+1] = 0;
                }
            }
        }

        System.out.println(cnt);
    }
}


Measured memory_bytes: 59892
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
#define eb(t) emplace_back(t)
typedef long long ll;
typedef long long unsigned int llu;
ll MOD = 1000000007;
ll INF = 1000000009;

ll x[200010];

void solve(){

    ll m;
    cin >> m;
    ll ans = 0;
    ll D=0;
    ll S=0;
    rep(i,m){
        ll d,c;
        cin >> d >> c;
        D += c;
        S += c*d;
    }
    ans = (D-1) + (S-1)/9;

    cout << ans << endl;

}

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


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

int main(){
	int n;
	string s,res;
	cin>>n>>s;
	int cnt=0;
	for(int i=0;i<s.size();i++){
		if(s[i]=='(') cnt++;
		else cnt--;
		if(cnt<0){
			res+='(';
			cnt++;
		}
	}
	cout<<res<<s;
	while(cnt--) cout<<')';
	return 0;
}

Measured memory_bytes: 256
import heapq

x, y, z, K = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

a = sorted(a)
b = sorted(b)
c = sorted(c)

n = []
heapq.heapify(n)
heapq.heappush(n, (-(a[-1]+b[-1]+c[-1]), 1, 1, 1))
for _ in range(K):
    (m, i, j, k) = heapq.heappop(n)
    print(-m)
    if i + 1 <= x:
        s = (-(a[-i-1]+b[-j]+c[-k]), i+1, j, k)
        if s not in n:
            heapq.heappush(n, s)
    if j + 1 <= y:
        s = (-(a[-i]+b[-j-1]+c[-k]), i, j+1, k)
        if s not in n:
            heapq.heappush(n, s)
    if k + 1 <= z:
        s = (-(a[-i]+b[-j]+c[-k-1]), i, j, k+1)
        if s not in n:
            heapq.heappush(n, s)

Measured memory_bytes: 3828
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int  N = sc.nextInt();
        long M = sc.nextLong();
        long[] A = new long[N],
               B = new long[N];
        List<long[]> al = new ArrayList<>();
        for(int i = 0; i < N; i++){
            A[i] = sc.nextLong();
            B[i] = sc.nextLong();
            al.add(new long[]{A[i], B[i]});
        }
        al.sort(Comparator.comparing(x -> x[0]));   
        int shop = 0;
        long money = 0;
        while(true){
            long stock = al.get(shop)[1],
                 price = al.get(shop)[0];
            if(stock < M){
                money += price*stock;
                M -= stock;
                shop++;
            }
            else{
                money += price*M;
                break;
            }
        }
        System.out.println(money);
    }
}

Measured memory_bytes: 95332
#include <bits/stdc++.h>
#define F first
#define S second
#define mp make_pair
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pi;
const ll inf = 1e18+5;
ll n, a[405], dp[405][405];
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin >> n;
	for (ll i= 0; i < n; i++)cin >> a[i];
	for (ll L = n; L >= 0; L--){
		for (ll R = L; R < n; R++){
			if (R == L){
				dp[L][R] = 0;continue;
			}else if (R == L+1){
				dp[L][R] = a[L]+a[R];continue;
			}
			dp[L][R] = inf;
			//~ dp[L][R] = min(a[L]+2*dp[L+1][R], a[R]+(R == 0 ? inf:2*dp[L][R-1]));
			//~ for (ll i = L+1; i < R; i++){
				//~ //consider L and R separately, likely out of loop
				//~ dp[L][R] = min(a[L]+dp[L+1][R], a[R]+(R == 0 ? inf:dp[L][R-1]));
				//~ dp[L][R] = min(dp[L][R], (a[i]+dp[L][i-1]*2)*2+dp[i+1][R]*2);
				//~ dp[L][R] = min(dp[L][R], dp[L][i-1]*2+(dp[i+1][R]*2+ a[i])*2);
			//~ }
			ll sum = 0;
			for (ll i = L; i <= R; i++)sum += a[i];
			for (ll i = L; i < R; i++){
				dp[L][R] = min(dp[L][R], sum + dp[L][i]+dp[i+1][R]);
			}
		}
	}
	cout << dp[0][n-1];	
	//~ for (ll i =0; i< n; i++){
		//~ for (ll j = 0; j < n; j++){
			//~ cout << dp[i][j] << ' ';
		//~ }
		//~ cout << '\n';
	//~ }
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define REPr(i,n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m , n) for(int i = (n);i >=(m);--i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define VSCD(v,N) REP(i,N){int (x); SCD(x); v.PB(x);}
#define VSCLLD(v,N) REP(i,N){long long (x); SCLLD(x); v.PB(x);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x,S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x,y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int,int> PII;
typedef pair<long long,long long> PLL;
typedef vector<int> VI;
typedef vector < VI > VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
const ll MOD = 1000000007;
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}

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

/*（๑•﹏•๑｀) */

int main() {
    int N;
    cin >> N;
    string S;
    cin >> S;

    int wl = 0;
    int wr = 0;
    int bl = 0;
    int br = 0;

    REP(i,N){
        if (S[i] == '#') br++;
        else wr++;
    }

    int ans = wr;

    REP(i,N){
        if (S[i] == '#'){
            bl++;
            br--;
        }else{
            wl++;
            wr--;
        }

        chmin(ans,bl+wr);
    }

    cout << ans << "\n";

}


Measured memory_bytes: 640
n=gets.to_i
a=gets.split.map(&:to_i)
puts a.join(" ")

1.upto(n-1) do |i|
  v=a[i]
  j=i-1

  while v<a[j] && j>=0
    a[j+1]=a[j]
    j-=1
  end
  a[j+1]=v
  puts a.join(" ")

end



Measured memory_bytes: 8852
#include <stdio.h>
#include <stdlib.h>

#include <iostream>
#include <iomanip>
#include <sstream>
#include <stdint.h>
#include <string.h>

#include <unordered_set>

#define _USE_MATH_DEFINES
#include <math.h>


#include <vector>
#include <list>

#include <set>
#include <map>

#include <unordered_map>

#include <queue>
#include <stack>

#include <string>

#include <vector>

#define sqr(x) (x) * (x)

#include <algorithm>
#include <functional>

#include <bitset>

#include <functional>

#include <chrono>

typedef unsigned int u32;
typedef int i32;

typedef unsigned long long int u64;
typedef long long int i64;

typedef uint16_t u16;
typedef int16_t i16;

typedef uint8_t u8;
typedef int8_t i8;


using namespace std;
using namespace std::chrono;

struct less_key
{
    bool operator() (pair<i64, i64> p1, pair<i64, i64> p2)
    {
        return p1.first > p2.first || (p1.first == p2.first && p1.second < p2.second);
    }
};

struct pair_hash {
public:
    std::size_t operator()(const std::pair<u64, u64> &x) const
    {
        return std::hash<u64>()(x.first) ^ std::hash<u64>()(x.second);
    }
};
#include <random>

const i64 mod = 1000000007ll;
const i64 smod = 998244353ll;
const i64 inf = 10000000000000007ll;

const double eps = 1e-10;

// del

const i64 MAXN = 100005;

i64 n, k;

int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(15); cout.setf(ios::fixed);

    cin >> n >> k;

    i64 R = n - k + 1;

    cout << R;

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;

namespace cswork {
    class Program {
        static void Main (string[] args) {
                        string s = ReadStr();
            string t = ReadStr();

            if(s.Equals(t.Substring(0,t.Length-1))){
                Write("Yes");
            }else{
                Write("No");
            }
            Exit ();
        }

        public static void Write (string str) {
            Console.WriteLine (str);
        }

        public static void Write (int i) {
            Console.WriteLine (i);
        }

        public static void Write (double d) {
            Console.WriteLine (d);
        }

        public static string ReadStr () {
            return Console.ReadLine ();
        }

        public static int ReadInt () {
            return int.Parse (Console.ReadLine ());
        }

        public static long Read () {
            return long.Parse (Console.ReadLine ());
        }

        public static double ReadDouble () {
            return double.Parse (Console.ReadLine ());
        }

        public static void Exit () { }

        public static List<string> ReadListStr () {
            return new List<string> (ReadStr ().Split (" "));
        }

        public static List<long> ReadList () {
            return ReadListStr ().ConvertAll (x => long.Parse (x));
        }
    }
}

Measured memory_bytes: 25812
// Problem : C - Sum of product of pairs
// Contest : AtCoder - AtCoder Beginner Contest 177
// URL : https://atcoder.jp/contests/abc177/tasks/abc177_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define int long long
#define db double
#define mod 1000000007
#define pb push_back
#define pp pair<int,int>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repe(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=b;i>=a;i--)
#define maxn 200005
#define ss second
#define ff first
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
int inv(int a, int b){
 return 1<a ? b - inv(b%a,a)*b/a : 1;
}
void solve()
{
	int n;
	cin >> n;
	int a[n];
	for(int i=0;i<n;i++)
		cin >> a[i];
	int pre= 0,ans=0;
	repr(i,0,n-1)
	{
		ans += ((pre*a[i])%mod);
		ans %= mod;
		pre += a[i];
		pre %=  mod;
	}
	cout << ans;
}
signed main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    //cin >> t;
    while(t--)
    solve();
    return 0;
}


Measured memory_bytes: 5144
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VL = vector<LL>;
using PII = pair<int, int>;
using PLL = pair<LL, LL>;

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define f first
#define s second
#define FOR(i, a, b) for (int i = (a); i<(b); ++i)
#define RFOR(i, b, a) for (int i = (b)-1; i>=(a); --i)
#define FILL(a, b) memset(a, b, sizeof(a))

void dout() { cerr << endl; }

template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << H << ' ';
    dout(T...);
}

const int MOD = 998244353;

vector<vector<pair<int, __float128>>> g; 

__float128 dist(PII a, PII b)
{
	return sqrt((LL)(a.f - b.f) * (a.f - b.f) + (LL)(a.s - b.s) * (a.s - b.s));
}

int main()
{
    ios::sync_with_stdio(false);
    PII s, t;
    cin >> s.f >> s.s >> t.f >> t.s;
    int n;
    cin >> n;
    g.resize(n + 2);
    VI x(n + 1), y(n + 1), r(n + 1);
    for (int i = 1; i < n + 1; ++i)
    {
    	cin >> x[i] >> y[i] >> r[i];
    }

    for (int i = 1; i < n + 1; ++i)
    {
    	for (int j = i + 1; j < n + 1; ++j)
    	{
    		__float128 d = dist({x[i], y[i]}, {x[j], y[j]});
    		d = max((__float128)0.0, d - r[i] - r[j]);
    		g[i].EB(j, d);
    		g[j].EB(i, d);
    	}
    }

    g[0].EB(n + 1, dist(s, t));
    g[n + 1].EB(0, dist(s, t));
    for (int i = 1; i < n + 1; ++i)
    {
    	__float128 d = dist(s, {x[i], y[i]});
    	d = max((__float128)0.0, d - r[i]);
    	g[0].EB(i, d);
    	g[i].EB(0, d);
    	d = dist(t, {x[i], y[i]});
    	d = max((__float128)0.0, d - r[i]);
    	g[n + 1].EB(i, d);
    	g[i].EB(n + 1, d);
    }

    vector<__float128> dist(n + 2, 1e18);
    dist[0] = 0;
    set<pair<__float128, int>> que;
    que.emplace(dist[0], 0);
    while(!que.empty())
    {
    	auto kek = *que.begin();
    	__float128 cur_d = kek.f;
    	int v = kek.s;
    	que.erase(que.begin());
    	for (auto el : g[v])
    	{
    		int to = el.f;
    		__float128 w = el.s;
    		if (dist[to] > dist[v] + w)
    		{
    			que.erase({dist[to], to});
    			dist[to] = dist[v] + w;
    			que.emplace(dist[to], to);
    		}
    	}
    }

    cout << fixed << setprecision(12) << (long double)dist[n + 1] << "\n";

    return 0;
}

Measured memory_bytes: 32640
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<tuple>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int N,M;
	scan(N);scan(M);
	ll pos[100001];
	fill(pos,pos+N,INFl);
	int L[200001],R[200001],D[200001];
	vpint adj[100001];
	rep(i,M){
		scan(L[i]);scan(R[i]);scan(D[i]);
		L[i]--;
		R[i]--;
		adj[L[i]].push_back(mp(R[i],D[i]));
		adj[R[i]].push_back(mp(L[i],-D[i]));
	}
	rep(n,N){
		if(pos[n]==INFl){
			pos[n]=0;
			vint recordnode;
			recordnode.push_back(n);
			while(recordnode.size()){
				vint beforenode=recordnode;
				recordnode.clear();
				rep(i,beforenode.size()){
					int u=beforenode[i];
					rep(j,adj[u].size()){
						int v=adj[u][j].first,d=adj[u][j].second;
						if(pos[v]==INFl){
							pos[v]=pos[u]+d;
							recordnode.push_back(v);
						}
						else{
							if(pos[v]!=pos[u]+d){
								prin("No");
								return 0;
							}
						}
					}
				}
			}
		}
	}
	prin("Yes");
	return 0;
}


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

using namespace std;

#define NAX 1e9

int main()
{
    int n,k;
    scanf("%d%d",&n,&k);
    vector<int> arr(n),dp(n,NAX);

    for(int i=0;i<n;i++)
        scanf("%d",&arr[i]);
    dp[0]=0;
    for(int i=0;i<n;i++)
    {
        for(int j=1;j<=k;j++)
        {
            if(i+j<n)
                dp[i+j]=min(dp[i+j],abs(arr[i+j]-arr[i])+dp[i]);
        }
    }
    printf("%d",dp[n-1]);
}


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

#ifndef ONLINE_JUDGE
	#define W(x, y) cerr << "\033[31m" << #x << " = " << x << "\033[0m" << y;
#else
	#define W(x, y)
#endif


#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vii vector<pii>
#define vl vector<ll>
#define vll vector<pll>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define pi acos(-1)
#define ld long double
#define prime (1000000000 + 7)

using namespace std;

#define INF 1000000000


bool flag = false;
vl res;
string s;
int n;
ll dfs1(ll m, ll u, ll val);
ll dfs2(ll m, ll u, ll val);
int maior = -1, menor = 11;
ll dfs1(ll m, ll u, ll val){
	if(m == n){
		return 1;
		flag = true;
	}

	for(int i = 1; i < 11; ++i){
		W(i, " ")
		W(s[i], " ")
		W(maior, endl)
		if(s[i] == '1' && i != u && 0 < val + i && val + i < maior){
			if(dfs2(m+1, i, val+i)){
				res[m] = i;
				return 1;
			}
		}
	}

	return 0;

}
ll dfs2(ll m, ll u, ll val){
	if(m == n){
		return 1;
		flag = true;
	}

	for(int i = 1; i < 11; ++i){
		if(s[i] == '1' && i != u && 0 > val - i && val - i > -maior){
			if(dfs1(m+1, i, val - i)){
				res[m] = i;
				return 1;
			}
		}
	}

	return 0;
}

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

    ll a, b;
	cin >> a >> b;

	if(b%a == 0){
		cout << a + b << endl;
	} else{
		cout << b - a << endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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; }
using namespace std;

int main(){
    Init();
    string s; cin >> s;
    ll sum = 0;
    rep(i, s.size()) sum += s[i]-'0';
    (sum%9 == 0) ? Yes() : No();
}

Measured memory_bytes: 3736
import sys
import math
input = lambda: sys.stdin.readline().rstrip()

def main():
    a, b, h, m = map(int, input().split())
    h_deg = math.pi * 2 * ((h / 12) + ((m / 60) / 12))
    m_deg = math.pi * 2 * (m / 60)

    deg = h_deg - m_deg
    print(math.sqrt(a**2 + b**2 - (2 * a * b * math.cos(deg))))

if __name__ == '__main__':
    main()


Measured memory_bytes: 9376
#include <cmath>
#include <ctime>
#include <cstdio>
#include <cassert>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#define debug(...) fprintf(stderr,_VA_ARGS_)

typedef long long LL;
typedef unsigned int uint;
typedef std::vector<int> vi;
typedef unsigned long long uLL;
template<typename T> inline void I(T &x){
	register int ch,k=1;
	while(ch=getchar(),ch<'/')k=(ch=='-' ? -1 : k);x=ch-'0';
	while(ch=getchar(),ch>'/')x=((x+(x<<2))<<1)+ch-'0';x*=k;
}

const int maxn=2e5+7;
int n,m,L;
int sx,sy;
char a[maxn];
char b[maxn];
int main(){
	scanf("%d%d%d%d%d%s%s",&n,&m,&L,&sx,&sy,a+1,b+1);
	{
		int s=1,t=n;
		for(int i=L;i;--i){
			if(b[i]=='U' || b[i]=='D'){
				if(b[i]=='U')
					t=std::min(t+1,n);
				else s=std::max(s-1,1);
			}
			if(a[i]=='U' || a[i]=='D'){
				if(a[i]=='U')++s;
				else --t;
			}
			if(s>t)return!puts("NO");
		}
		if(sx<s || t<sx)
			return!puts("NO");
	}{
		int s=1,t=m;
		for(int i=L;i;--i){
			if(b[i]=='L' || b[i]=='R'){
				if(b[i]=='L')t=std::min(t+1,m);
				else s=std::max(s-1,1);
			}
			if(a[i]=='L' || a[i]=='R'){
				if(a[i]=='L')++s;
				else --t;
			}
			if(s>t)return!puts("NO");
		}
		if(sy<s || t<sy)
			return!puts("NO");
	}puts("YES");
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define fastio() ios_base::sync_with_stdio(false);
using namespace std;
typedef long long ll;
typedef long double ld;


int main(){
	string s; cin >> s;
	bool a = false, b = false;
	for(char c: s){
		if (c == 'A') a = true;
		if (c == 'B') b = true;
	}
	if (a and b) puts("Yes");
	else puts("No");
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using Graph=vector<vector<int>>;
#define MAX 1000000
#define MOD 1000000007
#define INF 100000000000000

int main(){
  int N;
  cin>>N;
  vector<int> a(N);
  int plus=0,minus=0;
  for(int i=0;i<N;i++){
    cin>>a.at(i);
    if(a.at(i)>0){
      plus=max(plus,a.at(i));
    }
    if(a.at(i)<0){
      minus=max(minus,-a.at(i));
    }
  }

  if(plus>minus){
    int k;
    for(int i=0;i<N;i++){
      if(a.at(i)==plus){
        k=i;
      }
    }
    cout<<2*N-2<<endl;
    for(int i=0;i<N;i++){
      if(i==k){
        continue;
      }
      cout<<k+1<<" "<<i+1<<endl;
    }
    for(int i=0;i<N-1;i++){
      cout<<i+1<<" "<<i+2<<endl;
    }
  }else{
    int k;
    for(int i=0;i<N;i++){
      if(a.at(i)==-minus){
        k=i;
      }
    }
    cout<<2*N-2<<endl;
    for(int i=0;i<N;i++){
      if(i==k){
        continue;
      }
      cout<<k+1<<" "<<i+1<<endl;
    }
    for(int i=N-1;i>0;i--){
      cout<<i+1<<" "<<i<<endl;
    }
  }
}


Measured memory_bytes: 256
n=int(input())
a=[int(i) for i in input().split()]

x=a[0]
y=sum(a[1:])
m=abs(x - y)

i=1

while i < n-1:
  x+=a[i]
  y-=a[i]
  m = min(abs(x - y),m)
  i+=1
print(m)



Measured memory_bytes: 24832
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>


int main(){
  int N; cin >> N;
  int a[N]; rep(i,N) cin >> a[i];

  int cnt = 0;
  rep(i,N){
    int A = a[i];
    while (A%2==0){
      A /= 2;
      cnt++;
    }
  }
  cout << cnt << endl;

  // cout << fixed << setprecision(6);
  return 0;
}



Measured memory_bytes: 256
n = gets.to_i
s = gets.chomp

ans = 0
n.times{|i|
  x = s[0...i]
  y = s[i..-1]
  res = (?a..?z).to_a.map{|t|
    !!x.index(t)&&!!y.index(t)
  }.count(true)
  ans = res if ans < res
}

p ans


Measured memory_bytes: 1788
import java.io.*;
import java.math.*;
import java.util.*;

class Main {
    private static final Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        int n = Integer.parseInt(sc.nextLine());
        long[] xs = new long[n];
        long[] ys = new long[n];
        int odd = 0, even = 0;
        for (int i = 0; i < n; i++) {
            String[] xy = sc.nextLine().split(" +");
            xs[i] = Long.parseLong(xy[0]);
            ys[i] = Long.parseLong(xy[1]);
            if ((xs[i] + ys[i]) % 2 == 0)  {
                even++;
                xs[i]--;
            }
            else odd++;
        }

        if (odd * even != 0) {
            System.out.println(-1);
        }
        else {
            System.out.println(even > 0 ? 32 : 31);
            if (even > 0) System.out.print("1 ");
            for (long bit = 1; bit < (1L << 31); bit <<= 1)
                System.out.printf("%d%c", bit, bit == (1 << 30) ? '\n' : ' ');

            for (int i = 0; i < n; i++) {
                long u = xs[i] + ys[i];
                long v = xs[i] - ys[i];

                long maskU = (u + (1 << 31) - 1) >> 1;
                long maskV = (v + (1 << 31) - 1) >> 1;

                long x = 0, y = 0;
                if (even > 0) {
                    System.out.print("R");
                    x++;
                }
                for (long bit = 1; bit < (1L << 31); bit <<= 1) {
                    if ((maskU & bit) == 0 && (maskV & bit) == 0) {
                        System.out.print("L");
                        x -= bit;
                    }
                    else if ((maskU & bit) != 0 && (maskV & bit) != 0) {
                        System.out.print("R");
                        x += bit;
                    }
                    else if ((maskU & bit) == 0 && (maskV & bit) != 0) {
                        System.out.print("D");
                        y -= bit;
                    }
                    else if ((maskU & bit) != 0 && (maskV & bit) == 0) {
                        System.out.print("U");
                        y += bit;
                    }
                }
                System.out.println();
                //System.out.printf("x=%d y=%d\n", x, y);
            }
        }
        sc.close();
    }
}

Measured memory_bytes: 33116
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

int main(void)
{
    IOS
    int x,a,b;
    cin >> x >> a >> b;
    string ans = ( abs(x-a) < abs(x-b) ) ? "A" : "B";
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#ifndef err
#define err(...)(void)0
#endif
using namespace std;
using ll = long long;
using ull = decltype(1ull);
template<class T>int size(T&&a) { return a.size(); }
#define REP(t,a)for(typename make_signed<decltype(a.second)>::type t=a.first,_l##t=a.second;t<_l##t;t++)
#define RREP(t,a)for(typename make_signed<decltype(a.second)>::type t=a.second-1,_l##t=a.first;t>=_l##t;t--)
template<class B>pair<int, B>make_pair(B b) { return{ 0,b }; }
#define rep(t,...)REP(t,make_pair(__VA_ARGS__))
#define rrep(t,...)RREP(t,make_pair(__VA_ARGS__))
#define all(a)begin(a),end(a)
#define rall(a)a.rbegin(),a.rend()

void Calc();
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr); cin.exceptions(istream::failbit | istream::badbit);
  cout << fixed << setprecision(15); Calc(); cout.flush(); return 0;
}
template<class A>void amax(A&a, A b) { a = max(a, b); }
template<class A>void amin(A&a, A b) { a = min(a, b); }
struct Scanner {
  template<class A = string>A Next() { A a; cin >> a; return a; }
  template<class A = int>vector<A>Array(int n) { vector<A>a(n); for (A&i : a) cin >> i; return a; }
  string Line() const { string s; getline(cin, s); return s; }
  template<class A>Scanner&operator,(A&a) { a = Next<A>(); return *this; }
  template<class A>operator A() { return Next<A>(); }
}in;

/*---------------------------------------------------------------------*/

void Calc() {

  int sx, sy, tx, ty;
  in, sx, sy, tx, ty;
  rep(i, sy, ty) cout << ('U') ;
  rep(i, sx, tx) cout << ('R') ;

  rep(i, sy, ty) cout << ('D') ;
  rep(i, sx, tx) cout << ('L') ;

  cout << ('L') ;
  rep(i, sy, ty + 1) cout << ('U');
  rep(i, sx, tx + 1) cout << ('R');
  cout << ('D');

  cout << ('R');
  rep(i, sy, ty + 1) cout << ('D');
  rep(i, sx, tx + 1) cout << ('L');
  cout << ('U')<<endl;


}


Measured memory_bytes: 256
import math
 
N = int(input())
x_list = list(map(int, input().split()))
 
result = 1
if 0 in x_list:
  print(0)
  exit()
for x in x_list:
  result *= x
  if result > 1e18:
    print(-1)
    exit()
print(result)

Measured memory_bytes: 22496
H = input().split()
sdy =0
if int(H[2]) >= int(H[0]):
  sdy = int(H[2])*60 +int(H[3])-int(H[0])*60 -int(H[1]) - int(H[4])
else:
  H[2] = (int(H[2])+24)
  sdy = int(H[2])*60 +int(H[3])-int(H[0])*60 -int(H[1]) - int(H[4])
if int(sdy) < 0:
  sdy = 0
print(sdy)

Measured memory_bytes: 9156
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long

bool kai(string s){
  string t = s;
  reverse(t.begin(),t.end());
  return t == s;
}

signed main(){

  string s; cin >> s;
  if(kai(s) && kai(s.substr(0, s.size()/2))){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

  return 0;
}


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

if abs(n-m) >1:
    print(0)
    exit()

p = 10**9+7
fact =[1,1]
for i in range(2, max(n,m) + 1):
    fact.append((fact[-1] * i) % p)
    
if n ==m:
    res = fact[n]*fact[m]*2

else:
    res = fact[n]*fact[m]

print(res%p)

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

int main(){
  int x,y[99]={1,4,8,9,16,25,27,32,36,49,64,81,100,121,125,128,144,169,196,216,225,243,256,289,324,343,361,400,441,484,512,529,576,625,676,729,784,841,900,961,1000,1024};
  cin>>x;
  fr(i,99) if(x<y[i]){cout<<y[i-1]<<endl;break;}
}

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

using namespace std;

typedef long long ll;
typedef long double ld;

template<typename t>
void myMemset(t *arr, t val, unsigned int size) {
	size /= sizeof(t);
	t *ptr = arr;
	while (size--) {
		*ptr = val;
		ptr++;
	}
}

const int mod = 1e9 + 7;

int add(int a, int b) {
	return (a + b) % mod;
}

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

int fastpow(int b, int p) {
	if (!p)
		return 1;
	int ret = fastpow(b, p / 2);
	ret = mul(ret, ret);
	if (p & 1)
		ret = mul(ret, b);
	return ret;
}

const int N = 2e5 + 5;
vector<int> g[N];
vector<int> szs[N];
int n, sz[N];

void dfs(int node, int parent = -1) {
	sz[node] = 1;
	for (auto &neg : g[node])
		if (neg != parent)
			dfs(neg, node), sz[node] += sz[neg], szs[node].push_back(sz[neg]);
	if (n - sz[node] >= 1)
		szs[node].push_back(n - sz[node]);
}

int dp[N];
int dp2[N][3];
int val[N];
int mark[N][3], half;

int solve2(int sz) {
	if (sz == 0)
		return 0;
	int &ans = dp[sz];
	if (ans != -1)
		return ans;
	return ans = add(half, mul(half, solve2(sz - 1)));
}

int solve(int node, int idx, int cnt) {
	if (idx == szs[node].size())
		return cnt == 2;
	int &ans = dp2[idx][cnt];
	if (mark[idx][cnt] == node)
		return ans;
	mark[idx][cnt] = node;
	return ans = add(mul(solve(node, idx + 1, cnt), val[szs[node][idx]])
			, mul(solve(node, idx + 1, min(cnt + 1, 2)), solve2(szs[node][idx])));
}

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	half = fastpow(2, mod - 2);
	val[0] = 1;
	for (int i = 1; i < N; i++)
		val[i] = mul(val[i - 1], half);
	cin >> n;
	for (int i = 0; i < n - 1; i++) {
		int u, v;
		cin >> u >> v;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	dfs(1);
	int ans = 0;
	memset(dp, -1, sizeof dp);
	for (int i = 1; i <= n; i++)
		ans = add(ans, mul(half, solve(i, 0, 0)));
	cout << ans;
	return 0;
}



Measured memory_bytes: 46872
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		int d = scan.nextInt();

		int area1 = a * b;
		int area2 = c * d;
		if (area1 >= area2) {
			System.out.println(area1);
		} else {
			System.out.println(area2);
		}

	}

}


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

using namespace std;

vector<long long> a;

vector<vector<long long>> memo;

long long minimize(int start, int end) {
    if(start + 1 >= end)
        return 0;
    
    if(memo[start][end] != -1)
        return memo[start][end];

    memo[start][end] = LLONG_MAX;
    for(int i = start + 1; i < end; i++)
        memo[start][end] = min( memo[start][end], minimize( start, i) + minimize( i, end));

    for(int i = start; i < end; i++)
        memo[start][end] += a[i];

    return memo[start][end];
}

int main() {

    int n;
    cin >> n;
    
    a = vector<long long>(n);
    memo = vector<vector<long long>>( n + 1, vector<long long>(n + 1, -1));


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

    cout << minimize( 0, n) << endl;
    
    return 0;
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define ll long long
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define vi vector<int>
#define INF (1<<30)-1
using namespace std;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }

int main(){
  cin.tie(0), ios::sync_with_stdio(false);
  int n; cin >> n;
  vector<ll> cnt(n);
  ll sum = 0;
  rep(i,n){
    int a,b; cin >> a >> b;
    cnt[i] = a+b;
    sum += b;
  }
  sort(all(cnt),greater<int>());
  ll first = 0;
  rep(i,n) if(i % 2 == 0) first += cnt[i];
  cout << first-sum;
  cout << "\n";
  return 0;
}


Measured memory_bytes: 3980
package main

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

const N = 210
var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		log.Fatal(err)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)

	n := nextInt()
	var x [N]int

	for i := 0; i < n; i++ {
		x[i] = nextInt()
	}

	//fmt.Println(x)

	loopCount := 0
	for {
		// 奇数があるフラグ
		existOdd := false

		for i := 0; i < N; i++ {
			if x[i] % 2 != 0 {
				existOdd = true
			}
		}

		if existOdd {
			break
		}

		// 割ったものを詰める
		for i := 0; i < N; i++ {
			x[i] = x[i] / 2
		}
		loopCount++
	}

	fmt.Println(loopCount)
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define s size
#define pb push_back
#define in insert
#define PI 3.1415926535897932384626433832795
#define MOD 100000007
#define F first
#define S second
#define aLL(str) (str).begin(), (str).end()
#define IOS                  \
	ios::sync_with_stdio(0); \
	cin.tie(0);              \
	cout.tie(0)
#define ll long long
typedef vector<ll> vl;
typedef map<ll,ll> ml;
typedef vector<string> vs;
typedef vector<vector<int>> vvi;
int main()
{IOS;
ll t;
//cin>>t;
t=1;
while(t--)
{ll n,i,q,j;
cin>>n;
vl v(n,0);
unordered_map<int,int>Mp;
ll su=0;
for(i=0;i<n;i++)
cin>>v[i],su+=v[i],Mp[v[i]]++;
cin>>q;
ll a,b;
while(q--){
	cin>>a>>b;
	su+=Mp[a]*(b-a);
	Mp[b]+=Mp[a];
	Mp.erase(a);
	cout<<su<<endl;
}
}
return 0;}


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

int main(){
	int k,n;
	cin >> k >> n;
	vector<int> a(n);
	for(int i=0; i < n; i++){
		cin >> a[i];
	}
	int sum=0,max=a[0];
	for(int i = 0; i < n; i++){
		if(i == n-1){
			int tmp = a[0] + k - a[i];
			sum += tmp;
			if(tmp > max)
				max = tmp;
		}else{
			int tmp = a[i+1] - a[i];
			sum += tmp;
			if(tmp > max)
				max = tmp;
		}
	}
	cout << sum - max << endl;
	return 0;
}


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

#define TEST 0
#if TEST
FILE* in = freopen("./Q.txt", "r", stdin);
FILE* out = freopen("./A.txt", "w",stdout);
#endif

#define MAXN 300
#define MAXINPUT 1000001

vector<int> seq;
int normalAns[MAXINPUT];
int oddAns[MAXINPUT];

int main(int argc, const char * argv[]) {
    for(int i = 0; i < MAXN; i++){
        seq.push_back(i*(i + 1)*(i + 2)/6);
    }
    
    for(int i = 0; i < MAXINPUT; i++){
        normalAns[i] = oddAns[i] = i;
        for(int j = 0; i - seq[j] >= 0; j++){
            normalAns[i] = min(normalAns[i], normalAns[i-seq[j]] + 1);
            if(seq[j]&1) oddAns[i] = min(oddAns[i], oddAns[i-seq[j]] + 1);
        }
    }
    
    while(1){
        int n; cin >> n;
        if(!n) break;
        
        cout << normalAns[n] << " " << oddAns[n] << endl;
    }
    
#if TEST
    fclose(in);
    fclose(out);
#endif
}

Measured memory_bytes: 9032
#include <bits/stdc++.h>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
#define sz(s) (int)(s.size())
#define vecprint(v) rep(i,0,v.size()-1)cout << v[i] << " ";cout << endl;
#define arrprint(v,n) rep(i,0,n-1)cout << v[i] << " ";cout << endl;
#define matprint(v,n,m) rep(i,0,n-1){rep(j,0,m-1){cout << v[i][j] << " ";}cout << endl;}
using namespace std;
const int mod=1000000007;
const int INF=1001001001;
typedef long long ll;
typedef pair<int,int> P;



int main(){
    int n,x,y;
    cin >> n >> x >> y;
    x--;y--;
    // visited.resize(n);
    vector<int> to[n];

    rep(i,0,n-2){
        to[i].push_back(i+1);
        to[i+1].push_back(i);
    }
    to[x].push_back(y);
    to[y].push_back(x);
    vector<int> dist(n+2);
    rep(i,0,n-1){
        vector<bool> visited(n);
        queue<P> q;
        q.push(make_pair(i,0));
        visited[i] = true;
        while(!q.empty()){
            P now = q.front();q.pop();
            dist[now.second]++;
            for(auto child : to[now.first]){
                if(visited[child])continue;
                q.push(make_pair(child,now.second+1));
                visited[child] = true;
            }
        }
    }
    rep(i,1,n-1){
        cout << dist[i]/2 << endl;
    }


    // cout << ans << endl;
//  printf("%.10f\n",ans);

    return 0;
}

Measured memory_bytes: 384
#include<iostream>

using namespace std;


int main(){
    int color[101] = {};
    int i,x;
    int ans = 0;

    for( i = 0 ; i < 3 ; i++){
        cin >> x;
        color[x] = 1;
    }


    for( i = 0; i  < 101 ; i++ ){
        if(color[i] != 0) ans++ ;
    }

    cout << ans << endl;
    return 0;

}


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

void input()
{ 
    #ifndef ONLINE_JUDGE 
    freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
    #endif
}
#define endl "\n"
#define ll long long int
#define vll vector<ll>
#define pb push_back
#define pll pair<ll,ll>
#define mp make_pair
#define ff first
#define ss second
#define tll tuple<ll,ll,ll>
#define mt make_tuple
#define INF LONG_LONG_MAX
#define mod 1000000007
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a;i>=b;i--)
#define cases ll t; cin>>t; while(t--)
#define array(a,n) ll a[n]; rep(i,0,n) cin>>a[i];
#define vector(a,n) vll a(n); rep(i,0,n) cin>>a[i];
#define sortall(a) sort(a.begin(),a.end())
#define printall(a,n) rep(i,0,n) cout<<a[i]<<" "; cout<<endl;

// --------------- My Template End --------------- //


int main()
{
    ios_base::sync_with_stdio(0); 
    cin.tie(0); cout.tie(0);
  // input();
   int n,k;
   cin>>n>>k;
   vector(a,n);
   sortall(a);
   vector<bool>dp(k+1);

    rep(i,1,k+1)
    {
        rep(j,0,n)
        {
            if(a[j]<=i&&!dp[i-a[j]])
            {
                dp[i]=true;
            }
        }
    }
    cout<<(dp[k]?"First":"Second")<<endl;
}  

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

def getNum(s):
    if int(s) >N:
        return 0
    ret = 0
    if all(s.count(c) > 0 for c in '357'):
        ret = 1
    for c in '357':
        ret += getNum(s+c)
    return(ret)

print(getNum('0'))

Measured memory_bytes: 53852
#include<algorithm>
#include<cmath>
#include<deque>
#include<iomanip>
#include<iostream>
#include<list>
#include<numeric> //xとyの最大公約数は__gcd(x,y),xとyの最小公倍数は(x*y)/__gcd
#include<string>
#include<vector>

#include<map>
#include<set>
#define rep0_n(i,n) for(int i=0; i<n; i++)
#define rep1_n(i, n) for(int i=1; i<n+1; i++)
#define reps_n(i, s, n) for(int i=s; i<n; i++)
typedef long long ll;
using namespace std;

int main(){
 double w,h,x,y;
  cin >> w >> h >> x >> y;
  cout << setprecision(7) << w*h/2.0 << " ";
  if( w/2 == x and h/2 == y ){
    cout << 1;
  }else{
    cout << 0;
  }
  return 0;
}


Measured memory_bytes: 256
n = int(input())
l = list(map(int,input().split()))
a = []
for i in range(n):
  for j in range(len(l)-1,-1,-1):
    if j+1 == l[j]:
      a.append(j+1)
      del l[j]
      break
if len(a) == n:
  print(*a[::-1],sep='\n')
else:
  print(-1)

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

ll INF = 1e18;
ll MOD = 1e9+7;



int main(){
    ll N, K; cin >> N >> K;
    vector<ll> P(N); for(int i = 0; i < N; i++) cin >> P[i];
    vector<double> E(1001);
    for(int i = 1; i < 1001; i++){
        E[i] = (double)E[i-1] + (double)i;
    }
    for(int i = 1; i < 1001; i++) E[i] /= (double) i;
    long double ans = 0.0;
    
    int id = 0;
    long double p = 0.0;
    for(int i = 0; i < K; i++) p += E[P[i]];
    ans = max(ans, p);
    for(int i = K; i < N; i++){
        p += E[P[i]];
        p -= E[P[i-K]];
        ans = max(ans, p);
    }

    
    cout << setprecision(10) <<  ans << endl;
}

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

int main() {
  string s; cin >> s;
  bool f = true;
  for ( int i = s.length()-2; i >= 0; i-- ) {
    f = true;
    if ( i % 2 == 1 ) {
      for ( int j = 0; j < (i+1) /2; j++ ) {
	if ( s[j] != s[j+ (i+1)/2] ) f = false;

      }
      	if(f) {
	  cout << i+1 <<endl;
	  return 0;
	}
    }
  }
  return 0;
}


Measured memory_bytes: 256
n,m = map(int,input().split())
a = [int(i) for i in input().split()]
bc = [[int(i) for i in input().split()] for i in range(m)]
a.sort()
bc.sort(key=lambda x:x[1],reverse=True)
d = []
cnt1 = 0
cnt2 = 0
x = 0

for lst in bc:
    cnt2 = 0
    while cnt1 < n and cnt2 < lst[0]:
        d.append(lst[1])
        cnt1 += 1
        cnt2 += 1
    if cnt1 == n:
        break

for i in range(len(d)):
    if d[i] - a[i] < 0:
        x = i
        break
else:
    x += i+1

print(sum(d[:x]+a[x:]))

Measured memory_bytes: 27512
def main():
    n = int(input())

    tmp = n % 10
    if tmp == 3:
        ans = 'bon'
    elif tmp in [0, 1, 6, 8]:
        ans = 'pon'
    else:
        ans = 'hon'
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9148
#include<bits/stdc++.h>
using namespace std;
    static const double pi = 3.141592653589793;
 typedef pair<int64_t,int64_t> P;
#define rep(i, n) for (int i = 0; i < (n); i++)
 #define all(v) (v).begin(),(v).end()
 using ll = long long;
using Graph = vector<vector<int>>;
const int MAX = 510000;
const int MOD = 1000000007;
 
 
 
int main(){
string s;
  cin>>s;
  ll n=s.size();
  ll dp[n+1];
  rep(i,n+1) dp[i]=0;
  
  for(ll i=1;i<n+1;i++)
  {
  if(s[i-1]=='<') dp[i]=dp[i-1]+1;
  
  }
    for(ll i=n-1;i>=0;i--)
  {
  if(s[i]=='>') dp[i]=max(dp[i],dp[i+1]+1);
  
  }
  
  ll ans=0;
  rep(i,n+1) ans=ans+dp[i];
  
  cout<<ans;
  }


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

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

ll getatpos(ll off, ll flen) {
    if (off < flen/2)
        return 0;
    off -= flen/2;
    return (off+1)%2;
}

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

    ll a, b;
    cin >> a >> b;
    
    ll flen = 2;
    vi bits;
    while (true) {
        ll aoff = (a-1) % flen;
        ll boff = b % flen;

        ll aval = a>=0 ? getatpos(aoff, flen) : 0;
        ll bval = getatpos(boff, flen);
        
        if (flen == 2)
            bits.push_back((b-a+1+a%2)/2%2);
        else {
            bits.push_back(aval ^ bval);
        }
        if (a < flen && b < flen)
            break;
        flen *= 2;
    }
    ll res = 0;
    while (!bits.empty()) {
        res <<= 1;
        res |= bits.back();
        bits.pop_back();
    }
    cout << res << "\n";
}


Measured memory_bytes: 256
import std.stdio;
import std.algorithm;
import std.string;
import std.range;
import std.array;
import std.conv;
import std.complex;
import std.math;
import std.ascii;
import std.bigint;
import std.container;
import std.typecons;

auto readInts() {
	return array(map!(to!int)(readln().strip().split()));
}
auto readInt() {
	return readInts()[0];
}
auto readLongs() {
	return array(map!(to!long)(readln().strip().split()));
}
auto readLong() {
	return readLongs()[0];
}

const real eps = 1e-10;

void main(){
	while(true) {
		auto nm = readInts();
		auto n = nm[0];
		auto m = nm[1];
		if(n == 0 && m == 0) {
			return;
		}
		long[][] dp;
		for(int i; i < n; ++i) {
			dp ~= readLongs();
		}
		dp.sort!((a,b) => a[1] > b[1]); 
		while(m > 0 && !dp.empty) {
			auto l = dp[0][0];
			if(l <= m) {
				dp = dp[1..$];
				m -= l;
			} else {
				dp[0][0] -= m;
				m = 0;
			}
		}
		writeln(reduce!("a+b")(0L,dp.map!(a => a[0]*a[1])));
	}
}

Measured memory_bytes: 9736
#include <bits/stdc++.h>
using namespace std;
using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;
using msi=map<string,int>;
using mii=map<int,int>;
using pii=pair<int,int>;
using vlai=valarray<int>;
using ll=long long;
#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

using vd=vector<double>;
using vvd=vector<vd>;


int main(){
    int n,m;
    vi tg(2);
    cin>>n>>tg[0]>>tg[1]>>m;
    vector<vvi> line(2,vvi(2,vi(n,0)));  //0:usagi,1:neko.   0:tate,1:yoko
    vvi naname(2,vi(2,0));
    vector<vector<pii>> card(2,vector<pii>(1000001,mp(-1,-1)));
    rep(pl,2)rep(i,n)rep(j,n){
        int num;cin>>num;
        card[pl][num]=mp(i,j);
    }
    vi bingo(2,0);
    int stat=0;
    rep(lp,m){
        int num;cin>>num;
        stat=0;
        rep(pl,2){
            int y=card[pl][num].fs;
            int x=card[pl][num].sc;
            if(y==-1)continue;
            line[pl][0][x]++;
            line[pl][1][y]++;
            if(x==y){naname[pl][0]++; if(naname[pl][0]==n)bingo[pl]++;}
            if(x+y+1==n){naname[pl][1]++; if(naname[pl][1]==n)bingo[pl]++;}
            if(line[pl][0][x]==n)bingo[pl]++;
            if(line[pl][1][y]==n)bingo[pl]++;
            if(n==1)bingo[pl]=min(bingo[pl],1);
            if(bingo[pl]>=tg[pl])stat+=pl+1;
            //cout<<pl<<" : "<<line[pl][0][x]<<","<<line[pl][1][y]<<","<<naname[pl][0]<<","<<naname[pl][1]<<endl;
        }
        //cout<<bingo[0]<<","<<bingo[1]<<endl;
        if(stat!=0){
            break;
        }
    }
    if(stat==2)cout<<"NEKO"<<endl;
    else if(stat==1)cout<<"USAGI"<<endl;
    else cout<<"DRAW"<<endl;

	return 0;
}



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

int main() {
    int n;
    cin>>n;
    int ans=0;
    for(int j=1;j<=n;j+=2){
        int count=0;
        for(int i=1;i<=j;i++){
            if(j%i==0) count++;
        }
        if(count==8) ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
/* HARE KRSNA HARE KRSNA KRSNA KRSNA HARE HARE
    HARE RAMA HARE RAMA RAMA RAMA HARE HARE  */

#include <bits/stdc++.h>
using namespace std;

#define nl "\n"
#define ff first
#define ss second
#define pp pop_back
#define pf pop_front
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define b_s binary_search
#define all(x) x.begin(),x.end()
#define test ll t; cin>>t; while(t--)
#define loop(i,s,n) for(ll i=s;i<n;i++)
#define rloop(i,s,n) for(ll i=s;i>=n;i--)
#define fill(a,value) memset(a,value,sizeof(a))

#define debug2(a)  for(auto x : a)  cout<<x<<" ";  cout<<nl;
#define debug4(a)  for(auto x : a)  cout<<x.ff<<" "<<x.ss<<nl;
#define debug1(a,n) loop(i,0,n)  cout<<a[i]<<" ";  cout<<nl;
#define debug3(a,n,m)  loop(i,0,n){ loop(j,0,m)	cout<<a[i][j]<<" ";	cout<<nl; }

typedef long long ll;
typedef long double ld;

typedef stack<ll> sll;
typedef queue<ll> qll;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<string> vs;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef pair<ll, pll> ppll;
typedef vector<vector<ll>> vvll;
typedef priority_queue<ll> pqll;

const ll mod = 1000000007;	//998244353;
const ld pi =  acos((ld) - 1);	//3.1415926535;

ll num_generator()		{   return rand() % 1000;	}
void array_generator(ll a[], ll n)		{   loop(i, 0, n)	a[i] = rand() % 100;	}

void solve()
{
	ll n;	cin >> n;
	cout << (ll)ceil((ld)n / 1000) * 1000 - n;
}

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

#ifndef ONLINE_JUDGE
	freopen("input1.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	// test
	solve();
	return 0;
}

Measured memory_bytes: 3608
H,W,K = map(int,input().split())

import numpy as np 

C = np.array([[0 if i=="." else 1 for i in input()] for _ in range(H)])
np.where(C==".",0,1)

from itertools import combinations

counter= 0
for n in range(H):
    for conb_H in combinations(range(H), n):
        for i in range(W):
            for conb_W in combinations(range(W), i):
                D = C.copy()
                
                D[list(conb_H),:]=0
                D[:,list(conb_W)]=0
                
                if np.count_nonzero(D==1)==K:
                    counter += 1

print(counter)

Measured memory_bytes: 27404