akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input! {
        l: i64, r: i64,
    }
    if r - l >= 2019 {
        puts!("0\n");
        return;
    }
    let mut mi = 2019;
    for i in l..r + 1 {
        for j in i + 1..r + 1 {
            mi = min(mi, i * j % 2019);
        }
    }
    puts!("{}\n", mi);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


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

using i64 = int64_t;

int main(){
    int n;
    cin >> n;
    bool approved = true;
    for(int i=0;i<n;++i){
        int a;
        cin >> a;
        if(a % 2 == 0 && a%3 != 0 && a%5 != 0)approved = false;
    }

    cout << (approved ? "APPROVED" : "DENIED") << endl;

    return 0;
}

Measured memory_bytes: 256
# import sys
# import math #sqrt,gcd,pi
# import decimal
# import queue # queue
# import bisect
# import heapq # priolity-queue
# import time
# from itertools import product,permutations,\
#     combinations,combinations_with_replacement
# 重複あり順列、順列、組み合わせ、重複あり組み合わせ
# import collections # deque
# from operator import itemgetter,mul
# from fractions import Fraction
# from functools import reduce

mod = int(1e9+7)
# mod = 998244353
INF = 1<<50

def readInt():
    return list(map(int,input().split()))

def main():
    n,k = readInt()
    p = readInt()
    p.sort()
    ans = 0
    for i in range(k):
        ans += p[i]
    print(ans)
    return

if __name__=='__main__':
    main()


Measured memory_bytes: 62448
#include<bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<vll> vvll;
typedef vector<ld> vld;
typedef map<ll,ll> mpll;
typedef set<ll> setll;
typedef multiset<ll> msetll;
 
#define F first
#define S second
#define pb push_back
#define mp make_pair 

const ll inf = ll(1e18);
const ll MOD = (1e9 + 7);

int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifdef DEBUG_
		freopen("input.txt","r",stdin);
	#endif
	cout.setf(ios::fixed), cout.precision(20);
    ll a,b;
    cin >> a >> b;
    cout<<(a*b)/__gcd(a,b)<<"\n";
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
class Main {
  public static void main(String[] args) {
	  int a, b, c;
	  Scanner sc = new Scanner(System.in);
	  a = sc.nextInt();
	  b = sc.nextInt();
	  c = sc.nextInt();
	  int temp;
	  if (a > b) {
		  temp = a; a = b; b = temp;
	  }
	  if (b > c) {
		  temp = b; b = c; c = temp;
	  }
	  if (a > b) {
		  temp = a; a = b; b = temp;
	  }
	  System.out.println(a + " " + b + " " + c);
  }
}


Measured memory_bytes: 26368
import math
import itertools
N = int(input())
xy_list = []
for i in range(N):
    xy_list.append(list(map(int, input().split())))
distance = 0
count = 0
permutations = itertools.permutations(xy_list)
for permutation in permutations:
    count += 1
    for i in range(len(permutation) - 1):
        xi = permutation[i][0]
        yi = permutation[i][1]
        xj = permutation[i + 1][0]
        yj = permutation[i + 1][1]
        d = math.sqrt((xi - xj) ** 2 + (yi - yj) ** 2)
        distance += d
print(distance / count)


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

using namespace std;

using ll = long long;
using ii = std::pair<int, int>;
using vi = vector<int>;
using vii = vector<ii>;
using vvi = vector<vi>; //vector<vector<int>>
using vs = vector<string>;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ppb pop_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend() 
#define sz(x) (int)((x).size())
#define arrsz(x) (int) (sizeof((x))/sizeof((x)[0]))

#define LSOne(S) (S & (-S))
#define isBitSet(S, i) ((S >> i) & 1)

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)

/* Usage: output_vector(solution), which prints elements with spaces and then new line*/
template<typename T>
void output_vector(const vector<T> &v, int start = -1, int end = -1) {
    if (start < 0) start = 0;
    if (end < 0) end = int(v.size());
 
    for (int i = start; i < end; i++)
        cout << v[i] << " ";
    cout << endl;
}
// FILE I/O
void setIn(string s) { freopen(s.c_str(),"r",stdin); }
void setOut(string s) { freopen(s.c_str(),"w",stdout); }
void unsyncIO() { ios_base::sync_with_stdio(0); cin.tie(0); }
void setIO(string s = "") {
	unsyncIO();
	// cin.exceptions(cin.failbit); 
	// throws exception when do smth illegal
	// ex. try to read letter into int
	if (sz(s)) { setIn(s+".in"), setOut(s+".out"); } // for USACO
}

int main()
{
  int n, k;
  cin >> n >> k;
  vector<int> input;
  for (int i = 0; i < n; i++)
  {
    int num;
    cin >> num;
    input.push_back(num);
  }
  sort(all(input));
  int total = 0;
  for (int i = 0; i < k; i++)
  {
    total += input[i];
  }
  cout << total << endl;
}
   

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

int n;
int dp[100005], v[100005];

int solve(int pos){
    if(pos >= n) return 1e9+5;
    if(pos == n-1) return 0;
    if(dp[pos] != -1) return dp[pos];
    int esq = solve(pos+1) + abs(v[pos+1]-v[pos]);
    int dir = solve(pos+2) + abs(v[pos+2]-v[pos]);
    return dp[pos] = min(esq, dir);
}

int main(){
    memset(dp, -1, sizeof dp);
    scanf("%d", &n);
    for(int i = 0; i < n; i++)
        scanf("%d", &v[i]);
    printf("%d\n", solve(0));
	return 0;
}


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

int main() {
  string a;
  cin >> a;
  
  int ans = 0;
  
  for (int i = 0; i < 3; i = i + 1) {
    if (a.at(i) == '1') {
      ans = ans + 1;
    }
  }
  
  cout << ans << endl; 
}
  

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;
using P = pair<int, int>;

int main()
{
    ll n, k;
    cin >> n >> k;
    ll r = n % k;
    ll a = abs(r - k);
    cout << min(a, r) << endl;
    return 0;
}

Measured memory_bytes: 3540
#include<iostream>
#include<algorithm>

using namespace std;

// Problem https://atcoder.jp/contests/abc070/tasks/abc070_b

int solver(int ASTART,int ASTOP,int BSTART,int BSTOP){
    int result;
    result = 0;
    int switchingtime;
    switchingtime = min(ASTOP,BSTOP)-max(ASTART,BSTART);
    if(0 < switchingtime){
        result = switchingtime;
    }
    return result;
}

int main(void){
    int A,B,C,D;
    int answer;
    answer = 0;
    cin >> A >> B >> C >> D;
    answer = solver(A,B,C,D);
    cout << answer;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
void bsort(int a[],int n){
  int i,j;

  for(i = 0;i < n-1;i++){
    for(j = n-1;j > i;j--){
      if(a[j-1] > a[j]){
        int temp = a[j];
        a[j] = a[j-1];
        a[j-1] = temp;
      }
    }
  }
}
int main(void)
{
int i,n,k;
int sum=0;
int p[1000];
scanf("%d", &n);
scanf("%d", &k);

for(i = 0; i < n;i++){
scanf("%d", &p[i]);
}
bsort(p,n);
for(i = 0; i < k;i++)
sum +=p[i];
printf("%d", sum);

  return 0;
}


Measured memory_bytes: 1736
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define D()
#define INF 1000000000000
#define MOD 10000007
#define MAXR 100000
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define INITA(a,i,j,v) for(ll k=i;k<=j;k++){a[k]=v;}

int main() {
    ll n; cin >> n;
    map<ll, ll> m;
    REP(i, n) {
        ll tmp;
        cin >> tmp;
        if (m.find(tmp) == m.end()) {
            m[tmp] = 0;
        }
        m[tmp]++;
    }
    ll res = 0;
    for (auto e:m) {
        if (e.first < e.second) {
            res += e.second - e.first;
        } else if (e.first > e.second) {
            res += e.second;
        }
    }
    cout << res << endl;
    return 0;
}

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

int ans[510][510];

void f(vector<int> v, int lv) {
    if (v.size() == 1) return;
    vector<int> v1, v2;
    for (int i = 0; i < v.size(); i++) {
        if (i < v.size() / 2) {
            v1.push_back(v[i]);
        } else {
            v2.push_back(v[i]);
        }
    }
    for (int i = 0; i < v1.size(); i++) {
        for (int j = 0; j < v2.size(); j++) {
            ans[v1[i]][v2[j]] = lv;
            ans[v2[j]][v1[i]] = lv;
        }
    }
    f(v1,lv+1);
    f(v2,lv+1);
}

int main() {
    int n;
    cin >> n;
    vector<int> v;
    for (int i = 1; i <= n; i++) {
        v.push_back(i);
    }
    f(v,1);
    for (int i = 1; i < n; i++) {
        for (int j = i + 1; j <= n; j++) {
            cout << ans[i][j] << " \n"[j == n];
        }
    }
    return 0;
}


Measured memory_bytes: 1536
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
#include <set>
#include <map>
#include <tuple>
using namespace std;

#define ll long long
#define ull unsigned long long
#define rep(i,N) for (int i=0;i<N;i++)
#define loop(i,N,M) for(int i=N;i<M;i++)
#define MAX(v) *max_element(v.begin(),v.end())
#define MIN(v) *min_element(v.begin(),v.end())
#define SORTL2S(type,v) sort(v.begin(),v.end(),greater<type>())
#define SORTS2L(type,v) sort(v.begin(),v.end())
#define SORTMF(v,func) sort(v.begin(),v.end(),func)

//変数
ll K,A,B;

//解法
void solve() {
	
	if (A >= B) {
		cout << K + 1;
		return;
	}
	if (B - A == 1) {
		cout << K + 1;
		return;
	}

	if (1 + K <= A) {
		cout << K + 1;
		return;
	}

	ll ans = A;
	K -= A - 1;
	if (K % 2 == 1) {
		K--;
		ans++;
	}
	
	ans += K / 2 * (B - A);

	cout << ans;

	return;
}

int main() {

	//入力
	cin >> K >> A >> B;

	solve();
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
s = input()
former = s[:2]
latter = s[2:]
#前者がMMの可能性
if int(former) >= 1 and int(former) <= 12:
    if int(latter) >= 1 and int(latter) <= 12:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if int(latter) >= 1 and int(latter) <= 12:
        print("YYMM")
    else:
        print("NA")


Measured memory_bytes: 2940
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()

ans = N * (N + 1) // 2
a = (N // 3) * (N // 3 + 1) // 2 * 3
b = (N // 5) * (N // 5 + 1) // 2 * 5
c = (N // 15) * (N // 15 + 1)  // 2 * 15
# print(ans, a, b, c)
print(ans - a - b + c)



# c = 0
# for i in range(1, N):
#     if i % 5 != 0 and i % 3 != 0:
#         c += i

# print(c)

Measured memory_bytes: 10576
#include<stdio.h>
#define N 2000001
int B[N], n;

void CountingSort(int A[], int k){
  int C[k + 1], i, j;
  for(i = 0; i <= k; i++) C[i] = 0;
  for(j = 1; j <= n; j++) C[A[j]]++;
  for(i = 1; i <= k; i++) C[i] = C[i] + C[i - 1];
  for(j = n; j > 0; j--){
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }
}
int main(){
  int A[N], i, k = 0;
  scanf("%d", &n);
  for(i = 1; i <= n; i++){
    scanf("%d", &A[i]);
    if(k < A[i]) k = A[i];
  }
  CountingSort(A, k + 1);
  for(i = 1; i <= n; i++){
    printf("%d", B[i]);
    if(i < n)printf(" ");
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 16264
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define PI                acos(-1)
#define pb                push_back
#define mp                make_pair
#define all(a)            (a).begin(), (a).end()
#define clr(a,h)          memset(a, (h), sizeof(a))
#define forr(i, b, e)     for(ll i = b; i < e; i++)
#define forite(i, b, e)    for(auto i = b; i!=e; i++)
#define forg(i, b, e, m)  for(ll i = b; i < e; i+=m)

#define F first
#define S second

using namespace std;
using namespace __gnu_pbds;

typedef long long       ll;
typedef pair<ll, ll>  ii;
typedef vector<ll>     vi;
typedef vector<ii>      vii;
typedef vector<ll>      vll;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
const ll INF = ll(1e9+7);
#define tam 320000
#define tamlog 61
#define ptr nodo*

typedef pair<ii,ll> iii;
ll resp[tam];
int  main()
{
    ll n;
    cin>>n;
    map<ll,ll> occur,minpos;
    ll valor;
    forr(i,0,n)
    {
        cin>>valor;
        if (occur[valor]==0)
            minpos[valor]=i;
        occur[valor]++;
    }
    occur[0]=0;
    minpos[0]=n+10;
    auto ite=occur.end();
    ll pos=tam;
    ll totoccur=0;
    do{
        //if (ite->F==0)break;
        ite--;
        
        pos=min(pos,minpos[ite->F]);
        auto ite2=ite;ite2--;
        totoccur+=ite->S;
        if (ite->F!=0)
        resp[pos]+=(ite->F-ite2->F)*totoccur;

    }while(ite!=occur.begin());
    forr(i,0,n)
    cout<<resp[i]<<endl;
}
// PLUS ULTRA!

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (ll i=(ll)from; i<(ll)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = 998244353;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }


int main() {
  ll A, B, C, D; cin >> A >> B >> C >> D;
  ll dp[C+1][D+1] = {}; dp[A][B] = 1;
  repr(i,A,C+1) repr(j,B,D+1) {
    if (i==A&&j==B) continue;
    else if (i==A) dp[i][j] = dp[i][j-1] * i % MOD;
    else if (j==B) dp[i][j] = dp[i-1][j] * j % MOD;
    else dp[i][j] = (( dp[i-1][j] * j + dp[i][j-1] * i - dp[i-1][j-1] * (i-1) * (j-1))%MOD+MOD)%MOD;
  }
  // rep(i,C+1) debug(dp[i],dp[i]+(D+1));

  ll result = dp[C][D];
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 73952
#include <iostream>
#include <limits>
#include <cfenv>
#include <cmath>
#include <algorithm>
#include <array>
#include <bitset>
#include <cstring>
#include <map>
#include <stack>
#include <set>
#include <tuple>
#include <queue>
#include <vector>
#include <cmath>
#include <random>
#include <math.h>
#include <list>
#include <random>
#include <functional>


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

using lli = long long int;
using range = std::pair<lli, lli>;
using datum = std::pair<int, range>;
std::vector<datum> A;

int main(void){
    lli N, X, D; scanf("%lld%lld%lld", &N, &X, &D);
    if(D < 0){
        //X += D * (N-1);
        X = -X;
        D = -D;
    }
    if(D == 0){
        if(X == 0) puts("1");
        else printf("%lld\n", N+1);
        return 0;
    }
    A.resize(N+1);
    for(lli k = 0; k <= N; ++k){
        // 0 + D + 2D + ... + (k-1)D = D * k(k-1)/2
        // (n-1)D + (n-2)D + ... + (n-k)D = (nk - k(k+1)/2)D
        lli MinL = k * X + D * k * (k-1) / 2;
        lli MaxR = k * X + D * (N * k - k * (k + 1) / 2);
        lli M = MinL % D; if(M < 0) M += D; // 正のあまり
        // { n | nD + M が選べる}
        lli L = (MinL - M) / D;
        lli R = (MaxR - M) / D;
        A[k] = {M, range(L, R)};
    }
    std::sort(A.begin(), A.end());
    lli res = 0;
    int idx = 0; 
    while(idx <= N){
        int cnt = 1;
        lli left  = A[idx].second.first;
        lli right = A[idx].second.second;
        while(idx + cnt <= N and 
              A[idx].first == A[idx+cnt].first and
              A[idx+cnt].second.first <= right)
              {
                  if(right < A[idx+cnt].second.second) right = A[idx+cnt].second.second;
                  cnt++;
              }
        res += right - left + 1; 
        idx += cnt;
    }
    printf("%lld\n", res);
    return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
int main() {
  int count=0;
  vector<char> a(4);
  for (int i=0;i<4;i++) {
    cin >> a.at(i);
    if(a.at(i)=='+') {
      count++;
    }
    else if (a.at(i)=='-') {
      count--;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
import Control.Applicative( (<$>))

main = do
    [n_, t_] <- map read . words <$> getLine
    ts_ <- map read . words <$> getLine
    let
	sumup = t_ * length ts_

	minus [_] = 0
	minus (t1:ts@(t2:_)) = let
				end = t1+t_
				eaten = max (end - t2) 0
			    in
				eaten + minus ts

    print $ sumup - minus ts_

Measured memory_bytes: 152956
import java.util.*;

public class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        String S = sc.next();
        sc.close();

        int[] numB = new int[N]; //i番目までに黒が何個あるか
        for(int i = 0; i < N; i++){
            if(i == 0){
                if(S.charAt(i) == '#')
                    numB[i] = 1;
            } else {
                if(S.charAt(i) == '#')
                    numB[i] = numB[i-1]+1;
                else
                    numB[i] = numB[i-1];
            }
        }
        int n = numB[N-1];
        int min = Math.min(n, N-n); //全部白に変える
        for(int i = 0; i < N; i++){
            if(i == 0 ){
            } else {
                if(numB[i] > numB[i-1]) {
                    int cnt = 0;
                    cnt += (numB[i]-1);
                    cnt += ((N-i-1) - (n-numB[i]));
                    min = Math.min(min, cnt);
                }
            }
        }
        System.out.println(min);

    }
}

Measured memory_bytes: 26816
import sys
input = sys.stdin.readline
def print_ans(N, ar):
    """Test Case
    >>> print_ans(5, [6, 7, 9, 10, 31])
    APPROVED
    >>> print_ans(3, [28, 27, 24])
    DENIED
    """
    flg = True
    for a in ar:
        if a % 2 == 0 and a % 3 != 0 and a % 5 != 0:
            flg = False
            break

    if flg:
        print("APPROVED")
    else:
        print("DENIED")



if __name__ == '__main__':
    N = int(input().rstrip())
    ar = list(map(int, input().rstrip().split()))
    print_ans(N, ar)




Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph= vector<vector<int>>; 
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
#define mpa make_pair
#define fi first
#define se second 
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
ll  dp[55][2505] ;
ll  cop[55][2505];
int main(){
 ll n ,k ;cin>>n>>k ;
 vector<ll> A(n) ; rep(i,n)  cin>>A[i] ;
 rep(i,55){
   rep(j,2505) dp[i][j]= 0 ;
 }
 dp[0][0]=1 ;
 rep(i,55){
   rep(j,2505) cop[i][j]= dp[i][j] ;
 }
 
 rep(i,n){
   rep(j,55){
     rep(l,2505){
       if(j>=1&&l>=A[i]) dp[j][l]+=cop[j-1][l-A[i]] ; 
     }
   }
 
   rep(a,55){
     rep(b,2505) cop[a][b]= dp[a][b] ;
   }
 
 }
 ll ans= 0;
 for(ll i=1 ;i<=n ;i++){
   ans+= dp[i][i*k] ;
 }
  cout<<ans<<endl ;
  return 0;
  }

Measured memory_bytes: 5744
#include <iostream>
#include <utility>
#include <map>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <array>
#include <math.h>
#include <numeric>
#include <sstream>
typedef long long ll;
using namespace std;

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

ll lcm(ll a, ll b) {
    ll x = gcd(a, b);
    ll hoge = a/x;
    ll ans = hoge*b;
    return ans;
}

int main(int argc, char const *argv[]) {
    ll n;
    cin >> n;
    vector<ll> t(n);
    for (int i = 0; i < n; ++i) cin >> t[i];
    ll ans = 1ll;
    for (int i = 0; i < n; ++i) ans = lcm(ans, t[i]);
    cout << ans << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 998244353
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n;
vector<ll>vec;
ll x;


struct xor_sum_lower_bound{
	vector<pair<int,ll> >t;
	//call init first!!!!!
	void init(vector<ll>a){
		t.clear();
		vector<ll>vec = a;
		int cur = 0;
		for(int mask=60;mask>=0;mask--){
			bool found = 0;
			for(int j=cur;j<vec.size();j++){
				if(((vec[j]>>mask)&1LL)){
					swap(vec[cur],vec[j]);
					found = 1;
					break;
				}
			}
			if(!found) continue;
			for(int j=cur+1;j<vec.size();j++){
				if(((vec[j]>>mask)&1LL)){
					vec[j] ^= vec[cur];
				}
			}
			cur++;
		}
		if(vec.size() > 100) vec.resize(100);
		while(vec.size() && vec[vec.size()-1] == 0) vec.pop_back();
		for(int i=0;i<vec.size();i++){
			int up = -1;
			for(int j=60;j>=0;j--){
				if(((vec[i]>>j)&1LL)){
					up = j;
					break;
				}
			}
			t.pb(mp(up,vec[i]));
		}
	}
	//if impossible return -1LL
	//xrとxorしてnum以上にしたい。いくつになるか？
	ll calc(ll num,ll xr){
		if(num<0) num = 0;
		ll ret = -1;
		for(int mask=60;mask>=-1;mask--){
			if(mask >= 0 && ((num>>mask)&1)) continue;
			//(mask,INF)...same [mask,mask]...big
			int nxt = 0;
			ll num2 = num+(mask>=0?(1LL<<mask):0LL),sum = 0;
			bool bad = 0;
			for(int see=60;see>=(mask>=0?mask:0);see--){
				ll cur = (sum^xr);
				if( ((cur>>see)&1LL) == ((num2>>see)&1LL) ) continue;
				while(nxt != t.size() && t[nxt].fi > see) nxt++;
				if(nxt == t.size() || t[nxt].fi != see){
					bad = 1; break;
				}
				sum ^= t[nxt].sc;
			}
			if(bad) continue;
			for(int see=mask-1;see>=0;see--){
				ll cur = (sum^xr);
				if( ((cur>>see)&1LL) == 0 ) continue;
				while(nxt != t.size() && t[nxt].fi > see) nxt++;
				if(nxt == t.size() || t[nxt].fi != see){
					continue;
				}
				sum ^= t[nxt].sc;
			}
			//assert(ret > (sum^xr));
			ret = (sum^xr);
		}
		return ret;
	}
}kaede;

int main(){
    cin >> n;
    rep(i,n){ ll a; cin>>a; vec.pb(a); x^=a; }
    vector<int>pos;
    rep(i,60){
        if(!((x>>i)&1LL)) continue;
        rep(j,n){
            if((vec[j]&(1LL<<i)) > 0) vec[j] -= (1LL<<i);
        }
    }
    //cout << x << endl;
    //for(auto A:vec) cout << A << endl;
    kaede.init(vec);
    ll lb = 0, ub = (1LL<<61);
    while(ub-lb>1){
        ll mid = (lb+ub)/2;
        if(kaede.calc(mid,0) >= mid) lb = mid; else ub = mid;
    }
    cout << lb*2LL+x << endl;
}

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

#define int long long

int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int N, s[100];

signed main() {
    cin >> N;
    int sum = 0;
    for (int i = 0; i < N; i++) {
        cin >> s[i];
        sum += s[i];
    }
    int m = sum;
    for (int i = 0; i < N; i++) {
        if (s[i] % 10 != 0) {
            m = min(m, s[i]);
        }
    }
    if (sum % 10 != 0) {
        m = 0;
    }
    cout << sum - m << endl;
    return 0;
}


Measured memory_bytes: 256
program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils,Classes;
var
  sa,sb,sc:string;
  turn,temp:char;
begin
  try
    { TODO -oUser -cConsole Main : ここにコードを記述してください }
    Readln(sa);
    Readln(sb);
    Readln(sc);

    turn:='A';
    while True do begin
      case turn of
        'A':begin
          if (sa='') then
            Break;
          temp:=sa[1];
          Delete(sa, 1, 1);
        end;
        'B':begin
          if (sb='') then
            Break;
          temp:=sb[1];
          Delete(sb, 1, 1);
        end;
        'C':begin
          if (sc='') then
            Break;
          temp:=sc[1];
          Delete(sc, 1, 1);
        end;
      end;

      case temp of
        'a':turn:='A';
        'b':turn:='B';
        'c':turn:='C';
      end;
    end;
    Writeln(turn);
    Readln;
  except
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);
  end;
end.


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

int main()
{
    int N;
    cin >> N;
    int64_t M = 0;
    for (int i = 1; i <= N; i++)
    {
        if (i % 3 != 0 && i % 5 != 0)
            M += i;
    }
    cout << M;
}

Measured memory_bytes: 3636
from collections import defaultdict
from collections import deque
from collections import Counter
import itertools
import math

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()

n = readInt()
c = Counter(readInts())

ans = 0
for i in c:
	if c[i]-i>0:
		ans+=c[i]-i
	elif c[i]-i<0:
		ans+=c[i]

print(ans)

Measured memory_bytes: 22448
import java.util.Scanner;
 
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
	int num1 = Integer.parseInt(sc.next());
	int num0 = Integer.parseInt(sc.next());
    int numMinus1 = Integer.parseInt(sc.next());
    int numToSelect = Integer.parseInt(sc.next());

    int sum = 0;
	if(numToSelect <= num1){
    	sum = numToSelect * 1;
    }else if(num1 < numToSelect && numToSelect <= (num1+num0)){
        sum = num1 * 1;
    }else if((num1+num0) < numToSelect && numToSelect <= (num1+num0+numMinus1)){
        sum = num1 * 1 + (numToSelect-(num1+num0)) * -1;
    }else if((num1+num0+numMinus1) < numToSelect){
      	sum = num1 * 1 + numMinus1 * -1;
    }

    System.out.println(sum);
  }
}

Measured memory_bytes: 35452
import { readFileSync } from "fs";

// eslint-disable-next-line @typescript-eslint/no-unused-vars
const range = (n: number | bigint) => [...Array(Number(n))].map((_, i) => i);
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { cin, nCin, biCin } = (() => {
  const inputs = readFileSync("/dev/stdin", "utf-8").split(/[\n|\s]+/);
  let count = 0;
  const cin = () => inputs[count++];
  return { cin: cin, nCin: () => Number(cin()), biCin: () => BigInt(cin()) };
})();

type Result = "AC" | "WA" | "TLE" | "RE";

{
  const n = nCin();
  const ss = range(n).map(() => cin() as Result);
  const map: {
    [R in Result]: number;
  } = {
    AC: 0,
    WA: 0,
    TLE: 0,
    RE: 0,
  };
  ss.forEach((s) => map[s]++);
  (Object.keys(map) as Result[]).map((s) => `${s} x ${map[s]}`).forEach((msg) => console.log(msg));
}


Measured memory_bytes: 42288
#include <iostream>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int main() {
	int n, l;
	cin >> n >> l;
	string s[100];
	for (int i = 0; i < n; i++) {
		cin >> s[i];
	}
	sort(s, s + n);
	for (int i = 0; i < n; i++) {
		cout << s[i];
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define int long long
const int MOD=1e9+7;
const int INF=1e15;

signed main(){
    int H,W;cin>>H>>W;
    char maze[H][W];
    REP(i,H){
        REP(j,W)cin>>maze[i][j];
    }
    int ls[H][W];
    int rs[H][W];
    int us[H][W];
    int ss[H][W];
    REP(i,H){
        REP(j,W){
            if(maze[i][j]=='#')ls[i][j]=0;
            else{
                if(j==0)ls[i][j]=1;
                else ls[i][j]=ls[i][j-1]+1;
            }
        }
    }
    REP(i,H){
        for(int j=W-1;j>=0;j--){
            if(maze[i][j]=='#')rs[i][j]=0;
            else{
                if(j==W-1)rs[i][j]=1;
                else rs[i][j]=rs[i][j+1]+1;
            }
        }
    }
    REP(j,W){
        REP(i,H){
            if(maze[i][j]=='#')us[i][j]=0;
            else{
                if(i==0)us[i][j]=1;
                else us[i][j]=us[i-1][j]+1;
            }
        }
    }
    REP(j,W){
        for(int i=H-1;i>=0;i--){
            if(maze[i][j]=='#')ss[i][j]=0;
            else{
                if(i==H-1)ss[i][j]=1;
                else ss[i][j]=ss[i+1][j]+1;
            }
        }
    }
    int ans=0;
    REP(i,H){
        REP(j,W)ans=max(ans,ls[i][j]+rs[i][j]+us[i][j]+ss[i][j]-3);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 131200
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.nextLine());
    String s = sc.nextLine();
    
    int c = 0;
    for(int i = 0; i < N; i++){
      if(s.charAt(i) == 'E'){
        c++;
      }
    }
    
    int d = 0;
    if(s.charAt(0) == 'E'){
      c--;
    }else{
      d++;
    }
    int n = c;
    for(int i = 1; i < N; i++){
      if(s.charAt(i) == 'E'){
        c--;
      }else{
        d++;
      }
      if(c+d < n){
        n = c+d;
      }
    }
    System.out.println(n);
  }
}

Measured memory_bytes: 30276
#include<iostream>
#include<iomanip>
#include <math.h>
using namespace std;
int main(){
    double r, PI;
    PI = 3.14159265358979;
    cin >> r;
    cout << fixed << setprecision(6) << PI * r * r << " " << 2 * PI * r << endl;
    return 0;
}



Measured memory_bytes: 3252
import java.util.Scanner;

/**
 * Created by enpingkuang on 2020/9/20 11:36 下午
 */
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        long x = scanner.nextLong();
        long k = scanner.nextLong();
        long d = scanner.nextLong();
        long ans = 0;
        if(x <= 0){
            long n = -x/d;
            if(x%d !=0)n++;
            if(n > k){
                ans = Math.abs(x+k*d);
            }else{
                if((k - n)%2 == 0){
                    ans = Math.abs(x+n*d);
                }else{
                    ans = Math.abs(x+(n-1)*d);
                }
            }
        }else{
            long n = x/d;
            if(x%d !=0)n++;
            if(n > k){
                ans = Math.abs(x-k*d);
            }else{
                if((k - n)%2 == 0){
                    ans = Math.abs(x-n*d);
                }else{
                    ans = Math.abs(x-(n-1)*d);
                }
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 35844
#include <iostream>
#include <utility>
#include <vector>
#include <list>
#include <unordered_set>
#include <set>
#include <unordered_map>
#include <map>
#include <stack>
#include <queue>
#include <cassert>
#include <cmath>
#include <algorithm>
#include <stdlib.h>
#include <stdio.h>
#include <fstream>
#include <tuple>

//....................................................................................................................//

using std::cin;
using std::cout;
using std::vector;
using std::list;
using std::unordered_set;
using std::set;
using std::map;
using std::unordered_map;
using std::multimap;
using std::unordered_multimap;
using std::pair;
using std::make_pair;
using std::min;
using std::max;
using std::swap;
using std::stack;
using std::deque;
using std::queue;
using std::ios_base;
using std::ifstream;
using std::ofstream;
using std::string;
using std::tuple;
using std::make_tuple;
using std::get;
using std::upper_bound;
using std::lower_bound;
using std::max_element;
using std::min_element;
using std::multiset;
using std::greater;
using std::priority_queue;
using std::less;

//....................................................................................................................//

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned long ul;

[[maybe_unused]] const string endl = "\n";
[[maybe_unused]] const string sep = " ";
[[maybe_unused]] const string yes = "YES\n";
[[maybe_unused]] const string no = "NO\n";
[[maybe_unused]] const string ng = "NG\n";
[[maybe_unused]] const string ok = "OK\n";
[[maybe_unused]] const double pi = acos(-1);
[[maybe_unused]] const ull modular = 998244353;

//....................................................................................................................//


int main() {
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    cout.precision(15);
    int n, m;
    cin >> n >> m;
    map<int, set<int>> M;
    for (int i = 0; i < m; ++i) {
        int a, b;
        cin >> a >> b;
        M[a].insert(b);
        M[b].insert(a);
    }
    vector<int> V(n + 1, -1);
    V[1] = 0;
    V[0] = 0;
    queue<int> Q;
    Q.push(1);
    while(!Q.empty()) {
        auto x = Q.front();
        Q.pop();
        for (auto t : M[x]) {
            if (V[t] == -1) {
                Q.push(t);
                V[t] = x;
            }
        }
    }
    if (*min_element(V.begin(), V.end()) == -1) {
        cout << "No";
    } else {
        cout << "Yes" << endl;
        for (int i = 2; i <= n; ++i) {
            cout << V[i] << endl;
        }
    }
}


Measured memory_bytes: 30232
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;


class Program {

	static long mod = 998244353;
	static int[] ans;
	static void Main(string[] args) {

		char[] cs = new char[] { ' ' };
		//char[] cs = new char[] { ' ', ',' };

		//int n = int.Parse(Console.ReadLine());
		//int val = int.Parse(Console.ReadLine());
		//int[] vals = parseAry(Console.ReadLine().Split(cs));
		//string str = Console.ReadLine();
		//string[] strs = Console.ReadLine().Split(cs);

		int res = 0;
		int n = int.Parse(Console.ReadLine());

		int[] vals = parseAry(Console.ReadLine().Split(cs));
		Array.Sort(vals);
		Array.Reverse(vals);
		res = vals[( n / 2 ) - 1] - vals[( n / 2 )];


			Console.WriteLine(res);
				return;

	}



	//	文字列strをindex番目からdで上書き
	static string strOverWrite(string str, int i, string s) {
		return str.Remove(i, s.Length).Insert(i, s);
	}

	//　String[]  ----->  int[]
	static int[] parseAry(string[] str) {
		int[] nums = new int[str.Length];
		for ( int i = 0; i < str.Length; i++ ) { nums[i] = int.Parse(str[i]); }
		return nums;
	}
	//　String[]  ----->  long[]
	static long[] parseAryL(string[] str) {
		long[] nums = new long[str.Length];
		for ( int i = 0; i < str.Length; i++ ) { nums[i] = long.Parse(str[i]); }
		return nums;
	}

	//文字列を1文字ずつString[]に入れる
	static string[] strAry(String str) {
		string[] re = new string[str.Length];
		for ( int i = 0; i < str.Length; i++ ) { re[i] = str[i].ToString(); }
		return re;
	}


}

Measured memory_bytes: 18656
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<string>
#define mm(a,x) memset(a,x,sizeof(a))
#define sync std::ios::sync_with_stdio(false);std::cin.tie(0)
#define ll long long
using namespace std;
string s;
int main(void)
{
    sync;
    cin>>s;
    if(s[0]=='R'&&s[1]=='R'&&s[2]=='R')
        cout<<3<<endl;
    else if((s[0]=='R'&&s[1]=='R')||(s[1]=='R'&&s[2]=='R'))
        cout<<2<<endl;
    else if(s[0]=='R'||s[1]=='R'||s[2]=='R')
        cout<<1<<endl;
    else
        cout<<0<<endl;
    return 0;
}

Measured memory_bytes: 3164
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

     static Scanner scanner;

     public static void main(String[] args) {
         scanner = new Scanner(System.in);

         int N=gi();
         int[] A=new int[N];
         int[] B=new int[N];

         long sa=0;
         long sb=0;
         for (int i=0; i<N;i++) {
        	 A[i]=gi();
        	 sa+=A[i];
         }
         for (int i=0; i<N;i++) {
        	 B[i]=gi();
        	 sb+=B[i];
         }
         boolean f=true;
         if (sb<sa) f=false;

         long ca=0;
         long cb=0;
         for (int i=0; i<N;i++) {
        	 int a=A[i];
        	 int b=B[i];
        	 if (a>=b) {
        		 cb+=a-b;
        	 } else {
        		 if((b-a)%2==0) {
        			 ca+=(b-a)/2;
        		 } else {
        			 ca+=Math.floorDiv(b-a, 2)+1;
        			 cb++;
        		 }
        	 }
         }
         if (ca>cb) {
        	 sa+=2*ca;
        	 sb+=ca;
        	 if(sb<sa) f=false;
         } else {
        	 sa+=2*cb;
        	 sb+=cb;
        	 if(sb<sa) f=false;
         }
         if(f==true) {
             System.out.println("Yes");
         } else {
        	 System.out.println("No");
         }
     }

  // 素因数分解
 	public static List<Integer> insuB(int n) {
 		List<Integer> l=new ArrayList<Integer>();
 		int i=2;
 		while(i*i<=n) {
 			if (n%i==0) {
 				l.add(i);
 				n/=i;
 			} else {
 				i++;
 			}
 		}
 		if(n!=1)l.add(n);
 		return l;
 	}
     // 文字列として入力を取得
     public static String gs() {
          return scanner.next();
     }

     // intとして入力を取得
     public static int gi() {
          return Integer.parseInt(scanner.next());
     }

     // longとして入力を取得
     public static long gl() {
          return Long.parseLong(scanner.next());
     }

     // doubleとして入力を取得
     public static double gd() {
          return Double.parseDouble(scanner.next());
     }
}

Measured memory_bytes: 47636
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <vector>

using namespace std;

int main(){
	
	int N, M;
	
	cin >> N >> M;
	
	int target[1000];
	int score[1000];
	
	for(int i = 0; i < 1000; i++){
		score[i] = 0;
	}
	
	for(int i = 0; i < M; i++){
		cin >> target[i];
	}
	
	for(int i = 0; i < M; i++){
		for(int j = 1; j <= N; j++){
			int num;
			cin >> num;
			if(num == target[i]){
				score[j]++;
			}else{
				score[target[i]]++;
			}
		}
	}
	
	for(int i = 1; i <= N; i++){
		cout << score[i] << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3112
//#define _GLIBCXX_DEBUG
#include "bits/stdc++.h"

using namespace std;

//------------------------------- Type Names -------------------------------//

using i64 = int_fast64_t;

using seika = string;
//{akari : 1D, yukari : 2D, maki : 3D} vector
template <class kizuna>
using akari = vector<kizuna>;
template <class yuzuki>
using yukari = akari<akari<yuzuki>>;
template <class tsurumaki>
using maki = akari<yukari<tsurumaki>>;
//{akane : ascending order, aoi : decending order} priority queue
template <class kotonoha>
using akane = priority_queue<kotonoha, akari<kotonoha>, greater<kotonoha>>;
template <class kotonoha>
using aoi = priority_queue<kotonoha>;

//------------------------------- Libraries ---------------------------------//

//------------------------------- Dubug Functions ---------------------------//

inline void print()
{
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest)
{
    cout << first << ' ';
    print(rest...);
}

//------------------------------- Solver ------------------------------------//

void solve()
{
    seika s, t, u;
    cin >> s >> t;
    int x, y;
    cin >> x >> y >> u;
    if (s == u)
    {
        x--;
    }
    else
    {
        y--;
    }
    cout << x << ' ' << y << endl;
}

int main()
{
    solve();
    return 0;
}


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

int main(){
  string s; cin >> s;
  int count, max; count=0, max=0;
  int flag = 0;
  
  for(int j=0; j<s.length(); j++){
    for(int i=0; i<s.length(); i++){
      if(s[i+j]=='A' or s[i+j]=='T' or s[i+j]=='G' or s[i+j]=='C') {
        count += 1;
      }else{
        break;
      }
    }
    if(max < count){
        max = count;
      }
      flag += 1;
      count = 0;
  }
  cout << max << endl;
}

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

int main(){
    int k,s;
    cin>>k>>s;
    int ans=0;
    for(int i=0;i<k+1;i++){
        for(int j=0;j<k+1;j++){
               int z=s-i-j;
               if(0<=z&&z<=k){
                 ans++;
               }

                }
            }
        
    cout<<ans<<endl;
}

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

using namespace std;

bool check(string& s) {
  if (s[0] != 'A') return false;
  int cnt = 0;
  string work = s.substr(2, s.length() - 3);
  for (int i = 0; i < work.length(); i++) {
    char c = work[i];
    if (c == 'C') cnt++;
  }
  if (cnt != 1) return false;

  for (int i = 0; i < s.length(); i++) {
    if (i == 0 || (2 <= i && i <= s.length() - 2)) continue;
    char c = s[i];
    if (c < 'a' || 'z' < c) return false;
  }
  return true;
}
int main() {
  string s;
  cin >> s;
  cout << (check(s) ? "AC" : "WA") << endl;
  return 0;
}

Measured memory_bytes: 764
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;
typedef pair <int, int> P;

vector <P> edges[100005];
vector <int> color(100005);

void dfs(int cur, int par, int c) {
    color[cur] = c;

    for (P p : edges[cur]) {
        int nxt = p.first;
        int w = p.second;

        if (nxt == par) continue;

        if (w % 2 == 0) {
            dfs(nxt, cur, c);
        } else {
            dfs(nxt, cur, (c + 1) % 2);
        }
    }
}

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

    int n;
    cin >> n;

    for (int i = 1; i < n; i++) {
        int u, v, w;
        cin >> u >> v >> w;
        u--; v--;
        edges[u].push_back(P(v, w));
        edges[v].push_back(P(u, w));
    }

    dfs(0, -1, 0);

    for (int i = 0; i < n; i++) {
        cout << color[i] << "\n";
    }

    return 0;
}

Measured memory_bytes: 9216
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <utility>
#define ll long long int
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()

using namespace std;

int main(){
	int N,M;
	cin >>N>>M;
	vector<int> X(M);
	vector<int> range;
	rep(i,0,M){
		cin >> X[i];
	}
	if(N>=M){
		cout << 0 << endl;
		return 0;
	}
	sort(all(X));
	rep(i,1,M){
		range.push_back(abs(X[i]-X[i-1]));
	}
	sort(all(range));
	int j=0;
	int sumrange = X[M-1]-X[0];
	while(j != N){
		sumrange -= range[M-1-j];
		j++;
	}
	cout << sumrange << endl;
}


Measured memory_bytes: 1276
#include<bits/stdc++.h>
using namespace std;
int main()
{
long long int n,i,j=1,k,d=0,t,q;
string s;
char c;
vector<char> v;
cin>>s;
for(i=0;i<s.length();i++)
{
v.push_back(s[i]);
}
cin>>q;
for(i=0;i<q;i++)
{
cin>>t;
if(t==1)
j=j*(-1);
else if(t==2)
{
cin>>d>>c;
if(d==1&&j==1)
    v.insert(v.begin(),c);
else if(d==1&&j==-1)
    v.push_back(c);
else if(d==2&&j==1)
    v.push_back(c);
else
   v.insert(v.begin(),c);
}
}
char a[v.size()+1];
a[v.size()]=0;
if(j==-1)
    reverse(v.begin(),v.end());
//cout<<v.size()<<endl;
for(i=0;i<v.size();i++)
{
a[i]=v[i];
}
cout<<a<<endl;
}


Measured memory_bytes: 1400
#pragma GCC optimize(3,"Ofast","inline")
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define ms(a,b) memset(a,b,sizeof(a))
#define msn(a,n,b) for(int i=0;i<=n;i++)a[i]=b
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define fi first
#define se second
using namespace std;
mt19937 rng_32(chrono::steady_clock::now().time_since_epoch().count());
typedef long long ll;
typedef long double ld;
typedef pair<ll,int> P;
const int mod=1e9+7;
const int seed=233;
const double PI=acos(-1.0);
const double eps=1e-7;
const int inf=0x3f3f3f3f;
const int max_n=200005;
ll ceil(ll x,ll y){if(x==0)return 0;if(y<0)x=-x,y=-y;bool sign=x>0;x=abs(x);return sign?(x+y-1)/y:-x/y;}
ll floor(ll x,ll y){if(x==0)return 0;if(y<0)x=-x,y=-y;bool sign=x>0;x=abs(x);return sign?x/y:-(x+y-1)/y;}
namespace {
    inline int Add(int x,int y){return (x+=y)>=mod?x-mod:x;}
    inline int Sub(int x,int y){return (x-=y)<0?x+mod:x;}
    inline int Mul(int x,int y) {return 1ll*x*y%mod;}
    inline int Pow(int x,int y=mod-2){if(y==0)return 1;int res=1;while(y){if(y&1)res=1ll*res*x%mod;x=1ll*x*x%mod;y>>=1;}return res;}
}
/**********************head************************/
int n,d,a;
P p[max_n];
int bit[max_n];
void update(int i,int x){
    for(;i<=n;i+=i&-i)bit[i]+=x;
}
int query(int i){
    int res=0;
    for(;i;i-=i&-i)res+=bit[i];
    return res;
}
int main(){
    scanf("%d%d%d",&n,&d,&a);
    for(int i=1;i<=n;i++)scanf("%lld%d",&p[i].fi,&p[i].se);
    sort(p+1,p+n+1);
    ll ans=0;
    for(int i=1;i<=n;i++){
        int x=ceil(p[i].se,a)-query(i);
        x=max(x,0);
        int index=upper_bound(p+1,p+n+1,P(p[i].fi+d*2,inf))-p-1;
        update(i,x);
        update(index+1,-x);
        ans+=x;
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 4096
//============================================================================
// Name        : HelloWorld.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
using namespace std;

int main() {
    string str;
	cin>>str;
	int R=0;
    for(int i=0;i<3;i++){
    	for(int j=i+1;j<4;j++){
    		if(str[i]==str[j])R++;
    	}
    }
    if(R==2){
    	cout<<"Yes"<<endl;
    }else{
    	cout<<"No"<<endl;
    }

	return 0;
}


Measured memory_bytes: 256