akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

const double EPS = 1e-10;

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;


int main(){
    int N; cin >> N;
    vector<int> P(N);
    rep(i,N) cin >> P[i];
    int m = INF;
    int ans = 0;
    rep(i,N){
        if(P[i] <= m) ans++;
        m = min(m,P[i]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include <iostream> 
using namespace std;
int main()
{
	int a; cin>>a;
	int b=a%100;
	a/=100;
	if(a>0 and a<13 and b>0 and b<13) cout<<"AMBIGUOUS";
	else if((a==0 and b==0) or (b==0 and b>12) or (a>12 and b==0) or (a>12 and b>12)) cout<<"NA";
	else if(a>0 and a<13) cout<<"MMYY";
	else cout<<"YYMM";
}






Measured memory_bytes: 3020
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n, all = 1, bad = 1;
	cin >> n;
	vector<int> arr(n);
	for(int i = 0; i < n; i++) {
		cin >> arr[i];
		all *= 3;
		if(arr[i] % 2 == 0) bad *= 2;
	}
	cout << all - bad << endl;

	return 0;
}

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

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

    if(s[s.size()-1]=='s'){
        s+="es";
    }
    else{
        s+='s';
    }

    cout << s << endl;

    return 0;
}



Measured memory_bytes: 3628
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <stdio.h>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <tuple>
#include <math.h>
#include <set>
#include <map>
using namespace std ;
using ll = long long ;
using ld = long double ;
using vll = vector<ll> ;
using vvll = vector<vll> ;
using vc = vector<char> ;
using vvc = vector<vc> ;
using vb = vector<bool> ;
using vvb = vector<vb> ;
using pll = pair<ll,ll> ;
#define all(v) v.begin(),v.end() 
const ll INF = 1e18 ;
const ll mod = 1e9+7 ;
const double pie = acos(-1); 
vll dx4 = {-1,0,1,0} ;
vll dy4 = {0,-1,0,1} ;
vll dx8 = {-1,0,1,1,1,0,-1,-1} ;
vll dy8 = {-1,-1,-1,0,1,1,1,0} ; 

void fix_cout(){cout << fixed << setprecision(20) ; }
ll gcd(ll a,ll b){if(b==0) return a ; return gcd(b,a%b) ; }
ll lcm(ll a,ll b){return a/gcd(a,b)*b ; }
void chmax(ll &a,ll b){if(a<b) a = b ; }
void chmin(ll &a,ll b){if(a>b) a = b ; }


int main(){
	char c ; cin >> c ;
	cout << (c<='Z'?'A':'a') << endl ;
}




Measured memory_bytes: 3628
n = int(input())
a = list(map(int,input().split()))
a.sort()
mean = sum(a)//n
ansl = 0
anss = 0
for i in range(n):
    ansl += (a[i]-mean)**2
    anss += (a[i]-mean-1)**2

print(min(ansl,anss))



Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<int> vec(5);
  int ans = 0;
  for (int i = 0; i < 5; i++) {
    cin >> vec.at(i);
    if (vec.at(i) == 0) {
      cout << i + 1;
    }
  }
}

Measured memory_bytes: 3572
import sys, math
from functools import lru_cache
from collections import deque
sys.setrecursionlimit(10**9)

def input():
    return sys.stdin.readline()[:-1]

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

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]


def main():
    N = ii()
    a = list(mi())

    a.sort(reverse=True)

    print(sum(a[1::2][:N]))

    

if __name__ == '__main__':
    main()


Measured memory_bytes: 43532
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<pair<int,int>> vp;
#define pb push_back
#define ll long long int 

void solve()
{
	int n;
	cin>>n;
	ll a[n];
	for(auto &x:a)
	{
		cin>>x;
	}
	ll s=0LL;
	
	for(int i=1;i<n;i++)
	{
		if(a[i]<a[i-1])
		s+=a[i-1]-a[i],a[i]=a[i-1];
	}
	cout<<s;
}
int main()
{ 
    

   solve();
    
	return 0;
}



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

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

dic = {}

asum = 0

for i in A:
    if i not in dic:
        dic[i] = 1
    else:
        dic[i] += 1

for i in dic:

    asum += dic[i] * (dic[i]-1) // 2

for i in A:

    print (asum - (dic[i] * (dic[i]-1) // 2) + ((dic[i]-1)*(dic[i]-2)//2) )


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

bool isPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

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

    int ans = 0;
    for(int i = X; i <= 1e6;i++){
        if(isPrime(i)){
            ans = i;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define int unsigned long long
using namespace std;
constexpr int mod=1e9+7;
signed main(){
    int n,a[200000],b[200000];
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>a[i]>>b[i];
    sort(a,a+n);
    sort(b,b+n);
    if(n%2==1)
        cout<<b[n/2]-a[n/2]+1<<endl;

    else
        cout<<b[n/2]+b[n/2-1]-a[n/2]-a[n/2-1]+1<<endl;
}

Measured memory_bytes: 6764
import Data.List
import Data.Maybe
import qualified Data.ByteString.Char8 as B
import qualified Data.Vector as V
main=putStr.f.g.B.lines=<<B.getContents
ris=map(fst.fromJust.B.readInt).B.words
g(nq:s:lrs)=(ris nq,s,map ris lrs)
f([n,q],s,lrs)=unlines$map(\[l,r]->show$vs V.!r - vs V.!l)lrs where
  vs=V.fromList$scanl'(+)0$0:B.zipWith(\x y->if x=='A' && y=='C' then 1 else 0)s(B.tail s)

Measured memory_bytes: 11644
o=str(input())
e=str(input())
ans=''
if len(o)==len(e):
  for i in range(len(o)):
    ans+=o[i]
    ans+=e[i]
else:
  for i in range(len(e)):
    ans+=o[i]
    ans+=e[i]
  ans+=o[len(o)-1]
print(ans)


Measured memory_bytes: 3060
import Data.Maybe
import Data.List
import Data.Char

main :: IO ()
main = do
  input <- getContents
  putStrLn $ trim (solve (trim input))

--処理
solve :: String -> String
solve = fmap (toUpper . head) . words

trimHead :: String -> String
trimHead = dropWhile (\s -> isJust (elemIndex s [' ', '\t', '\n', '\r']))

trim :: String -> String
trim = reverse . trimHead . reverse . trimHead

Measured memory_bytes: 380
#include <algorithm>
#include <iostream>
#include <vector>
#include <bitset>
using namespace std;

const int MAX_ROW = 1e5;    // to be set appropriately
const int MAX_COL = 60;    // to be set appropriately
struct BitMatrix {
    int H, W;
    bitset<MAX_COL> val[MAX_ROW];
    BitMatrix(int m = 1, int n = 1) : H(m), W(n) { }
    bitset<MAX_COL>& operator[](int i) { return val[i]; }
};
int gauss_jordan(BitMatrix &A, bool is_extended = false) {
    int rank = 0;
    for (int col = A.W - 1; col >= 0; --col) {
        if (is_extended && col == A.W - 1) break;
        int pivot = -1;
        for (int row = rank; row < A.H; ++row) {
            if (A[row][col]) { pivot = row; break; }
        }
        if (pivot == -1) continue;
        swap(A[pivot], A[rank]);
        for (int row = 0; row < A.H; ++row) {
            if (row != rank && A[row][col]) A[row] ^= A[rank];
        }
        ++rank;
    }
    return rank;
}

int main() {
    int n; cin >> n;
    vector<long long> a(n);
    for (auto &ai: a) cin >> ai;
    long long odd = 0;
    for (int i = 0; i < n; i++) odd ^= a[i];
    BitMatrix A(n, 60);
    for (int d = 0; d < 60; d++) {
        if (odd >> d & 1) continue;
        for (int i = 0; i < n; i++) if (a[i] >> d & 1) A[i][d] = 1;
    }
    gauss_jordan(A);
    bitset<60> even = 0;
    for (int i = 0; i < n; i++) even ^= A[i];
    cout << odd + even.to_ullong() * 2 << endl;
    return 0;
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  vector<pair<int, int>> e(m);
  for (auto& x : e) {
    cin >> x.first >> x.second;
    x.first--;
    x.second--;
  }
  vector<int> par(n, -1);
  auto root = [&](int t) {
    if (par[t] < 0) return t;
    for (int i = t;; i = par[i])
      if (par[i] < 0) return par[t] = i;
  };
  vector<ll> ans;
  ll a = (ll)n * (n - 1) / 2;
  for (int i = m; i--;) {
    ans.push_back(a);
    int r1 = root(e[i].first), r2 = root(e[i].second);
    if (r1 != r2) {
      a -= (ll)par[r1] * par[r2];
      if (par[r1] > par[r2]) swap(r1, r2);
      par[r1] += par[r2];
      par[r2] = r1;
    }
  }
  reverse(ans.begin(), ans.end());
  for (auto x : ans) cout << x << "\n";
}


Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b;
  cin >> a >> b;
  a = a % 2;
  b = b % 2;
  if (a == 1 && b == 1) {
    cout << "Odd" << endl;
  }
  else {
    cout << "Even" << endl;
  }
}

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

int main() {
	
	ll n;
	cin >> n;
	vector <ll> arra(n);
	vector <ll> arrb(n);
	vector <ll> arrc(n);
	ll total =0;
	ll temp=0;

	for (int i = 0; i < n; ++i)
	{
		cin >> arra[i];
	}
	for (int i = 0; i < n; ++i)
	{
		cin >> arrb[i];
	}
	for (int i = 0; i < n-1; ++i)
	{
		cin >> arrc[i];
	}

	for (int x = 0; x < n ; ++x)
	{
		if((temp==(arra[x]-1))&&(temp!=0)){
			temp=arra[x];
			total+=(arrb[temp-1]+arrc[temp-2]);
		}
		else{
			temp=arra[x];
			total+=arrb[temp-1];
		}
	}
	cout << total;
	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 using namespace std;
int main(){
  int y, m, d;
  char c1,c2;
    cin >> y >> c1 >> m >> c2 >> d;
//    std::cout << y << c1 << m << c2 << d << '\n';
  string res = "Heisei";

  if (y > 2019) {
    res = "TBD";
  } else if (y == 2019 && m > 4) {
    res = "TBD";
  }
  cout << res << "\n";
}


Measured memory_bytes: 256
import sys, math
def input():
    return sys.stdin.readline()[:-1]
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial
from bisect import bisect_left #bisect_left(list, value)
#from fractions import gcd
enu = enumerate

sys.setrecursionlimit(10**7)
H, W = map(int, input().split())

al = H*W // 2

if H==1 or W==1:
    print(1)
elif H%2==1 and W%2==1:
    print(al+1)
else:
    print(al)



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

int main(){
  int N; 
  cin >>N;
  
  vector<int> V(N);
  repeat(i,N) cin >>V[i];
  vector<int> C(N);
  repeat(i,N) cin >>C[i];
  
  int ans = 0;
  repeat(i,N) if((V[i]-C[i])>0) ans += V[i]-C[i];
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <iomanip>
#include <stack>
#include <bitset>

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

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(a>b){a=b;return 1;}return 0;}

int _gcd(unsigned a, unsigned b) {
  if(a < b) _gcd(b, a);
  int r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int pre[100005],suf[100005];

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

  int n;
  cin >> n;
  vector<int> a(n); 
  REP(i, n) cin >> a[i];  
  //sort(a.begin(), a.end());

  pre[0] = a[0];
  FOR(i, 1, n+1) pre[i] = __gcd(pre[i-1], a[i]);

  suf[n-1] = a[n-1];
  ROF(i, n-2, 0) suf[i] = __gcd(suf[i+1], a[i]);

  int ans = 0;
  REP(i, n) ans = max(ans, __gcd(pre[i-1], suf[i+1]));
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 1408
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#define REP(i,n) for(int i = 0;i < (n);i++)
#define pb push_back
using namespace std;
const int INF = 1e9;
typedef long long ll;

int main(){
  int n;
  cin >> n;
  vector <ll> L;
  REP(i,2*n){
    ll a;
    cin >> a;
    L.pb(a);
  }
  sort(L.begin(),L.end());
  ll sum = 0;
  for(int i = 0;i < 2*n;i = i+2){
    sum += L[i];
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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; }
const ll INF = 1LL << 60;
const int MAX = 1000000010;
const ll MOD = 1000000007;
const double PI = acos(-1);

int main() {
    int x, a, b; cin >> x >> a >> b;
    if (a >= b) {
        cout << "delicious" << endl;
    } else if (b - a <= x) {
        cout << "safe" << endl;
    } else {
        cout << "dangerous" << endl;
    }
    return 0;
}

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

int main()
{
	string s;
	cin >> s;
	int ans = 0;
	for (int i = 0; i < 3; i++) {
		if (s[i] == '1')
			ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import sys
#1が書かれたカードA,0-B,-1-C,K枚選ぶ
A, B, C, K = map(int, input().split())

if A >= K:
    print(1*K)
    sys.exit()

elif A+B >= K:
    print(1*A)
    sys.exit()

else:
    print(A*1 + (K-(A+B))*(-1))
    sys.exit()


Measured memory_bytes: 9068
def c_ChocolateBar(H, W):
    ans = float('inf')
    # for文の順は解説における矩形の分け方の図の左からの順と一致
    for h in range(1, H):
        S_A = h * W
        hh = (H - h) // 2
        S_B = hh * W
        S_C = (H - h - hh) * W
        ans = min(ans, max([S_A, S_B, S_C]) - min([S_A, S_B, S_C]))
    for h in range(1, H):
        S_A = h * W
        w = W // 2
        S_B = (H - h) * w
        S_C = (H - h) * (W - w)
        ans = min(ans, max([S_A, S_B, S_C]) - min([S_A, S_B, S_C]))
    for w in range(1, W):
        S_A = H * w
        ww = (W - w) // 2
        S_B = H * ww
        S_C = H * (W - w - ww)
        ans = min(ans, max([S_A, S_B, S_C]) - min([S_A, S_B, S_C]))
    for w in range(1, W):
        S_A = H * w
        h = H // 2
        S_B = h * (W - w)
        S_C = (H - h) * (W - w)
        ans = min(ans, max([S_A, S_B, S_C]) - min([S_A, S_B, S_C]))
    return ans
H,W = [int(i) for i in input().split()]
print(c_ChocolateBar(H, W))

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod * mod;
constexpr int MAX = 200010;

int main(){
    int n;
    while(scanf("%d", &n) && n){
        int in[1010], ans[1010];
        memset(in, 0, sizeof(in));
        memset(ans, 0, sizeof(ans));
        rep(_, n){
            int month, day, hour, minute, id;
            char enter;
            scanf("%d/%d %d:%d %c %d", &month, &day, &hour, &minute, &enter, &id);
            int time = hour * 60 + minute;
            if(id == 0){
                if(enter == 'I'){
                    rep(i, 1010)if(in[i]) in[i] = time;
                    in[0] = time;
                }
                else{
                    rep(i, 1010)if(in[i]) ans[i] += time - in[i];
                    in[0] = 0;
                }
            }
            else{
                if(enter == 'I') in[id] = time;
                else{
                    if(in[0]) ans[id] += time - max(in[0], in[id]);
                    in[id] = 0;
                }
            }
        }
        printf("%d\n", *max_element(ans+1, ans+1010));
    }
}


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

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;


signed main() {
    int N, K;
    int RSP[3];
    string T;
    cin >> N >> K >> RSP[0] >> RSP[1] >> RSP[2] >> T;
    int ans = 0;
    int dp[3][N / K + 10];
    map<char, int> ma;
    ma['r'] = 0;
    ma['s'] = 1;
    ma['p'] = 2;
    for (int t = 0; t < K; ++t) {
        //t,t+K,t+2K,...回目の手
        memset(dp, 0, sizeof(dp));
        int idx;
        for (int tt = t; tt < N; tt += K) {
            idx = (tt - t) / K + 1;
            for (int hand = 0; hand < 3; ++hand) {
                if (hand == (ma[T[tt]] + 2) % 3) {
                    //勝つ
                    dp[hand][idx] = max(dp[(hand + 1) % 3][idx - 1], dp[(hand + 2) % 3][idx - 1]) + RSP[hand];
                } else {
                    dp[hand][idx] = max(dp[(hand + 1) % 3][idx - 1], dp[(hand + 2) % 3][idx - 1]);
                }
            }
        }
        ans += max({dp[0][idx], dp[1][idx], dp[2][idx]});
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2816
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 10;


int main()
{
  int N; cin >> N;
  vector<int> W(N);
  for (int i = 0; i < N; i++) {
    cin >> W.at(i);
  }
  int dif_min = INF;

  for (int i = 0; i < N; i++)
  {
    int S1 = 0;
    int S2 = 0;
    for (int j = 0; j < N; j++)
    {
      if (j <= i) S1 = S1 + W[j];
      else S2 = S2 + W[j];
    }
    int dif = abs(S1 - S2);
    if (dif <= dif_min)
    {
      dif_min = dif;
    }
  }
  cout << dif_min << endl;
}

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

public class Main {
	public static void main(String[] args) throws IOException
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		String s = br.readLine();
		StringTokenizer st = new StringTokenizer(s, " ");
		int a = Integer.parseInt(st.nextToken());
		int b = Integer.parseInt(st.nextToken());
		int c = Integer.parseInt(st.nextToken());
		if(a < b) {
			if(b < c) {
				System.out.println("Yes");
			}else {
				System.out.println("No");
			}
		}else{
			System.out.println("No");
		}
	}

}

Measured memory_bytes: 16856
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;
using namespace std;
int n;
int a[100010],b[100010],c[100010];
int x[100010];
int y[100010];

int main(){
  cin>>n;
  lol(i,n)cin>>a[i];
  lol(i,n)cin>>b[i];
  lol(i,n)cin>>c[i];
  sort(a,a+n);
  sort(b,b+n);
  sort(c,c+n);
  int pnt=n-1;
  for(int i=n-1;i>=0;i--){
    while(true){
      if(pnt==-1)break;
      if(b[i]>=c[pnt])break;
      pnt--;
    }
    x[i]=n-1-pnt;
  }
  pnt=n-1;
  ll cls=0,ans=0;
  for(int i=n-1;i>=0;i--){
    while(true){
      if(pnt==-1)break;
      if(a[i]>=b[pnt])break;
      cls+=x[pnt];
      pnt--;
    }
    ans+=cls;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1792
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author emli
 */


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

typedef long long ll;
#define all(x) x.begin(),x.end()
class CAXBC {
public:
    void solve(std::istream& cin, std::ostream& cout) {
		ios::sync_with_stdio(false);
        cin.tie(nullptr);

        int n;
        cin >> n;

        vector<int> d(n + 1);

        for (int i = 2; i <= n; ++i) {
            for (int j = i; j <= n; j += i) {
                d[j]++;
            }
        }

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


#define loveAfterTheGame main

int loveAfterTheGame() {
	CAXBC solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 7144
while True:
    H, W = map(int, input().split())
    if (H == W == 0):
        break
    else:
        for j in range(H):
            if (j == 0 or j == H - 1):
                for i in range(W):
                    print("#", end='')
            else:
                for f in range(W):
                    if (f == 0 or f == W - 1):
                        print("#", end='')
                    else:
                        print(".", end='')


            print()
        print()

Measured memory_bytes: 9044
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
const int N = 2e5 + 5;

int n;
ll k , a [ N ] , L , R;
int main ( void ) {
    scanf( "%d %lld" , &n , &k );
    for ( int i = 0 ; i < n ; i++ ) scanf( "%lld" , &a [ i ] );
    sort ( a , a + n );
    L = -1e18 , R = 1e18;
    while ( L + 1 != R ) {
        ll Mid = ( L + R ) / 2;
        ll cnt = 0;
        for ( int i = 0 ; i < n ; i++ ) {
            if ( a [ i ] < 0 ) {
                int l = i ,r = n;
                while ( l + 1 != r ) {
                    int mid = ( l + r ) / 2;
                    if ( a [ i ] * a [ mid ] <= Mid ) r = mid;
                    else l = mid;
                }
                cnt += n - r;
            } else{
                int l = i , r = n;
                while( l + 1 != r ) {
                    int mid = ( l + r ) / 2;
                    if ( a [ i ] * a [ mid ] <= Mid ) l = mid;
                    else r = mid;
                }
                cnt += l - i;
            }
        }
        if ( cnt < k ) L = Mid;
        else R = Mid;
    }
    printf ( "%lld" , R );
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,a,n)  for (int i=(int)(a); i<=(int)(n); ++i)
#define rrep(i,a,n) for (int i=(int)(a); i>=(int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) rep(f, 0, (x.size()-1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define all(x) x.begin(),x.end()
#define int long long
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = ((1LL << 30) + (1LL << 29));
const int MOD = 1000000007;

int N,M,K,X,Y;
int a,b,c,d;
string S,T;
vector<int> A,B;
void input()
{
    cin>>S;
}
void solve()
{
    int countt=0,counts=0;
    int mx=-INF;
    for(auto x : S){
        if (x=='T') countt++;
        if (x=='S') counts++;
        mx = max(mx,countt-counts);
    }

    cout<<mx*2<<endl;
}
signed main()
{
    input();
    solve();
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#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(c) sort((c).begin(),(c).end())

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//sort(v.rbegin(), v.rend(), [](auto& x, auto& y){return x[1] < y[1];});
//cout << fixed << setprecision(10) << ans << defaultfloat << endl;
typedef long long ll;
typedef vector<int> Vi;
typedef vector<ll> Vl;
typedef vector<double> Vd;
typedef vector<string> Vs;

ll mod = 1e9+7;

int main() {
    int N,K;
    cin >> N >> K;
    string S;
    cin >> S;
    Vi v;

    if (S[0]=='0') v.push_back(0);

    int c=1;
    REP(i,N-1) {
        if (S[i+1]==S[i]) {
            c++;
        }
        else {
            v.push_back(c);
            c = 1;
        }
    }
    v.push_back(c);
    if (S[N-1]=='0') v.push_back(0);

    //for(auto i:v) cout << i << endl;

    int l=0,r=2*K,ans=0;
    if (r+1>v.size()) {
        cout << accumulate(v.begin(),v.end(),0) << endl;
        return 0;
    }
    int count=accumulate(v.begin(),v.begin()+r+1,0);
    ans = count;
    while (r+2<=v.size()-1) {
        count += v[r+1] - v[l];
        //ans = max({ans,count});
        r++;
        l++;
        count += v[r+1] - v[l];
        ans = max({ans,count});
        r++;
        l++;
    }
    cout << ans << endl;

}

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

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

  int dis = 0;
  
  for ( int i = 0; i < N; i++){
    int x;
    cin >> x;
    
    if (x >= K - x){
      dis += 2*(K -x);
    }
    else {
      dis += 2*x;
    }
  }
    cout << dis << endl;
  }
  

Measured memory_bytes: 3576
import java.awt.Point;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.Set;

public class Main {

	public static final int MAX = 5000;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		/*
		 * ArrayList<HashSet<Integer>> dot_list = new
		 * ArrayList<HashSet<Integer>>(MAX + 1); for(int i = 0; i <= MAX; i++){
		 * dot_list.add(new HashSet<Integer>()); }
		 */

		boolean[][] is_point = new boolean[MAX + 1][MAX + 1];
		int[] x_pos = new int[3001];
		int[] y_pos = new int[3001];

		while (true) {
			final int n = sc.nextInt();

			if (n == 0) {
				break;
			}

			for (int i = 0; i <= MAX; i++) {
				Arrays.fill(is_point[i], false);
			}
			// System.gc();

			for (int i = 0; i < n; i++) {
				final int x = sc.nextInt();
				final int y = sc.nextInt();

				is_point[y][x] = true;
				x_pos[i] = x;
				y_pos[i] = y;
			}

			int max_size = 0;

			for (int i = 0; i < n; i++) {
				for (int j = i + 1; j < n; j++) {
					final int x1 = x_pos[i];
					final int y1 = y_pos[i];
					final int x2 = x_pos[j];
					final int y2 = y_pos[j];

					int diff_x = x2 - x1;
					int diff_y = y2 - y1;

					int pt_1_x = x1 + diff_y;
					int pt_1_y = y1 - diff_x;

					if (pt_1_x < 0 || pt_1_x > MAX || pt_1_y < 0
							|| pt_1_y > MAX) {
						continue;
					} else if (!is_point[pt_1_y][pt_1_x]) {
						continue;
					}

					int pt_2_x = pt_1_x + diff_x;
					int pt_2_y = pt_1_y + diff_y;

					if (pt_2_x < 0 || pt_2_x > MAX || pt_2_y < 0
							|| pt_2_y > MAX) {
						continue;
					} else if (!is_point[pt_2_y][pt_2_x]) {
						continue;
					}

					max_size = Math.max(max_size, diff_x * diff_x + diff_y
							* diff_y);

				}
			}

			System.out.println(max_size);
		}
	}
}

Measured memory_bytes: 85244
#include<stdio.h>
int main(){
	double ax,ay,bx,by,cx,cy,dx,dy,tax,tay,tcx,tcy;
	int n,a;
	scanf("%d",&n);
	for(a=0;a<n;a++){
		scanf("%lf %lf",&ax,&ay);
		scanf("%lf %lf",&bx,&by);
		scanf("%lf %lf",&cx,&cy);
		scanf("%lf %lf",&dx,&dy);
		tax=ax-bx;
		tay=ay-by;
		tcx=cx-dx;
		tcy=cy-dy;
		if(tcy*tax==tcx*tay){printf("YES\n");}
		else{printf("NO\n");}
	}
	return 0;
}

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

int main(){
	int N, D, ans;
	cin >> N >> D;
	int man = 2*D+1 ;
	if (N%man==0){
		ans = N/man;
	}
	else{
		ans = (N/man) + 1;
	}
	cout << ans << endl;
}

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

using namespace std;
typedef         long long int   ll;

#define         input           freopen("input.txt","r",stdin)
#define         output          freopen("output.txt","w",stdout)
#define         si(a)           scanf("%d",&a)
#define         sii(a,b)        scanf("%d%d",&a,&b)
#define         siii(a,b,c)     scanf("%d%d%d",&a,&b,&c)
#define         pi(a)           printf("%d",a)
#define         spc             printf(" ")
#define         bl              printf("\n")
#define         here(a)         printf("#### %d ####",a)
#define         pii             pair<int,int>
#define         fr(i,n)         for(int i=0;i<n;i++)
#define         case(num)       printf("Case %d:",num)
#define         inf             1000000050
#define         MAX             100010*2
#define         MOD             1000000007

vector<ll>v,val;

int main(){

    //input;
    //output;

    ll sum,n,tmp;
    cin>>n;
    sum = 0;

    for(int i=0;i<n;i++){
        cin>>tmp;
        sum += tmp;
        v.push_back(sum);
        val.push_back(tmp);
    }

    ll ans = 0;

    for(int i=0;i<(n-1);i++){
        ans = (ans + ((v[n-1]-v[i])%MOD * val[i])%MOD)%MOD;
    }


    cout<<ans<<endl;


    return 0;
}
/**
*/


Measured memory_bytes: 6576
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<iostream>
#define N 2100
#define mmod 924844033
using namespace std;
int n,m,A[N],du[N],f[N],g[N][N][2],siz,num,p[N],jc[N],ans;
void upd(int &x,int y)
{
	x=(x+y)%mmod;
}
void solve(int st)
{
	num=0;
	while(st<=n) {A[++num]=st;st+=2*m;}
	for(int i=1;i<=num;i++)
	{
		du[i]=0;
		if(A[i]-m>=1) du[i]++;
		if(A[i]+m<=n) du[i]++;
	}
	if(num==1 && du[1]==0) {siz++;return;}
	for(int i=1;i<=num;i++)
		for(int j=0;j<=i;j++)
			for(int o=0;o<=1;o++)
				g[i][j][o]=0;
	g[1][0][0]=1;g[1][1][1]=1;
	if(du[1]==2) g[1][1][0]=1;
	for(int i=1;i<num;i++)
		for(int j=0;j<=i;j++)
		{
			upd(g[i+1][j][0],g[i][j][0]);
			upd(g[i+1][j][0],g[i][j][1]);
			upd(g[i+1][j+1][0],g[i][j][0]);
			if(du[i+1]==2) 
			{
				upd(g[i+1][j+1][1],g[i][j][0]);
				upd(g[i+1][j+1][1],g[i][j][1]);
			}
		}
	for(int i=0;i<=siz+num;i++) p[i]=0;
	for(int i=0;i<=siz;i++)
		for(int j=0;j<=num;j++)
			upd(p[i+j],1ll*f[i]*(g[num][j][0]+g[num][j][1])%mmod);
	siz+=num;
	for(int i=0;i<=siz;i++) f[i]=p[i];
}
int main()
{
	scanf("%d%d",&n,&m);
	int lim=min(n,2*m);
	siz=0;
	f[0]=1;
	for(int i=1;i<=lim;i++) solve(i);
	jc[0]=jc[1]=1;
	for(int i=2;i<=n;i++) jc[i]=1ll*jc[i-1]*i%mmod;
	for(int i=0;i<=n;i++)
	{
		int t=1ll*jc[n-i]*f[i]%mmod;
		if(i%2) upd(ans,-t);
		else upd(ans,t);
	}
	upd(ans,mmod);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 17280
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
#include<iomanip>
using namespace std;
int main() {
	int N, T;	cin >> N >> T;
	vector<int> t(N);
	long long ans = 0;
	for (int i = 0; i < N; ++i) {
		cin >> t[i];
	}
	int tt = 0;
	for (int i = 1; i < N; ++i) {
		if (tt + T > t[i]) {
			ans += t[i] - t[i - 1];
		}
		else {
			ans += T;
		}
		tt = t[i];
	}
	ans += T;
	cout << ans << endl;
	cin >> N;
}

Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;


class Program
{


    static void Main(string[] args)
    {
        Solve();
    }

    static void Solve()
    {
        Scan sc = new Scan();
        write wr = new write();

        var s = sc.longarr;

        long a = s[0];
        long b = s[1];
        long k = s[2];

        for (long i = a; i <= Math.Min(a + k - 1, b); i++)
        {
            wr.wri(i);
        }
        for(long i = Math.Max(b-k+1, Math.Min(a + k - 1, b)+1); i <= b; ++i)
        {
            wr.wri(i);
        }

    }


}
    class Scan
    {
        public string str => Console.ReadLine();

        public string[] strarr => str.Split(' ');

        public long[] longarr => strarr.Select(long.Parse).ToArray();
        public int[] intarr => strarr.Select(int.Parse).ToArray();
        public char[] chararr => str.ToArray();


}



class write
{
    public void wri<Type>(Type x)
    {
        Console.WriteLine(x);
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep2(i,n) for (int i = 1; i < (n); ++i)
using namespace std;
typedef long long ll;
using namespace std;
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; }

const long long INF = 1LL << 60;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    // 入力
    int N;
    long long h[100010];

    // DP テーブル
    long long dp[100010];

    cin >> N;
    rep(i,N) cin >> h[i];

    // 初期化 (最小化問題なので INF に初期化)
    rep(i,100010) dp[i] = INF;

    // 初期条件
    dp[0] = 0;

    // ループ
    rep2(i,N) {
        chmin(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
        if (i > 1) chmin(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
    }

    // 答え
    cout << dp[N-1] << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <stdio.h>
#include <string.h>
#define MAX_N 45
#define MAX_S 150000
#define MOD 1000000007
#define int long long

using namespace std;

int n,x,y,z,ans=1;
int dp[MAX_N][MAX_S];

signed main()
{
	scanf("%lld%lld%lld%lld",&n,&x,&y,&z);
	for(int i=1;i<=n;i++) ans=ans*10%MOD;
	int t=(1<<(x-1)|(1<<(x+y-1))|(1<<(x+y+z-1)));
	dp[0][0]=1;
	for(int i=1;i<=n;i++)
	{
		for(int state=0;state<(1<<(x+y+z));state++)
		{
			for(int j=1;j<=10;j++)
			{
				int nex=((state<<j)|(1<<(j-1)))&((1<<(x+y+z))-1);
				if((nex&t)!=t) dp[i][nex]=(dp[i][nex]+dp[i-1][state])%MOD;
			}
		}
	}
	for(int state=0;state<(1<<(x+y+z));state++) ans=((ans-dp[n][state])%MOD+MOD)%MOD;
	printf("%lld\n",ans);
}


Measured memory_bytes: 48256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <functional>
using namespace std;

typedef long long ll;

vector<int> edg[100003];
int col[100003], s[100003], dis[100003];
int dp[100003][13];



int main() {
	int n, m; cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int a, b; cin >> a >> b;
		a--; b--;
		edg[a].push_back(b);
		edg[b].push_back(a);
	}
	int q; cin >> q;
	for (int i = 1; i <= q; i++) {
		int v, d, c; cin >> v >> d >> c;
		--v;
		col[i] = c;
		s[i] = v;
		dis[i] = d;
	}
	deque<pair<int, pair<int, int> > > que;
	for (int i = q; i > 0; i--) {
		if (dp[s[i]][dis[i]] != 0) continue;
		que.push_back({ s[i], {dis[i], i} });
		while (!que.empty()) {
			int pos = que.front().first, d = que.front().second.first, ran = que.front().second.second;
			que.pop_front();
			for (int j = d; j >= 0; j--) {
				if (dp[pos][j] != 0) continue;
				dp[pos][j] = ran;
				if (j == 0) break;
				for (int i : edg[pos]) {
					if (dp[i][j - 1] != 0) continue;
					que.push_back({ i, {j - 1, ran} });
				}
			}
		}
	}
	for (int i = 0; i < n; i++) cout << col[dp[i][0]] << endl;
	return 0;
}

Measured memory_bytes: 20856
import math
t = input().split()
t = [int(i) for i in t]
r = math.sqrt(t[0]*t[0]+ t[1]*t[1])
h = t[2]
m = t[3]
if (h == 12):
    h = 0
if (m == 60):
    m = 0
hour_angle = 0.5 * (h * 60 + m) 
minute_angle = 6 * m 
angle = abs(hour_angle - minute_angle) 
angle = min(360 - angle, angle)
print(math.sqrt(r*r - 2*t[0]*t[1]*math.cos(angle*(2*math.pi/360))))

Measured memory_bytes: 9540
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 3e5 + 5;
struct node {
	int e, w, next;
}edge[maxn];
int head[maxn], len, vis[maxn], dis[maxn];
void init() {
	memset(head, -1, sizeof(head));
	len = 0;
}
void add(int s, int e, int w) {
	edge[len].e = e;
	edge[len].w = w;
	edge[len].next = head[s];
	head[s] = len++;
}
void dfs(int x, int fa) {
	for (int i = head[x]; i!= -1; i = edge[i].next) {
		int y = edge[i].e;
		if (y == fa)
			continue;
		dis[y] = dis[x] + edge[i].w;
		if (dis[y] % 2)
			vis[y] = 1;
		else
			vis[y] = 0;
		dfs(y, x);
	}
}
int main() {
	int n;
	while (cin >> n) {
		init();
		int x, y, z;
		for (int i = 1; i < n; i++) {
			scanf("%d%d%d", &x, &y, &z);
			add(x, y, z);
			add(y, x, z);
		}
		memset(vis, 0, sizeof(vis));
		memset(dis, 0, sizeof(dis));
		vis[1] = 0;
		dis[1] = 0;
		dfs(1, 0);
		for (int i = 1; i <= n; i++)
			cout << vis[i] << endl;
	}
}


Measured memory_bytes: 8832
#include <iostream>
#include <cstdio>
#include <cstdlib>

using namespace std;

int H;
int heap[500000];

inline void max_heapify(int node) {
    int left = node * 2 + 1, right = node * 2 + 2, largest = node;
    if (left < H && heap[left] > heap[node]) {
        largest = left;
    }
    else {
        largest = node;
    }
    if (right < H && heap[right] > heap[largest]) {
        largest = right;
    }
    if (largest != node) {      // a child is bigger than the parent.
        int tmp = heap[node];
        heap[node] = heap[largest];
        heap[largest] = tmp;
        max_heapify(largest);
    }
}

inline void build_max_heap() {
    for (int i = H / 2 - 1; i >= 0; --i) {
        max_heapify(i);
    }
}

int main(void) {

    cin >> H;

    for (int i = 0; i < H; ++i) {
        scanf("%d", heap + i);
    }

    build_max_heap();

    for (int i = 0; i < H; ++i) {
        printf(" %d", heap[i]);
    }
    printf("\n");

    return 0;
}

Measured memory_bytes: 3184
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
bool check(ll y){
    ll x=sqrt(y);
    for(ll i=x-1;i<=x+1;i++){
        if(i*i == y)
            return true;
        }
        return false;
}   
int main()
{
    ll n,a,b,d,i,j,k,x;
    cin>>a>>b;
    set<int> s;
    for(i=a;i<=b;i++){
        s.insert(i%2019);
        if(s.size()==2019)
            break;
    }
    if(s.size()==2019){
        cout<<"0";
    }
    else{
        vector<int> v;
        ll mod=2019;
        ll ans=1e9;
        for(auto it:s)  v.push_back(it);
        for(i=0;i<v.size();i++){
            
            for(j=i+1;j<v.size();j++){
                ans=min(ans,(v[i]*v[j])%mod);
            }
        }
        cout<<ans;
    }
    
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define Sort(x) sort((x).begin(), (x).end())
#define Reverse(x) reverse((x).begin(), (x).end())
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define INF INT_MAX
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15) //15桁まで表示
#define str string
typedef std::pair<int,int> pii;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<ui,ui> puu;
typedef pair<int, int> P;
typedef vector<int> vi;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a * b / gcd(a, b);};
int floor(int a,int b){return (a+b-1)/b;};
int month[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
template<class T>inline bool chmax(T& a,T b){if(a < b){a=b;return true;}return false;};
template<class T>inline bool chmin(T& a,T b){if(a > b){a=b;return true;}return false;};

int main() {
	int n,x,Min=1010;
	cin >> n >> x;
	vi m(n);
	rep(i,n) {cin >> m[i]; x-=m[i]; Min=min(Min,m[i]);}
	cout << n+x/Min << endl;
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;
int main()
{
    int A, B;
    cin >> A >> B;
    cout << max(0, A - (2 * B)) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

int main() {
  int n;
  cin >> n;
  bool ans = true;
  vector<vector<int>> a(n, vector<int>(3));
  for (int i = 0; i < 3; i++) {
    cin >> a[i][0] >> a[i][1] >> a[i][2];
  }
  for (int i = 0; i < n; i++) {
    if (a[i][0] % 2 != (a[i][1] + a[i][2]) % 2) ans = false;
    if (a[i][0] < abs(a[i][1]) + abs(a[i][2])) ans = false;
  }
  if (ans) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 5760
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()

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;
}
constexpr int mod = 1e9+7;
constexpr int inf = 3e18;

int N,D;
signed main(){
	cin>>N>>D;
	int ans=0;
	while(N--){
		int x,y;cin>>x>>y;
		if(x*x+y*y<=D*D)ans++;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using ll = long long;
using namespace std;
const ll INF = 1000000000000000000;
const ll mod = 1000000007;
//printf("%.10f\n", n);
signed main() {
	ll n; string s; cin >> s;
	for (int h = 0; h < s.size(); h++) {
		if (s[h] == '?') { s[h] = 'D'; }
	}
	cout << s << endl;
	cin >> n; return 0;
}

Measured memory_bytes: 3728
nk = list(map(int,input().split()))
h = list(map(int,input().split()))
n,k = nk[0], nk[1] #5,3
DP = [0]
for i in range(1, n):#0~3 -> 1~4
  act = float("inf")
  for k_ in range(1, k+1):#0~2 -> 1~3
    if i-k_ < 0 : continue
    act = min(DP[-k_] + abs(h[i-k_]-h[i]), act)#
  DP+= [act]#[0,20,]
print(DP[-1])

Measured memory_bytes: 58080
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
	"strings"

)


func main() {
	solve(os.Stdin, os.Stdout)
}

type ReaderEx struct {
	baseScanner *bufio.Scanner
	words       []string
	nextWordIdx func() int
	initWordIdx func(int)
}

func NewScannerEx(stdin io.Reader) *ReaderEx {
	var this ReaderEx
	var idx int
	var wordsCnt int
	this.baseScanner = bufio.NewScanner(stdin)
	this.baseScanner.Buffer(make([]byte, 0), 1E+11)
	this.nextWordIdx = func() int {
		cur := idx
		idx = (idx + 1) % wordsCnt
		return cur
	}
	this.initWordIdx = func(wc int) {
		idx = 0
		wordsCnt = wc
	}
	return &this
}

func (me *ReaderEx) Scan(doSplit bool) (isScanned bool) {
	isScanned = me.baseScanner.Scan()
	if doSplit {
		me.words = strings.Fields(me.baseScanner.Text())
	} else {
		me.words = []string{me.baseScanner.Text()}
	}
	me.initWordIdx(len(me.words))
	return
}

func (me *ReaderEx) nextBytes() []byte {
	return []byte(me.words[me.nextWordIdx()])
}
func (me *ReaderEx) nextString() string {
	return me.words[me.nextWordIdx()]
}

type StringArray []string

func (me *ReaderEx) nextStringArray() StringArray {
	return me.words[me.nextWordIdx():]
}

func (me StringArray) toStrings() []string {
	return me
}

func (me StringArray) toInts() []int {
	strValues := me.toStrings()
	values := make([]int, len(strValues))
	for i, v := range strValues {
		n, err := strconv.Atoi(v)
		if err != nil {
			panic(err)
		}
		values[i] = n
	}
	return values
}
func (me *ReaderEx) nextInt() int {
	n, err := strconv.Atoi(me.words[me.nextWordIdx()])

	defer func() {
		if err != nil {
			panic(fmt.Sprintf("getInt(%d)", n))
		}
	}()
	return n
}

func pow(x, y, mod int) (ans int) {

	ans = 1
	for bit := 1 << uint(math.Floor(math.Log2(float64(y)))); ; bit >>= 1 {
		if y&bit != 0 {
			ans *= x
			if mod > 0 {
				ans %= mod
			}
		}
		if bit <= 1 {
			return
		}
		ans *= ans
		if mod > 0 {
			ans %= mod
		}
	}
}

type factType struct {
	prime int
	count int
}

func fact(n int) (facts []*factType) {

	for i := 2; i*i <= n; i++ {
		if n%i == 0 {
			fa := factType{prime: i}
			for n%fa.prime == 0 {
				n /= fa.prime
				fa.count++
			}
			facts = append(facts, &fa)
		}
	}
	if n > 1 {
		facts = append(facts, &factType{prime: n, count: 1})
	}
	return facts
}
func dec2bin(n int) (ret []bool) {
	for bit := 1 << uint(math.Floor(math.Log2(float64(n)))); ; bit >>= 1 {
		ret = append(ret, n&bit != 0)

		if bit <= 1 {
			return
		}
	}

}

func abs(v int) int {
	if v < 0 {
		v = -v
	}
	return v
}

func b2i(b bool) (i int) {
	if b {
		i = 1
	} else {
		i = 0
	}
	return
}

func solve(stdin io.Reader, stdout io.Writer) {

	r := NewScannerEx(stdin)
	r.Scan(true)
	s := r.nextString()
	r.Scan(true)
	t := r.nextString()

	fmt.Fprintln(stdout, []string{"No", "Yes"}[b2i(s == t[:len(t)-1])])
}


Measured memory_bytes: 1776
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(){
   int N;
   char S[51],S2[51];
   int flag = 0, ans = 0;
   scanf("%d\n",&N);
   for(int i = 0;i < N;i++){
      if(flag == 4)
         flag = 0;
      scanf("%c",&S[i]);
      if((S[i] == 'A') && (flag == 0))
         flag++;
      else if((S[i] == 'A') && (flag == 1));
      else if((S[i] == 'B') && (flag == 1))
         flag++;
      else if((S[i] == 'C') && (flag == 2))
         flag++;
      else 
         flag = 0;
      if(flag == 3){
         ans++;
         flag++;
      }
      //printf("i=%d:Debag:%c:%d\n",i,S[i],flag);
   }
   printf("%d\n",ans);
   return 0;
}

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

#define MAXN 100005
#define INF 0x3f3f3f3f

using namespace std;

int alturas[MAXN];
int dp[MAXN];
int k;

int solve(int n){
    if(n <= 0) return INF;

    if(dp[n] != -1) return dp[n];

    dp[n] = INF;

    for(int i = n - 1; i >= max(n - k, 1); i--){
        dp[n] = min(dp[n], solve(i) + abs(alturas[i] - alturas[n]));
    }

    return dp[n];
}

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

    int n;
    cin >> n >> k;

    for(int i = 1; i <= n; i++) cin >> alturas[i];

    memset(dp, -1, sizeof(dp));

    dp[1] = 0;

    cout << solve(n) << endl;

    return 0;
}

Measured memory_bytes: 5760
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC_C
{
    class C093
    {
        static void Main(string[] args)
        {
            string[] a0 = Console.ReadLine().Split(' ');
            List<int> a = a0.Select(x => int.Parse(x)).ToList();
            a.Sort();

            int d1 = a[2] - a[0];
            int d2 = a[2] - a[1];
            int count = 0;
            count += d1 / 2;
            count += d2 / 2;
            int e1 = d1 % 2, e2 = d2 % 2;
            if (e1 == 1 && e2 == 1) count++;
            else if (e1 == 1 || e2 == 1) count += 2;
            Console.WriteLine(count);
        }

    }
}


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

//#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1002000007
#define INF LONG_LONG_MAX

int main(){
    int k,x;
    cin>>k>>x;
    if ((k*500>=x) ? cout<<"Yes"<<endl : cout<<"No"<<endl);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cstdlib>
using namespace std;
typedef long long ll;
//bool comp(ll a, ll b)
//{
  //  return (a < b);
//}
int main(){

ll n,i,j,k,ans=0;
vector <ll> v,dp;
cin>>n;
for(i=0;i<n;i++){
    cin>>j;
    v.push_back(j);
}
for(i=0;i<n;i++){
 if(i==0)
   dp.push_back(0);
  else if(i==1)
    dp.push_back(abs(v[i]-v[i-1]));
  else{
	dp.push_back(min(dp[i-1]+abs(v[i]-v[i-1]),dp[i-2]+abs(v[i]-v[i-2])));
  }
}

cout<<dp[n-1]<<endl;

return 0;
}


Measured memory_bytes: 2548