akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;

vi f_table(const int lim) {
    vi ans(lim + 1, 1);
    ans[0] = 0;

    for (int i = 3; i <= lim; ++i) {
        const int p = __builtin_popcount(i);
        ans[i] = 1 + ans[i % p];
    }

    return ans;
}

ll two_exp_mod(const ll power, const ll m) {
    if (!power) return 1;
    if (power % 2) return (2 * two_exp_mod(power - 1, m)) % m;

    const ll sq = two_exp_mod(power / 2, m);
    return (sq * sq) % m;
}

ll big_bin_mod(const string &bits, const ll m) {
    const int sz = bits.size();
    ll ans = 0;

    for (auto it = bits.crbegin(); it != bits.crend(); ++it) {
        if (*it == '0') continue;
        const int i = distance(bits.crbegin(), it);
        assert(i >= 0 && i < sz);

        ans = (ans + two_exp_mod(i, m)) % m;
    }

    return ans;
}

vi f_xi_values(const string &bits) {
    const int sz = bits.size();
    const int ones = count(bits.cbegin(), bits.cend(), '1');
    const vi ys = f_table(2 * 1e5 + 1);
    const ll a = (ones <= 1) ? 0 : big_bin_mod(bits, ones - 1);
    const ll b = big_bin_mod(bits, ones + 1);

    vi ans(sz, 0);

    for (int power = sz - 1; power >= 0; --power) {
        const int i = sz - 1 - power;

        if (bits[i] == '1' && ones != 1) {
            const ll m = ones - 1;
            ans[i] = 1 + ys[(a - two_exp_mod(power, m) + m) % m];
        } else if (bits[i] == '0') {
            const ll m = ones + 1;
            ans[i] = 1 + ys[(b + two_exp_mod(power, m) + m) % m];
        }
    }

    return ans;
}

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

    int sz;
    cin >> sz;
    string bits;
    cin >> bits;
    assert(static_cast<int>(bits.size()) == sz);

    for (const auto y : f_xi_values(bits)) {
        cout << y << '\n';
    }

    return 0;
}


Measured memory_bytes: 5164
x,y,a,b,c = map(int,input().split())

p = list(map(int,input().split()))
q = list(map(int,input().split()))
r = list(map(int,input().split()))

ps = sorted(p,reverse=True)
qs = sorted(q,reverse=True)
rs = sorted(r,reverse=True)

psc = ps[:x]
qsc = qs[:y]

d = []

d.extend(psc)
d.extend(qsc)
d.extend(rs)

ds = sorted(d,reverse=True)

dsc = ds[:(x+y)]

print(sum(dsc))

Measured memory_bytes: 115308
#include <stdio.h>

int main()
{
    int n, m, a[50], b[50], i;
    scanf("%d%d", &n, &m);
    for (i=0; i<m; i++)
    {
        scanf("%d %d", &a[i], &b[i]);
    }
    int ans[50] = {};
    for (i=0; i<m; i++)
    {
        ans[a[i]-1] ++;
        ans[b[i]-1] ++;
    }
    for (i=0; i<n; i++)
    {
        printf("%d\n", ans[i]);
    }
    return 0;
}


Measured memory_bytes: 128
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(S: str):
    if S[2] == S[3] and S[4] == S[5]:
        print(YES)
    else:
        print(NO)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()


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

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

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

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

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

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

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


const ll SIZE = 200+10;
ll n;
string s;
int mem[SIZE][SIZE],mem2[SIZE][SIZE];
int us[SIZE];

int main(){
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> s;
        for(int j = 0; j < s.length(); j++){
            if(s[j] == '0') mem[i][j] = 0;
            else
            {
                mem[i][j] = 1;
            }
        }
    }
    

    stack<int> st,st2;
    stack<pair<int,int>> ans_st;

    ll ans = -1;
    ll mem_ans = 0;

    for(int i = 0; i < n; i++){
        st.push(i);

        for(int j = 0; j < n; j++){
            us[j] = 0;
            for(int k = 0; k < n; k++){
                mem2[j][k] = mem[j][k];
            }
        }
        mem_ans = 0;
        while(true){
            if(st.size() == 0) break;
            ++mem_ans;
            while(true){
                if(st.size() == 0)  break;
                int mm = st.top();
                st.pop();
                for(int j = 0; j < n; j++){
                    if(mem2[mm][j] == 1){
                        st2.push(j);
                        pair<int,int> p = make_pair(j,mem_ans);
                        ans_st.push(p);
                        mem2[mm][j] = 0;
                        mem2[j][mm] = 0;
                    }
                }
            }
            while(true){
                if(st2.size() == 0) break;
                st.push(st2.top());
                st2.pop();
            }
        }

        bool fla = false;
        while(true){
            if(ans_st.size() == 0)  break;
            pair<int,int> mem_p = ans_st.top();
            ans_st.pop();

            if(us[mem_p.first] != mem_p.second && us[mem_p.first] != 0)  fla = true;
            us[mem_p.first] = mem_p.second;
        }

        if(!fla){
            ans = max(ans,mem_ans);
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define ll long long
#define vi vector<int>
#define pii pair<int,int>
#define F first
#define S second
#define pb push_back
#define forn(b) for(int i = 0; i < b; i++)
#define rforn(b) for(int i = b - 1 ;i >= 0; i--)
#define It(m) for(auto it = m.begin(); it != m.end(); it++)
#define N 500500
#define PI 3.14159265358979323846264338327950L
#define speed ios_base :: sync_with_stdio(0);cin.tie(0);cout.tie(0);
    
const ll mod = (ll)1e9 + 7;
    
int main(){
    speed;
    int n, k; cin >> n >> k;
    vi v(n);
    forn(n) cin >> v[i];
    sort(all(v));
    ll res = 0;
    for(int i = 0; i < k; i++) {
        res += v[i];
    }   
    cout << res;
    return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
int main () {
  string s; cin >> s;
  if (s=="Sunny") cout << "Cloudy" << endl;
  if (s=="Cloudy") cout << "Rainy" << endl;
  if (s=="Rainy") cout << "Sunny" << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
 
   int N = sc.nextInt();
   long[] a =new long[N];
   long[] sumar = new long[N];
   
   long sum =0;
   for(int i=0;i<N;i++) 
   {
     a[i]=sc.nextLong();
     sum += a[i];
     sumar[i]= sum;
   }
   long ans =Math.abs(sum-2*sumar[0]);
   for(int i=1;i<N-1;i++)
   {
     if(Math.abs(sum-2*sumar[i])<ans) ans = Math.abs(sum-2*sumar[i]);
   }
   System.out.println(ans);
 }
}

Measured memory_bytes: 64412
#include<iostream>
#include<cstdio>
using namespace std;
int n,k,ans[350005],cnt;
int main(){
    scanf("%d%d",&k,&n);
    if(k&1){
        cnt=n;
        for(int i=1;i<=n;i++)
            ans[i]=k/2+1;
        for(int i=1;i<=n/2;i++){
            if(ans[cnt]==1){
                cnt--;
                continue;
            }
            ans[cnt]--;
            for(int j=cnt+1;j<=n;j++)
                ans[j]=k;
            cnt=n;
        }
        for(int i=1;i<=cnt;i++) printf("%d ",ans[i]);
        return 0;
    }
    //tttteeeeeepppppaaaaaaaaannnnnnn
    printf("%d ",k/2);
    for(int i=2;i<=n;i++)
        printf("%d ",k);
    return 0;
}

Measured memory_bytes: 3456
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <algorithm>
#include <climits>
#include <iomanip>
#include <string.h>
#define endl "\n"
#define debug(x) cout << #x << " : " << x << endl;
#define debug2(x, y) cout << #x << " : " << x  << ", " << #y << " : " << y << endl;
#define FASTIO ios_base::sync_with_stdio(false),cin.tie(0);
typedef long long ll;
using namespace std;


int main()
{
	int n;
	cin >> n;
	
	int dp[n + 1][3];
	memset(dp, 0, sizeof(dp));
	for(int i = 0; i < n; i ++)
	{
		int a, b, c;
		cin >> a >> b >> c;
		
		dp[i + 1][0] = max(dp[i][1], dp[i][2]) + a;
		dp[i + 1][1] = max(dp[i][0], dp[i][2]) + b;
		dp[i + 1][2] = max(dp[i][0], dp[i][1]) + c;
	}
	
	int ans = max({dp[n][0], dp[n][1], dp[n][2]});
	cout << ans << endl;
}	


Measured memory_bytes: 4704
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	lint n, s;
	cin >> n >> s;

	auto check = [&](const lint b) {
		if (b < 2) return false;
		lint tmp = n, sum = 0;
		while (tmp) {
			sum += tmp % b;
			tmp /= b;
		}
		return sum == s;
	};

	auto end = [&](const lint b) {
		cout << b << "\n";
		exit(0);
	};

	if (n < s) end(-1);
	else if (n == s) end(n + 1);

	for (int i = 2; i < 320000; i++) if (check(i)) end(i);
	for (int i = 320000; i >= 1; i--) {
		lint b = (n - s) / i + 1;
		if (check(b)) end(b);
	}

	end(-1);

}


Measured memory_bytes: 384
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>
#include <set>
using namespace std;

int main() {
    long long N;
    cin >> N;
    set<long long> s;
    long long a;
    for (int i = 0; i < N; i++) {
        cin >> a;
        s.insert(a);
    }
    string ans = "NO";
    if (N == s.size()) {
        ans = "YES";
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 9600
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)
#define PI 3.14159265359
#define EPS 0.0000000001
#define MOD 1000000007
//cout << std::fixed << std::setprecision(15) << y << endl;


int main(){
    ll A, B, X;
    cin >> A >> B >> X;

    if(X >= A && X <= A + B){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 3636
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author mikit
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CDaydream solver = new CDaydream();
        solver.solve(1, in, out);
        out.close();
    }

    static class CDaydream {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            out.println(
                    in.next()
                            .replace("eraser", "/")
                            .replace("erase", "/")
                            .replace("dreamer", "/")
                            .replace("dream", "/")
                            .replace("/", "")
                            .isEmpty() ? "YES" : "NO"
            );
        }

    }
}



Measured memory_bytes: 30600
n = int(input())

a_list = [int(s) for s in input().split()]
a_list = [a for a in a_list if a % 2 == 0]
# print(a_list)

approved_flag = True
for a in a_list:
    if a % 3 != 0 and a % 5 != 0:
        approved_flag = False
        break

ans = "APPROVED" if approved_flag else "DENIED"
print(ans)


Measured memory_bytes: 2940
let n = read_int ()
let a = n / 1000
let b = n / 100 - a * 10
let c = n / 10 - a * 100 - b * 10
let d = n mod 10
let ans = if a = b && b = c || b = c && c = d then "Yes" else "No"
let () = print_endline ans

Measured memory_bytes: 384
#input
N=int(input())
An=list(int(i) for i in input().split())
x=0
point=0
flag=True
while(flag):
  x=0
  for x in range(N):
    if An[x]%2==0:
      An[x]/=2
    else:
      flag=False
      break
  point+=1 
point-=1
print(point) 

    

Measured memory_bytes: 3060
const stdin = require("fs").readFileSync("/dev/stdin", "utf8");

const [x, a, b] = stdin.split(' ').map(v => parseInt(v));

if(b <= a) {
    console.log('delicious');
} else if(b <= (a + x)) {
    console.log('safe');
} else {
    console.log('dangerous');
}

Measured memory_bytes: 7372
#include <bits/stdc++.h>
#define pi pair<int, int>
#define pb push_back
#define int long long

using namespace std;

const int maxn = 3e5 + 1;

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n; cin >> n;
    int ans = 0;
    for (int i = 1; i * i <= n - 1; i++) {
        if ((n - 1) % i) continue;
        ++ans; if ((n - 1) / i != i) ++ans;
    }
    for (int i = 2; i * i <= n; i++) {
        if (n % i) continue;
        int x = n;
        for (; x % i == 0; x /= i);
        if (x % i == 1) ++ans;
        if (n / i == i) continue;
        x = n;
        for (; x % (n / i) == 0; x /= (n / i));
        if (x % (n / i) == 1) ++ans;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define cvector vector<char>
#define svector vector<string>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define rep(i,n) for(ll i=0; i<n; ++i)
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,ans=0,b;cin>>n;
  for(ll a=1;a<=1000000;++a) ans+=(n-1)/a;
  print(ans);
  return 0;
}

Measured memory_bytes: 3652
#![allow(non_snake_case)]

#[allow(unused_macros)]
macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($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, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

fn main() {
    input!{
        N: usize,
        K: usize,
        h:[usize;N]
    }
    let mut ans = 1 << 30;
    let mut h = h;
    h.sort();
    for i in 0..N - K + 1 {
        ans = std::cmp::min(ans, h[K + i - 1] - h[i]);
    }
    println!("{}", ans);
}

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

int main(){
  int n, k;
  cin >> n >> k;
  
  vector<int> v;
  int hi, ans = 1 << 30;
  for(int i = 0; i < n; i++){
      cin >> hi;
      v.push_back(hi);
  }

  sort(v.begin(), v.end());
  for(int i = 0; i < n - k + 1; i++)
    if(v[i+k-1] - v[i] < ans) ans = v[i+k-1] - v[i];
  
    
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fill fill_n
#define pf push_front
#define pb push_back
#define FOR(i,l,r) for(int i=l;i<r;i++)
#define ROF(i,r,l) for(int i=r;i>=l;i--)
#define comp(v) (v).begin(),(v).end()
#define ff first
#define ss second
#define infile freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
typedef vector<int> vi;
typedef vector<ll> vli;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvli;
const int M = 1e9+7;
const int N = 2e5;
ll po(int,int);


void solve(){
    int s,w;
    cin>>s>>w;
    if(w>=s) cout<<"unsafe\n";
    else cout<<"safe\n";
    
}





int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    int t=1;
    //cin>>t;
    FOR(i,1,t+1){
        //cout<<"Case #"<<i<<": "; 
        solve();
    }
    
	return 0;
	
	
}


ll po(int a,int b){
    if(b==0) return 1;
    ll ans=1;
    if(b%2==0){
        ans = po(a,b/2)%M;
        ans=(ans%M * ans%M)%M;
    }
    else{
        ans = po(a,(b-1)/2)%M;
        ans = (ans%M * ans%M * a)%M;
    }
    return ans%M;
}


Measured memory_bytes: 3688
// https://atcoder.jp/contests/abc145/tasks/abc145_e

#include "algorithm"
#include "functional"
#include "iostream"
#include "numeric"
#include "queue"
#include "set"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define fi first
#define se second
using namespace std;
typedef long long ll;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;
template <typename T>
inline bool chmax(T& a, T b);
template <typename T>
inline bool chmin(T& a, T b);
void print_ints(vector<ll> v);
template <typename T>
void drop(T a);

const ll INF = 1e18;

void solve() {
  ll N, T;
  cin >> N >> T;
  VPL fs(N);

  rep(i, N) {
    ll a, b;
    cin >> a >> b;
    fs[i] = {a, b};
  }

  sort(all(fs));

  ll MAX = 6000;
  // dp[i][j][k] i (>=1) 番目の料理までだけを考えた時の、注文後 j
  // 分以下となる美味しさの最大値. k は i 番目を使用したかどうか
  V<VVL> dp(N + 1, VVL(MAX + 1, VL(2)));

  repf(i, 1, N + 1) {
    PL f = fs[i - 1];
    ll time = f.first;
    ll del = f.second;

    rep(j, MAX + 1) {
      ll pm = max(dp[i - 1][j][0], dp[i - 1][j][1]);
      rep(k, 2) chmax(dp[i][j][k], pm);

      if (time <= j && j - time < T) {
        chmax(dp[i][j][1], dp[i][j - time][0] + del);
      }
    }
  }

  ll res = 0;
  rep(i, MAX + 1) rep(k, 2) { chmax(res, dp[N][i][k]); }

  cout << res << endl;
}

void solve2() {
  ll N, T;
  cin >> N >> T;
  VPL fs(N);

  rep(i, N) {
    ll a, b;
    cin >> a >> b;
    fs[i] = {a, b};
  }

  sort(all(fs));

  // dp[i][j] i (>=1) 番目の料理までだけを考えた時の、注文・食事後 j
  // 分以下となる美味しさの最大値
  VVL dp(N + 1, VL(T + 1));

  repf(i, 1, N + 1) {
    PL f = fs[i - 1];
    ll time = f.first;
    ll del = f.second;

    rep(j, T + 1) {
      chmax(dp[i][j], dp[i - 1][j]);

      if (time <= j) chmax(dp[i][j], dp[i - 1][j - time] + del);
    }
  }

  ll res = 0;

  // i 番目まで食べるケースの最大値。かかる時間でソートしているため i
  // 番目は最後に食べるとして良い
  rep(i, N - 1) { chmax(res, dp[i + 1][T - 1] + fs[i + 1].second); }

  cout << res << endl;
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

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

  try {
    solve2();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

template <typename T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

void print_ints(vector<ll> v) {
  rep(i, v.size()) {
    if (i > 0) {
      cout << " ";
    }

    cout << v[i];
  }

  cout << endl;
}

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}


Measured memory_bytes: 70784
#include <stdio.h>

int main(void)
{
	int a,b;
	char op;
	while(1){
	if( op == '?'){
		break;
	}
	scanf("%d %c %d",&a,&op,&b);
	if(op == '+'){
	printf("%d\n",a + b);
	}
	if(op == '-'){
		printf("%d\n",a - b);
	}
	if(op == '*'){
		printf("%d\n",a * b);
	}
	if(op == '/'){
		printf("%d\n",a / b);
	}
	}
	return 0;
}

Measured memory_bytes: 600
#include<stdio.h>
#include<math.h>
#define N 10000

int main(){

  int i,a,n,count=0,flag=0;
  int arr[N];

  scanf("%d",&n);
  
  for(i=0;i<n;i++){
    scanf("%d",&arr[i]);
  }
  
  for(i=0;i<n;i++){
    if(arr[i]==2){
      count++;
      continue;
    }
    if(arr[i]<2||arr[i]%2==0)continue;
    
    a=3;
    while(a<=sqrt(arr[i])){
      if(arr[i]%a==0){
	flag=1;
	break;
      }
      a = a + 2;
    }
    if(flag==0){
      count++;
    }
    flag=0;
  }
  
  printf("%d\n",count);
  
  return 0;
}

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

int main() {
  int n, m, X, Y;
  cin >> n >> m >> X >> Y;
  int x[n], y[m];
  for ( int i = 0; i < n; i++ ) { cin >> x[i]; }
  for ( int i = 0; i < m; i++ ) { cin >> y[i]; }
  sort(x, x+n);
  sort(y, y+m);
  int mn, mx;
  mn = x[n-1] + 1;
  mx = y[0];
  string ans = "War";
  for ( int i = mn; i <= mx; i++ ) {
    if ( X < i && i <= Y ) { ans = "No War"; break; }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
 
 
using namespace std;
 
//conversion
//------------------------------------------
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();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const long long MOD = 1000000007;

void solve(long long N, long long K, std::vector<long long> A){

}

int main(){
    int N;

    cin >> N;
    vector<int> a(N);
    REP(i, N){
        cin >> a[i];
    }
    SORT(a);
    int smallest=0;
    while(1){
        SORT(a);
        int idx = 0;
        REP(i, N){
            if(i == N-1 && a[i]>0){
                cout<<a[i]<<endl;
                return 0;
            }
            else if(a[i]>0){
                smallest=a[i];
                idx = i;
                break;
            }
        }
        FOR(i, idx+1, N){
            a[i] %= smallest;
        }
        
    }
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
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;
}

const int mod = MOD9;
const int max_n = 200005;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
}comb(max_n);

mint dp[3010][3010];
int main(){
    ll n,s;cin >> n >>s;
    vl v(n);rep(i,n)cin >> v[i];
    dp[0][0]=1;
    rep(i,n+1){
        rep(j,s+1){
            if(j+v[i]<=s)dp[i+1][j+v[i]]+=dp[i][j];
            dp[i+1][j]+=dp[i][j]*2;
        }
    }
    cout << dp[n][s] <<endl;
}

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

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int N; cin >> N;
	if (N == 1) {
		cout << "No\n";
		exit(0);
	}
	if ((N & (N-1)) == 0) {
		cout << "No\n";
		exit(0);
	}

	cout << "Yes\n";

	for (int i = 2; i+1 <= N; i += 2) {
		cout << 1 << ' ' << i << '\n';
		cout << i << ' ' << i+1 << '\n';
		cout << 1 << ' ' << N+i+1 << '\n';
		cout << N+i+1 << ' ' << N+i << '\n';
	}
	cout << 3 << ' ' << N+1 << '\n';

	if (N % 2 == 0) {
		int a = 1 << (31 - __builtin_clz(N));
		int b = N ^ a ^ 1;
		cout << ((a % 2 == 0) ? a : (N+a)) << ' ' << N << '\n';
		cout << ((b % 2 == 0) ? b : (N+b)) << ' ' << N+N << '\n';
	}

	return 0;
}


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

const int N = 233;
const int INF = 1 << 28;

struct edge {
    int to, cap, next;
    edge(int t = 0, int c = 0, int n = 0):to(t), next(n), cap(c) {}
};
edge G[N * N * 10];
int head[N * N], cur[N * N];
int Gcnt, n, m, S, T, clc, cnt, ans;
char mp[N][N];
int dis[N * N], vis[N * N];
int in[N][N], out[N][N];
int r[N], c[N];
queue<int> Q;

inline void AddEdge(int from, int to, int cap) {
    G[++Gcnt] = edge(to, cap, head[from]); head[from] = Gcnt;
    G[++Gcnt] = edge(from, 0, head[to]); head[to] = Gcnt;
}
inline bool bfs(int S, int T) {
    dis[S] = 0; Q.push(S); vis[S] = ++clc;
    while (!Q.empty()) {
        int u = Q.front(); Q.pop();
        for (int i = head[u]; i; i = G[i].next) {
            edge &e = G[i];
            if (e.cap && vis[e.to] != clc) {
                dis[e.to] = dis[u] + 1;
                vis[e.to] = clc; Q.push(e.to);
            }
        }
    }
    return vis[T] == clc;
}
inline int dfs(int u, int a) {
    int flow = 0, f;
    if (u == T || a == 0) return a;
    for (int &i = cur[u]; i; i = G[i].next) {
        edge &e = G[i];
        if (e.cap && dis[e.to] == dis[u] + 1
                && (f = dfs(e.to, min(a, e.cap))) > 0) {
            e.cap -= f; flow += f;
            G[i ^ 1].cap += f; a -= f;
            if (a == 0) break;
        }
    }
    return flow;
}
inline int MaxFlow(int S, int T) {
    int flow = 0;
    while (bfs(S, T)) {
        for (int i = 1; i <= cnt; i++) cur[i] = head[i];
        flow += dfs(S, INF);
    }
    return flow;
}

int main(void) {
    Gcnt = 1;
    scanf("%d %d\n", &n, &m);
    S = ++cnt; T = ++cnt;
    for (int i = 1; i <= n; i++) {
        scanf("%s", mp[i] + 1);
        for (int j = 1; j <= m; j++)
            if (mp[i][j] == 'o') {
                in[i][j] = ++cnt;
                out[i][j] = ++cnt;
            }
    }
    for (int i = 1; i <= n; i++) r[i] = ++cnt;
    for (int i = 1; i <= m; i++) c[i] = ++cnt;
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= m; j++)
            if (mp[i][j] == 'S') {
                AddEdge(S, r[i], INF);
                AddEdge(S, c[j], INF);
            } else if (mp[i][j] == 'T') {
                AddEdge(r[i], T, INF);
                AddEdge(c[j], T, INF);
            } else if (mp[i][j] == 'o') {
                AddEdge(r[i], in[i][j], INF);
                AddEdge(c[j], in[i][j], INF);
                AddEdge(in[i][j], out[i][j], 1);
                AddEdge(out[i][j], r[i], INF);
                AddEdge(out[i][j], c[j], INF);
            }
    ans = MaxFlow(S, T);
    if (ans > n * m) ans = -1;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 10620
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
int main()
{
	int t;cin>>t;int a=0,b=0,c=0,d=0;
	while(t--)
	{
		string s;
		cin>>s;
		if(s=="AC") a++;
		if(s=="WA") b++;
		if(s=="TLE") c++;
		if(s=="RE") d++;
	}
	cout<<"AC x "<<a<<endl;
	cout<<"WA x "<<b<<endl;
	cout<<"TLE x "<<c<<endl;
	cout<<"RE x "<<d<<endl;
 } 

Measured memory_bytes: 3628
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fls(x) (64 - __builtin_clzll(x))
#define pcnt(x) __builtin_popcountll(x)
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h, w, k = 0; cin >> h >> w;
    vector<vector<bool>> used(h, vector<bool>(w));
    vector<string> a(h);
    used[0][0] = true;
    rep (i, h) cin >> a[i];
    rep (i, h) rep (j, w) if (a[i][j] == '#') k++;
    rep (_, h + w + 1) {
        rep (i, h) {
            rep (j, w) {
                if (i > 0) if (used[i - 1][j] && a[i][j] == '#') used[i][j] = true;
                if (j > 0) if (used[i][j - 1] && a[i][j] == '#') used[i][j] = true;
            }
        }
    }
    eprintf("%d %d\n", k, (int)used.back().back());
    cout << (k == h + w - 1 && used.back().back() ? "Possible\n" : "Impossible\n") << "\n";
    return 0;
}

Measured memory_bytes: 3668
/*
  A2738
  title:A un breathing
  @kanki573

 */

#include <stdio.h>

int main()
{
  int n,i,a,b,flag;
  char s[3];

  scanf("%d",&n);
  for(i=a=b=0,flag=1;i<n;i++)
    {
      scanf("%s",s);
      if(*s=='A')
	a++;
      else if(*s=='U')
	b++;
      if(b>a)
	flag=0;
    }
  if(flag==1 && a==b)
    printf("YES\n");
   else
     printf("NO\n");
  return(0);
}

Measured memory_bytes: 580
// In the name of god
#include <bits/stdc++.h>
#pragma GCC optimze("02")
using namespace std;
using ll=long long;
const ll maxn=1e5+5,inf=1e18+18;
ll n,m,a;
int main(){
	ios::sync_with_stdio(false) , cin.tie(0) , cout.tie(0);
	cin>>n;
	if(n%10==3)cout<<"bon";
	else if(n%10==0||n%10==1||n%10==6||n%10==8)cout<<"pon";
	else cout<<"hon";
}


Measured memory_bytes: 3652
# include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	long long n, k;
	cin >> n >> k;
	cout << min(n % k, k - n % k) << endl;
}

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

int main() {
  int N, M;
  cin >> N >> M;
  int stu[N][2];
  for (int i=0; i<N; i++) cin >> stu[i][0] >> stu[i][1];
  int cps[M][2];
  for (int j=0; j<M; j++) cin >> cps[j][0] >> cps[j][1];
  
  int x, y, d;
  const int maxd = 400000005;
  for (int i=0; i<N; i++) {
    int mind = maxd;
    int pt;
    for (int j=0; j<M; j++) {
      x = stu[i][0]-cps[j][0];
      y = stu[i][1]-cps[j][1];
      x = max(x, -x);
      y = max(y, -y);
      d = x+y;
      if (d < mind) {
        mind = d;
        pt = j+1;
      }
    }
    cout << pt << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import math 

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

m_deg = 360/60*M
#print(m_deg)

h_deg = 360/(12*60)*(H*60+M)
#print(h_deg)

a2 = A**2 + B**2 -2*A*B*math.cos(math.radians(abs(h_deg - m_deg)))
print(math.sqrt(a2))

Measured memory_bytes: 9436
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 1005
#define inf 1e9
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

inline ll read()
{
	ll x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}
ll a,b,v,w,t;
int main()
{
    cin>>a>>v>>b>>w>>t;
    int d=abs(a-b);
    if(w>=v)puts("NO");
    else{
        if(t*(v-w)>=d) puts("YES");
        else puts("NO");
    }

}


Measured memory_bytes: 3624
import java.util.*;

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

        var N = scanner.nextInt();
        var A = new TreeSet<Integer>();
        var duplicated = new TreeSet<Integer>();
        for(int i=0; i<N; i++) {
            var A_i =  scanner.nextInt();
            if(!A.add(A_i)) duplicated.add(A_i);
        }

        var A_MAX = A.last();
        var isPTable = new boolean[A_MAX+1];
        Arrays.fill(isPTable, true);

        for (Integer value : A) {
            if(!isPTable[value]) continue;
            if(duplicated.contains(value)) isPTable[value] = false;

            for(int i=2; ; i++) {
                var multiple = value*i;
                if(multiple > A_MAX) break;
                isPTable[multiple] = false;
            }
        }
        System.out.println(A.stream().filter(value -> isPTable[value]).count());
    }
}

Measured memory_bytes: 71472
#include <iostream>
#include <string>
#include <vector>
#define N_MAX 1000
#define M 1000000007
using namespace std;
typedef long long ll;
 
ll func(int);
 
int N,s,t;
string n[N_MAX];
vector<int> edge[N_MAX];
 
int main(){
  cin>>N;
  for(int i=0;i<N;i++) cin>>n[i];
  for(int i=0;i<N-1;i++) cin>>s>>t,edge[s-1].push_back(t-1);
  cout<<func(0)%M<<endl;
  return 0;
}

ll func(int x){
  ll res=0,res2=1;
  if(!edge[x].size()){
    if(n[x]=="E") return 1;
    if(n[x]=="E?") return 2;
    return 0;
  }
  if(n[x][0]=='E'){
    for(int i=0;i<edge[x].size();i++) res2*=func(edge[x][i]);
    if(n[x]=="E") return res2%M;
    return (res2+1)%M;
  }
  if(n[x][0]=='A'){
    for(int i=0;i<edge[x].size();i++) res+=func(edge[x][i]);
    if(n[x]=="A") return res%M;
    return (res+1)%M;
  }
  if(n[x][0]=='R'){
    for(int i=0;i<edge[x].size();i++) res2*=(1+func(edge[x][i]));
    if(n[x]=="R?") return res2%M;
    return (res2-1)%M;
  }
}

Measured memory_bytes: 1356
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
using namespace std;

#define MAX 2000000000
#define SIZE 500000
int cnt;
int L[SIZE/2+2],R[SIZE/2+2];

int merge(int a[],int l,int m,int r)
{
	int n1=m-l;
	int n2=r-m;
	for(int i=0;i<n1;i++)
	{
		L[i]=a[l+i];
	}
	L[n1]=MAX;
	for(int i=0;i<n2;i++)
	{
		R[i]=a[m+i];
	}
	R[n2]=MAX;
	int i=0,j=0;
	for(int k=l;k<r;k++)
	{
		if(L[i]<=R[j])
		{
			a[k]=L[i++];
		}
		else
		{
			a[k]=R[j++];
		}
		cnt++;
	}
}

int mergeS(int a[],int l,int r)
{
	if(l+1<r)
	{
		int m=(l+r)/2;
		mergeS(a,l,m);
		mergeS(a,m,r);
		merge(a,l,m,r);
	}
}

int main()
{
	int n;cin>>n;int a[SIZE];
	for(int i=0;i<n;cin>>a[i++]);
	mergeS(a,0,n);
	cout<<a[0];
	for(int i=1;i<n;cout<<" "<<a[i++]);
	cout<<endl<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 6968
N, K = list(map(int, input().split()))
S = input()

S = S + 'E'   # 終端処理
ans = -1    # 答えの初期値（十分に小さい値）

# 立った人の連続の数
if (S[0] == '0'):
    stand = 1
else:
    stand = 0

L = 0
R = 0

# 尺取り法
while (R < N):
    # 右端を進めることが可能（立った人の連続の数がK以下）なら、右端を進める
    if (stand <= K):
        # 立った人の連続の集合数が増えるなら1足す
        if (S[R] == '1' and S[R + 1] == '0'):
            stand += 1
        # 答えの更新
        ans = max(ans, R - L + 1)
        R += 1
    # 進められない場合、左端と右端が同じなら両者を進める
    # 左端が右端を追い越さないための処理
    elif (L == R):
        L += 1
        R += 1
    # それ以外は左端のみを進める
    else:
        # 立った人の連続の数が減るなら1減らす
        if (S[L] == '0' and S[L + 1] == '1'):
            stand -= 1
        L += 1
        # 左端のみを進めた場合は答えを更新し得ない

print(ans)


Measured memory_bytes: 3316
# coding: utf-8
from collections import deque

inputs = deque(raw_input().split())
q = deque()
while len(inputs):
    op = inputs.popleft()
    if op == '+':
        q.append(q.pop() + q.pop())
    elif op == '-':
        v1 = q.pop()
        v2 = q.pop()
        q.append(v2 - v1)
    elif op == '*':
        q.append(q.pop() * q.pop())
    else:
        q.append(int(op))

print q.pop()



Measured memory_bytes: 4980
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($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)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $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, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

fn main() {
    input! {
        n: usize, t: usize,
        a: [u64; n],
    }
    let mut ans = 1;
    let mut diff = vec![std::u64::MAX; n - 1];
    let mut min_ = a[0];

    for i in 1..n {
        if a[i] > min_ {
            diff[i - 1] = a[i] - min_;
        } else {
            diff[i - 1] = 0;
        }
        min_ = min(min_, a[i]);
    }
    diff.sort();
    diff.reverse();
    for i in 1..n - 1 {
        if diff[i] == diff[0] {
            ans += 1;
        } else {
            break;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 6396
#include <bits/stdc++.h>
using namespace std;
 
int main() {  
  
  int N, types;
  cin >> N;
  types = 0;
  
  vector<string> arare(N);
  for (int i = 0; i < N; i++) {
  cin >> arare.at(i);
  }
  
  string type= "PYWG";
  string a, b;

  for(int j = 0;j < 4;j++){ 
     for(int k = 0;k < N;k++){
     a = arare.at(k);
     b = type.at(j);
        if(a == b){
        types++;
        break;
        } 
     }
  }

  if(types == 3){
    cout << "Three" << endl;
  }
  else if(types == 4){
    cout << "Four" << endl;
  }
}

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

struct task{
	ll tm, dead;
}ara[MAX];

bool comp(task a, task b)
{
	if(a.dead == b.dead)
		return a.tm < b.tm;
		
	return a.dead < b.dead;
}

int main()
{
	ios_base::sync_with_stdio(false); cin.tie(0);
	
	ll n;
	cin >> n;
	
	for(int i = 0; i < n; i++){
		cin >> ara[i].tm >> ara[i].dead;
	}
		
	int flag = 1;
	sort(ara, ara + n, comp);
	
	ll sum = 0;
	for(int i = 0; i < n; i++){
		sum += ara[i].tm;
		if(ara[i].dead < sum){
			flag = 0;
			break;
		}
	}
	
	if(flag){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}
}


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

int main(){
  string s, ans;
  cin >> s;
  
  for (int i = 0; i < s.size(); i++){
    if(s.at(i) != 'B'){
      ans += s.at(i);
    } else if (!ans.empty()) ans.pop_back();
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define all(aaa) aaa.begin(), aaa.end()

const int N = 1e5 + 5, MOD = 1e9 + 7;
int a[N];

ll bp(ll a, ll p) {
    ll r = 1;
    while (p > 0) {
        if (p & 1)
            r = r * a % MOD;
        a = a * a % MOD;
        p >>= 1;
    }
    return r;
}

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

    int n;
    cin >> n;

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

    ll ans = 0, x = 0;

    for (int i = 0; i + 1 < n; i++) {
        x = (x + bp(i + 1, MOD - 2)) % MOD;
        ans = (ans + x * (a[i + 1] - a[i])) % MOD;
    }

    for (int i = 1; i <= n - 1; i++) {
        ans = ans * i % MOD;
    }

    cout << ans;

    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <limits.h>
#include <queue>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)

int H[100100];
int DP[100100];

int main(){
    int N, K;
    cin >> N >> K;
    REP(i,N){
        int h;
        cin >> h;
        H[i] = h;
    }

    REP(i,K+1){
        DP[i] = abs(H[0] - H[i]);
    }

    for(int i = K+1; i < N; i++){
        int m = INT_MAX;
        for(int j = 1; j <= K; j++){
            m = min(m, DP[i-j] + abs(H[i] - H[i-j]));
        }
        DP[i] = m;
    }

    cout << DP[N-1] << endl;
    return 0;
}


Measured memory_bytes: 1024
import sys
import math

# -*- coding: utf-8 -*-

n ,m = list(map(int, input().split()))

a=list(map(int, input().split()))
##まずソート
a.sort()

dist = [None] * m
##次のターゲットとの距離を出す
for i in range(m-1):
    dist[i] = (a[i+1]-a[i])

##最後のターゲットは右隣がないので大きな値
dist[m-1] = 1000000

dist.sort()
score = 0
##隣との距離が小さい順に駒に回らせる
for i in range(m-n):
    score += dist[i]

print(score)




Measured memory_bytes: 13576
import std.stdio, std.range, std.conv, std.string, std.array, std.functional;
import std.algorithm.comparison, std.algorithm.iteration, std.algorithm.mutation, std.algorithm.searching, std.algorithm.setops, std.algorithm.sorting;
import std.container.binaryheap;

void main()
{

    string S;
    // scanf("%s", &S);
    S = readln().strip();
    int res;
    foreach(i; 0..S.length)
    {
        int count;
        foreach(c; S[i..$])
        {
            if(
                c=='A' ||
                c=='C' ||
                c=='G' ||
                c=='T'
                )
                {
                    count++;
                    continue;
                }
            break;
        }
        res = max(res, count);
    }
    writeln(res);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using ll = long long;
const int INF = 2147483647;
const ll MOD = 1000000007;
// const ll INF = 1000000000000000000LL;


int main(){
   int n;
   cin >> n;
   vector<int> v(n);
   rep(i,n) cin >> v[i];
   map<int,int> odd;
   map<int,int> even;
   int odd1=0;
   int o1 = 0;
   int odd2=0;
   int o2 = 0;
   int even1=0;
   int e1 = 0;
   int even2=0;
   int e2 = 0;
   //奇数,偶数
   rep(i,n){
       if(i%2==0){
           odd[v[i]]++;
       }
       else{
           even[v[i]]++;
       }
   }
   for(auto a:odd){
       if(a.second>odd1){
           odd2 = odd1;
           o2 = o1;
           odd1 = a.second;
           o1 = a.first;
       }
       else if(a.second>odd2)
            odd2 = a.second;
   }
    for(auto a:even){
       if(a.second>even1){
           even2 = even1;
           e2 = e1;
           even1 = a.second;
           e1 = a.first;
       }
       else if(a.second>even2)
            even2 = a.second;
   }
    if(e1!=o1){
        cout << n-odd1-even1 << endl;
    }
    else{
        cout << min(n-even1-odd2,n-even2-odd1) << endl;
    }
    return 0;

}

Measured memory_bytes: 8256
#include <iostream>

using namespace std;

int main() {
    int r, g, b;
    cin >> r >> g >> b;
    int sum = 100 * r + 10 * g + b;
    if (sum % 4 == 0)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 256