akhauriyash/Code-Regression huggingface dataset:
N, M = map(int, input().split())
p = list(map(int,input().split()))
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

uf = UnionFind(N)
for _ in range(M):
    x, y = map(lambda n: int(n) - 1, input().split())
    uf.union(x, y)
ans = 0
for i in range(N):
    if uf.same(i, p[i]-1):
        ans += 1
print(ans)

Measured memory_bytes: 13812
#include<cstdio>
long long a,b,x;
long long s,e;
int main(){
    scanf("%lld%lld%lld",&a,&b,&x);
    if(a%x==0)s=a/x;
    else s=a/x+1;
    e=b/x;
    printf("%lld",e-s+1);
    return 0;
}

Measured memory_bytes: 128
# AB -> BBAA -> BAAAA -> BA
# Thus, this problem has commutative property.
# So, if we let A and B satisfy x^2 + x + 1 == 0,
# then A^2 == B, B^2 == A, and A^3 == B^3 == 1.
# So this makes an invariant.

from itertools import accumulate

S = input()
T = input()
q = int(input())
abcds = [tuple(map(int, input().split())) for _ in range(q)]

S_csum = list(map(lambda x: x%3, [0] + list(accumulate(map(lambda c: 1 if c == 'A' else -1, S)))))
T_csum = list(map(lambda x: x%3, [0] + list(accumulate(map(lambda c: 1 if c == 'A' else -1, T)))))

for a, b, c, d in abcds:
    if (S_csum[b] - S_csum[a-1]) % 3 == (T_csum[d] - T_csum[c-1]) % 3:
        print("YES")
    else:
        print("NO")

Measured memory_bytes: 36008
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(int X = 0; X < N; X++)
#define repvin(V,N) for(int i = 0; i < N; i++) {int tmp; cin >> tmp; V.push_back(tmp);}

using namespace std;

int main(){

    int d,g;
    cin >> d >> g;

    vector<int> p;
    vector<int> c;

    int ans = INT_MAX;

    rep(i,d){
        int tp,tc;
        cin >> tp >> tc;

        p.push_back(tp);
        c.push_back(tc);
    }


    for(int bit = 0; bit < (1 << d); bit++){

        int tmpans = 0;
        int tmpscore = 0;

        rep(j,d){
            if(bit & (1 << j)){
                tmpans = tmpans + p[j];
                tmpscore = tmpscore + (j + 1) * 100 * p[j] + c[j];
            }
        }

        for(int i = d - 1; i >= 0; i--){
            if(g <= tmpscore) break;
            if(bit & (1 << i)) continue;

            int restscore = g - tmpscore;

            int solvenum = max(0, p[i] - 1);

            if(restscore <= solvenum * (i + 1) * 100){
                tmpans = tmpans + (restscore + ((i + 1) * 100) - 1 ) / ((i + 1) * 100);
                tmpscore = tmpscore + (i + 1) * 100 * (restscore + ((i + 1) * 100) - 1 ) / ((i + 1) * 100);
            }else{
                tmpscore = tmpscore + solvenum * (i + 1) * 100;
                tmpans = tmpans + solvenum;
            }

        }

        if(tmpscore >= g) ans = min(ans,tmpans);

    }

    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
D = list(map(int, input().split()))

ans = N
while True:
    tmp = ans
    finish = True
    while tmp > 0:
        if tmp % 10 in D:
            finish = False
            break
        tmp //= 10
    if finish:
        break
    ans += 1
print(ans)


Measured memory_bytes: 2940
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

i64 n;
int main() {
  cin >> n;
  map<string, int> mp;
  for (int i = 0; i < n; ++i) {
    string s;
    cin >> s;
    sort(begin(s), end(s));
    mp[s]++;
  }
  i64 ans = 0;
  for (auto p : mp) {
    i64 x = p.second;
    ans += x * (x - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}


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

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

#define MAX 1145141

vector<bool>isPrime(MAX,true);
void sieve(){
        for(ll i=2;i<MAX;i++){
                if(isPrime[i]){
                        for(ll j=i+i;j<MAX;j+=i)isPrime[j]=false;
                }
        }
        isPrime[0]=false;
        isPrime[1]=false;
}

int main(){
        ll n;
        sieve();
        while(cin>>n&&n){
                int ans=0;
                for(ll i=n+1;i<=2*n;i++){
                        if(isPrime[i])ans++;
                }
                cout<<ans<<endl;
        }
}



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

int main(void){

    long long N;
    cin >> N;
    
    long long ans = 0;
    for(long long i = 0; i <= N;i++){
        if(i%5==0||i%3==0)continue;
        ans += i;
        //cout << i <<endl;
        
    }
    cout << ans <<endl;
}


Measured memory_bytes: 3604
fun main(array: Array<String>) {
    val s = readLine()!!.toMutableList()
    var cnt = 0
    repeat(s.size-1) {
        if(s[it] == s[it+1]) {
            cnt++
            if(s[it+1] == '0') {
                s[it+1] = '1'
            }
            else {
                s[it+1] = '0'
            }
        }
    }
    print(cnt)
}

Measured memory_bytes: 34668
#include<bits/stdc++.h>
using namespace std ;
typedef long long ll;
int main(){
ll blah[90];
string s;
cin >> s ;
ll len= s.size();

for(ll i = 0 ; i <90 ; i++ ) blah[i]=0;
for( ll i = 0 ; i<len ; i++){

    if(s[i]== 'N') blah['N']=1;
    else if(s[i]=='S') blah['S']=1;
    else if (s[i]=='E') blah['E']=1;
    else blah['W'] = 1;

}
if(blah['N']!=blah['S']) cout<<"No"<<endl;

else if(blah['E']!=blah['W']) cout<<"No"<<endl;

else cout<<"Yes"<<endl;
return 0;
}






Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <cassert>

using namespace std;
constexpr int kN = 5010;
char d[kN][kN];
char d_rev[kN][kN];

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

    int n, k;
    cin >> n >> k;
    std::vector<int> v(n);
    for (auto& el : v) {
        cin >> el;
    }
    v.push_back(0);
    reverse(v.begin(), v.end());
    v.push_back(0);

    reverse(v.begin(), v.end());
    d[0][0] = 1;
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j <= k; j++) {
            d[i][j] = d[i - 1][j];
            if (j >= v[i]) d[i][j] = max(d[i - 1][j - v[i]], d[i - 1][j]);
        }
    }

    std::reverse(v.begin(), v.end());
    d_rev[0][0] = 1;
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j <= k; j++) {
            d_rev[i][j] = d_rev[i - 1][j];
            if (j >= v[i]) d_rev[i][j] = max(d_rev[i - 1][j - v[i]], d_rev[i - 1][j]);

        }
    }

    std::reverse(v.begin(), v.end());
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        int l = i - 1;
        int r = n - i;
        int cur = v[i];
        if (cur >= k) {
            continue;
        }
        int sum_r = 0;
        for (int j = k - 1; j >= k - cur; j--) {
            sum_r += d_rev[r][j];
        }

        bool ok = false;
        for (int cur_l = 0; cur_l <= k - 1; cur_l++) {
            if (sum_r && d[l][cur_l]) {
                ok = true;
                break;
            }
            int id_add = k - cur_l - 1 - cur;
            int id_del = k - cur_l - 1;
            if (id_add >= 0) {
                sum_r += d_rev[r][id_add];
            }
            if (id_del >= 0) {
                sum_r -= d_rev[r][id_del];
            }
        }
        if (!ok) ans++;
    }
    cout << ans << endl;
    return 0;
}



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

int main(){
  int n,k; cin>>n>>k;
  vector<int> v(n);
  for(int i=0; i<n;++i)cin>>v[i];

  int ans=0;
  for(int i=0; i<=min(n,k); ++i){
    for(int j=0; j<=i; ++j){
      vector<int> vv;
      for(int l=0; l<i-j; ++l)vv.push_back(v[l]);
      for(int l=n-1; l>n-1-j; --l)vv.push_back(v[l]);
      sort(vv.begin(),vv.end());
      int sum=accumulate(vv.begin(),vv.end(),0);
      for(int l=0; l<min(k-i,i); ++l)if(vv[l]<0)sum-=vv[l];      
      ans=max(ans,sum);
    }
  }

  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

bool next(const std::string& s, std::vector<char>& vocab, std::string& result) {
    if (s.empty()) {
        return false;
    }
    char back = s.back();
    auto s2 = s.substr(0, s.size() - 1);
    auto it = std::upper_bound(vocab.begin(), vocab.end(), back);
    if (it != vocab.end()) {
        result = s2 + *it;
        return true;
    } else {
        vocab.insert(it, back);
        return next(s2, vocab, result);
    }
}

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    std::string s;
    std::cin >> s;
    std::vector<char> vocab;
    for (char c = 'a'; c <= 'z'; ++c) {
        if (s.find(c) == std::string::npos) {
            vocab.push_back(c);
        }
    }
    if (!vocab.empty()) {
        std::cout << s << vocab.front() << '\n';
    } else {
        std::string result;
        if (next(s, vocab, result)) {
            std::cout << result << '\n';
        } else {
            std::cout << -1 << '\n';
        }
    }
    return 0;
}

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

int main() {
 int A,B,C,D;
 int L,R;

 cin >> A >> B >> C >> D;
 L = A + B;
 R = C + D;

 if (L > R) {
	cout << "Left" << endl;
 } else if (L == R) {
	cout << "Balanced" << endl;
 } else if (L < R) {
	cout << "Right" << endl;
 }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(kbrni,v.size())cout<<" "<<v[kbrni];cout<<endl
#define sset(s) cout<<#s<<":";each(kbrni,s)cout<<" "<<kbrni;cout<<endl
#define smap(m) cout<<#m<<":";each(kbrni,m)cout<<" {"<<kbrni.first<<":"<<kbrni.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 14;

int sm[(1 << MAX_N)];
double dp[(1 << MAX_N)];
double pp[101];

int main()
{
    int n,m,p;
    scanf("%d%d%d",&n,&m,&p);
    pp[0] = 1;
    vp edge(m);
    rep(i,m){
        pp[i+1] = pp[i] * (p / 100.0);
        scanf("%d%d",&edge[i].fi,&edge[i].se);
    }
    rep(i,(1 << n)){
        int res = 0;
        rep(j,m){
            int u = edge[j].fi - 1,v = edge[j].se - 1;
            if((i >> u) & (i >> v) & 1){
                res++;
            }
        }
        sm[i] = res;
    }
    for(int S=1;S<(1 << n);S=(S+1)|1){
        double res = 0;
        for(int T=S;T>0;T=(T-1)&S){
            res += dp[T]*pp[sm[S]-sm[T]-sm[S^T]];
        }
        dp[S] = 1.0 - res;
    }
    printf("%.12lf\n",dp[(1 << n)-1]);
    return 0;
}

Measured memory_bytes: 3388
use std::cmp::*;
use std::io::*;
use std::num::*;
use std::str::*;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let s = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok().unwrap()
}
fn string() -> String {
    read()
}
fn int() -> i64 {
    read()
}
fn char() -> char {
    read::<String>().pop().unwrap()
}
fn vecchar() -> Vec<char> {
    string().chars().collect()
}
fn vecint(n: i64) -> Vec<i64> {
    let mut vec = Vec::new();
    for i in 0..n {
        vec.push(int())
    }
    vec
}

fn main() {
    let a = int();
    let b = int();
    let c = int();

    if a == b {
        println!("{}", c)
    } else if b == c {
        println!("{}", a)
    } else {
        println!("{}", b)
    }
}


Measured memory_bytes: 4352
<?php
list($N, $M) = explode(" ", trim(fgets(STDIN)));

$v = [];
While ($str = trim(fgets(STDIN))) {
    $v = array_merge($v, explode(" ", $str));
}

$cnt = array_count_values($v);
ksort($cnt);

for($i=1; $i <= $N; $i++){
    echo (isset($cnt[$i]) ? $cnt[$i] : 0) . "\n";
}


Measured memory_bytes: 4728
import numpy as np
from collections import deque
n, m = [int(i) for i in input().split()]

e = [ [] for i in range(n)]



for _ in range(m):
    a, b = [int(i) for i in input().split()]
    e[a-1].append(b-1)
    e[b-1].append(a-1)
    
    
q = deque()
q.append(0)
ans = np.ones(n-1)
check = np.zeros(n)

while len(q) > 0:
    # キューの先頭（左端）からnodeを取り出す
    node = q.popleft()

    if node is not None:
        check[node] = 2
        con = e[node]
        for i in con:
            if check[i] ==0:
                ans[i-1] = int(node) + 1
                q.append(i)
                check[i] = 1

        

print('Yes')

for i in ans:
    print(int(i))

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

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

    int N0=0, N1=0;

    for(int i=0; i<S.length(); i++){
        if(S[i]=='0') N0++;
        else N1++;
    }

    cout << 2*min(N0, N1) << endl;

}

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

int *S, n;

//void rec(int i)
//{
//	// << "call rec. i: " << i << endl;
//	if (i == n) {
//		for (int i = 0; i < n; i++) cout << S[i];
//		cout << endl;
//		return;
//	}
//	rec(i + 1);
//	S[i] = 1;
//	rec(i + 1);
//	S[i] = 0;
//}
//
//void makeCombination()
//{
//	for (int i = 0; i < n; i++)
//		S[i] = 0;
//	rec(0);
//}

int solve(int i, int m)
{
	if (m == 0) return 1;
	if (i >= n) return 0;
	int ret = solve(i + 1, m) || solve(i + 1, m - S[i]);
	return ret;
}

int main()
{
	int q, m;

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

	scanf("%d", &q);
	for (int i = 0; i < q; i++) {
		scanf("%d", &m);
		if (solve(0, m)) printf("yes\n");
		else printf("no\n");
	}
	delete[] S;
	return 0;
}

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

int main()
{
  int H, W;
  cin >> H >> W;
  
  vector<string> pic(H);
  
  for(int i = 0; i < H; i++){
	   cin >> pic.at(i);
  }
  
  for(int j = 0; j < W+2; j++){
    cout << '#'; 
  }
  cout << endl;
  
  for(int i = 0; i < H; i++){
    cout << '#' << pic.at(i) << '#' << endl;
  }
  
  for(int j = 0; j < W+2; j++){
    cout << '#';
  }
  cout << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <cassert>
#include <random>
using namespace std;
using ll = long long;


int main() {
	int p, q, r; cin >> p >> q >> r;
	cout << min({ p + q, q + r, r + p }) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};


///////////////////////////

struct rest {
	ll id;
	string s;
	ll p;
};

bool cmp(rest a, rest b) {
	if (a.s == b.s) { return a.p > b.p; }
	return a.s < b.s;
}


int main() {

	ll N;
	cin >> N;

	vector<rest>r(N + 1);

	repn(i, N) {
		cin >> r[i].s >> r[i].p;
		r[i].id = i;
	}

	sort(++r.begin(), r.end(),cmp);

	repn(i, N) cout << r[i].id << endl;


	system("PAUSE");

	

}


Measured memory_bytes: 504
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
using namespace std;
const int maxn = 1e5 + 1;
int main(){
    int x,y;
    cin >> x >> y;
    int pts[300] = {0,300000,200000,100000};
    int sum = 0;
    sum += pts[x] + pts[y];
    if (x == 1 && y == 1){
       sum += 400000;
    }
    cout << sum << endl;



    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int H, W;
bool dp[100][100][41000] = {};
int A[100][100], B[100][100];
int const offset = 20000;

int main() {
    cin >> H >> W;
    for(int i=0; i<H; ++i) {
        for(int j=0; j<W; ++j) cin >> A[i][j];
    }
    for(int i=0; i<H; ++i) {
        for(int j=0; j<W; ++j) cin >> B[i][j];
    }
    
    dp[0][0][A[0][0] - B[0][0] + offset] = true;
    dp[0][0][B[0][0] - A[0][0] + offset] = true;
    for(int i=0; i<H; ++i) {
        for(int j=0; j<W; ++j) {
            for(int k=-20000; k<=20000; ++k) {
                int px = i - 1, py = j;
                if(px >= 0) {
                    dp[i][j][k + A[i][j] - B[i][j] + offset] |= dp[px][py][k + offset];
                    dp[i][j][k + B[i][j] - A[i][j] + offset] |= dp[px][py][k + offset];
                }
                px = i, py = j - 1;
                if(py >= 0) {
                    dp[i][j][k + A[i][j] - B[i][j] + offset] |= dp[px][py][k + offset];
                    dp[i][j][k + B[i][j] - A[i][j] + offset] |= dp[px][py][k + offset];
                }
            }
        }
    }

    int res = 1001001001;
    for(int k=-20000; k<=20000; ++k) {
        if(dp[H - 1][W - 1][k + offset]) res = min(res, abs(k));
    }
    cout << res << '\n';
}

Measured memory_bytes: 321792
#include <stdio.h>

int main()
{
    int in, n[3], out;
    int i;


    scanf("%d", &in);
    
    n[0] = in / 100;
    n[1] = in / 10 - n[0]*10;
    n[2] = in - (n[0]*100 + n[1]*10);

//printf("%d %d %d\n", n[0], n[1], n[2]);

    if((n[0] >= n[1] && n[0] > n[2]) || (n[0] > n[1] && n[1] < n[2]))
    out = n[0] *100 + n[0]*10+n[0];
    else if(n[0] < n[1] || n[0] < n[2])
    out = (n[0]+1)*100 + (n[0]+1)*10+(n[0]+1);
    else if (n[0] == n[1] && n[0] == n[2])
    out = n[0]*100+n[1]*10+n[0];
    else
    out = n[0]*100+n[1]*10+n[0];
    printf("%d\n", out);
    return 0;

}

Measured memory_bytes: 128
def calc(a,op,b):
    if op == "+":
        r = a + b 
    if op == "-":
        r = a - b 
    if op == "*":
        r = a * b 
    if op == "/":
        r = a // b
    return r
 
if __name__ == '__main__':
    while True:
        a,op,b = input().split()
        if op == "?":
            break
        print(calc(int(a),op,int(b)))

Measured memory_bytes: 6724
#include<bits/stdc++.h>
#include<numeric>
namespace std {
  template <class M, class N>
  constexpr common_type_t<M, N> lcm(M m, N n);
}
using namespace std;

int main(){
long long a,b;
cin >> a >> b;
long long x,r,tmp;

x = a*b;
 if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  /* ユークリッドの互除法 */
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }


cout << x/b;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int n,m=999999999,cnt;
int main()
{
    cin>>n;
    for (int i=1;i<=n;i++)
    {
        int a;
        cin>>a;
        if (a<=m)
        {
            cnt++;
            m=a;
        }
    }
    cout<<cnt;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdlib>
#include<string>
#include<vector>
#include<queue>
#include<algorithm>
using namespace std;
using ll = long long int;
const int mod = 1e9 + 7;
#define rep(i, a, b) for(int i = a;i < b; i++)

int main() {

	string s;
	cin >> s;

	if (s == "AAA" || s == "BBB") cout << "No" << endl;
	else cout << "Yes" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
inline ll gcd(ll a,ll b){return b?gcd(b,a%b):a;} //最大公約数
inline ll lcm(ll a,ll b){return a/gcd(a,b)*b;} //最小公倍数
ll A,B,C,D;
ll calc(ll v){
    ll dist = B - A + 1;
    ll pos = A;
    if(A % v != 0){
        pos += v - (A % v);
    }
    if(pos > B) return 0;
    ll tt = (B - pos + 1 + v - 1) / v;
    return tt;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> A >> B >> C >> D;
    ll ans = calc(C) + calc(D) - calc(lcm(C,D));
    ans = B - A + 1 - ans;
    print(ans);
    
}

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

int main() {

	int n;
	cin >> n;
	
	vector<long long> v(n);
	for(int i = 0; i < n; ++i){
		cin >> v[i];
	}
	
	int q;
	cin >> q;
	for(int i = 0; i < q; ++i){
		int k;
		cin >> k;
		
		auto it = lower_bound(v.begin(), v.end(), k);
		cout << distance(v.begin(), it) << endl;
	}

	return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vp;
typedef pair<int,int> pii;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9+7;
const int MAX = 10000000;
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
//cout << 'H' << endl;
//next_permutation(ALL(p));
//typedef priority_queue<int> pque;//これは大きい順
//typedef priority_queue<int, vector<int>, greater<int>> pque;//これは小さい順
//factorizeは、素因数分解用の関数

int main(){
	ll n,m;
  cin >> n >> m;
  priority_queue<ll,vector<ll>,greater<ll>> q;
  rep(i,n){
    ll x;
    cin >> x;
    q.push(x);
  }

  vector<pair<ll,ll>> p;
  ll sum = 0;
  rep(i,m){
    pair<ll,ll> pair;
    cin >> pair.second >> pair.first;
    p.push_back(pair);
  }
  sort(p.rbegin(),p.rend());

  rep(i,m){
    rep(j,p[i].second){
      if(q.empty()){
        break;
      }
      ll x = q.top();q.pop();
      if(x < p[i].first){
        sum += p[i].first;
      }else{
        sum += x;
      }
    }
  }

  while(!q.empty()){
    ll x = q.top();q.pop();
    sum += x;
  }

  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <deque>
using namespace std;
typedef long long ll;

const ll mod = 998244353;
struct mint {
    ll x;
    mint(ll x=0):x((x%mod+mod)%mod){}
    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 {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=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 {
        mint res(*this);
        return res/=a;
    }
};

int main(){
    ll N;
    cin >> N;
    string X,S,T = "";
    cin >> X;
    for(int i=0;i<N;i++){
        if(X[i]=='0') T += '1';
        else T += '0';
    }
    mint ans = 0;
    S = X+T;
    vector<mint> cnt(2*N+1,0);
    vector<mint> beki(2*N+1,1);
    vector<int> check(2*N+1,0);
    for(int i=1;i<=2*N;i++) beki[i] = beki[i-1]*2;
    for(int k=1;k<=2*N;k++){
        if(2*N%k!=0) continue;
        if(k%2==1) continue;
        if((2*N/k)%2==0) continue;
        check[k] = true;
//        cerr << k << endl;
        int n = k/2;
        string t = S.substr(0,n);
        string rt = "";
        for(int i=0;i<n;i++){
            if(t[i]=='0') rt += '1';
            else rt += '0';
        }
        //tより小さい部分を数える
        for(int i=n-1;i>=0;i--){
            if(t[i]=='1') cnt[k] += beki[n-1-i];
        }
        //tと同じものが条件を満たすか判定
        string now = "";
        for(int i=0;i<N;i+=k){
            if((i/k)%2==0) now += t;
            else now += rt;
        }
        if(now<=X) cnt[k] += 1;
    }
    for(int i=1;i<=2*N;i++){
        for(int j=2*i;j<=2*N;j+=i){
            if(!check[j]) continue;
            cnt[j] -= cnt[i];
        }
    }
    for(ll k=1;k<=2*N;k++){
        ans += cnt[k]*k;
//        cerr << k << " " << cnt[k].x << endl;
    }
    cout << ans.x << endl;
}

Measured memory_bytes: 9540
#include <iostream>
#include <cstdio>
#include <cstring>
#include <climits>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <sstream>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

// namespace
using namespace std;
namespace mp = boost::multiprecision;

// types
using pii = pair<int, int>;
using ll = long long int;
using ld = long double;
using mpi = mp::cpp_int;
using mpf = mp::number<mp::cpp_dec_float<1024>>;

ll n, a, b;

int main() {
    cin >> n >> a >> b;
    if (a == 0) {
        cout << 0 << endl;
        return 0;
    }
    if (b == 0) {
        cout << n << endl;
        return 0;
    }
    ll x = n / (a + b);
    ll y = min(n % (a + b), a);
    cout << x * a + y << endl;
    return 0;
}


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

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

    vector<int> dp(N, 0);
    dp.at(1) = abs(h.at(0) - h.at(1));
    for (int i = 2; i < N; i++) {
        dp.at(i) = min(dp.at(i - 2) + abs(h.at(i) - h.at(i - 2)), dp.at(i - 1) + abs(h.at(i) - h.at(i - 1)));
    }

    cout << dp.at(N - 1) << endl;
}

Measured memory_bytes: 1024
from itertools import accumulate
import sys
input = sys.stdin.readline

class BIT:
    def __init__(self, size):
        self.bit = [0] * (size + 1)
        self.size = size

    def sum(self, i):
        i += 1
        s = 0
        while i > 0:
            s += self.bit[i]
            i -= i & -i
        return s

    def add(self, i, x):
        i += 1
        while i <= self.size:
            self.bit[i] += x
            i += i & -i

N = int(input())
a = list(map(int, input().split()))
lb, ub = -1, 10**9
while ub - lb > 1:
    m = (lb + ub) // 2
    b = [0] * (N+1)
    for i in range(N):
        if a[i] <= m:
            b[i+1] = 1
    b = list(accumulate(b))
    # b[j+1] - b[i] > (j+1)//2 - i//2
    # b[j+1] - (j+1)//2 > b[i] - i//2
    bit_odd = BIT(2*N)
    bit_even = BIT(2*N)
    cnt = 0
    for i in range(N):
        x = N + b[i+1] - i//2 - 1
        y = N + b[i+1] - (i+1)//2 - 1
        if i % 2 == 0:
            bit_even.add(N + b[i] - i//2, 1)
            cnt += bit_even.sum(x) + bit_odd.sum(y)
        else:
            bit_odd.add(N + b[i] - i//2, 1)
            cnt += bit_even.sum(y) + bit_odd.sum(x)
    if cnt < N*(N+1)//4 + 1:
        lb = m
    else:
        ub = m
print(ub)

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

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			Scanner cin = new Scanner();
			int n = cin.Int();
			Console.WriteLine(n * n * n);
		}
	}

	public class Scanner
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private string[] buf_;
		private int index_;

		public Scanner()
		{
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = Console.ReadLine();
			while (st == "") {
				st = Console.ReadLine();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

		public int Int()
		{
			return int.Parse(Next());
		}
		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long Long()
		{
			return long.Parse(Next());
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double Double()
		{
			return double.Parse(Next());
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}
	}
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
 
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;
 
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }
 
const int mod=1e9+7;
 
struct mint {
  ll x;
  mint(ll x=0):x(x%mod){}
  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 {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
};
 
mint c[4005][4005];
void init() {
  c[0][0] = 1;
  for (int i = 0; i <= 4000; i++) {
    for (int j = 0; j <= i; j++) {
      c[i+1][j] += c[i][j];
      c[i+1][j+1] += c[i][j];
    }
  }
}
mint comb(int n, int k) {
  return c[n][k];
}
 
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
 
    return true;
}
 
map<ll, ll> primeFact(ll n) {
  map<ll, ll> res;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      res[i]++;
      n /= i;
    }
  }
  if (n != 1) res[n]++;
  return res;
}
 
void printv(vi& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
void printv(vll& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
int vtotal(vi& v){
  int total=0;
  rep(i,v.size()) total+=v[i];
  return total;
}
 
int main()
{
  //init(); // mint初期化
  cin.tie( 0 );
  ios::sync_with_stdio( false );
 
  int h,w;cin>>h>>w;
  int hh,ww;cin>>hh>>ww;
  int ans=h*w-(hh*w+ww*h)+hh*ww;
  cout<<ans<<endl;
 
  return 0;
}

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

int main(){ 
	int a,b; cin>>a>>b;
	if(a+b>=24){
		cout<<a+b-24<<endl;
	}
	else{
		cout<<a+b<<endl;
	}
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
	int x; cin >> x;
	while (true) {
		for (int i = 2; i <= x; i++) {
			if (i == x) {
				cout << x << endl;
				return 0;
			}
			if (x % i == 0) break;
		}
		x++;
	}
}

Measured memory_bytes: 3664
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<stdarg.h>
#include<malloc.h>

int round2(double x);

int main()
{
	int a, b, sum=0, ave=0, n=0;

	while(scanf("%d,%d", &a, &b) != EOF){
		sum += a * b;
		ave += b;
		n++;
	}

	ave = round2((double)ave / n);

	printf("%d\n%d\n", sum, ave);

	return 0;
}

	
int round2(double x)
{
	int buf;
	if(x>=0)
		x = floor(x + 0.5);
	else
		x = -1.0 * floor(fabs(x) + 0.5);
	buf =  (int)x;
	return buf;
}

Measured memory_bytes: 592
#include<bits/stdc++.h>
#define lli long long int
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string s,s1="",s2="";
    cin>>s;
    int x=s.size();
    s1+=s+"es";
    s2+=s+"s";
    if(s[x-1]=='s')
     cout<<s1<<"\n";
    else
     cout<<s2<<"\n";
}

Measured memory_bytes: 3664
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        //2~20
        int A = sc.nextInt();
        //1~20
        int B = sc.nextInt();
        int Ans = 0;
        while((B-1) > (A-1)*Ans){
            Ans += 1;
        }
        System.out.println(Ans);
        sc.close();
    }
}

Measured memory_bytes: 25300
#include<iostream>
#include<cmath>
#include<iomanip>
using namespace std;

int main(){
  int N,K;  cin >> N >> K;
  double ans = 0;
  for(int i=0;i<N;i++){
    int a = i+1;
    double temp = 1;
    while(a<K){
      a *= 2;
      temp /= 2;
    }
    ans += temp/N;
  }
  cout << fixed << setprecision(15) << (double)ans << endl;
}

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

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

    n %= 500;

    if (n <= a)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


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

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

//    int S_len = S.size();
    
    
    if (S.size() <= K) {
        cout << S << endl;
    }
    
    else {cout << S.substr(0,K) << "..." << endl;
         }
    
}



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

int main() {
    string S, T;
    cin >> S >> T;
    int ans = 1000;
    for(int i = 0; i < S.size() - T.size() + 1; i++){
        int temp = 0;
        string compare(S.begin() + i, S.begin() + i + T.size());
        for(int j = 0; j < T.size(); j++){
            if(compare[j] != T[j])
                temp++;
        }
        ans = min(ans, temp);
    }
    cout << ans << endl;
    return 0;
}

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


int main() {
    rep(i,5){
        int x;
        cin>>x;
        if(x==0){
            cout<<i+1<<endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3620
while True:
    n, m = map(int, input().split())
    if n == m == 0:
        quit()
    s1, s2 = [], []
    for i in range(n):
        s1.append(int(input()))
    for i in range(m):
        s2.append(int(input()))
    s1.sort()
    s2.sort(reverse=True)
    sum1 = sum(s1)
    sum2 = sum(s2)
    temp = 101
    for i in s1:
        for j in s2:
            if sum1 - i + j == sum2 - j + i:
                if temp > abs(i-j):
                    temp = abs(i-j)
                    ans = [i, j]
    if temp == 101:
        print(-1)
    else:
        print(ans[0], ans[1])


Measured memory_bytes: 5596
#include <bits/stdc++.h>
#define lld unsigned long long int
#define MAX 900000
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
using namespace std;

char a, b, c, d;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    scanf(" %c%c%c%c", &a,&b,&c,&d);
    if(a==b||b==c||c==d)cout<<"Bad";
    else cout<<"Good";
    cout<<endl;

}


Measured memory_bytes: 256
def cal(S):
    tmp, a, cnt = S[0], 1, 0
    flag = True
    for s in S[1:]:
        if S[0]!=s: flag=False
        if flag: a+=1
        if tmp[-1]==s:
            s = '*'
            cnt += 1
        tmp += s
    return a, cnt


S = input().replace('\n', '')
k = int(input())
ans = 0
if len(list(set(S)))==1:
    ans = len(S)*k//2
else:
    a, cnt = cal(S)
    b, _ = cal(S[::-1])
    ans = cnt*k
    if S[0]==S[-1]:
        ans -= ((a//2)+(b//2)-((a+b)//2))*(k-1)
print(ans)

Measured memory_bytes: 3064
#include<stdio.h>
 
int main(void){
 
int a,b,k,i;
 
scanf("%d%d%d",&a,&b,&k);

if(2*k >= b - a + 1 ) {
for(i = a; i <= b; i++){
printf("%d\n", i);
}
}

else{
for(i = 0; i < k; i++){
printf("%d\n", a+i);
}
 
for(i = k-1; i >= 0; i--){
printf("%d\n", b-i);
}
 }
return 0;
 
}

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

int main() {
  int N;
  cin >> N;
  int sum = 0;
  for (int i=0; i<N; i++){
    string S;
    cin >> S;
    if (S =="Y"){
      sum +=1;
    }
    else 
      continue;
  }
   if (sum ==0){
     cout <<"Three"<<endl;
   }
   else{
     cout <<"Four"<<endl;
   }
}


Measured memory_bytes: 3632
#include <stdio.h>

int main(){
  int a,b,c,d;
  int cu_a, cu_b;
  scanf("%d%d%d%d", &a, &b, &c, &d);

  cu_a = a*b;
  cu_b = c*d;

  int ans;
  if(cu_a >= cu_b){
    ans = cu_a;
  } else {
    ans = cu_b;
  }

  printf("%d", ans);
  return 0;
}

Measured memory_bytes: 128
import sys
import math
A, B = map(int, input().split())

def nXor(n):
  if n % 2 == 0:
    if (n//2) % 2 == 0:
      return 0 ^ n
    else:
      return 1 ^ n
  else:
    if ((n+1)//2) % 2 == 0:
      return 0
    else:
      return 1
n = 0
for i in range(9):
  n = n^i
print (nXor(A-1) ^ nXor(B))


Measured memory_bytes: 3060
#include<stdio.h>
#include<algorithm>
using namespace std;
int main()
{
	int a,i;
	scanf("%d",&a);
	int x[a],y[a],z[a];
	for(i=0;i<a;i++){
		scanf("%d",&x[i]);
		y[i]=x[i];
	}
	sort(y,y+a);
	for(i=0;i<a;i++){
		if(x[i]==y[a-1]){
			printf("%d\n",y[a-2]);
		}
		else if(x[i]<=y[a-1]){
			printf("%d\n",y[a-1]);
		}
	}
	return 0;
}

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

int main(void){
	int n, t;
	scanf("%i %i", &n, &t);
	int m = 0;
	int am = 0;
	int mi = 1000000000;
	for(int i=0; i<n; i++){
		int a;
		scanf("%i", &a);
		mi = min(mi, a);
		if(a-mi > m){
			m = a-mi;
			am = 1;
		} else if(a-mi==m) am++;
	}
	printf("%i\n", am);
}

Measured memory_bytes: 3796
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
template<class T> inline void read(T &x){
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
template<class T> inline void umin(T &x, T y){x=x<y?x:y;}
template<class T> inline void umax(T &x, T y){x=x>y?x:y;}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
const int N = 1021000, mo = 998244353;
inline void add(int &x,int y){x=x+y<mo?x+y:x+y-mo;}
inline void sub(int &x,int y){x=x-y>=0?x-y:x-y+mo;}
int n,k,res,fac[N],ifac[N];
int power(int a, int n){
	int res=1;
	while(n){
		if(n&1)res=1LL*res*a%mo;a=1LL*a*a%mo;n>>=1;
	}
	return res;
}
void init(int n){
	fac[0]=1;rep(i,1,n)fac[i]=1LL*fac[i-1]*i%mo;
	ifac[n]=power(fac[n],mo-2);per(i,n-1,0)ifac[i]=1LL*ifac[i+1]*(i+1)%mo;
}
inline int C(int n, int m){
	return m>=0&&m<=n?1LL*fac[n]*ifac[m]%mo*ifac[n-m]%mo:0;
}
inline int f(int n, int lim){
	if(lim<0)lim=-lim;if(lim>n||(n-lim)%2)return 0;
	assert(lim>=0);return C(n,(n+lim)/2);
}
int vio(int n, int k){
	int res=0;
	rep(s,0,(1<<k)-1){
		int a=0,b=0;
		rep(i,0,k-1)if(s>>i&1)b++;
		else if(b)b--;else a++;
		int i=(k-a-b)/2;
		if(i>=0&&2*i+a+b==k&&i+b-a>=n&&(b-a>=(a>0)))res++;
		else {rep(i,0,k-1)printf("%d",s>>i&1);puts("");}
	}
	return res;
}
int main() {
	init(N-1);
	read(n);read(k);
	rep(d,0,k)if((d-k)%2==0){
		int up=(k+d-2*n)/2;if(d==0){//umin(up,0);
			if(k-2*n>=0){add(res,f(k-1,1));sub(res,f(k-1,-k+2*n-3));}//WA
			continue;
		}
		if(up>=0)add(res,f(k,d)),sub(res,f(k,2*up+2+d));
	}
	printf("%d\n",res);
//	cerr<<vio(n,k);//0110
	return 0;
}


Measured memory_bytes: 8192
#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(S: int):
    S = str(S)
    print(min([abs(int(S[i:i+3])-753) for i in range(len(S)-2)]))
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = int(next(tokens))  # type: int
    solve(S)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong();
		long b = sc.nextLong();
		long x = sc.nextLong();

		long sum;
		if (a > 0) {
			sum = (b / x) - ((a - 1) / x);
		} else {
			sum = b / x + 1;
		}

		System.out.println(sum);
	}
}


Measured memory_bytes: 10192
#include<cstdio>
using namespace std;
typedef long long ll;
const int N=100100;
int i,j,k,n,m,ch,ff,x,y,En;
int A[N],h[N],fa[N];
struct edge { int s,n;} E[N<<1];
void R(int &x) {
	x=ff=0;ch=getchar();
	while (ch<'0' || '9'<ch) { if (ch=='-') ff=1;ch=getchar();}
	while ('0'<=ch && ch<='9') x=x*10+ch-'0',ch=getchar();
	if (ff) x=-x;
}
void W(int x) {
	if (x<0) putchar('-'),x=-x;
	if (x>=10) W(x/10);
	putchar(x%10+'0');
}
void R(ll &x) {
	x=ff=0;ch=getchar();
	while (ch<'0' || '9'<ch) { if (ch=='-') ff=1;ch=getchar();}
	while ('0'<=ch && ch<='9') x=x*10+ch-'0',ch=getchar();
	if (ff) x=-x;
}
void W(ll x) {
	if (x<0) putchar('-'),x=-x;
	if (x>=10) W(x/10);
	putchar(x%10+'0');
}
void E_add(int x,int y) {
	E[++En].s=y;E[En].n=h[x];h[x]=En;
	E[++En].s=x;E[En].n=h[y];h[y]=En;
}
void dfs(int x,int F) {
	fa[x]=F;
	for (int k=h[x];k;k=E[k].n) if (E[k].s!=F) dfs(E[k].s,x);
}
int Dfs(int x,int F) {
	int sz=1;
	for (int k=h[x];k;k=E[k].n) if (E[k].s!=F) sz+=Dfs(E[k].s,x);
	return sz;
}
int main() {
	R(n);
	for (i=1;i<n;i++) {
		R(x);R(y);
		E_add(x,y);
	}
	dfs(1,0);
	int t=n,nm=0;
	while (t) A[++nm]=t,t=fa[t];
	int num1=Dfs(A[nm/2],A[nm/2+1]);
	int num2=Dfs(A[nm/2+1],A[nm/2]);
	if (num2>num1) puts("Fennec");
	else puts("Snuke");
}

Measured memory_bytes: 6016
from math import log10, ceil


def S(n: int) -> int:
    """n を十進法で表した時の各桁のあたいの総和
    :param n: 任意の正の整数
    :return: 十進法の各桁の和
    """
    s = 0
    while n > 0:
        s += n % 10
        n //= 10
    return s


def f(N: int) -> int:
    if N < 10:
        return N

    D = ceil(log10(N) + 1)
    x = 10 * (N // 10 + 1) - 1
    for d in range(1, D + 1):
        td = 10 ** (d + 1)
        nx = td * (N // td + 1) - 1

        if nx / S(nx) < x / S(x):
            x = nx
    return x


if __name__ == "__main__":
    K = int(input())
    N = 1
    for _ in range(K):
        print(N)
        N = f(N+1)


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

int main()
{
  int i,H;
  long *A;
  scanf("%d",&H);
  A = (long*)malloc(sizeof(long) * (H+1));
  for (i = 1; i <= H; i++) {
    scanf("%ld",A+i);
  }
for (i = 1; i <= H; i++) {
  printf("node %d: key = %ld, ",i,A[i]);
  if(i/2 > 0) printf("parent key = %ld, ", A[i/2]);
  if(2*i <= H) printf("left key = %ld, ", A[2*i]);
  if(2*i+1 <= H) printf("right key = %ld, ", A[2*i+1]);
  printf("\n");
 }

  return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,k;
  cin>>n>>k;
  int count[n+1]={0};
  int d,x;
  for(int i=0;i<k;i++)
  {
    cin>>d;
    for(int i=0;i<d;i++)
    {
      cin>>x;
      count[x]++;
      
      
    }
    
    
    
  }
  int ans=0;
  for(int i=1;i<=n;i++)
  {
    if(count[i]==0)
      ans++;
    
  }
  cout<<ans<<endl;


  
  
  
  
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
ll mx(ll a,ll b){if(a>=b) return a;return b;}
ll mn(ll a,ll b){if(a<b) return a;return b;}
#define pb push_back
#define mp make_pair
#define M (ll) (2e5+7)
#define INF (3e18)
ll add[M], res[M];
vector<vi> to(M);
void dfs(ll r,ll val,ll p=-1){
    val+=add[r];
    res[r]=val;
    for(ll i=0;i<to[r].size();i++)
        if(to[r][i]!=p)
            dfs(to[r][i],val,r);
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
//    freopen("xorr.gir","r",stdin);
//    freopen("xorr.cik","w",stdout);
    ll n,q;cin>>n>>q;
    for(ll i=0;i<n-1;i++){
        ll x,y;cin>>x>>y;
        to[x].pb(y);
        to[y].pb(x);
    }
    for(ll i=0;i<q;i++){
        ll p,x;cin>>p>>x;
        add[p]+=x;
    }
    dfs(1,0);
    for(ll i=1;i<=n;i++) cout<<res[i]<< " ";
    cout<<endl;
    return 0;
}













Measured memory_bytes: 25600
#include<bits/stdc++.h>
#include<tr1/unordered_map>
#define pb push_back
#define pii pair<int,int>
#define SZ(x) (int)x.size()
#ifdef __linux__
#define getchar getchar_unlocked
#endif
#define mem(a,b) memset(a,b,sizeof(a))
#define  For(i,a,b) for(int i=a,i##E=b;i<=i##E;++i)
#define rFor(i,a,b) for(int i=a,i##E=b;i>=i##E;--i)
typedef long long LL;
using namespace std;
const int inf=0x3f3f3f3f;
template<typename T>inline bool chkmin(T &a,const T &b){return a>b?a=b,1:0;}
template<typename T>inline bool chkmax(T &a,const T &b){return a<b?a=b,1:0;}
template<typename T>inline void read(T &x)
{
	x=0;int _f(0);char ch=getchar();
	while(!isdigit(ch))_f|=(ch=='-'),ch=getchar();
	while( isdigit(ch))x=x*10+ch-'0',ch=getchar();
	x=_f?-x:x;
}
inline void file()
{
#ifdef ztzshiwo
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
#endif
}
int n,A,K,ans;
inline int Solve(int A,int K)
{
	if(A<K)return 0;
	if(A%K==0)return A/K;
	int x=max(((A-A/K*K)/(A/K+1)),1);
	return Solve(A-x*(A/K+1),K);
}
int main()
{
	file();
	read(n);
	while(n--)
	{
		read(A),read(K);
		ans^=Solve(A,K);
	}
	if(ans)puts("Takahashi");
	else puts("Aoki");
	return 0;
}


Measured memory_bytes: 256