akhauriyash/Code-Regression huggingface dataset:
N = int(input())
S = input()

ans = 0
for i in range(N-1):
    S1 = S[:i+1]
    S2 = S[i+1:]
#    print(S1, S2)
    ans = max(ans, len(set(list(S1)) & set(list(S2))))
print(ans)

Measured memory_bytes: 38256
#include <bits/stdc++.h>                                           
 
//#define int long long
//#pragma GCC optimize("Ofast")
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
 
 
#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);
#define forev(i, b, a) for(int i = (b); i >= (a); --i)
#define forn(i, a, b) for(int i = (a); i <= (b); ++i)
#define all(x) x.begin(), x.end()
#define sz(s) (int)s.size()
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define s second
#define f first
 
 
using namespace std;
 
 
typedef pair < long long, long long > pll;    
typedef pair < int, int > pii;  
typedef unsigned long long ull;         
typedef vector < pii > vpii;                                   	
typedef vector < int > vi;
typedef long double ldb;  
typedef long long ll;  
typedef double db;
 
 
const int inf = 1e9, maxn = 1e6 + 48, mod = 1e9 + 7, N = 1e5 + 24;
const int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1}, block = 555;
const pii base = mp(1171, 3307), Mod = mp(1e9 + 7, 1e9 + 9);
const db eps = 1e-12, pi = acos(-1);
const ll INF = 1e18;


int n, m, a, b, res[N];
queue < int > q;
bool was[N];
vi g[N];                      



main () {
	cin >> n >> m;
	while (m--) {
		cin >> a >> b;
		g[a].pb(b);
		g[b].pb(a);
	}

	memset(res, -1, sizeof(res));
	q.push(1);
	res[1] = 0;
	while (sz(q)) {
		int v = q.front();
		q.pop();
		for (auto to : g[v])
			if (res[to] == -1) {
				res[to] = v;
				q.push(to);
			}
	}
	

	cout << "Yes\n";
	for (int i = 2; i <= n; ++i)
		cout << res[i] << endl;
}	

Measured memory_bytes: 10420
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <map>
#include <tuple>

#define INF 1001001001
#define rep(i,n) for(int i=0; i<(n); i++)
typedef long long ll;
using namespace std;
 

int main(){
    int n,m; cin >> n >> m;
    
    int L,R; L = 0; R = INF;
    int ans;
    rep(i,m){
        int l,r;
        cin >> l >> r;
        if(L<l){
            L = l;
        }
        if(r<R){
            R = r;
        }
 
        
    }
    ans = R-L+1;
    if(ans < 0){
        cout << 0 << endl;
        return 0;
    }
    cout << ans << endl;
    
}


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

int main() {
	ll ans = 0, n;
	cin >> n;
	vector<ll> a(n), b(n+1);
	map<ll, int> c;
	b[0] = 0;
	c[0]++;
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
		b[i+1] = b[i] + a[i];
		ans += c[b[i+1]];
		c[b[i+1]]++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 15872
/*input
5 3
1 2 3 4
10 1 1
1 1 1
1 10 1
1 1 1
1 1 10
*/
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>
using namespace std;
#define sp ' '
#define endl '\n'
#define fi first
#define se second
#define mp make_pair
#define int long long
#define N
// const int INF = 1e18;
// const int mod = 1e9+7;

int n, m;
int a[5005];
int b[5005][205];
pair<int, int> tree[205][5005 * 4];
int dp[5005][5005];

void init(const int wh, int k, int l, int r) {
#define f tree[wh]
	if (l == r) {
		f[k].fi = b[l][wh];
		f[k].se = l;
		return;
	}
	int mid = (l + r) / 2;
	init(wh, k * 2, l, mid); init(wh, k * 2 + 1, mid + 1, r);
	f[k] = max(f[k * 2], f[k * 2 + 1]);
}

pair<int, int> get(const int wh, int k, int l, int r, int L, int R) {
	if (r < L || R < l) return mp(0, 0);
	if (L <= l && r <= R) return f[k];
	int mid = (l + r) / 2;
	return max(get(wh, k * 2, l, mid, L, R), get(wh, k * 2 + 1, mid + 1, r, L, R));
}

void back(const int wh, int l, int r) {
	if (l > r) return;
	pair<int, int> rec = get(wh, 1, 1, n, l, r);
	if (l == r) {
		dp[l][r] += rec.fi;
		dp[l][r + 1] -= rec.fi;
		return;
	}
	for (int i = l; i <= rec.se; i++) dp[i][rec.se] += rec.fi, dp[i][r + 1] -= rec.fi;
	back(wh, l, rec.se - 1); back(wh, rec.se + 1, r);
}

signed main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin >> n >> m;
	for (int i = 2; i <= n; i++) cin >> a[i], a[i] += a[i - 1];
	for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) cin >> b[i][j];
	for (int i = 1; i <= m; i++) init(i, 1, 1, n);
	for (int wh = 1; wh <= m; wh++) {
		back(wh, 1, n);
	}
	for (int i = 1; i <= n; i++) {
		for (int j = i; j <= n; j++) {
			dp[i][j] += dp[i][j - 1];
		}
	}
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		for (int j = i; j <= n; j++) {
			dp[i][j] -= a[j] - a[i];
			ans = max(ans, dp[i][j]);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 176896
#include "bits/stdc++.h"

// Begin {{{
using namespace std;
#define all(x) x.begin(), x.end()
#define rep(i, n) for (i64 i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, b, e) for (i64 i = (b), i##_limit = (e); i <= i##_limit; ++i)
#define repr(i, b, e) for (i64 i = (b), i##_limit = (e); i >= i##_limit; --i)
#define var(Type, ...) Type __VA_ARGS__; input(__VA_ARGS__)
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T> using MaxHeap = priority_queue<T>;
template <class T> using MinHeap = priority_queue<T, vector<T>, greater<>>;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
inline i64 sigma(i64 n) { return n * (1 + n) >> 1; }
inline i64 updiv(i64 n, i64 d) { return (n + d - 1) / d; }
constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;
#ifndef DEBUG
#define dump(...)
#endif

inline void input() {}
template <class Head, class... Tail>
inline void input(Head&& head, Tail&&... tail) {
    cin >> head;
    input(forward<Tail>(tail)...);
}

inline void outs() { cout << "\n"; }
template <class Head, class... Tail>
inline void outs(Head&& head, Tail&&... tail) {
    cout << head << (sizeof...(tail) ? " " : "");
    outs(forward<Tail>(tail)...);
}

template <class T>
inline void outs(vector<T> &vec) { for (auto &e : vec) cout << e << " \n"[&e == &vec.back()]; }

template <class T>
inline void outs(vector<vector<T>> &df) { for (auto &vec : df) outs(vec); }

inline void outl() { cout << "\n"; }
template <class Head, class... Tail>
inline void outl(Head&& head, Tail&&... tail) {
    cout << head << (sizeof...(tail) ? "\n" : "");
    outl(forward<Tail>(tail)...);
}

template <class T>
inline void outl(vector<T> &vec) { for (auto &e : vec) cout << e << "\n"; }

inline void outn() {}
template <class Head, class... Tail>
inline void outn(Head&& head, Tail&&... tail) {
    cout << head;
    outn(forward<Tail>(tail)...);
}

template <class T>
inline void outn(vector<T> &vec) { for (auto &e : vec) cout << e; }

template <class T>
inline vector<T> make_v(const T &initvalue, size_t sz) {
    return vector<T>(sz, initvalue);
}

template <class T, class... Args>
inline auto make_v(const T &initvalue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initvalue, args...))>(sz, make_v<T>(initvalue, args...));
}
// }}} End

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    var(int, N);
    vector<bool> exist(2030);
    vector<int> x(N + 10);
    reps(i, 1, N) {
        input(x[i]);
        exist[x[i]] = true;
    }
    var(int, M);
    rep(i, M) {
        var(int, a);
        if (x[a] + 1 < 2020 && !exist[x[a]+1]) {
            exist[x[a]] = false;
            exist[x[a]+1] = true;
            ++x[a];
        }
    }
    reps(i, 1, N) outl(x[i]);
    return 0;
}



Measured memory_bytes: 3172
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <climits>
#include <cmath>
#include <algorithm>
#include <cassert>

#define TEST_ASSERT(msg, cond) do { if (cond) { cout << msg << " => pass" << endl;} else { cout << msg << " => failed" << endl;} } while(0)

using namespace std;

// convert hh:mm::ss to sec
int convertSec(const string& str) {
  int h = 10 * (str[0] - '0') + (str[1] - '0');
  int m = 10 * (str[3] - '0') + (str[4] - '0');
  int s = 10 * (str[6] - '0') + (str[7] - '0');
  return 3600 * h + 60 * m + s;
}

int main() {

  while (true) {
    int n;
    cin >> n;
    if (n == 0) break;

    vector<int> table(23 * 3600 + 59 * 60 + 59, 0);

    for (int i = 0; i < n; i++) {
      string s, e;
      cin >> s >> e;

      table[convertSec(s)]++;
      table[convertSec(e)]--;
    }

    // simulate
    for (int i = 0; i < table.size(); i++) {
      if (i != 0) table[i] += table[i - 1];
    }

    // find max value
    int maxValue = 0;
    for (int i = 0; i < table.size(); i++) {
      if (table[i] > maxValue) maxValue = table[i];
    }

    cout << maxValue << endl;
  }

  return 0;
}

Measured memory_bytes: 3436
#include <stdio.h>

int main(void)
{
	int array[100], n, i, j, temp, num;
	
	while (scanf("%d", &n), n != 0){
		num = 0;
		
		for (i = 0; i < n; i++){
			scanf("%d", &array[i]);
		}
		
		for (i = n - 1; i >= 1; i--){
			for (j = 0; j < i; j++){
				if (array[j] > array[j + 1]){
					temp = array[j];
					array[j] = array[j + 1];
					array[j + 1] = temp;
					num++;
				}
			}
		}
		
		printf("%d\n", num);
	}
	
	return (0);
}

Measured memory_bytes: 596
// url: http://abc075.contest.atcoder.jp/tasks/abc075_a

import std.algorithm, std.conv, std.range, std.stdio, std.string;

void main()
{
  auto a = readln.split.to!(int[]);
  a.sort();
  writeln(a[0] == a[1] ? a[2] : a[0]);
}


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();
		ArrayList<Integer> arr = new ArrayList<Integer>(N);
		long sum = 0;
		for(int i = 0; i < N; i++) {
			arr.add(sc.nextInt());
		}
		for(int i = 0; i < N; i++) {
			for(int j = i + 1; j < N; j++) {
				sum += arr.get(i) * arr.get(j);				
			}
		}
		System.out.println(sum);

	}

}


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

int main() {
	int n;
	cin >> n;
	string s;
	cin >> s;
	if (n & 1) puts("No");
	else {
		string a;
		string b;
		for (int i = 0; i < n / 2; i++) a += s[i];
		for (int i = n / 2; i < n; i++) b += s[i];
		if (a == b) puts("Yes");
		else puts("No");
	}
	return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <complex>
#include <ctime>
#include <cstdlib>

using namespace std;

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

typedef long long ll;

/*
equation := equation + factor | factor
factor   := factor   * term   | term
term     := (equation) | Number 

↓

equation := factor (+ factor)*
factor   := term (* term)*
term     := (equation) | Number 
 */
int equation();
int term();
int factor();
int id;
string s;

int main()
{
	int n;
	cin >> n;
	
	while(n--)
	{
		cin >> s;
		id = 0;
		cout << equation() << endl;
	}
}

int equation()
{
	int left = term();
	while(s[id] == '+' || s[id] == '-')
	{
		if(s[id] == '+')
		{
			id++;
			int right = term();
			left += right;
		}
		if(s[id] == '-')
		{
			id++;
			int right = term();
			left -= right;
		}
	}
	return left;
}
int term()
{
	int left = factor();
	while(s[id] == '*' || s[id] == '/')
	{
		if(s[id] == '*')
		{
			id++;
			int right = factor();
			left *= right;
		}
		if(s[id] == '/')
		{
			id++;
			int right = factor();
			left /= right;
		}
	}
	return left;
}
int factor()
{
	char c = s[id];
	if(c == '(')
	{
		id++;
		int res = equation();
		id++;
		return res;
	}
	else
	{
		int res = 0;
		while(isdigit(s[id]))
		{
			res = res*10 + (s[id++]-'0');
		}
		return res;
	}
}

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

int main() {
  long long int a, b;
  cin >> a >> b;
  if((a+b)%2 == 0)
    cout << (a+b)/2 << endl;
  else
    cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
mod = 10**9 + 7
s = sum(A) % mod
ans = 0
for i in range(N):
    s -= A[i]
    if 0 > s:
        s += mod
    ans += A[i] * s
    ans %= mod
print(ans)

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

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

    ll ans = 0;
    for (ll i = 2; i * i < n; i++) {
        int cnt = 0, j = 1;
        while (n % i == 0) n /= i, cnt++;
        while (cnt >= j) cnt -= j, ans++, j++;
    }

    if (n != 1) ans++;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define srt(x) sort((x).begin(), (x).end());
#define rsrt(x) sort((x).rbegin(), (x).rend());
#define deb(x) cout<<#x<<" = "<<(x)<<" (L"<<LINE<<")"<<endl;
#define vdeb(x) {cout<<#x<<" = { "; rep(i, x.size()) cout<<x[i]<<' '; cout <<'}'<<" (L"<<LINE<<")"<<endl;}
using namespace std;
using ll = long long;
using vi = vector<int>;
using vivi = vector<vi>;
using vll = vector<long long>;
using vllvll = vector<vll>;
using vs = vector<string>;

int main()
{
    int R;
    cin >> R;
    cout << 2 * M_PI * R << endl;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)    FOR (i,0,n)
#define ALL(f,x,...) ([&](decltype((x)) ALL) {                          \
            return (f)(begin(ALL), end(ALL), ## __VA_ARGS__); })(x)

using namespace std;

const int MAX_K = 5;

set<string> ss;

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

    REP (i, (int)s.length()) REP (j, MAX_K)
    {
        string tmp = s.substr(i, j + 1);
        ss.insert(tmp);
    }

    auto itr = ss.begin();
    cout << *next(itr, K - 1) << endl;

    return 0;
}


Measured memory_bytes: 1664
#include<bits/stdc++.h>
#define eps 1e-9
#define MOD 1000000007
#define INV_10 299473306
#define INF 1000000000
using namespace std;
int main()
{
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	long long a, b, n;
	cin >> a >> b >> n;
	long long m=a%b, d=a/b, m1=min(n, b-1);
	long long ans=(a*m1)/b+a*(m1/b);
	//cout << m1 << ' ';
	cout << ans << '\n';
}

Measured memory_bytes: 3608
N,M = map(int,input().split())
bridges = [list(map(int,input().split())) for _ in range(M)]
bridges.sort(key=lambda x: x[1])
cut = -1
ans = 0
for b in bridges:
    if b[0] <= cut <= b[1]:
        continue
    else:
        cut = b[1]-1 # なるべく後続にも影響する範囲を切る
        ans += 1
print(ans)

Measured memory_bytes: 64600
#include <iostream>
#define ll long long
#define ld long double
#define CS ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;

int main()
{
    CS
    int w,a,b;cin>>w>>a>>b;
    if((b>=a&&b<=a+w)||(b+w>=a&&b<=a))cout<<0<<endl;
    else {
        if(b+w<a)cout<<a-(b+w)<<endl;
        else if(b>a+w)cout<<b-(a+w)<<endl;
    }
    return 0;
}


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

using namespace std;

int main() {
    uint8_t suit;
    uint16_t n, num;
    vector<bool> cards(52, false);

    cin >> n;

    for (uint16_t i = 0; i < n; i++) {
        cin >> suit >> num;

        switch (suit) {
            case 'S':
                cards[0 * 13 + num - 1] = true;
                break;
            case 'H':
                cards[1 * 13 + num - 1] = true;
                break;
            case 'C':
                cards[2 * 13 + num - 1] = true;
                break;
            case 'D':
                cards[3 * 13 + num - 1] = true;
                break;
        }
    }

    for (uint16_t i = 0; i < 52; i++) {
        if (cards[i] == false) {
            switch (i / 13) {
                case 0:
                    cout << "S";
                    break;
                case 1:
                    cout << "H";
                    break;
                case 2:
                    cout << "C";
                    break;
                case 3:
                    cout << "D";
                    break;
            }

            cout << " " << i % 13 + 1 << endl;
        }

    }

    return 0;
}

Measured memory_bytes: 3060
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, usize1) => {
        read_value!($next, usize) - 1
    };

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

fn main() {
    input! {
        a: u32,
        b: u32,
        c: u32,
        x: u32
    }
    let mut cnt = 0;
    for i in 0..a+1 {
        for j in 0..b+1 {
            for k in 0..c+1 {
                let total: u32 = 500*i + 100*j + 50*k;
                if total == x {
                    cnt = cnt + 1;
                }
            }
        }
    }
    println!("{}", cnt);
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr long double EPS = 1e-15;
const long double PI = acos(-1);
constexpr int inf = 1e9;
constexpr ll INF = 2e18;
constexpr ll MOD = 1e9+7;
constexpr ll MOD1 = 998244353;
typedef pair<ll,ll> P;
//#define all(v) (v).begin(), (v).end()
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
//#define mp make_pair

int n;
string s;
int q;
int k;
void solve();
void input() {
    cin >> n >> s >> q;
    REP(i,q) {
        cin >> k;
        solve();
    }
    // solve();
}

void solve() {
    ll dp[3] = {};
    ll ans = 0;
    REP(i,n) {
        if (s[i] == 'D') {
            dp[0]++;
        } else if (s[i] == 'M') {
            dp[1]++;
            dp[2] += dp[0];
        } else if (s[i] == 'C') {
            ans += dp[2];
        }
        if (i >= k - 1) {
            if (s[i - k + 1] == 'D') {
                dp[0]--;
                dp[2] -= dp[1];
            } else if (s[i - k + 1] == 'M') {
                dp[1]--;
            }
        }
    }
    cout << ans << endl;
}

int main(int argc, char *argv[]){
    input();
    // solve();
    return 0;
}


Measured memory_bytes: 1412
// C - Next Prime
// https://atcoder.jp/contests/abc149/tasks/abc149_c
#include <bits/stdc++.h>
#define lli long long int
#define uli unsigned long long int
#define rep(i, m, n) for (lli i = m; i < (n); i++)
#define repe(i, m, n) for (lli i = m; i <= (n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((lli)(x).size())
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007      //10^9+7
#define SORT(n) sort(n.begin(), n.end())
#define SORTR(n) sort(n.begin(), n.end(), greater<int>())
#define REV(n) reverse(n.begin(), n.end())
#define Vec(K, L, N, S) vector<L> K(N, S)
#define rt sqrt
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vlli = vector<lli>;
using vs = vector<string>;
using ll = long long;
// vector入力
template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
  for (T &x : vec)
    is >> x;
  return is;
}
// vector出力
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec)
{
  // os << '{';
  for (int i = 0; i < vec.size(); i++)
  {
    os << vec[i] << (i + 1 == vec.size() ? "" : "");
  }
  // os << '}';
  return os;
}
bool is_prime(long long N)
{
  if (N == 1)
    return false;
  for (long long i = 2; i * i <= N; ++i)
  {
    if (N % i == 0)
      return false;
  }
  return true;
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli a, b, c, h, k, n, w, ans = 0, count = 0;
  string s, t;
  cin >> n;
  rep(i, n, 100010)
  {
    if (is_prime(i))
    {
      cout << i << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int intEqual(int i, int j, int k){
    if (i == j){
        return  k; 
    } else if (j == k)
    {
        return i;
    } else {
        return j;
    }
}
int main(){
    int A, B, C;
    cin >> A >> B >> C;
    cout << intEqual(A, B, C) << endl;
    
}

Measured memory_bytes: 256
#include<iostream>
#include<string.h>
#include<math.h>
using namespace std;
typedef long long ll;
int main(){
	ll n,i,a[200000],sum=0;
	cin>>n;
	for(i=0;i<n;i++){
		cin>>a[i];
		if(a[i]<a[i-1]&&i-1>=0){
			sum+=a[i-1]-a[i];
			a[i]=a[i-1];
		}
	}
	cout<<sum;
}

	

Measured memory_bytes: 4728
# coding: utf-8

S = input()

year, month, day = map(int, S.split("/"))

h = "Heisei"
t = "TBD"

if year < 2019:
    output = h
elif year == 2019:
    if month < 4:
        output = h
    elif month == 4:
        output = h
    else:
        output = t
else:
    output = t

print(output)

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

int main(){
    int n, m, l;
    cin >> n >> m >> l;
    std::vector<int> a = {n, m, l};
    if (a[0] > a[1]) swap(a[0],a[1]);
    if (a[1] > a[2]) swap(a[1],a[2]);
    if (a[0] > a[1]) swap(a[0],a[1]);
    cout << a[0] << " " << a[1] << " " << a[2] << endl;
    return 0;
}


Measured memory_bytes: 3088
n,m = list(map(int,input().split()))
swi = []

for _ in range(m):
    k, *sss = list(map(int,input().split()))
    t = 0
    for s in sss:
        t += 1 << (s-1)
    swi.append(t)
ppp = list(map(int,input().split()))
ans = 0

for bit in range(1<<n):
    for s,p in zip(swi,ppp):
        t = bit & s
        c = bin(t).count("1") % 2
        if c != p:
            break
    else:
        ans += 1
print(ans)


Measured memory_bytes: 3064
a,b,k=gets.chomp.split.map(&:to_i)
k.times do |i|
    if i % 2 == 0
        if a%2 == 1
            a -= 1
        end
        b += a/2
        a /= 2        
    else
        if b%2 == 1
            b -= 1
        end
        a += b/2
        b /= 2        
    end
end

printf("%d %d\n",a,b)

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

int main(){
	int n;
	while(cin >> n,n){
		for(int i = 0;i < n;i++){
			int x1,y1,z1,w1,x2,y2,z2,w2,x3,y3,z3,w3;
			cin >> x1 >> y1 >> z1 >> w1 >> x2 >> y2 >> z2 >> w2;
			x3 = x1 * x2 - y1 * y2 - z1 * z2 - w1 * w2;
			y3 = x1 * y2 + y1 * x2 + z1 * w2 - w1 * z2;
			z3 = x1 * z2 - y1 * w2 + z1 * x2 + w1 * y2;
			w3 = x1 * w2 + y1 * z2 - z1 * y2 + w1 * x2;
			cout << x3 << " " << y3 << " " << z3 << " " << w3 << endl;
		}
	}
	return 0;
}

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

ll power(ll x,int y){
  if(y==0){
    return 1;
  }else if(y==1){
    return x%MOD;
  }else if(y%2==0){
    return power(x,y/2)*power(x,y/2)%MOD;
  }else{
    return power(x,y-1)*x%MOD;
  }
}

ll no(ll x){
  if(x<0){
    x = MOD+(x%MOD);
  }
  x = x%MOD;
  return x;
}

int main(){
  ll N,K;
  cin >> N >> K;
  vector<ll> C(N+1,0);
  for(ll n=(K-1);n<=N;n++){
    if(n==(K-1)){
      C[n]=1;
    }else{
      C[n] = C[n-1]*n%MOD*power(n-(K-1),MOD-2)%MOD;
    }
  }
  //for(int i=0;i<=N;i++){
  //  cout << C[i] << " ";
  //}
  ll sum=0;
  vector<ll> A(N,0);
  for(int i=0;i<N;i++){
    cin >> A[i];
  }
  sort(A.begin(),A.end());
  for(ll i=0;i<N;i++){
    sum += no((C[i]-C[N-1-i])*A[i]);
    sum = sum%MOD;
  }
  cout << sum << endl;
}

Measured memory_bytes: 1920
from collections import deque

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

li=[[] for i in range(n+1)]
ans=[0]*(n+1)

for i in range(n-1):
  a,b=map(int,input().split())
  li[a].append(b)
  li[b].append(a)

for i in range(q):
  p,x=map(int,input().split())
  ans[p]+=x

Q=deque([1])
sumi=set([1])

while Q:
#  print(Q)
  now=Q.pop()
  for i in li[now]:
    if i in sumi:
      continue
    else:
      sumi.add(i)
      Q.append(i)
      ans[i]+=ans[now]
print(*ans[1:])


Measured memory_bytes: 64128
#include <algorithm>
#include <bitset>
#include <cfloat>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define ll long long
#define eps LDBL_EPSILON
#define mod 1000000007
#define int long long
#define double long double
#define INF LLONG_MAX/10
#define P pair<int,int>
#define prique priority_queue
using namespace std;
int n, q;
queue<pair<string, int>> que;
string name;
int tim;
signed main() {
	cin >> n >> q;
	rep(i, n) {
		cin >> name >> tim;
		que.push(make_pair(name, tim));
	}
	int passed = 0;
	while (!que.empty()) {
		auto p = que.front();
		que.pop();
		if (p.second > q) {
			passed += q;
			p.second -= q;
			que.push(p);
		}
		else {
			passed += p.second;
			cout << p.first << " " << passed << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 6312
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = (n)-1; i >=0; --i)
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

using namespace std;
using ll = long long;
using ld = long double;
using pi = pair<ll, ll>;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
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;}
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
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];
  }
} c(200005);



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

  vector<int> v(n);
  rep(i, n){
    cin >> v[i];
  }

  sort(v.begin(), v.end());
  reverse(v.begin(), v.end());

  ll a=0;
  ll b=0;
  rep(i, n){
    if(i%2==0) a+= v[i];
    else b+= v[i];
  }
  
  cout << a-b  << endl;
  return 0;
}


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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))


struct SegmentTree {
private:
    ll n;
    vector<ll> node;
 
public:
    SegmentTree(vector<ll> v) {
        int sz = v.size();
        //cout << sz << endl;
        n = 1; while(n < sz) n *= 2;
        //cout << n << endl;
        node.resize(2*n-1, 0);
        for(ll i=0; i<sz; i++) node[i+n-1] = v[i];
        for(ll i=n-2; i>=0; i--){
            //cout << i << endl;
            node[i] = node[2*i+1] + node[2*i+2];
        }
        //cout << "b" << endl;
    }
 
    void update(ll x, ll val) {
        x += (n - 1);
        node[x] = val;
        while(x > 0) {
            x = (x - 1) / 2;
            node[x] = node[2*x+1] + node[2*x+2];
        }
    }
 
    ll getsum(int a, int b, int k=0, int l=0, int r=-1) {
        if(r < 0) r = n;
        if(r <= a || b <= l) return 0;
        if(a <= l && r <= b) return node[k];
 
        ll vl = getsum(a, b, 2*k+1, l, (l+r)/2);
        ll vr = getsum(a, b, 2*k+2, (l+r)/2, r);
        return vl + vr;
    }
};

int main() {
    //cout.precision(10);
    string s;
    map<char, vector<int> > vec;
    cin >> s;
    for(int i = 0; i < s.size(); i++){
        vec[s[i]].push_back(i);
    }
    char odd = '#';
    for(char buf = 'a'; buf <= 'z'; buf++){
        //cout << vec[buf].size() << endl;
        if((vec[buf].size() % 2) != 0){
            if((s.size() % 2) == 0){
                cout << -1 << endl;
                return 0;
            }
            if(odd != '#'){
                cout << -1 << endl;
                return 0;
            }
            odd = buf;
        }
    }
    map<char, int> now;
    int complete[200500];
    int posi = 0;
    for(int i = 0; i < s.size(); i++){
        char buf = s[i];
        if(vec[buf].size() == (now[buf] * 2 + 1)){
            now[buf]++;
            complete[i] = (s.size() / 2);
            continue;
        }
        if(vec[buf].size() > (now[buf] * 2)){
            now[buf]++;
            complete[i] = posi;
            posi++;
            continue;
        }
        int mirror = vec[buf].size() - 1 - now[buf];
        mirror = vec[buf][mirror];
        now[buf]++;
        complete[i] = s.size() - 1 - complete[mirror];
    }
    vector<ll> in(s.size());
    SegmentTree seg(in);
    ll ans = 0;
    for(ll i = 0; i < s.size(); i++){
        //cout << seg.getsum(0, complete[i]) << endl;
        ans += (i - seg.getsum(0, complete[i]));
        seg.update(complete[i], 1);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 9468
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
 int wari(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }
 int keta(int a){//桁数
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
 int souwa(int a){
  return a*(a+1)/2;
 }
 int lcm(int a,int b){//最小公倍数
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){//最大公約数
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }
signed main(){
  int a,b,c;
  cin>>a>>b>>c;
  if(a+b>=c)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
}
  

Measured memory_bytes: 256
//#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1LL<<60LL)
typedef long long ll;

using namespace std;


int main() {
	ll a, p; cin >> a >> p;
	cout << (p + a * 3) / 2 << endl;
}

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

#pragma warning(disable:4996)


int main(void) {
	int A, B, C;
	scanf("%d %d %d", &A, &B, &C);

	if (A > B) {
		if ((B <= C) && (A >= C)) {
			printf("Yes");
		}
		else {
			printf("No");
		}

	}
	else {
		if ((B >= C) && (C >= A)) {
			printf("Yes");
		}
		else {
			printf("No");
		}
	}

	return 0;
}

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

int main() {
    int N; cin >> N;
    
    ll res = 0;
    for (int i = 1; i <= N; ++i) {
        if (i % 3 == 0 || i % 5 == 0) {
        } else {
            res += i;
        }
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3672
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
gosa = 1.0 / 10**9
mod = 10**9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


def main():
    n = I()
    a = LI()
    d = collections.defaultdict(int)
    for c in a:
        d[c%4] += 1

    d[1] += d[3]
    if d[2] == 1:
        d[1] += 1
    if (d[1] == 0) or (d[1] - (1 if d[2] < 2 else 0) <= d[0] and d[0] > 0):
        return 'Yes'

    return 'No'



print(main())



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

unsigned long long int i, j, k,counter,a,b;
unsigned long long int t, y;
unsigned long long int ef[110][110];
int main() {
	counter = 0;
	a = 0;
	b = 0;
	cin >> t >> y;
	for (i = 0;i < t;i++) {
		for (j = 0;j < y;j++) {
			cin >> ef[i][j];
			cout << ef[i][j] << ' ';
			a += ef[i][j];
		}
		ef[i][y] = a;
		cout << ef[i][y] << endl;
		a = 0;
	}
	///////////////////
	for (j = 0;j <= y;j++) {
		for (i = 0;i < t;i++) {
			k += ef[i][j];
		}
		ef[t][j] = k;
		k = 0;
	}
	////////////////
	for (i = 0;i < y;i++) {
		cout << ef[t][i] << ' ';
	}
	cout << ef[t][y] << endl;
	return 0;
}

Measured memory_bytes: 1240
alps = 'abcdefghijklmnopqrstuvwxyz'

n = int(input())
if n == 1:
    print('a')
    exit()

ansl = []
curr_n = n
for i in range(15, -1, -1):
    if n <= pow(26,i):
        continue
    val = curr_n//pow(26,i)
    ansl.append(val)
    curr_n -= val*pow(26,i)


for j in range(100):
    for i in range(len(ansl)-1):
        if ansl[i+1] == 0:
            ansl[i+1] = 26
            ansl[i] -= 1

ans = ''
for a in ansl:
    if a == 0: continue
    ans += alps[a-1]

print(ans)

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

int main() {
  string s;
  cin >> s;
  int n = s.size();
  bool ans = true;
  if (s[0] != 'A') ans = false;
  bool b1 = false;
  bool b2 = false;
  for (char c = 'a'; c <= 'z'; c++) {
    if (s[1] == c) b1 = true;
    if (s[n - 1] == c) b2 = true;
  }
  if (b1 == false || b2 == false) ans = false;
  int numofC = 0;
  for (int i = 2; i <= n - 2; i++) {
    if (s[i] == 'C') numofC++;
    else {
      bool b3 = false;
      for (char c = 'a'; c <= 'z'; c++) {
        if (s[i] == c) b3 = true;
      }
      if (b3 == false) ans = false;
    }
  }
  if (numofC != 1) ans = false;
  if (ans) cout << "AC" << endl;
  else cout << "WA" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <tuple>
#include <queue>
#include <set>
#include <math.h>
#include <array>
#include <list>
#include <set>
const int MOD=1000000007;
const int INF=1000000000;
using namespace std;
typedef long long ll;
typedef tuple<ll,int,int> tup;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vp;

int main(int argc,char const* argv[])
{
  int a;
  cin >> a;
  if(a<=999)
    {
      cout << "ABC" << endl;
    }
  else
    {
      cout << "ABD" << endl;
    }
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Numerics;


namespace AtCoderWorkspace
{
    class Program
    {
        static void Main(string[] args)
        {
            var cin = new Scanner();
            var A = cin.nextInt();
            var B = cin.nextInt();
            var C = cin.nextInt();

            var hairu = A - B;
            var ans = C - hairu;
            
            Console.WriteLine(ans<0? 0:ans);
        }
    }





    class Scanner
    {
        string[] s;
        int i;

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

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            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] = nextInt() + add;
            }
            return Array;
        }

        public long nextLong()
        {
            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] = nextLong() + add;
            }
            return Array;
        }

        public double nextDouble()
        {
            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] = nextDouble() + add;
            }
            return Array;
        }
    }
}


Measured memory_bytes: 13140
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
//java8
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();

		Map<Integer, Integer> zyousi = new HashMap<>();
		for(int i=0; i<N; i++) {
			zyousi.put(i+1, 0);

			if(i > 0) {
				int n = sc.nextInt();
				int num = zyousi.get(n);
				zyousi.put(n, num+1);
			}
		}


		for(int i=1; i<=N; i++) {
			System.out.println(zyousi.get(i));
		}
	}

}


Measured memory_bytes: 74732
//set many funcs template
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#define inf 1072114514
#define llinf 4154118101919364364
#define mod 1000000007
#define pi 3.1415926535897932384

int max(int a,int b){if(a>b){return a;}return b;}
int min(int a,int b){if(a<b){return a;}return b;}
int zt(int a,int b){return max(a,b)-min(a,b);}
int round(int a,int b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
int ceil(int a,int b){if(a%b==0){return a/b;}return (a/b)+1;}
int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}
int nCr(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
int fact(int a){int i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
int pow(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
long long llmax(long long a,long long b){if(a>b){return a;}return b;}
long long llmin(long long a,long long b){if(a<b){return a;}return b;}
long long llzt(long long a,long long b){return llmax(a,b)-llmin(a,b);}
long long llround(long long a,long long b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
long long llceil(long long a,long long b){if(a%b==0){return a/b;}return (a/b)+1;}
long long llgcd(long long a,long long b){long long c;while(b!=0){c=a%b;a=b;b=c;}return a;}
long long lllcm(long long a,long long b){long long c=llgcd(a,b);a/=c;return a*b;}
long long llnCr(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
long long llfact(long long a){long long i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
long long llpow(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
double dbmax(double a,double b){if(a>b){return a;}return b;}
double dbmin(double a,double b){if(a<b){return a;}return b;}
double dbzt(double a,double b){return dbmax(a,b)-dbmin(a,b);}
int sortfncsj(const void *a,const void *b){if(*(int *)a>*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int sortfnckj(const void *a,const void *b){if(*(int *)a<*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int llsortfncsj(const void *a,const void *b){if(*(long long *)a>*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int llsortfnckj(const void *a,const void *b){if(*(long long *)a<*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int dbsortfncsj(const void *a,const void *b){if(*(double *)a>*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}
int dbsortfnckj(const void *a,const void *b){if(*(double *)a<*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}

int main(void){
    int n,a,b;
    scanf("%d%d%d",&n,&a,&b);
    printf("%d\n",min(n*a,b));
    return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main(void)
{
	long long i,n,a[200000],m,sum;
	scanf("%lld",&n);
	for(i=0;i<n;i++)	scanf("%lld",&a[i]);
	m=a[0];	sum=0;
	for(i=1;i<n;i++){
		if(a[i]>=m)	m=a[i];
		else	sum+=m-a[i];
	}
	printf("%lld\n",sum);
	return 0;
}


Measured memory_bytes: 3224
#include <iostream>
#include <vector>
#include <cstring>
#include <map>
#include <bitset>
#include <assert.h>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <set>
#include <queue>
#include <unordered_map>
#include <random>
#include <chrono>
#include <stack>
#include <deque>
// cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
using namespace std;
const int N = 1e6, inf = 1e9;
typedef long long ll;
#define deb(x) cout << #x << " = " << x << endl;
#define debg cout << "yes" << endl;
 
#define fast                     \
    ios::sync_with_stdio(false); \
    cin.tie(NULL);               \
    cout.tie(NULL)
#define Test  \
    int t;    \
    cin >> t; \
    while (t--)
#define F first
#define S second
#define fo(i, n) for (int i = 0; i < n; i++)
#define fo1(i, b, n) for (int i = b; i < n; i++)
#define fon(i, n) for (int i = n - 1; i >= 0; i--)
#define Ln length()
#define pb push_back
ll finditm(vector<ll> v, ll itm, ll n)
{
    ll sum = 0;
    fo(i, n)
    {
        sum += itm / v[i];
    }
    return sum;
}
int main()
{
    fast;
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
// online submission
#endif
string s1,t;
cin>>s1>>t;
ll mx=0,l=s1.Ln,h=t.Ln;

for(int i=0;i<=l-h;i++)
{
	int c=0;
	for(int j=i,k=0;k<h;j++,k++)
	{
		if(s1[j]==t[k]){c++;}
	}
	if(mx<c){mx=c;}
}

cout<<h-mx<<endl;
}

Measured memory_bytes: 3652
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		string[] input = Console.ReadLine().Split(' ');
		long n = long.Parse(input[0]);
		long x = long.Parse(input[1]);
    long m = long.Parse(input[2]);

    int[] usedNums = new int[m];
    for(int i = 0; i < m; i++) usedNums[i] = -1;
    long[] sums = new long[m+1];
		long answer = 0;
    bool answered = false;
    long lastNum = x;

    for(int i = 0; i < (int)(m+1); i++)
    {
      //Console.WriteLine(i);
      if(usedNums[lastNum] != -1)
      {
        if(usedNums[lastNum] > 0)
        {
          answer += sums[usedNums[lastNum]-1];
          answer += (n-usedNums[lastNum])/(i-usedNums[lastNum])*(sums[i-1]-sums[usedNums[lastNum]-1]);

          if((n-usedNums[lastNum])%(i-usedNums[lastNum])!=0)
          {
            answer += sums[usedNums[lastNum]-1+((n-usedNums[lastNum])%(i-usedNums[lastNum]))]-sums[usedNums[lastNum]-1];
          }
        }else
        {
          answer += (n-usedNums[lastNum])/(i-usedNums[lastNum])*sums[i-1];

          if((n-usedNums[lastNum])%(i-usedNums[lastNum])!=0)
          {
            answer += sums[((n-usedNums[lastNum])%(i-usedNums[lastNum])) -1];
          }
        }
        
        answered = true;
        break;
      }
    
      usedNums[lastNum] = i;
      if(i == 0) sums[0] = x;
      else sums[i] = sums[i-1] +lastNum;

      lastNum = (lastNum*lastNum)%m;
      //Console.WriteLine(lastNum+"a");

      if(i >= n-1) break;
    }

		if(answered) Console.WriteLine(answer);
    else
    {
      Console.WriteLine(sums[n-1]);
    }
	}
}

Measured memory_bytes: 28096
from collections import defaultdict
it = lambda: list(map(int, input().strip().split()))
INF = float('inf')

def solve():

    N = int(input())
    A = it()
    Q = int(input())

    S = 0
    E = defaultdict(int)
    for i, a in enumerate(A):
        E[a] += 1
        S += a

    for _ in range(Q):
        B, C = it()
        if E[B] > 0:
            S += (C - B) * E[B]
            E[C] += E[B]
            E[B] = 0
        print(S)
    

if __name__ == '__main__':
    solve()


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

using namespace std;

typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define debug(a) cout << #a << ": " << a << endl;

int main() {
  int N; cin >> N;
  if (N == 1) {
    cout << "Hello World" << endl;
  } else {
    int A, B; cin >> A >> B;
    cout << A + B << endl;
  }
  return 0;
}


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

int main(){
    ll n,m;
    cin >> n >> m;
    ll ans=m;
    for(ll i=0;i*i<=m;++i){
        if(i!=0 and m%i==0){
            if((m/i)>=n){
                ans=min(ans,m/i);
            }
            if(i>=n){
                ans=min(ans,i);
            }
        }
    }

    cout << m/ans << endl;
    

    return 0;
}

Measured memory_bytes: 3644
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <utility>
#include <iomanip>

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

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

signed main(){
    int n, m;
    cin >> n >> m;

    vector<bool> a(n+1, false);
    vector<int> b(n+1, 1);
    a[1] = true;
    rep(i, m){
        int x, y;
        cin >> x >> y;

        if(a[x]){
            a[y] = true;
            b[x]--;
            b[y]++;
        }else{
            b[x]--;
            b[y]++;
        }
        if(b[x] == 0){
            a[x] = false;
        }
    }

    int ans = 0;
    rep(i, n+1){
        if(a[i]){
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
attrs = Array.new
while line = $stdin.gets
  attrs << line.chomp.split
end

N = attrs[0][0].to_i
M = attrs[0][1].to_i
H = attrs[1].map &:to_i
res = Array.new(N, true)
M.times do |m|
  a = attrs[m+2][0].to_i
  b = attrs[m+2][1].to_i
  if (H[a-1] == H[b-1]) then
    res[a-1] = false
    res[b-1] = false
  elsif (H[a-1] < H[b-1]) then
    res[a-1] = false
  else
    res[b-1] = false
  end
end
puts (res.select {|r| r==true}).count

Measured memory_bytes: 36032