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

#define mod 1000000007
typedef int integer;
#define int long long
using namespace std;

const int N = 100005;

integer main() {
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    string s;
    cin >> s;
    int ans = 0;
    for (int i = 2; i < n; i++){
        if (s.substr(i - 2, 3) == "ABC") ans++;
    }
    cout << ans;

}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

  int L[101];
  int longest = 0;
  int idx = 0;
  for (int i = 0; i < N; i++) {
    cin >> L[i];
    if (L[i] > longest) {
      longest = L[i];
      idx = i;
    }
  }

  int sum = 0;
  for (int i = 0; i < N; i++) {
    if (i == idx)
      continue;
    sum += L[i];
  }

  if (sum > L[idx])
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}

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

using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, __VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

#define MOD 1000000007
#define INF 1000000000
#define MAX_N 2010

int N, X, Y;
int A[MAX_N];

// 0: X 1: Y
// 次が i さんのターンで、相手が持っているのが山札の上から j 番目のカードの場合
// 0 は初期手札とする
int dfs(int i, int j) {
    int ret = 0;
    if(i == 0) {
        // X さんの番
        if(j == N - 1) {
            ret = abs(A[N] - A[N-1]);
        } else {
            ret = abs(A[N] - A[j]);
            for(int k = j + 1; k < N; ++k) {
                ret = max(ret, dfs(1, k));
            }
        }
    } else {
        // Y さんの番
        if(j == N - 1) {
            ret = abs(A[N] - A[N-1]);
        } else {
            ret = abs(A[N] - A[j]);
            for(int k = j + 1; k < N; ++k) {
                ret = min(ret, dfs(0, k));
            }
        }
    }
    return ret;
}

int dp[2][MAX_N];

int main()
{
    ZERO(dp);

    cin >> N >> X >> Y;

    A[0] = Y;
    for(int i = 1; i <= N; ++i) {
        cin >> A[i];
    }

    //printf("%d\n", dfs(0, 0));

    dp[0][N-1] = abs(A[N] - A[N-1]);
    dp[1][N-1] = abs(A[N] - A[N-1]);
    for(int j = N - 2; j >= 0; --j) {
        int cand = abs(A[N] - A[j]);
        for(int i = 0; i < 2; ++i) {
            if(j == 0 && i == 1) { continue; }
            for(int k = j + 1; k < N; ++k) {
                if(i == 0) {
                    cand = max(cand, dp[1][k]);
                } else {
                    cand = min(cand, dp[0][k]);
                }
            }
            dp[i][j] = cand;
        }
    }
    printf("%d\n", dp[0][0]);
    return 0;
}


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

int main()
{
  int i, n, q, *S, cnt = 0, num, left, right, mid;

  scanf("%d", &n);

  /* n個の整数を含む数列Sを格納する配列を動的に確保 */
  S = (int *)malloc( sizeof(int) * n );

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

  scanf("%d", &q);

  for( i = 0; i<q; i++ )
    {
      /* Tの数字がSに含まれる個数を数える */
      scanf("%d", &num);
      left = 0;
      right = n;

      while( left < right )
	{
	  mid = ( left + right )/2;

	  if( S[mid] == num )
	    {
	      cnt++;
	      break;
	    }
	  else if( S[mid] < num )
	    left = mid+1;
	  else
	    right = mid;
	}
    }

  printf("%d\n", cnt);

  return 0;
}



Measured memory_bytes: 2108
# Your code here!
my @coms = ('AC', 'WA', 'TLE', 'RE');
my @vals = (0, 0, 0, 0);
my $n = <>;
for( $i = 0; $i < $n; $i ++ )
{
    my $tm = <>;
    chomp($tm);
    for( $j = 0; $j < 4; $j ++ )
    {
        if( $coms[$j] eq $tm )
        {
            $vals[$j] ++;
            
        }
    }
    
}

for( $j = 0; $j < 4; $j ++ )
{
    print("$coms[$j] x $vals[$j]\n");
}

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

#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 MP make_pair
#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()
#define DB(x) cerr << #x << " = " << x << endl
#define DB2(x, y)                                                              \
    cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n";
#define DEBUG                                                                  \
    int x12345;                                                                \
    cin >> x12345;
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 long long MOD = 1e9 + 7;
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;
}

///////////////////////////////////////////////
/// 🍈( '-' 🍈 |AC|
int main() {
    ll N; cin >> N;
    ll ans = 0;
    vector<ll> A(N+2);
    for (size_t i = 1; i <= N; i++) {
        cin >> A[i];
    }

    map<ll,ll> F;
    F[A[1] + 1]++;
    for (size_t i = 2 ; i <= N ; i++) {
        ll req = i - A[i];
        ans += F[req];
        F[A[i] + i]++;
    }

    cout << ans << endl;
}

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

using namespace std;

template <class T>inline T updmax(T& a, T b) {return a = max(a, b);}
template <class T>inline T updmin(T& a, T b) {return a = min(a, b);}

class Solution {
public:
	void solve() {
		int n;
		cin >> n;
		vector<int> a(n, 0);
		for(int i=0; i<n; i++)cin >> a[i];
		vector<int> ans(n, 0);
		for(int i=0; i < n; i++){
			ans[a[i]-1] = i;
		}
		for(int i=0; i<n; i++)cout << ans[i] +1 << " ";
		cout << "\n";
		
		return;
	};
};

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	Solution solution;
	solution.solve();
	return 0;
}

Measured memory_bytes: 1664
import java.util.Scanner;
import java.util.HashMap;

public class Main {
    public static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) throws Exception {
        long n = sc.nextLong();
        int res = 0;
        while (true) {
            if(n == 2 || n == 3) {
                res++;
                break;
            }
            n = (n + 2)/3;
            res++;
        }
        
        System.out.println(res);
    }
}

Measured memory_bytes: 26324
# 二次元累積和
# 写経
# https://ikatakos.com/pot/programming_algorithm/contest_history/atcoder/2017/1014_abc075

from collections import namedtuple
from operator import attrgetter

Coordinates = namedtuple('Coordinates', ('ind', 'x', 'y'))

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

e = []
for ind in range(n):
    x, y = map(int, input().split())
    e.append(Coordinates(ind=ind, x=x, y=y))
x_asc = sorted(e, key=attrgetter('x'))  # x昇順
y_asc = sorted(e, key=attrgetter('y'))  # y昇順

# print(x_asc)
# print(y_asc)

tbl = [[0] * (n + 1) for _ in range(n + 1)]
for yi, py in enumerate(y_asc, 1):
    for xi, px in enumerate(x_asc, 1):
        tbl[xi][yi] = tbl[xi - 1][yi] + tbl[xi][yi - 1] - tbl[xi - 1][yi - 1] + (1 if py == px else 0)

ans = float('inf')

for left in range(1, n - (k - 1) + 1):
    for top in range(1, n - (k - 1) + 1):
        for right in range(left + k - 1, n + 1):
            for bottom in range(top + k - 1, n + 1):
                if tbl[right][bottom] - tbl[left - 1][bottom] - tbl[right][top - 1] + tbl[left - 1][top - 1] >= k:
                    ans = min(ans, (y_asc[bottom - 1].y - y_asc[top - 1].y) * (x_asc[right - 1].x - x_asc[left - 1].x))
print(ans)


Measured memory_bytes: 45032
#![allow(unused_macros)]
#![allow(dead_code)]
#![allow(unused_imports)]

use text_io::*;

const U_INF: usize = 1 << 60;
const I_INF: isize = 1 << 60;

fn main() {
    let n: usize = read!();
    let m: usize = read!();
    let k: usize = read!();
    let mut a = Vec::with_capacity(n);
    let mut b = Vec::with_capacity(m);

    for _ in 0..n {
        let ai: usize = read!();
        a.push(ai);
    }

    for _ in 0..m {
        let bi: usize = read!();
        b.push(bi);
    }

    for i in 1..a.len() {
        a[i] += a[i - 1];
    }

    for i in 1..b.len() {
        b[i] += b[i - 1];
    }

    let mut ans = -I_INF;

    for i in 0..=a.len() {
        let sum = if i == 0 { 0 } else { a[i - 1] };
        if k < sum {
            ans = (ans).max(0);
        } else {
            let over = k - sum;
            let j = b.lower_bound(|m| *m > over);
            ans = (ans).max((i + j) as isize);
        }
    }

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

trait BinarySearch<T> {
    fn lower_bound<F>(&self, f: F) -> usize
    where
        F: Fn(&T) -> bool;
}

impl<T> BinarySearch<T> for [T] {
    fn lower_bound<F>(&self, f: F) -> usize
    where
        F: Fn(&T) -> bool,
    {
        let mut left: isize = -1;
        let mut right = self.len() as isize;

        while right - left > 1 {
            let mid = (left + right) / 2;
            if f(&self[mid as usize]) {
                right = mid;
            } else {
                left = mid;
            }
        }

        right as usize
    }
}


Measured memory_bytes: 5164
#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 rFORq(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)
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector < VI > VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
////////////////////////////////////////////////////////////////////
int main(){
    int n;
    SCD(n);
    getchar();

    map<char,int> c[51];

    REP(i,n){
        string S; cin >> S;
        REP(j,S.length()){
            c[i][S[j]]++;
        }
    }

    for( char a = 'a' ; a <= 'z' ; a++) {
        int m = 1000;
        REP(i,n){
            m = min(c[i][a],m);
        }
        
        REP(k,m){
            cout << a;
        }
    }

    cout << "\n";
    
}

Measured memory_bytes: 256
N=int(input())
edge=[list(map(int,input().split())) for i in range(N-1)]
inf=10**20
c=[[] for i in range(N)]
for i,j in edge:
    c[i-1].append(j-1)
    c[j-1].append(i-1)
d=[0]+[inf]*(N-1)
v=[0]*N
import sys
sys.setrecursionlimit(10**6)
def dfs(p,v,d):
    for n in c[p]:
        if v[n]==0:
            d[n]=min(d[n],d[p]+1)
            v[n]=1
            dfs(n,v,d)
dfs(0,v,d)
d2=[inf]*(N-1)+[0]
v=[0]*N
dfs(N-1,v,d2)
c=0
for i,j in zip(d,d2):
    c=c+1 if i<=j else c-1
print(['Snuke','Fennec'][c>0])

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

using namespace std;

double maxvolume(double s) 
{ 
    double length = s / 3; 
    s -= length; 
    double breadth = s / 2; 
    double height = s - breadth; 
    return length * breadth * height; 
} 
int main() 
{ 
    double n;   cin >> n;
    cout << fixed << setprecision(7) << maxvolume(n);
} 

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

int main() {
    int N;
    vector<vector<int>> bingo(3, vector<int>(3));
    rep(i, 3) rep(j, 3) cin >> bingo.at(i).at(j);
    vector<vector<bool>> isCount(3, vector<bool>(3, false));
    cin >> N;
    vector<int> b(N);
    rep(i, N) cin >> b.at(i);
    rep(i, 3) rep(j, 3) {
        rep(k, N) {
            if(bingo.at(i).at(j) == b.at(k)) {
                isCount.at(i).at(j) = true;
            }
        }
    }
    rep(i, 3) {
        if(isCount.at(i).at(0) && isCount.at(i).at(1) && isCount.at(i).at(2)) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    rep(i, 3) {
        if(isCount.at(0).at(i) && isCount.at(1).at(i) && isCount.at(2).at(i)) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    if(isCount.at(0).at(0) && isCount.at(1).at(1) && isCount.at(2).at(2)) {
        cout << "Yes" << endl;
        return 0;
    }
    if(isCount.at(0).at(2) && isCount.at(1).at(1) && isCount.at(2).at(0)) {
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
/**
 *    author:  tourist
 *    created: 02.01.2020 17:44:53       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long a, b;
  cin >> a >> b;
  cout << (abs(a - b) <= 1 ? "Brown" : "Alice") << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long int
#define pb push_back
#define fi first
#define se second
#define ld long double
#define vi vector<vector<ll> >
using namespace std;
const int MOD=1000000007;
const int MOD2=15000007;
const ll MAX=9187201950435737471;
const int N=100005;
const int INF=1e17;
const long double PI=acos(-1);

vector<pair<int,int> >v[N];
int x[N];
bool vis[N];

void dfs(int node,int par,int dis){
    vis[node]=1;
    int y=node;
    if(dis%2==0){
        x[y]=x[par];
    }
    else {
        x[y]=1-x[par];
    }
    for(int i=0;i<v[y].size();i++){
        if(vis[v[node][i].fi])continue;
        dfs(v[node][i].fi,node,v[y][i].se);
    }
}

void solve(int T){
    int n;
    cin>>n;
    for(int i=1;i<n;i++){
        int a,b,c;
        cin>>a>>b>>c;
        v[a].pb({b,c});
        v[b].pb({a,c});
    }
    x[0]=1;
    dfs(1,0,0);
    for(int i=1;i<=n;i++){
        cout<<x[i]<<"\n";
    }
}

int main() {
    fastio
    int T=1;
    //cin>>T;
    for(int i=1;i<=T;i++){
        solve(i);
        //if(i<T)cout<<"\n";
    }
    return 0;
}





Measured memory_bytes: 11660
# 縦 H ピクセル、横 W ピクセルの画像があります。全てのピクセルは . または * で表されるものとします。
# 上から i 番目、左から j 番目のピクセルを表す文字を Ci,j で表します。
# この画像を 2 倍縦長にした画像を出力してください。
# すなわち、縦 2H ピクセル、横 W ピクセルの画像であって、上から i 番目、左から j 番目のピクセルは、
# C(i+1)/2,j (ただし、割り算は切り捨て)と等しい画像を出力してください。

hw = gets.chomp.split
h = hw[0].to_i

image = Array.new
h.times do
    input = gets
    image << input
end

h.times do |i|
    2.times do
        puts image[i]
    end
end

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

typedef long long int   ll;
#define int             ll
#define PI              3.1415926535897932384626433832795

#define pb              push_back
#define rep0            for(int i=0;i<n;i++)
#define rep1            for(int i=1;i<=n;i++)
#define inputar0(ar)    for(int i=0;i<n;i++)cin>>ar[i]
#define inputar1(ar)    for(int i=1;i<=n;i++)cin>>ar[i]

#define hell            freopen("input.txt","r", stdin);freopen("output.txt", "w", stdout);freopen("error.txt", "w",stderr);
#define fastasF_boi()   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl            "\n"
//#define cerr            if(false)cerr

int mod=1000000007;
int maxn=200001;
int binpow(int a,int b,int mod){int res=1;while(b>0){if(b%2){res=(res*a)%mod;b--;}a=(a*a)%mod;b/=2;}return res%mod;}
int binpow(int a,int b){int res=1;while(b>0){if(b%2){res=(res*a);b--;}a=(a*a);b/=2;}return res;}
bool isPrime(int n){if(n==1)return false;for(int i=2;i*i<=n;i++){if(n%i==0)return false;}return true;}
int mulmod(int a,int b){return ((a%mod)*(b%mod))%mod;}
int addmod(int a,int b){return (((a%mod)+(b%mod))+mod)%mod;}

void solve(){
    int n;cin>>n;
    if(n>=30) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

signed main(){
//    hell;

    fastasF_boi();
    int t=1;
//    cin>>t;
    for(int tt=1;tt<=t;tt++){
        solve();
    }
}



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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod =(1e9)+7;
using P = pair<ll,ll>;

int main(){
    ll n,m;cin>>n>>m;
    vector<P>card;
    for (int i = 0; i < n; ++i) {
        ll a;cin >>a;
        card.push_back({a,1});
    }
    for (int j = 0; j < m; ++j) {
        ll b,c;cin >>b>>c;
        card.push_back({c,b});
    }
    sort(all(card));
    reverse(all(card));
    ll cnt=0;
    ll ans=0;
    for(auto p:card){
        if(cnt+p.second<=n){
            ans+=p.first*p.second;
            cnt+=p.second;
        }
        else if(cnt>n){
            break;
        } else{
            ans+=p.first*(n-cnt);
            cnt=n;
        }
    }
    cout <<ans<<endl;
    return 0;
}


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

int main() {
  long long n, k;
  long long x = 0;
  long long sum = 0;
  cin >> n >> k;
  while (n >= pow(k, x)) {
    x++;
  }
  cout << x << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cctype>
 
using namespace std;
int main() {
    char ch;
    int cnt[26] = {};
 
    while (cin >> ch) {
        ch = tolower(ch);
        if (isalpha(ch)) {
            cnt[ch - 'a']++;
        }
    }
 
    for (int i = 0; i < 26; i++) {
        printf("%c : %d\n", i + 'a', cnt[i]);
    }
 
    return 0;
}

Measured memory_bytes: 3120
n, a, b = map(int, input().split())
t = a + b
count = t if t > 0 else 0
r = 0
if count == 0:
	r = 0
else:
	d = int(n/t)
	if d*t == n:
		r = d * a
	else:
		r = d * a
		e = n - d*t
		if e <= a:
			r = r + e
		else:
			r = r + a
print(r)


Measured memory_bytes: 38256
n = int(input())
a = list(map(int, input().split()))
ans = 10 ** 10
for i in range(n):
    cnt = 0
    while a[i] % 2 == 0:
        cnt += 1
        a[i] = a[i] // 2
    ans = min(ans, cnt)
print(ans)


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


def length(n):
    return 4*2**n - 3


def func(n, x):
    if n == 0:
        return 1
    if x == 1:
        return 0
    half = length(n) // 2
    if x <= half:
        return func(n - 1, x - 1)
    elif x == half + 1:
        return func(n - 1, x - 1) + 1
    else:
        return (2*2**(n-1) - 1) + 1 + func(n - 1, x - length(n-1) - 2)


print(func(N, X))


Measured memory_bytes: 3188
#include <iostream>

using namespace std;

typedef long long int int64;

int main(int argc, char **argv)
{
    int64 A, B, K;
    cin >> A >> B >> K;

    if (A >= K) cout << A - K << " " << B;
    else {
        if (B >= K - A) cout << 0 << " " << B - (K - A);
        else cout << 0 << " " << 0;
    }
    return 0;
}


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

#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")"<< endl
#define BINARY(x) static_cast<bitset<16> >(x)

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

#define in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;
const int INF = 1e9;
const ll INFLL = 1e15;
typedef pair<int, int> PII;
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};

int main()
{
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    int NN = 3*N;
    vector<ll> A(NN);
    rep(i, NN) cin >> A[i];

    priority_queue<int, vector<int>, greater<int>> Q1;
    priority_queue<int> Q2;
    ll q_sum1 = 0, q_sum2 = 0;

    rep(i, N) {
        Q1.push(A[i]);
        q_sum1 += A[i];

        Q2.push(A[NN-i-1]);
        q_sum2 += A[NN-i-1];
    }

    DUMP2(q_sum1, q_sum2);

    vector<ll> sum1(NN), sum2(NN);
    for (int i=N-1; i<2*N; i++) {
        if (i > N-1 && Q1.top() < A[i]) {
            ll tmp = Q1.top(); Q1.pop();
            Q1.push(A[i]);
            q_sum1 += A[i] - tmp;
        } 
        sum1[i] = q_sum1;
    }
    for (int i=2*N; i>=N; i--) {
        if (i < 2*N && Q2.top() > A[i]) {
            ll tmp = Q2.top(); Q2.pop();
            Q2.push(A[i]);
            q_sum2 += A[i] - tmp;
        } 
        sum2[i-1] = q_sum2;
        // DUMP2(A[i], q_sum2);
    }

    ll ans = -INFLL;
    for (int i=N-1; i<2*N; i++) {
        // DUMP2(sum1[i], sum2[i]);
        ans = max(ans, sum1[i] - sum2[i]);
    }
    cout << ans << endl;
}



Measured memory_bytes: 8308
n, k = map(int, input().split())
p = list(map(int, input().split()))
max_sum_k = 0
cum_sum = [0] * (n+1)
cum_sum[0] = 0
cum_sum[1] = p[0]
for i in range(2, n+1):
    cum_sum[i] = p[i-1] + cum_sum[i-1]

for i in range(k, n + 1):
    sum_p = cum_sum[i] - cum_sum[i-k]
    if sum_p > max_sum_k:
        max_sum_k = sum_p

max_ex = (k + max_sum_k) / 2
print(max_ex)


Measured memory_bytes: 25060
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<long>A(N);
  for(int i=0;i<N;i++) cin>>A[i];
  vector<long>R(N);
  int e=N/2;
  long d=0;
  for(int i=0;i<e;i++){
    d+=2*A[2*i];
    d-=2*A[2*i+1];
  }
  //d=R[0]-R[N-1] R[0]+R[N-1]=2A[n-1]
  R[0]=(d+2*A[N-1])/2;
  for(int i=1;i<N;i++){
    R[i]=2*A[i-1]-R[i-1];
  }
  for(int i=0;i<N;i++)cout<<R[i]<<" ";
  cout<<endl;
}
  

Measured memory_bytes: 2944
/*************************************************************************
	> File Name: 1.cpp
	> Author: Knowledge_llz
	> Mail: 925538513@qq.com 
	> Blog: https://blog.csdn.net/Pig_cfbsl 
	> Created Time: 2020/5/2 20:10:44
 ************************************************************************/

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
#define For(i,a,b) for(register int i=(a);i<=(b);++i)
#define LL long long
using namespace std;
int read(){
	char x=getchar(); int u=0,fg=0;
	while(!isdigit(x)){ if(x=='-') fg=1; x=getchar(); }
	while(isdigit(x)){ u=(u<<3)+(u<<1)+(x^48); x=getchar(); }
	return fg?-u:u;
}
int A[100],n,m,q,cnt=0,ans=0;
int a[100],b[100],c[100],d[100];
int check(){
	int tmp=0;
	For(i,1,q)
		if(A[b[i]]-A[a[i]]==c[i])
			tmp+=d[i];
	return tmp;
}
void dfs(int pos,int val){
	++cnt;
	if(pos>n){
		ans=max(ans,check());
		return;
	}
	For(i,val,m){
		A[pos]=i;
		dfs(pos+1,i);
	}
}
int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.in", "r", stdin);
	freopen("output.out", "w", stdout);
#endif
	n=read();	m=read();	q=read();
	For(i,1,q){
		a[i]=read(); b[i]=read();
		c[i]=read(); d[i]=read();
	}
	dfs(1,1);
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 3748
A, B, K = [int(x) for x in input().split()]

for i in range(K):
    if i%2 == 0:
        if A%2==1:
            A -= 1
        A = A // 2
        B += A
    else :
        if B%2==1:
            B -= 1
        B = B // 2
        A += B

print(A, B)

Measured memory_bytes: 3060
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
#include <bitset>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define rep2(i, a)for(auto i : a)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x, std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
#define vec_unique(_a) _a.erase(std::unique(all(_a)), _a.end());
#define vvec vector<vector<ll>>
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
const int mod = 1000000007;
ll power(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x *= x; p /= 2; } else { a *= x; p--; } }return a; }
ll mpower(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x = x * x % mod; p /= 2; } else { a = a * x % mod; p--; } }return a; }
ll co(ll n, ll k) { ll a = 1; rep(i, 1ll, k) { a *= n - i + 1; a /= i; }return a; }
ll mc(ll n, ll m) { ll k = 1, l = 1; rep(i, n - m + 1, n + 1) k = k * i % mod; rep(i, 1, m + 1) l = l * i % mod; l = mpower(l, mod - 2); return k * l % mod; }

int main(void) {
	int n;
	ll ans = 0ll;
	cin >> n;
	vector<int> a(n), b(n), c(n);
	rep(i, 0, n)cin >> a[i];
	rep(i, 0, n)cin >> b[i];
	rep(i, 0, n)cin >> c[i];
	sort(all(a));
	sort(all(b));
	sort(all(c));
	rep(i, 0, n) {
		int cp = c.end() - upper_bound(all(c), b[i]);
		int ap = lower_bound(all(a), b[i]) - a.begin();
		ans += (ll)ap * cp;
	}
	printf("%lld\n", ans);
	return 0;
}

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

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

}

Measured memory_bytes: 3596
#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<iomanip>
#include<set>
#include<bitset>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define brep(index,num) for(int index=num-1;index>=0;index--)
#define brep1(index,num) for(int index=num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
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=(ll)1e+18+1;
int INF=1e+9+1;
int main(){
	int a,b,c;
	scan(a>>b>>c);
	int cnt[10]={};
	cnt[a]++; cnt[b]++; cnt[c]++;
	sort(cnt,cnt+10);
	if(cnt[9]==2&&cnt[8]==1) prin("Yes");
	else prin("No");
	return 0;
}


Measured memory_bytes: 256
N = int(input())
S = []
judge = 0
for i in range(N):
    S += [input().split()]
for i in range(N):
    if i <= N-3:
        if S[i][0] == S[i][1]:
            if S[i+1][0] == S[i+1][1]:
                if S[i+2][0] == S[i+2][1]:
                    print("Yes")
                    judge = 1
                    break
if judge == 0:
    print("No")

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

int main(){
  string s;
  cin >> s;
  int start, end;
  
  for(int i = 0; i < s.size(); i++){
    cin >> s.at(i);
    if(s.at(i) == 'A'){
      start = i;
      break;
    }
  }
  for(int i = 0; i < s.size(); i++){
    if(s.at(i) == 'Z')
      end = i;
  }
  cout << end - start + 1 << endl;
}

Measured memory_bytes: 640
while(n,k=gets.split.map &:to_i)[0]>0
l=(1..k).map{gets.to_i}.sort
d=l.each_cons(2).map{|i,j|"#{j-i}"}*""
p (l[0]>0?d.scan(/1+/):d[1..-1].gsub(/1+/){"#$& #$&"}.scan(/1+21*|1*21+|1+/)).map(&:size).max+(l[0]>0?1:2)
end

Measured memory_bytes: 11992
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <iostream>
#include <climits>
#include <cstring>
#include <functional>

using namespace std;

//using ll = long long;

#define rep(i, N) for(int i = 0;i < (int)N;i++)
#define LARGE INT_MAX / 2



int main() {
	int x, y, cnt = 0;
	while (1) {
		cnt++;
		cin >> x >> y;
		if (x == 0 && y == 0) break;
		else {
			cout << min(x, y) << ' ' << max(x, y) << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3060
def printRect(h,w):
    for i in range(h):
        print("#"*w)

while True:
    l = [int(i) for i in input().split(' ')]
    if l[0] == 0 and l[1] == 0:
        break
    else:
        printRect(l[0],l[1])
        print()

Measured memory_bytes: 6724
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;
using msi=map<string,int>;
using mii=map<int,int>;
using psi=pair<string,int>;
using pii=pair<int,int>;
using vlai=valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1e9
#define EPS 1e-9
#define MOD (1e9+7)
void solve(int r,int c){
    vector<vector<bool>> v(r,vector<bool>(c));
    int ans=0;
    int in;
    rep(i,r){
        rep(j,c){
            cin>>in;
            v[i][j]=in;
        }
    }
    vector<vector<bool>> vvv(r,vector<bool>(c));
    rep(i,pow(2,r)){
        int a=i;
        rep(j,r){
            rep(k,c){
                vvv[j][k]=((a&1)?v[j][k]:!v[j][k]);
            }
            a>>=1;
        }
        int tmp=0;
        // rep(j,r){
        //     rep(k,c){
        //         cout<<(vvv[j][k]?1:0);
        //     }
        //     cout<<endl;
        // }
        
        rep(k,c){
            int t=0;
            rep(j,r)if(vvv[j][k])t++;
            tmp+=max(t,r-t);
        }
        //cout<<tmp<<endl;
        ans=max(ans,tmp);
    }
    cout<<ans<<endl;
}

int main(){
    ios::sync_with_stdio(false);
    int a,b;
    while(cin>>a>>b,a){
        solve(a,b);
    }
}


Measured memory_bytes: 3364
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 

ll n,cnt,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s,ans;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

    cin>>s>>n;
    cout<<s[0];
    rrep(i,1,Size(s)){
        cnt++;
        if(cnt%n==0)cout<<s[i];
    }
    cout<<"\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
#define ll long long

int main(){
    std::ios_base::sync_with_stdio(false);
	std::cin.tie(NULL);
    ll n,a[200001],k,t=0;
    memset(a,0,sizeof(a));
    cin>>n;
    t=n-1;
    while(t--){
        cin>>k;
        a[k]++;
    }
    for(ll i=1;i<=n;i++){
        cout<<a[i]<<endl;
    }

}

Measured memory_bytes: 5224
#include<iostream>
#include<vector>
#include<string>
using namespace std;

int main(){
	vector< vector<char> > ans(10,vector<char>(0));
	int num=0;
	
	while(1){
		string str;
		vector<char> c1;
		getline(cin,str);
		if(str=="-") break;
		for(int i=0; i<str.size(); i++){
			char ch=str[i];
			c1.push_back(ch);
		}
		int n;
		cin>>n;
		int h[n];
		vector<char> c2(c1.size());
		for(int i=0; i<n; i++){
			cin>>h[i];
			for(int j=0; j<c1.size()-h[i]; j++){
				c2[j]=c1[h[i]+j];
			}
			for(int j=0; j<h[i]; j++){
				c2[c1.size()-h[i]+j]=c1[j];
			}
			
			c1=c2;
		}
		ans[num]=c2;
		num++;
		cin.ignore();
	}
	
	for(int i=0; i<num; i++){
		for(int j=0; j<ans[i].size(); j++){
			cout<<ans[i][j];
		}
		cout<<endl;
	}
	return 0;
}


Measured memory_bytes: 3224
MOD=10**9+7

N=int(input())
alist=list(map(int,input().split()))

#print(alist)
blist=[0]*64
for a in alist:
  bblist=[]
  acopy=a
  while(acopy>0):
    bblist.append(acopy%2)
    acopy//=2
    
  #print(bblist)
  for b in range(len(bblist)):
    blist[-1-b]+=bblist[b]
      
blist.reverse()
#print(blist)
answer=0
for i in range(64):
  answer+=blist[i]*(N-blist[i])*(2**i)
  
print(answer%MOD)

Measured memory_bytes: 122808
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}


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

    if(s.size()%2==1) {
        cout << "No" << endl;
        return 0;
    }
    rep(i, s.size()) {
        if(i%2==0 && s[i]!='h') {
            cout << "No" << endl;
            return 0;
        }
        if(i%2==1 && s[i]!='i') {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 256
import numpy

def main():
    h, w = map(int, input().split())
    max_value = h + w
    gridmap = []

    for y in range(h):
        gridmap.append([0 if v == '#' else max_value for v in input().strip()])

    values = numpy.array(gridmap)

    for x in range(w - 1):
        values[:, x + 1] = numpy.minimum(values[:, x] + 1, values[:, x + 1])

    for x in range(w - 1, 0, -1):
        values[:, x - 1] = numpy.minimum(values[:, x] + 1, values[:, x - 1])

    for y in range(h - 1):
        values[y + 1, :] = numpy.minimum(values[y, :] + 1, values[y + 1, :])

    for y in range(h - 1, 0, -1):
        values[y - 1, :] = numpy.minimum(values[y, :] + 1, values[y - 1, :])

    print(numpy.max(values))


main()


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

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

  string ans;

  while(n){
    int a = n / (-2);
    if(n < 0 && (int)abs(n) % 2) a++;

    if(n - (-2)*a == 1) ans = '1' + ans;
    else ans = '0' + ans;

    n = a;
  }

  if(ans == "") ans = '0';
  cout << ans << endl;

  return 0;
}


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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, char, ll> t4;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

const ll mod = 1000000007;

static const ll INF = 1e15;

struct Levenshtein_distance {
	const string s1;
	const string s2;
	vector<vector<ll>> dp;

	Levenshtein_distance(string s1, string s2) : s1(s1), s2(s2) {
	}

	ll solve() {
		dp.resize(s1.size() + 1, vector<ll>(s2.size() + 1, INF));
		rep(i, s1.size()) {
			dp[i][0] = i;
		}
		rep(j, s2.size()) {
			dp[0][j] = j;
		}
		rep(i, s1.size()) {
			rep(j, s2.size()) {
				if (s1[i] == s2[j]) {
					dp[i+1][j+1] = dp[i][j];
				}
				else {
					ll cost = dp[i+1][j+1];
					//insert
					cost = min(cost, dp[i][j+1] + 1);
					cost = min(cost, dp[i+1][j] + 1);
					//replace
					cost = min(cost, dp[i][j] + 1);
					dp[i+1][j+1] = cost;
				}
			}
		}
		return dp[s1.size()][s2.size()];
	}
};

int main(void)
{
	string s1,s2;
	cin >> s1 >> s2;
	Levenshtein_distance dist(s1, s2);
	auto d = dist.solve();
	cout << d << endl;
	return 0;
}




Measured memory_bytes: 10824
fifcount = 0
sevcount = 0
s  = list(map(int, input().split()))

for i in range(3):
  if s[i] == 5:
    fifcount += 1
  elif s[i] == 7:
    sevcount += 1
if fifcount ==2 and sevcount ==1:

  print("YES")
else:
  print("NO")

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"
#define int long long 
const int N=2e5+5;
int h,a;
int32_t main(){
	IOS;
	
	//code

	cin>>h>>a;
	if(h<=a){
		cout<<1<<endl;
	}
	else if(h%a==0)
		cout<<(h/a);
	else{
		cout<<(h/a)+1<<endl;
	}
	//code
	
	return 0;

}

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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define ANS(n) cout << (n) << endl
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int32 n;
    cin >> n;
    string s[2];
    cin >> s[0] >> s[1];
    vector<int64> dp(n, -1);
    if(s[0][0] == s[1][0]){
        dp[0] = 3;
    }else{
        dp[0] = 6;
    }
    FOR(i,1,n){
        if(s[0][i] == s[1][i]){
            if(s[0][i-1] == s[1][i-1]){
                dp[i] = dp[i-1] * 2;
            }else{
                dp[i] = dp[i-1];
            }
        }else{
            if(s[0][i] == s[0][i-1]){
                dp[i] = dp[i-1];
            }else if(s[0][i-1] == s[1][i-1]){
                dp[i] = dp[i-1] * 2;
            }else{
                dp[i] = dp[i-1] * 3;
            }
        }
        dp[i] %= MOD;
    }
    ANS(dp[n-1]);
    return 0;
}

Measured memory_bytes: 256
/*
 A Submission by $%U%$
 at time: $%Y%$-$%M%$-$%D%$ $%h%$:$%m%$:$%s%$
*/
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define rep(i,n) for(int64_t i=0;i < (int64_t)(n);i++)
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define FILE_IN "billboard.inp"
#define FILE_OUT "billboard.out"
#define ofile freopen(FILE_IN,"r",stdin);freopen(FILE_OUT,"w",stdout)
#define fio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define nfio cin.tie(0);cout.tie(0)
#define max(x,y) (((x)>(y))?(x):(y))
#define min(x,y) (((x)<(y))?(x):(y))
#define ord(a,b,c) ((a>=b)and(b>=c))
#define MOD (ll(1000000007))
#define MAX 300001
#define mag 320
#define p1 first
#define p2 second.first
#define p3 second.second
#define fi first
#define se second
#define pow2(x) (ll(1)<<x)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define piii pair<int,pii>
#define For(i,__,___) for(int i=__;i<=___;i++)
#define Rep(i,__,___) for(int i=__;i>=___;i--)
#define ordered_set tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update>
#define bi BigInt
#define pi 3.1415926535897
typedef long long ll;
//------------xúc xích normie tám muoi tám phan tram não----------//
ll n,m,k,cnt[100001],t,t1,i,j,minn=1e9,maxx,cur,lu,lv;
ll psuma[1000000],psumb[1000000];
vector<ll> lis;
int main() {
//	ofile;
	fio;
	string a,b;
	cin>>a>>b>>n;
	for (i=0;i<a.size();i++)
	{
		psuma[i+1]=psuma[i];
		if (a[i]=='A') psuma[i+1]++; else psuma[i+1]--;
	}
	for (i=0;i<b.size();i++)
	{
		psumb[i+1]=psumb[i];
		if (b[i]=='A') psumb[i+1]++; else psumb[i+1]--;
	}
	for (i=1;i<=n;i++)
	{
		int a,b,c,d;
		cin>>a>>b>>c>>d;
		if ((psuma[b]-psuma[a-1]+3000000)%3==(psumb[d]-psumb[c-1]+3000000)%3) cout<<"YES"; else cout<<"NO";
		cout<<endl;
	}
}

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

#define ll long long

ll N,x;
int main(){
	cin >> N >> x;
	ll a[N];
  ll ans=0;
	for(int i=0;i<N;i++){
		cin >> a[i];
    if(a[i]>x){
			int difff = a[i] - x;
      a[i]-= difff;ans+=difff;
    }
	}
  for(int i=0;i<N-1;i++){
		if(a[i]+a[i+1]>x){
			int diff = a[i]+a[i+1] - x;
			a[i+1]-= diff;ans+=diff;
		}
  }
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <queue>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FORL(i,x) for(int i=head[x];i;i=nxt[i])
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


  vector<pair<int,int>> p;
  vector<pair<int,int>> ans;
  priority_queue<pair<int,int>> que;

int main() {
  int N,M;
  scanf("%d%d", &N,&M);
  FOR(i,0,N-1){
    int neko,inu;

    cin >> neko;
    cin >> inu;
    inu = 0-inu;
    p.PB(MP(neko,inu));
  }

  sort(ALL(p));

  int output = 0;
  int ref = 0;
  FOR(i,0,M-1){
    int hold = -1;
    while(p[ref].first<=i+1 && ref<=SZ(p)-1){
      que.push(MP((-p[ref].second),p[ref].first));
      // cout << 0-p[0].second << " " << p[0].first << endl;
      ++ref;
    }
    if(!que.empty()) {
      // if(SZ(ans)>=2) sort(ALL(ans),greater<pair<int,int>>());
      output += que.top().first;
      que.pop();
    }
    // cout << output << endl;
    
  }

  cout << output << endl;

}

Measured memory_bytes: 2548
m1, d1 = gets.split.map(&:to_i)
m2, d2 = gets.split.map(&:to_i)
if (m1 >= 1 && m1 <= 12) && (m2 >= 1 && m2 <= 12) && (d1 >= 1 && d1 <= 31) && (d2 >= 1 && d2 <= 31)
  if (d1 == 30 || d1 == 31 || d1 == 28 || d1 == 29) && (d2 == 1)
    puts '1'
  else
    puts '0'
  end
else
  puts '0'
end

Measured memory_bytes: 1788
import sys
from math import sqrt
from collections import Counter

input = sys.stdin.readline


def I():
    return int(input())


def MI():
    return map(int, input().split())


def LI():
    return list(MI())


inf = float("inf")
mod = 10 ** 9 + 7


def main():
    x, y = MI()

    c = 0
    while x <= y:
        c += 1
        x *= 2

    print(c)
    pass


if __name__ == "__main__":
    main()


Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,W;
  cin>>N>>W;
  int dp[101][10001];
  int v[100],w[100];
  for(int i=0;i<N;i++)cin>>v[i]>>w[i];
  for(int i=0;i<101;i++)
    for(int j=0;j<10001;j++)
      dp[i][j]=-1;
  dp[0][0]=0;
  for(int i=0;i<N;i++)
    for(int j=0;j<=W;j++){
      if(dp[i][j]==-1)continue;
      dp[i+1][j]=max(dp[i+1][j],dp[i][j]);
      if(j+w[i]<=W)dp[i+1][j+w[i]]=max(dp[i+1][j+w[i]],dp[i][j]+v[i]);
    }
  int ans=0;
  for(int i=0;i<=W;i++)ans=max(ans,dp[N][i]);
  cout<<ans<<endl;
  return 0;
}



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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

#define MAX_N 1000

int n;

int main(){
	cin.sync_with_stdio(false);
	cin>>n;
	if(n==0||n==2)cout<<1<<endl;
	else if(n==1)cout<<2<<endl;
	else cout<<0<<endl;
	return 0;
}

Measured memory_bytes: 3156
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;

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

	int n, k, a, b;
	cin >> n >> k;
	a = n / k;
	if (n == a * k) cout << "0\n";
	else cout << "1\n";


	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;

vector<int> to[200005];
vector<int> ans;
void dfs(int v, int p=-1){
    //累積和をdfsで
    for(int u : to[v]){
        if(u == p) continue;
        ans[u] += ans[v];
        dfs(u,v);
    }
}

int main(){
    int n, q; cin >> n >> q;
    rep(i,n-1){
        int a, b; cin >> a >> b;
        --a, --b;
        to[a].pb(b);
        to[b].pb(a);
    }
    ans.resize(n);
    rep(i,q){
        int p, x; cin >> p >> x;
        --p;
        ans[p] += x;
    }
    dfs(0);
    rep(i,n) cout << ans[i] << endl;
}

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

int main() {
    int n,a,b,c,d;
    cin >> n >> a >> b >> c >> d;
    string s;
    cin >> s;

    bool x=true,y=false;
    for(int i = a; i < d-2; i++) {
        if(s[i]=='#' && s[i+1]=='#'){
            x=false;
        }
    }
    for(int i = a; i < c-2; i++) {
        if(s[i]=='#' && s[i+1]=='#'){
            x=false;
        }
    }
    
    for(int i = b-2; i < d-1; i++) {
        if(s[i]=='.' && s[i+1]=='.' && s[i+2]=='.'){
            y=true;
        }
    } 


    if(c<d){
        if(x) cout << "Yes" << endl;
        else cout << "No" << endl;
    }  
    else{
        if(x && y) cout << "Yes" << endl;
        else cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3708
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>
#include <random>

#define FOR_LT(i, beg, end) for (int i = (int)(beg); i < (int)(end); i++)
#define FOR_LE(i, beg, end) for (int i = (int)(beg); i <= (int)(end); i++)
#define FOR_DW(i, beg, end) for (int i = (int)(beg); (int)(end) <= i; i--)
#define REP(n)              for (int repeat_index = 0; repeat_index < (int)n; repeat_index++)


using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(20);

	int k, a, b; cin >> k >> a >> b;
	for (int i = k; i <= b; i += k) {
		if (a <= i && i <= b) {
			cout << "OK" << endl;
			return 0;
		}
	}
	cout << "NG" << endl;

	return 0;
}

Measured memory_bytes: 3692
/*
https://atcoder.jp/contests/dp/tasks/dp_a
*/

#include <iostream>

using namespace std;

int dp[100000];

int h_diff(int*arr, int N){
	if( N == 0 ) {
		dp[N]=0;
		return dp[N];
	}

	if( N == 1 )  {
		dp[N] = abs(arr[N]-arr[N-1]);
		return dp[N];
	}

	if(dp[N-1] == -1)
		dp[N-1] = h_diff(arr,N-1);
	if(dp[N-2] == -1)
		dp[N-2] = h_diff(arr,N-2);

	dp[N] = min(abs(arr[N] - arr[N-1]) + dp[N-1],abs(arr[N] - arr[N-2])+ dp[N-2]);
	
	return dp[N];

}


int main(){

	int N;
	cin >> N;
	int arr[N];

	for(int i=0;i<N;i++){
		cin >> arr[i];
		dp[i] = -1;
	}
	
	
	cout << h_diff(arr,N-1)<< endl;


	return 0;
}

Measured memory_bytes: 9088
#!/usr/bin/python3

import math

(a, b, h, m) = map(int, input().split())

hr = 2 * math.pi * ((h + m / 60) / 12)
mr = 2 * math.pi * m / 60

sr = min(hr, mr)
lr = max(hr, mr)

tr = min(lr - sr, sr + 2 * math.pi - lr)

d = math.sqrt((a * math.cos(tr) - b) ** 2 + (a * math.sin(tr)) ** 2)

print(d)



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

int main(){
  
  int n,k;
  cin >>n>>k;
  
  int h[n];
  for(int i=0; i<n; i++){
    cin >>h[i];
   h[i]-=k; 
  }
  int count=0;
  for(int i=0; i<n; i++){
  	if(h[i]>=0) count++;
  }

  cout << count << endl;
}

Measured memory_bytes: 640