akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1LL << 60;


const int MAX_N = 100010;

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string s; cin >> s;
	string t; cin >> t;
	reverse(ALL(s)); reverse(ALL(t));
	bool ok = false;
	rep(i, s.size() - t.size() + 1) {
		bool now = true;
		rep(j, t.size()) {
			if (s[i + j] != '?'&&s[i + j] != t[j]) {
				now = false;
			}
			else {
				
			}
		}
		if (now) {
			ok = true;
			rep(j, t.size()) {
				s[i + j] = t[j];
			}
			goto ex;
		}
	}
ex:;
	if (!ok) {
		cout << "UNRESTORABLE" << endl;
		return 0;
	}
	rep(i, s.size()) {
		if (s[i] == '?') {
			s[i] = 'a';
		}
	}
	reverse(ALL(s));
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <time.h>
#include <stdlib.h>
using namespace std;

int main(){
	double w,h,x,y,a,b,c;
	scanf("%lf %lf %lf %lf",&w,&h,&x,&y);
	a=w*h;
	printf("%lf ",a/2);
	if(w/2 == x && h/2 == y) printf("1\n");
	else printf("0\n");
	return 0;
}

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

int main(){
	int n;
	scanf("%d",&n);
	string str;
	cin>>str;
	string s="";
	for(int i=0;i<str.length();i++){
		if(s=="") s+=str[i];
		else{
			if(s[s.length()-1]!=str[i]){
				s+=str[i];
			}
		}
	}
	cout<<s.size()<<endl;
}


Measured memory_bytes: 640
//Author : Sukarna Paul

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>
#include<ext/pb_ds/detail/standard_policies.hpp>
#define pi acos(-1)
#define pb push_back
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define MAX 300005
#define INF 0x3f3f3f3f
template <class T> inline T bigmod(T p,T e,T M){ll ret = 1LL;for(; e > 0LL; e >>= 1LL){if(e & 1LL) ret = (ret * p) % M;p = (p * p) % M;}return (T)ret;}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}   // M is prime}

using namespace std;
using namespace __gnu_pbds;

typedef trie<string,null_type,trie_string_access_traits<>,pat_trie_tag,trie_prefix_search_node_update>pref_trie;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef tree<pair<int, int>,null_type,less<pair<int, int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;




int main(){
    IOS
    //freopen("output.txt","w",stdout);
    int a,b,c,d;
    cin>>a>>b>>c>>d;

    for(int i=0;;i++){
        if(i%2==0){
            c-=b;
        }
        else{
            a-=d;
        }
        if(a<=0){
            cout<<"No\n";
            break;
        }
        if(c<=0){
            cout<<"Yes\n";
            break;
        }

    }
}


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

int main() {
	long long a, b, c;
	cin >> a >> b >> c;
	if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0) {
		cout << 0 << endl;
		return 0;
	}
	else {
		long long dif[3];
		dif[0] = a * b;
		dif[1] = b * c;
		dif[2] = c * a;
		sort(dif, dif + 3);
		cout << dif[0] << endl;
		return 0;
	}
}

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

using db = double;
using ll = long long;
using vi = vector <int>;
#define op operator
#define pb push_back

int main() {
	ios :: sync_with_stdio(0);

	int n; cin >> n;
	while(n --) {
		string s; cin >> s;
		int p[8]; iota(p, p + 8, 0);
		int mi = stoi(s), ma = stoi(s);
		do {
			string t = "";
			for(int i = 0; i < 8; i ++)
				t += s[p[i]];
			mi = min(mi, stoi(t));
			ma = max(ma, stoi(t));
		} while(next_permutation(p, p + 8));
		cout << ma - mi << '\n';
	}

	return 0;
}

Measured memory_bytes: 3152
/**
*    created: 03.07.2020 02:26:19
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using namespace std;
#define int long long
#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++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) __builtin_popcountll(bit)
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> bool chmin(T &a, const T &b) {if (b < a) {a = b; return 1;} return 0;}
const long double pi = acos(-1.0);
const int INF = 1LL << 60;
const int MOD = 1000000007;
// const int MOD = 998244353;

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);

    int n, k;
    cin >> n >> k;
    map<int,int> mp;
    rep(i,n) {
        int a;
        cin >> a;
        mp[a]++;
    }
    if (mp.size() <= k) {
        cout << 0 << endl;
        return 0;
    }
    vector<int> v;
    for (auto p : mp) {
        v.push_back(p.second);
    }
    sort(all(v));
    int ans = 0;
    rep(i,mp.size()-k) {
        ans += v[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 17664
import java.util.*;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		int x = sc.nextInt(); 
		if(k * 500 >= x) {
		    System.out.println("Yes");
		}else {
		    System.out.println("No");
		}
	}
}


Measured memory_bytes: 20180
//TO CHANGE THE WORLD
#include <bits/stdc++.h>

using namespace std;

#define L first
#define R seoncd
#define mp make_pair
#define pb push_back
typedef long long ll;

const int maxn=1e5+10;
bool mark[maxn];
int cnt[maxn], n, m;
int main()
{
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    cin>>n>>m;
    mark[0]++;
    for(int i=0; i<n; i++) cnt[i]=1;
    while(m--)
    {
	int x, y;cin>>x>>y;x--;y--;
	if(mark[x]) mark[y]++;
	cnt[x]--;cnt[y]++;
	if(!cnt[x]) mark[x]=0;
    }
    int ans=0;
    for(int i=0; i<n; i++) ans+=mark[i];
    cout<<ans<<endl;
}

Measured memory_bytes: 768
import sys
sys.setrecursionlimit(10**6)

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

edges = []
routes  = [[] for i in range(n)]
rev_routes = [[] for i in range(n)]
from_start = set()
to_goal = set()

def dfs(node, routes, seen):
    if node in seen:
        return
    seen.add(node)
    candidates = routes[node]
    for to in candidates:
        dfs(to, routes, seen)


for _ in range(m):
    node1, node2, value = map(int, input().split())
    node1, node2, value = node1-1, node2-1, value - p
    edges.append([node1, node2, value])
    routes[node1].append(node2)
    rev_routes[node2].append(node1)

dfs(0, routes, from_start)
dfs(n-1, rev_routes, to_goal)

from_start_to_goal = from_start & to_goal

graph = [-float('INF')] * n
graph[0] = 0

for i in range(n):
    is_updated = False
    for node, to, value in edges:
        if node not in from_start_to_goal or to not in from_start_to_goal:
            continue
        current_point = graph[node]
        next_point = graph[node] + value
        if graph[to] < next_point:
            graph[to] = next_point
            is_updated = True
        else:
            continue
    if not is_updated:
        score = max(0, graph[n-1])
        break
else:
    score = -1
      
print(score)


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


int main(){
    ll n;cin>>n;
    multiset<ll> s;
    rep(i,0,n){
        ll a;
        cin>>a;
        auto ite=s.lower_bound(a);
        if(ite!=s.begin()){ite--;s.erase(ite);}
        s.insert(a);
    }
    cout<<s.size()<<endl;

}
    









Measured memory_bytes: 4992
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <iomanip>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
typedef long long ll;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};

int main(){
    int n;
    int c[510],s[510],f[510];
    cin >> n;
    rep(i,n-1){
        cin >> c[i] >> s[i] >> f[i];
    }
    for(int i=0;i<n-1;i++){
        int t=0;
        for(int j=i;j<n-1;j++){
            if(t<s[j])t=s[j];
            else if(t%f[j]==0){}
            else{
                t = t-(t%f[j])+f[j];
            }
            t+=c[j];
        }
        cout << t << endl;
    }
    cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

int main() {
  int X, Y, A, B, C;
  cin >> X >> Y >> A >> B >> C;
  vector<int> red(A), green(B), rg(C);
  rep(i, A) { cin >> red[i]; }
  rep(i, B) { cin >> green[i]; }
  rep(i, C) { cin >> rg[i]; }

  sort(red.begin(), red.end());
  sort(green.begin(), green.end());

  sort(rg.begin(), rg.end());

  int j = A - X, k = B - Y;
  rrep(i, C) {
    const int item = rg[i];
    if (j < A && item > red[j] && (k >= B || red[j] < green[k])) {
      red[j] = item;
      j++;
    } else if (k < B && item > green[k]) {
      green[k] = item;
      k++;
    }
  }

  int64_t result = 0;
  rep(i, X) { result += red[i + A - X]; }
  rep(i, Y) { result += green[i + B - Y]; }
  cout << result << endl;

  return 0;
}

Measured memory_bytes: 1408
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

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

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);

    string s;
    cin >> s;

    int c, f;
    c = f = -1;

    rep(i, SZ(s)){
        if(s[i] == 'C' && c == -1){
            c = i;
        }
        if(s[i] == 'F'){
            f = i;
        }
    }

    if(c != -1 && c < f){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}


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

int main() {
	ios_base::sync_with_stdio( false );

	int A, B, C, X, Y;
	cin >> A >> B >> C >> X >> Y;

	int n = max( X, Y );
	int result = INT_MAX;
	for( int i = 0; i <= n; ++i ) {
		int p = 2*C*i + A*max( X-i, 0 ) + B*max( Y-i, 0 );

		if( p < result ) {
			result = p;
		}
	}

	cout << result << 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;
typedef long long ll;
typedef pair<int,int> P;

class UnionFind {
public:
    vector <ll> par; // 各元の親を表す配列
    vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)

    // Constructor
    UnionFind(ll n){
    	rep(i,n){
    		par.push_back(i); // 初期では親は自分自身
    		siz.push_back(1);
    	}
    }

    // Member Function
    // Find
    ll root(ll x) { // 根の検索
    	if(par[x] == x) return x;
    	return par[x] = root(par[x]);
    }

    // Union(Unite, Merge)
    bool merge(ll x, ll y) {
        ll rx = root(x);
        ll ry = root(y);
        if (rx == ry) return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[rx] < siz[ry]) swap(rx, ry);
        siz[rx] += siz[ry];
        par[ry] = rx;
        return true;
    }

    bool issame(ll x, ll y) { // 連結判定
        return root(x) == root(y);
    }

    ll size(ll x) { // 素集合のサイズ
        return siz[root(x)];
    }
	
};


int main(){
    
    int n,m;
    cin >> n >> m;
	vector<P> bridge(m);
	UnionFind uf(n);
	rep(i,m){
		int a,b;
		cin >> a >> b;
		bridge[i] = make_pair(--a,--b);
	}
	reverse(bridge.begin(), bridge.end());
	
	vector<ll> csum(n);
	rep(i,n-1) csum[i+1] = csum[i] + i+1;
	
	vector<ll> res(m);
	res[0] = csum[n-1];
	
	rep(i,m-1){
		int n1 = bridge[i].first;
		int n2 = bridge[i].second;
		if(uf.issame(n1,n2)){
			res[i+1] = res[i];
		}
		else{
			int rs1 = uf.size(n1);
			int rs2 = uf.size(n2);
			res[i+1] = res[i] - rs1*rs2;
		}
		uf.merge(n1,n2);
	}
	reverse(res.begin(), res.end());
	rep(i,m) cout << res[i] << endl;
    return 0;
    
}


Measured memory_bytes: 5484
use std::cmp::{max, Reverse};
use std::collections::VecDeque;

fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());
    let n: usize = sc.read();
    let mut a = vec![];
    for i in 0..n {
        let v: i64 = sc.read();
        a.push((v, i));
    }

    a.sort_by_key(|a| (Reverse(a.0), a.1));

    let mut dp = vec![vec![0; n + 1]; n + 1];
    for i in 0..n {
        let (a, x) = a[i];
        for left in 0..(i + 1) {
            let right = i - left;

            let m = if left >= x { left - x } else { x - left };
            let gain = a * (m as i64);
            dp[left + 1][right] = max(dp[left + 1][right], dp[left][right] + gain);

            let r = n - 1 - right;
            let m = if r >= x { r - x } else { x - r };
            let gain = a * (m as i64);
            dp[left][right + 1] = max(dp[left][right + 1], dp[left][right] + gain);
        }
    }

    let mut ans = 0;
    for i in 0..=n {
        ans = max(ans, dp[n - i][i]);
    }
    println!("{}", ans);
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> Self {
        Self(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: ToString>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.to_string().as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 33536
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}


int main() {
  int sx,sy,tx,ty;
  cin>>sx>>sy>>tx>>ty;
  string t;
  int dx=abs(sx-tx);
  int dy=abs(sy-ty);

  for(int i=0;i<dx;i++){
      t.push_back('R');
  }
  for(int i=0;i<dy;i++){
      t.push_back('U');
  }

  for(int i=0;i<dx;i++){
      t.push_back('L');
  }
  for(int i=0;i<dy;i++){
      t.push_back('D');
  }
  
  t.push_back('L');
  for(int i=0;i<dy+1;i++){
      t.push_back('U');
  }
  for(int i=0;i<dx+1;i++){
      t.push_back('R');
  }
  t.push_back('D');

  t.push_back('R');
  for(int i=0;i<dy+1;i++){
      t.push_back('D');
  }
  for(int i=0;i<dx+1;i++){
      t.push_back('L');
  }
  t.push_back('U');

  cout<<t<<endl;
  return 0;
}

Measured memory_bytes: 3648
fun abc123a(args: Array<String>) {
    val numList = args.dropLast(1).map { it.toInt() }
    val k = args.takeLast(1).first().toInt()
    if (numList[4] - numList[0] <= k) {
        println("Yay!")
    } else {
        println(":(")
    }
}

fun main(args: Array<String>) {
    abc123a(readLineList())
}

fun readLineList(): Array<String> {
    val lineList = mutableListOf<String>()
    while (true) {
        val line = readLine()
        if (line.isNullOrBlank()) {
            break
        } else {
            lineList.add(line!!)
        }
    }
    return lineList.toTypedArray()
}

Measured memory_bytes: 36412
import numpy as np

A1=np.array(list(map(int,input().split())))
A2=np.array(list(map(int,input().split())))
A3=np.array(list(map(int,input().split())))
A=np.concatenate([A1,A2,A3]).reshape(3,3)

N=int(input())

for i in range(N):
    b=int(input())
    A[np.where(A==b)] = 0

if np.all(A[0,:]==0) or np.all(A[1,:]==0) or np.all(A[2,:]==0) or np.all(A[:,0]==0) or np.all(A[:,1]==0) \
    or np.all(A[:,2]==0) or A[0,0]**2+A[1,1]**2+A[2,2]**2==0 or A[0,2]**2+A[1,1]**2+A[2,0]**2==0:
    print('Yes')
else:
    print('No')

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

typedef long long ll;

const int N = 1000001;
bitset<N+10> bs;
vector<int> primes;

void sieve(ll n)
{
	bs[0] = bs[1] = 1;
	for (ll i = 2; i*i <= n; ++i) if (!bs[i]) {
		for (ll j = i*i; j <= n; j += i) bs[j] = 1;
		primes.push_back(int(i));
	}
}

int main()
{
	sieve(N+1);
	set<int> s;
	int n, a, g = 0, ans = 1;
	scanf("%d", &n);
	while (n--) {
		scanf("%d", &a);
		g = __gcd(g, a);
		for (int p : primes) {
			if (p*p > a) break;
			if (a%p==0) {
				if (s.count(p)) ans = 0;
				else s.insert(p);
				while (a%p==0) a /= p;
			}
		}
		if (a != 1) {
			if (s.count(a)) ans = 0;
			else s.insert(a);
		}
	}
	if (ans) puts("pairwise coprime");
	else if (g == 1) puts("setwise coprime");
	else puts("not coprime");
}

Measured memory_bytes: 7436
import os
import sys
from io import BytesIO, IOBase



def main():
    sys.setrecursionlimit(10**6 + 10)
    n, m = getints()
    g = [0] * n
    for i in range(n):
        g[i] = i
    def find(u):
        if u == g[u]:
            return u
        else:
            g[u] = find(g[u])
            return g[u]
    def merge(u, v):
        g[find(u)] = find(v)
    for _ in range(m):
        a, b = getints()
        merge(a - 1, b - 1)
    cnt = 0
    for i in range(n):
        if i == g[i]:
            cnt += 1
    print(cnt - 1)


# region fastio


BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)


def input(): return sys.stdin.readline().rstrip("\r\n")
def getint(): return int(input())
def getints(): return list(map(int, input().split()))
def getint1(): return list(map(lambda x: int(x) - 1, input().split()))


# endregion


if __name__ == "__main__":
    main()

Measured memory_bytes: 81308
import java.util.*;
import java.lang.*;

public class Main{
    public static void main(String[]args){
	Scanner sc = new Scanner(System.in);
    int N= sc.nextInt();
    long D=(long)Math.pow(sc.nextInt(),2);
    long d[]= new long[N];
    int ans =0;
    for(int i=0; i<N; i++){
        d[i]= (long)Math.pow(sc.nextInt(),2)+ (long)Math.pow(sc.nextInt(),2);
        if(D>=d[i]){
            ans++;
        }
    }
System.out.println(ans);
    }
}


Measured memory_bytes: 61004
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();
      	int N = sc.nextInt();
        int[] A = new int[N]; 
      	for(int i = 0; i < N; i++){
        	A[i] = sc.nextInt();
        }
      	int[] ad = new int[N]; 
      	for(int j = 0; j < N-1; j++){
        	ad[j] = A[j+1] - A[j];
        }
		ad[N-1] = K - A[N-1] + A[0];
      
      	Integer max = ad[0];
      	for(int k = 1; k < N; k++){
          if(max < ad[k]){
            max = ad[k];
          }
        }
      	int ii = (K-max);
		System.out.println(ii);
	}
}

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

int main()
{
    int n,a,b;
    cin>>n>>a>>b;
    map<int,int>mp;
    for(int i=1;i<=n;i++)
    {
        for(int j=i+1;j<=n;j++)
        {
            int k;
            k=min(j-i,abs(i-a)+abs(j-b)+1);
            mp[k]++;
        }
    }
    for(int i=1;i<n;i++)cout<<mp[i]<<endl;
}



Measured memory_bytes: 384
import math
isPrime = [True for i in range(10**5+1)]
for i in range(3, 10**5+1):
    for j in range(2, math.floor(math.sqrt(i))+1):
        if i % j == 0:
            isPrime[i] = False

cntPrime = [0 for i in range(10**5+1)]
for i in range(2,10**5+1):
    if i % 2 == 1 and isPrime[i] and isPrime[(i+1)//2]:
        cntPrime[i] = cntPrime[i-1]+1
    else:
        cntPrime[i] = cntPrime[i-1]

Q = int(input())
for i in range(Q):
    l, r = [int(_) for _ in input().split()]
    print(cntPrime[r]-cntPrime[l-1])


Measured memory_bytes: 52824
s=input()[::-1]

amari=[[(10**i)*x%13 for x in range(10)] for i in range(6)]
dp=[1]+[0]*12
new_dp=[0]*13

mod=10**9+7

for id,char in enumerate(s):
    new_dp=[0]*13
    if char!='?':
        for i in range(13):
            new_i=(i+amari[id%6][int(char)])%13
            new_dp[new_i]+=dp[i]
        dp=new_dp
    else:
        for i in range(13):
            for j in range(10):
                new_i=(i+amari[id%6][j])%13
                new_dp[new_i]+=dp[i]
        dp=[x%mod for x in new_dp]
print(dp[5])
        

Measured memory_bytes: 43372
/*
 ID: bradyawn
 PROG: contest
 LANG: C++11
 */

#include <iostream>
#include <algorithm>
#include <iomanip>
#include <fstream>
#include <vector>
#include <deque>
#include <string>
#include <cmath>
#include <map>
#include <unordered_map>
#include <utility>
#include <set>
#include <unordered_set>
#include <ctime>
#include <queue>
#include <stack>
#include <bitset>
#include <random>
#include <cstring>
#include <complex>
#include <cassert>

using namespace std;

typedef long long ll;
typedef pair<int,int> i2;
typedef pair<ll,ll> ll2;

int n;

ll pre[200001];

ll get(int a, int b)
{
    if (a > b) return 0; //flag
    return pre[b]-pre[a-1];
}

ll diff(ll2 p) { return p.second-p.first;}

ll getMin(ll2 p)
{
    return min(p.first, p.second);
}

ll getMax(ll2 p)
{
    return max(p.first, p.second);
}

ll2 solve(int a, int b) //try to best balance [a,b] > size 1
{
    ll2 ret1, ret2;
 
    //find best k s.t [a, mid] and [mid+1, b] are balanced
    int lo = a;
    int hi = b-1;
    
    //favors the left >= right
    while (hi > lo)
    {
        int mid = (lo+hi)/2;
        if (get(a, mid) < get(mid+1, b)) lo = mid+1; //shift to the right
        else hi = mid; //shift to the left
    }
    
    ret1 = make_pair(get(a, lo), get(lo+1, b));
    if (ret1.first > ret1.second) swap(ret1.first, ret1.second);
    assert(diff(ret1) >= 0);
    
    lo = a;
    hi = b-1;
    
    //favors the right >= left
    while (hi > lo)
    {
        int mid = (lo+hi+1)/2;
        if (get(a, mid) > get(mid+1, b)) hi = mid-1; //shift to the left
        else lo = mid; //shift to the right
    }
    
    ret2 = make_pair(get(a, lo), get(lo+1, b));
    if (ret2.first > ret2.second) swap(ret2.first, ret2.second);
    assert(diff(ret2) >= 0);
    
    if (diff(ret2) < diff(ret1)) return ret2;
    return ret1;
}

int main()
{
    //ifstream inf("");
    //ofstream outf("");
    //cout << setprecision(10);
    ios::sync_with_stdio(0); cin.tie(0);
    
    cin >> n;
    
    for (int i = 1; i <= n; i++) cin >> pre[i];
    for (int i = 1; i <= n; i++) pre[i] += pre[i-1];
    
    
    ll ret = 1e18;
    for (int i = 2; i <= n-2; i++) // [1, i] and [i+1, n]
    {
        ll2 leftAns = solve(1, i);
        ll2 rightAns = solve(i+1, n);
        
        ll mn = min(getMin(leftAns), getMin(rightAns));
        ll mx = max(getMax(leftAns), getMax(rightAns));
        
        ret = min(ret, mx-mn);
        
    }
    
    cout << ret << endl;
    
    return 0;
    
}




Measured memory_bytes: 1792
def inputV(h):
	return [list(map(int,input().split())) for i in range(h)]

def calcC(A,B,i,j):
	cij = 0
	for k in range(m):
		cij += A[i][k]*B[k][j]
	return cij

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

A=inputV(n) #[n][m]

B=inputV(m) #[m][l]

for i in range(n):
	for j in range(l):
		if j > 0 :
			print(" ",end="")
		print(calcC(A,B,i,j),end="")
	print()




Measured memory_bytes: 6564
#スペース区切りで代入する
a,b,c=gets.chomp.split(" ")
#それぞれの末尾1文字と頭文字1文字を切り出す。
al = a[-1,1]
bs = b[0,1]
bl = b[-1,1]
cs = c[0,1]
# p al
#p bs
#p bl
#p cs

if al == bs && bl == cs
  puts "YES"
else
  puts "NO"
  
end

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

int main(void)
{
    int n, b, f, r, v;
    vector<vector<vector <int>>> buildings
        = vector<vector <vector <int>>>(4, vector<vector <int>>(3, vector<int>(10, 0)));

    cin >> n;
    while (cin >> b >> f >> r >> v && n--)
        buildings[b - 1][f - 1][r - 1] += v;

    for (int i = 0; i < buildings.size(); i++) {
        if (i)
            cout << string(20, '#') << endl;
        for (auto y: buildings[i]) {
            for (auto z : y)
                cout << " " << z;
            cout << endl;
        }
    }

    return 0;
}



Measured memory_bytes: 3124
#include <bits/stdc++.h>  // clang-format off
using Int = long long;
#define REP_(i, a_, b_, a, b, ...) for (Int i = (a), lim##i = (b); i < lim##i; i++)
#define REP(i, ...) REP_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
struct SetupIO { SetupIO() { std::cin.tie(nullptr), std::ios::sync_with_stdio(false), std::cout << std::fixed << std::setprecision(13); } } setup_io;
#ifndef dump
#define dump(...)
#endif  // clang-format on

/**
 *    author:  knshnb
 *    created: Sun May 10 21:15:09 JST 2020
 **/

struct Doubling {
    int n;
    int size;                  // MSB + 1
    std::vector<std::vector<int>> next;  // next[k][i]: iから(1<<k)回でどこまで進めるか

    // edge[i]: 1回でiからどこまで進めるか
    Doubling(std::vector<int>& edge) : n(edge.size()), size(62) {
        next.resize(size, std::vector<int>(n, -1));
        for (int i = 0; i < n; i++) next[0][i] = edge[i];
        for (int k = 0; k < size - 1; k++) {
            for (int i = 0; i < n; i++) {
                next[k + 1][i] = next[k][next[k][i]];
            }
        }
        dump(next);
    }
    // i番目のx個先
    int get(int i, Int x) {
        int ret = i;
        for (int bit = 0; bit < size; bit++) {
            if (!(x >> bit & 1)) continue;
            ret = next[bit][ret];
        }
        return ret;
    }
    // iからはじめて何回進めば初めてj以上になるか
    // j以上になりえないときはnを返す
    int lower_bound(int i, int j) {
        int cur = i, acc = 0;
        for (int wid = size - 1; wid >= 0; wid--) {
            if (next[wid][cur] < j) {
                acc += 1LL << wid;
                cur = next[wid][cur];
            }
        }
        return std::min(n, acc + 1);
    }
};

signed main() {
    Int n, K;
    std::cin >> n >> K;
    std::vector<int> a(n);
    REP(i, n) std::cin >> a[i], a[i]--;
    Doubling d(a);
    std::cout << d.get(0, K) + 1 << std::endl;
}


Measured memory_bytes: 53364
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>
#include <stdbool.h>

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

//qsort(str, n, sizeof(int), up_comp);
int up_comp(const void *a, const void *b){return *(int*)a - *(int*)b;}
int down_comp(const void *a, const void *b){return *(int*)b - *(int*)a;}
int int_sort( const void * a , const void * b ) {return strcmp(( char * )a , ( char * )b );}
int count_digit(int a){int i=0;while(a!=0){a=a/10;i++;}return i;}
int euclid( int a, int b ){int temp;if(a<b){temp=a;a=b;b=temp;}if(b<1)return -1;if(a%b==0) return b;return euclid(b,a%b);}

int main(void){
 
    int n;
    int x, y, z;
    int s;
    int cnt=0;
    int ans;
    
    scanf("%d", &n);
    
    for (s=1; s<=n; s++) {
        cnt=0;
        for (x=1; x<=100; x++) {
            for (y=1; y<=100; y++) {
                if (4*s-3*x*x-3*y*y-2*x*y>=0) {
                    if (ceil(-x-y+sqrt(4*s-3*x*x-3*y*y-2*x*y))/2 == floor(-x-y+sqrt(4*s-3*x*x-3*y*y-2*x*y))/2&&(-x-y+sqrt(4*s-3*x*x-3*y*y-2*x*y))/2>=1) {
                        cnt++;
                    }
                }
            }
        }
        printf("%d\n", cnt);
    }
    
    
    return 0;
}



Measured memory_bytes: 2132
N, M = map(int, input().split())
L = []
for i in range(M):
  P, Y = map(int, input().split())
  L.append((P, Y, i))
ans = ['']*(M)
L.sort(key=lambda x:(x[0], x[1]))
before = L[0][0]
num = 0
for i in range(M):
  if L[i][0] == before:
    num += 1
    id = '{:06d}'.format(L[i][0]) + '{:06d}'.format(num)
    ans[L[i][2]] = id
  else:
    num = 1
    id = '{:06d}'.format(L[i][0]) + '{:06d}'.format(num)
    ans[L[i][2]] = id
    before = L[i][0]
for city in ans:
  print(city)


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

int main() {
	int n, t;
	cin >> n >> t;
	vector<int> lag(n-1);
	vector<int> time(n+1);
	for (int i = 0; i < n; ++i)
	{
		cin >> time[i];
	}
	for (int i = 0; i< n - 1; ++i)
	{
		lag[i] = time[i + 1] - time[i];
	}
	int ans = 0;
	for (int i = 0; i < n-1; ++i)
	{
		ans += min(t, lag[i]);
	}
	ans += t;
	cout << ans << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ll long long
#define si short int
using namespace std;
#define MOD 1000000007

int main(){
	int N, W;
	cin >> N >> W;
	int wv[N+1][2];
	ll dp[N+1][W+1];

	for(int i=1;i<=N;i++){
		cin >> wv[i][0] >> wv[i][1];
	}

	for(int i=0;i<=W;i++){
		dp[0][i] = 0;
	}

	for(int i=0;i<=N;i++){
		dp[i][0] = 0;
	}

	for(int i=1;i<=N;i++){
		for(int j=1;j<=W;j++){
			if(wv[i][0] <= j){
				dp[i][j] = max(dp[i-1][j], dp[i-1][j-wv[i][0]] + wv[i][1]);
			}
			else{
				dp[i][j] = dp[i-1][j];
			}
		}
	}

	cout << dp[N][W];
}

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


using namespace std;

#define ll long long


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int N,K;
	cin >> N >> K;
	unordered_map<int,int> cnt;
	int diff=0;
	for(int i=0;i<N;i++) {
		int x;cin >> x;
		if(cnt[x]==0) diff++;
		cnt[x]++;
	}
	
	vector<int> v;
	for(auto p : cnt) {
		v.push_back(p.second);
	}
	sort(v.begin(),v.end());
	int ans=0;
	for(int i : v) {
		if(diff<=K)break;
		diff--;
		ans+=i;
	}
	cout << ans;
	return 0;
}




Measured memory_bytes: 13276
#include <iostream>
#include <iomanip> //setprecision()
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
#include <set>
using ll = long long;
using namespace std;

double Mcos(double k){return cos(k*atan(1.0)*4/180);}

void monmo(){
    
}

int main() {
    int d,t,s;
    cin>>d>>t>>s;
    if(d<=t*s){
        cout<<"Yes";
    }else{
        cout<<"No";
    }
}


Measured memory_bytes: 3676
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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

const ll INF=1e15;

int main()
{
    ll n;
    cin >> n;
    vector<ll> a(n);
    vector<ll> s(n+1);
    s[0]=0;
    rep(i,n){
        cin >> a[i];
        s[i+1]=s[i]+a[i];
    }
    vector<vector<ll>> dp(n+1,vector<ll>(n+1,INF));
    for(ll i=0;i<=n;i++){
        dp[i][i]=0;
    }
    rep(i,n){
        dp[i][i+1]=0;
    }
    for(ll w=2;w<=n;w++){
        for(ll l=0;l+w<=n;l++){
            ll r=l+w;
            for(ll mid=l;mid<=r;mid++){
                dp[l][r]=min(dp[l][r],dp[l][mid]+dp[mid][r]+s[r]-s[l]);
            }
        }
    }
    cout << dp[0][n] << endl;
    return 0;
} 

Measured memory_bytes: 1664
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.next();
        String t = scanner.next();
        int n = s.length();

        Map<Character, Set<Integer>> sMap = new HashMap<>();
        Map<Character, Set<Integer>> tMap = new HashMap<>();

        for (int i = 0; i < n; i++) {
            int finalI = i;

            char sc = s.charAt(i);
            sMap.putIfAbsent(sc, new HashSet<>());
            sMap.compute(sc, (k, v) -> {
                v.add(finalI);
                return v;
            });

            char tc = t.charAt(i);
            tMap.putIfAbsent(tc, new HashSet<>());
            tMap.compute(tc, (k, v) -> {
                v.add(finalI);
                return v;
            });
        }

        Collection<Set<Integer>> sIndexes = sMap.values();
        Collection<Set<Integer>> tIndexes = tMap.values();

        if (sIndexes.size() != tIndexes.size()) {
            System.out.println("No");
            return;
        }

        for (Set<Integer> sIndex : sIndexes) {
            boolean ok = false;
            for (Set<Integer> tIndex : tIndexes) {
                if (sIndex.equals(tIndex)) {
                    ok = true;
                    break;
                }
            }
            if (!ok) {
                System.out.println("No");
                return;
            }
        }

        System.out.println("Yes");
    }
}


Measured memory_bytes: 87816
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long ll;

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

  cout << 100 << " " << 100 << endl;
  
  a--; b--;
  for(int i = 0; i < 50; i++){
    for(int j = 0; j < 100; j++){
      if(i % 2 == 0 && j % 2 == 0 && a > 0){
        cout << ".";  
        a--;
      }else{
        cout << "#";
      }
    }
    cout << endl;
  }

  for(int i = 0; i < 50; i++){
    for(int j = 0; j < 100; j++){
      if(i % 2 == 1 && j % 2 == 0 && b > 0){
        cout << "#";  
        b--;
      }else{
        cout << ".";
      }
    }
    cout << endl;
  }
  return 0;
}


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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};

int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    int mina = 1e9+7;
    int nowi=-1;
    int nexta = 1e9+8;
    int nexti=-1;
    for(int i = 0; i < n; i++)
    {
        cin>>a[i];
        if(a[i]<mina)
        {
            mina=a[i];
            nowi=i;
        }
    }
    bool koushin = true;
    while(koushin){
        koushin=false;
        for(int i = 0; i < n; i++)
        {
            if(i==nowi) continue;
            a[i]%=mina;
            if(a[i]>0 && a[i]<nexta)
            {
                nexta=a[i];
                nexti=i;
                koushin=true;
            }
        }
        if(koushin)
        {
            nowi = nexti;
            mina=nexta;
        }   
    }
    cout<<mina<<endl;

    return 0;
}

Measured memory_bytes: 640
import java.util.Arrays;import java.util.Scanner;class Main{public static void main(String[]a){Scanner s=new Scanner(System.in);int[]b=new int[10];for(int i=0;i<10;i++){b[i]=s.nextInt();}Arrays.sort(b);System.out.println(b[9]);System.out.println(b[8]);System.out.println(b[7]);}}

Measured memory_bytes: 12000
#include <iostream>
#include <string>
#define rep(i,s,N) for(int i=s;i<N;i++)
using namespace std;

int main(void)
{
	int A, B; cin >> A >> B;
	string S; cin >> S;
	bool flag = true;

	if (S[A] != '-')flag = false;
	else {
		rep(i, 0, A + B + 1) {
			if (i == A)continue;
			bool judge = false;
			rep(j, 0, 10) {
				if (S[i] == '0' + j) {
					judge = true;
					break;
				}
			}
			if (!judge) {
				flag = false;
				break;
			}
		}
	}

	cout << (flag ? "Yes" : "No") << endl;

	return 0;
}

Measured memory_bytes: 256
program main
integer*8 :: n, m, x,ans=10000000,cost=0
integer*8,allocatable :: c(:),r(:),a(:,:)

read(*,*)n,m,x
allocate(c(0:n-1),a(0:n-1,m),r(m))
do i = 0,n-1
read(*,*)c(i),(a(i,j),j=1,m)
end do

do i = 0,2**n-1
r(:) = 0
cost = 0
do j = 0,n-1

if (btest(i,j)) then
do k = 1,m
r(k) = r(k) + a(j,k)
end do
cost = cost + c(j)
end if

if(minval(r) >= x) ans = min(cost,ans)
end do
end do

if (ans == 10000000) then
write(*,*)-1
else
write(*,*)ans
end if
end program main

Measured memory_bytes: 2872
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <utility>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cassert>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

//const long double PIL = 3.141592653589793238462643383279502884L;
//const double PI = 3.14159265358979323846;

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vii;
#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()

int main() {
	//~ ios::sync_with_stdio(0);
	//~ cin.tie(0);

	int n;
	scanf("%d", &n);
	vi a(n);
	bool zero = false;
	int neg = 0;
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
		if (a[i] < 0) {
			a[i] = -a[i];
			++neg;
		}
		else if (a[i] == 0)
			zero = true;
	}

	ll ans = 0;
	for (int x : a) ans += x;
	if (neg % 2 == 1 && !zero)
		ans -= 2 * (*min_element(all(a)));
	printf("%lld\n", ans);
}


Measured memory_bytes: 640
x=[0]*2e5
y=x.dup
`sed 1d`.split.map{|v|[x,y][1&$.+=1][v.to_i]-=1}
a,b=x.sort
c,d=y.sort
p$..+a!=x[y.index c]?a+c:[a+d,b+c].min

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

int main() {
  int N;
  cin >> N;
  
  ll A[N+1], B[N];
  for (int i = 0; i < N+1; i++) cin >> A[i];
  for (int i = 0; i < N; i++) cin >> B[i];
  
  ll ans = 0;
  
  for (int i = 0; i < N; i++) {
    if (B[i] > A[i]) {
      ans += A[i];
      if (B[i] - A[i] >= A[i+1]) {
        ans += A[i+1];
        A[i+1] = 0;
      } else {
        ans += B[i] - A[i];
        A[i+1] -= B[i] - A[i];
      } 
    } else {
      ans += B[i];
    }
    
  }
  cout << ans << endl;
  
}

Measured memory_bytes: 1792
#include<iostream>
#include <bits/stdc++.h>
#include <stdlib.h>
#include <stdio.h>
using namespace std;

int main() {
  int a;
  cin >> a;
  int b,c;
  cin >> b >> c;
  int d[a];
  int x,y,z;
  x = 0;
  y = 0;
  z = 0;
  for(int i = 0;i < a;i++){
    cin >> d[i];
    if(d[i] > c){
      x++;
    }else if(d[i] > b){
      y++;
    }else if(d[i] <= b){
      z++;
    }
  }

  int answer;
  answer = x;
  if(answer > y){
    answer = y;
  }
  if(answer > z){
    answer = z;
  }
  cout << answer << endl;
  
}


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

int main() { 
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    int ans = 0;
    map<int,bool> used;
    vector<int> p(m);
    vector<string> s(m);
    for (int i = 0; i < m; ++i) {
        cin >> p[i] >> s[i];
        if (s[i] == "AC") {
            used[p[i]] = true;
        }
    }
    map<int,bool> was_ac;
    for (int i = 0; i < m; ++i) {
        if (used.find(p[i]) != used.end() && was_ac.find(p[i]) == was_ac.end()) {
            if (s[i] == "AC") {
                was_ac[p[i]] = true;
            }
            else {
                ans++;
            }
        }
    }
    cout << (int) used.size() << ' ' << ans << endl;
    return 0;
}



Measured memory_bytes: 15488
#include <iostream>

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

using namespace std;



int main() {
    int m1, m2, d1, d2;
    cin >> m1 >> d1 >> m2 >> d2;
    int ans = d2==1 ? 1 : 0;
    cout << ans << endl;

    return 0;
}


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

using namespace std;

using ll = long long int;

int result[310][310] = {};

int main(void) {

	string s;
	cin >> s;

	for (int i = 0; i < s.size(); i += 2) {
		cout << s[i];
	}
	cout << endl;

	return 0;
}


Measured memory_bytes: 512
S = input()
T = input()
N = len(S)
M = len(T)

dp = [ [0]* (len(T)+1) for _ in range(len(S)+1)]

for i in range(1, len(S)+1):
    for j in range(1,len(T)+1):
        if S[i-1] == T[j-1]:
            dp[i][j] = max(dp[i][j] , dp[i-1][j-1] + 1)
        else:
            dp[i][j] = max(dp[i][j] , dp[i-1][j], dp[i][j-1], dp[i-1][j-1] )
res = []

i = N
j = M
cnt = dp[N][M]

# while i > 0 and j > 0:
#     if dp[i][j] == dp[i-1][j]:
#         i -= 1
#     elif dp[i][j] == dp[i][j-1]:
#         j -= 1
#     else:
#         i -= 1 ; j -= 1
#         res.append(S[i])
while cnt :
    while cnt == dp[i][j]:
        i -= 1
    i += 1
    while cnt == dp[i][j]:
        j -= 1
    j += 1
    res.append(S[i-1])
    cnt -= 1
    i -= 1; j -= 1
print("".join(reversed(res)))
    


Measured memory_bytes: 113628
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define REP(i, n) for(int i=0;i<(n);++i)

int s[510][510];

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N, M, Q, L, R, p, q;
	cin >> N >> M >> Q;
	REP(i, M){
		cin >> L >> R;
		s[L][R]++;
	}
	for(int i = 1;i <= N;i++) for(int j = 1;j <= N;j++)
		s[i][j] += s[i-1][j] + s[i][j-1] - s[i-1][j-1];
	REP(i, Q){
		cin >> p >> q;
		cout << s[q][q]-s[p-1][q]-s[q][p-1]+s[p-1][p-1] << endl;
	}
	
	return 0;
}


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

int main() {
   string S, T;
  cin >> S >> T;
  int sum = 0;
  for (int i = 0; i < S.size(); i++) {
    if (S.at(i) == T.at(i)) {
      sum += 1;
    }
  }
  if (sum == S.size() && S.size() + 1 == T.size()) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1000000000;
const int MOD = (int)1e9 + 7;
template <class T>
inline T in()
{
    T x;
    cin >> x;
    return x;
}

signed main()
{
    int r = in<int>();
    int d = in<int>();
    int x = in<int>();
    for (int i = 0; i < 10; i++)
    {
        x = r * x - d;
        cout << x << "\n";
    }
}

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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 60;
const int mod = 1000000007;
//const int mod = 998244353;
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
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  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()
{
  int n; cin >> n;
  vector<int> ans(n+1, 0);
  for(int x = 1; x <= 100; ++x) {
    for(int y = 1; y <= 100; ++y) {
      for(int z = 1; z <= 100; ++z) {
        if(x*x + y*y + z*z + x*y + y*z + z*x > n) break;
        ++ans[x*x + y*y + z*z + x*y + y*z + z*x];
      }
    }
  }
  for(int i = 1; i <= n; ++i) cout << ans[i] << endl;
}


Measured memory_bytes: 3544
L, R =  map(int, input().split())
MOD = 2019

if L % MOD == 0 or L + (MOD - L % MOD) <= R:
  print(0)
  exit()

ans = MOD

for i in range(L, R):
  for j in range(i+1, R+1):
    ans = min(ans, (i*j) % MOD)

print(ans)


Measured memory_bytes: 40812