akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;

typedef long long LL;
typedef long double ldouble;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

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

    }

    int res = INF;
    for(int i = 0; i < n; ++i) {
        vector<int> vv;
        vector<int> b;
        for(int j = 0; j < n; ++j) {
            if(v[j] < v[i]) {
                if(vv.size() >= k) {
                    sort(all(vv));
                    for(int l = 0; l < int(vv.size()) - k + 1; ++l) {
                        b.pb(vv[l]);

                    }
                }
                vv.clear();
            } else {
                vv.pb(v[j]);

            }
        }
        if(vv.size() >= k) {
            sort(all(vv));
            for(int l = 0; l < int(vv.size()) - k + 1; ++l) {
                b.pb(vv[l]);

            }
        }

        sort(all(b));
        if(b.size() >= q) {
            res = min(res, b[q - 1] - b[0]);

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



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a.at(i);
  }
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  int64_t M = 10000000000;
  for (int i = 1; i < N; i++) {
    if (abs(M) > abs((a.at(0) / 2) - a.at(i))) {
      M = (a.at(0) / 2) - a.at(i);
    }
  }
  cout << a.at(0) << " " << (a.at(0) / 2) - M;
}
        

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vc = vector<char>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rrep(i, n, k) for (ll i = n; i >= k; i--)
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
#ifndef ONLINE_JUDGE
    #define debug(x) cerr << #x << ": " << x << endl;
#else
    #define debug(x)
#endif

int main() {
    cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(20);

    ll M, K;
    cin >> M >> K;

    if(M == 0) {
        if(K == 0) cout << "0 0" << endl;
        else cout << -1 << endl;
        return 0;
    }
    if(M == 1) {
        if(K == 0) cout << "0 0 1 1" << endl;
        else cout << -1 << endl;
        return 0;
    }
    if(M >= 2) {
        if(K <= pow(2, M) - 1) {
            rep(i, pow(2, M)) {
                if(i == K) continue;
                cout << i << " ";
            }
            cout << K << " ";
            rrep(i, pow(2, M)-1, 0) {
                if(i == K) continue;
                cout << i << " ";
            }
            cout << K << endl;
        }
        else cout << -1 << endl;
    }
}


Measured memory_bytes: 4096
#include<bits/stdc++.h>
using namespace std;
#define IO ios_base::sync_with_stdio(false)

int a[300000], b[300000];
int main()
{
        IO;
        long long int i, j, n, m, k, sum=0;
        cin>>n;
        for(i=1; i<=n; i++){
            cin>>a[i]; b[a[i]]++;
            sum+=(b[a[i]]-1);
        }
        for(i=1; i<=n; i++){
            cout<<sum-(b[a[i]]-1)<<endl;
        }

    return 0;
}



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

using ll = long long;
using ull = unsigned long long;
using st = string;
using db = double;
using vll = vector<long long>;
using vdb = vector<db>;
using vvll = vector<vll>;
using vst = vector<st>;
using vchar = vector<char>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
using vvpll = vector<vpll>;
#define rep(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define vrep(i, vec) for(auto& i : vec)
#define vin(vec) for(auto& i : vec) cin >> i
#define all(v) v.begin(), v.end()
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;}
ll mod = 1000000007;

int main(){
  ll n, k;
  cin >> n >> k;
  vll h(n);
  vin(h);
  vll dp(n, mod);
  dp.at(0) = 0;
  rep(i, 0, n)rep(j, i + 1,min(n, i + k + 1)) chmin(dp.at(j), dp.at(i) + abs(h.at(i) - h.at(j)));
  cout << dp.at(n - 1) << endl;
}

Measured memory_bytes: 1792
using System;
namespace ITP1_6_A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a = int.Parse(Console.ReadLine());
            string[] S = Console.ReadLine().Split();
            int i;
            for(i = a - 1; i > 0; i--)
            {
                Console.Write("{0} ", S[i]);
            }
            Console.WriteLine(S[0]);
        }
    }
}


Measured memory_bytes: 15888
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
#include <functional>
#include <random>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<ll, ll> PL;
typedef vector<PL> vpl;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e17;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define RFOR(i, a, b) for(ll i = (a); i > b; i--)
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rrep(i, n) for(ll i = n-1; i > -1; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define epb emplace_back
#define ALL(X) (X).begin(),(X).end()

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    sort(ALL(vec));
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}

inline ll popcnt(ll x){return __builtin_popcountll((unsigned long long)x);};
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
//friend bool operator<(const stc& lhs, const stc& rhs){
//    return std::tie(lhs.l, lhs.r) < std::tie(rhs.l, rhs.r);
//}



int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll N; cin >> N;
    vl A(N); rep(i, N) cin >> A[i];
    
    ll idx = 0, ans = 0, now = 1;
    while(idx < N){
        while(idx < N && A[idx] <= now){
            if(A[idx] == now) now++;
            idx++;
        }
        if(idx == N) break;
        ll tmp = (A[idx]-1 - now)/now;
        ans += tmp;
        A[idx] -= tmp*now;
        if(A[idx]-1 >= now){
            ans++; A[idx] = 1;
        }
        chmax(now, A[idx]+1);
        idx++;
    }
    cout << ans << endstr;
    return 0;
}


Measured memory_bytes: 1024
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

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

fn main() {
    input! {
        n: usize,
        v: [chars; n]
    }

    let vc = v.clone();
    let (ans_b, _) = bubble_sort(v);
    for i in 0..n {
        for c in &ans_b[i] {
            print!("{}", c);
        }
        if i != n - 1 {
            print!(" ");
        }
    }
    println!();
    println!("Stable");
    
    let (ans_s, _) = selection_sort(vc);
    for i in 0..n {
        for c in &ans_s[i] {
            print!("{}", c);
        }
        if i != n - 1 {
            print!(" ");
        }
    }
    println!();
    if ans_b == ans_s {
        println!("Stable");
    } else {
        println!("Not stable");
    }
}

fn bubble_sort(mut v: Vec<Vec<char>>) -> (Vec<Vec<char>>, u32) {
    let mut tmp;
    let mut t:u32 = 0;

    for i in 0..v.len()-1 {
        for j in (i+1..v.len()).rev() {
            if eval_val(&v[j]) < eval_val(&v[j-1]) {
                tmp = v[j].clone();
                v[j] = v[j-1].clone();
                v[j-1] = tmp;
                t += 1;
            }
        }
    }
    (v, t)
}

fn selection_sort(mut v: Vec<Vec<char>>) -> (Vec<Vec<char>>, u32) {
    let mut tmp;
    let mut t:u32 = 0;

    for i in 0..v.len()-1 {
        let mut mini = i;
        for j in i..v.len() {
            if eval_val(&v[j]) < eval_val(&v[mini]) {
                mini = j
            }
        }
        if i != mini {
            tmp = v[mini].clone();
            v[mini] = v[i].clone();
            v[i] = tmp;
            t += 1;
        }
    }
    (v, t)
}

fn eval_val(card: &Vec<char>) -> u32 {
    card[1] as u32 - 48
}



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

int main() {
    int n;
    scanf("%d", &n);
    vector<int> p(n+1);
    rep(i, n) {
        int r, c;
        scanf("%d %d", &r, &c);
        if (i == 0) p[i] = r;
        p[i+1] = c;
    }

    int m[n+1][n+1];
    for (int i = 1; i <= n; i++) {
        m[i][i] = 0;
    }
    for (int l = 2; l <= n; l++) {
        for (int i = 1; i <= n - l + 1; i++) {
            int j = i + l - 1;
            int MIN;
            for (int k = i; k < j; k++) {
                if (k == i) MIN = m[i][k] + m[k+1][j] + p[i-1] * p[k] * p[j];
                else MIN = min(MIN, m[i][k] + m[k+1][j] + p[i-1] * p[k] * p[j]);
            }
            m[i][j] = MIN;
        }
    }
    printf("%d\n", m[1][n]);
}


Measured memory_bytes: 3204
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define INF 1000000000
#define mod 1000000007
using ll=long long;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    int a,b;cin>>a>>b;
    cout<<a*b<<endl;
    return 0;
}


Measured memory_bytes: 3640
import bisect
def resolve():
    n = int(input())
    l = sorted(list(map(int,input().split())))
    ans = 0
    for a in range(n):
        for b in range(a+1,n):
            c = bisect.bisect_left(l,l[a]+l[b])
            if c > b:
                ans += c-b-1
            else:
                pass
    print(ans)
resolve()

Measured memory_bytes: 9304
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;

class Node {
    Node parent;
    Node[] child;

    int number;
    String type;
    int depth;

    Node(int number) {
        this.number = number;
        this.parent = null;
        this.type = "new";
    }

    void setDepth(int dep) {
        this.depth = dep;
        if (!this.type.equals("leaf")) {
            for (Node x : this.child) {
                x.setDepth(dep + 1);
            }
        }
    }

}

class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        int n = Integer.parseInt(br.readLine());

        Node[] tree = new Node[n];

        for (int i = 0; i < n; i++) {
            tree[i] = new Node(i);
        }

        for (int i = 0; i < n; i++) {
            String[] input = br.readLine().split(" ");

            int number = Integer.parseInt(input[0]);
            int k = Integer.parseInt(input[1]);
            if (k == 0) {
                tree[number].type = "leaf";
                continue;
            } else {
                tree[number].child = new Node[k];
                tree[number].type = "internal node"; // rootのみ後で上書き
            }

            for (int j = 0; j < k; j++) {
                tree[number].child[j] = tree[Integer.parseInt(input[2 + j])];
                tree[Integer.parseInt(input[2 + j])].parent = tree[number];
            }

        }

        Node root = tree[0];

        // find root;
        while (root.parent != null) {
            root = root.parent;
        }

        root.type = "root";

        // set depth;
        if(n != 1) root.setDepth(0);
        int rootNum = root.number;

        // display
        String format = "node %d: parent = %d, depth = %d, %s, ";
        for (int i = 0; i < n; i++) {
            if (i != rootNum) {
                System.out.printf(format, i, tree[i].parent.number, tree[i].depth, tree[i].type);
            } else {
                System.out.printf(format, i, -1, tree[i].depth, tree[i].type);
            }

            System.out.print("[");
            if(n != 1){
                if (!tree[i].type.equals("leaf")) {
                    int j;
                    for (j = 0; j < tree[i].child.length - 1; j++) {
                        System.out.printf(tree[i].child[j].number + ", ");
                    }
                    System.out.print(tree[i].child[j].number);
                }
            }
            System.out.println("]");
        }

    }
}


Measured memory_bytes: 225324
#include<stdio.h>
int main()
{
    int a,b,c=15;
    scanf("%d%d",&a,&b);
    if(a+b==c){
        printf("+\n");
    }
    else if(a*b==c){
        printf("*\n");
    }
    else
    printf("x\n");
}

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

int main(){
  int x,y;
  cin >> x >> y;
  set<int> a{1,3,5,7,8,10,12};
  set<int> b{4,6,9,11};
  set<int> c{2};
  auto iter1 = a.find(x);
  auto iter2 = a.find(y);
  auto iter3 = b.find(x);
  auto iter4 = b.find(y);
  
  if(iter1 != a.end()){
    if(iter2 != a.end()){
      cout << "Yes" << endl;
    }
    else{
      cout << "No" << endl;
    }
  }
  else if(iter3 != b.end()){
    if(iter4 != b.end()){
      cout << "Yes" << endl;
    }
    else{
      cout << "No" << endl;
    }
  }
  else{
    cout << "No" << endl;
  }
}


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

ll mod = 1000000007,mod2 = 998244353;



int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    ll ans = 0;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    for (int bit = 0; bit < 60; ++bit) {
        ll cnt0 = 0,cnt1 = 0;
        ll tmp = (1LL<<bit)%mod;
        for (int i = 0; i < n; ++i) {
            if(a[i] & 1LL<<bit) cnt1++;
            else cnt0++;
        }
        tmp = (tmp*cnt0)%mod;
        tmp = (tmp*cnt1)%mod;
        ans = (ans+tmp)%mod;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2560
#include<iostream>
#include<map>
#include<algorithm>
using namespace std;

using ll = long long;
const ll INF = 1e18;

const int MAXN = 2.1e5;
int N, Q, X[MAXN];

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> N >> Q;
	int A, B; cin >> A >> B;

	for (int q = 0; q < Q; q++) { cin >> X[q]; }

	ll cval = 0;
	map<int, ll> mp;
	mp[A] = 0;
	int prevVal = B;

	auto queryPt = [&](int x) -> ll {
		ll ans = INF;
		auto it = mp.lower_bound(x);
		if (it != mp.end()) {
			ans = min(ans, (it->first - x) + it->second);
		}
		if (it != mp.begin()) {
			--it;
			ans = min(ans, (x - it->first) + it->second);
		}
		return ans;
	};

	auto insertPt = [&](int x, ll v) {
		if (v >= queryPt(x)) return;
		auto it = mp.lower_bound(x);
		while (it != mp.end()) {
			if ((it->first - x) + v <= it->second) {
				it = mp.erase(it);
			}
			else {
				break;
			}
		}
		while (it != mp.begin()) {
			--it;
			if ((x - it->first) + v <= it->second) {
				it = mp.erase(it);
			}
			else {
				break;
			}
		}
		mp[x] = v;
	};

	for (int q = 0; q < Q; q++) {
		int curVal = X[q];
		insertPt(prevVal, queryPt(curVal) - abs(prevVal - curVal));
		cval += abs(prevVal - curVal);

		prevVal = X[q];
	}
	ll ans = INF;
	for (auto it : mp) ans = min(ans, it.second);
	cout << ans + cval << '\n';

	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define all(a) (a).begin(),(a).end()
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=10000000000000000;

int main(){
    int n;
    cin >> n;
    vector<int> a(n),b(n),c(n);
    vector<vector<int>> d(3,vector<int>(n+1,0));
    rep(i,n) cin >> a.at(i) >> b.at(i) >> c.at(i);
    rep(i,n){
        d.at(0).at(i+1)=max(d.at(1).at(i),d.at(2).at(i))+a.at(i);
        d.at(1).at(i+1)=max(d.at(0).at(i),d.at(2).at(i))+b.at(i);
        d.at(2).at(i+1)=max(d.at(1).at(i),d.at(0).at(i))+c.at(i);
    }
    int ans=max(d.at(0).at(n),d.at(1).at(n));
    ans=max(ans,d.at(2).at(n));
    cout << ans << endl;
}


Measured memory_bytes: 2944
import java.util.Scanner;
import java.util.Stack;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Stack<Integer> s = new Stack<Integer>();
		while(sc.hasNext()) {
			int a = sc.nextInt();
			if(a==0) System.out.println(s.pop());
			else s.push(a);
		}
	}
}



Measured memory_bytes: 26168
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(a,b) for(int a=0;a<(b);++a)
#define REP1(i,n) for(int i=1;i<=(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define INF (1<<29)
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}

const int MOD =(int)1e9+7;
const int MAX =510000;
ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
ll COM(int n,int k){
    if(n<k) return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
ll gcd(ll a,ll b){
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
    ll g;g=gcd(a,b);
    return a*b/g;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

bool compare_by_a(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
    }else{
        return a.second < b.second;
    }
}
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;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin>>s;
    REP(i,s.size()){
        cout<<"x";
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
N = gets.to_i
A = gets.split.map(&:to_i)
B = gets.split.map(&:to_i)
C = gets.split.map(&:to_i)

p (0...N).inject(0) {|sum, i|
    sum = A[i]+1 == A[i+1] ? sum + B[A[i]-1] + C[A[i]-1] : sum + B[A[i]-1]
}

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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

// grid
//--------------------------------------------
VL dx = {0, 1, 0, -1};
VL dy = {1, 0, -1, 0};
VL dx2 = {-1, 0, 1, -1, 1, -1, 0, 1};
VL dy2 = {-1, -1, -1, 0, 0, 1, 1, 1};
 
//debug
//--------------------------------------------
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//roop
//--------------------------------------------
#define rep(i,s,n) for(LL i = (s); i < (n); i++)
#define rep0(i,n) rep(i,0,n)
#define rep1(i,n) rep(i,1,n+1)
#define COUNTOF(array) (sizeof(array) / sizeof(array[0]))
#define BR "\n"
#define SP " "
#define SHOW(x) for(int i = 0; i < COUNTOF(x);i++) { cout << x[i] << SP; } cout << BR;

int main(){
    int N;
    int total = 0;
    cin >> N;
    int a[2][N];
    int cost[N] = {0};
    rep0(i, 2){
        rep0(j, N){
            cin >> a[i][j];
        }
    }
    rep0(k, N){
        rep0(m, k+1){
            cost[k] += a[0][m];
        }
        rep(n, k, N){
            cost[k] += a[1][n];
        }
    }
    sort(cost, cost + N);  
    cout << cost[N-1] << BR;
}

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;

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

int main(){
    int a,b;
    cin>>a>>b;
    cout<< a/gcd(a,b)*b << endl;
    return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
p = [list(map(int, input().split())) for _ in range(n)]
q = [list(map(int, input().split())) for _ in range(m)]
ans = [0]*n
for i in range(n):
    comp = abs(p[i][0]-q[0][0]) + abs(p[i][1]-q[0][1])
    for j in range(m):
        temp = abs(p[i][0]-q[j][0]) + abs(p[i][1]-q[j][1])
        if temp < comp:
            ans[i] = j
            comp = temp
for i in range(n):
    print(ans[i]+1)




Measured memory_bytes: 3064
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>

using namespace std;

#define REP(i,n) for(int i=0;i<int(n);i++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
typedef long long ll;
typedef pair<int,int> P;

vector<P> g[100010];
int vis[100010];
int n,v,vx,mx=0;

void dfs(int x,int d){
	if(d>mx){
		mx=d; vx=x;
	}
	vis[x]=1;
	for(int i=0;i<g[x].size();i++){
		int p=g[x][i].first,q=g[x][i].second;
		if(vis[p]==0) dfs(p,d+q);
	}
}

int main(void){

	cin >> n;
	for(int i=1;i<n;i++){
		int s,t,w;
		cin >> s >> t >> w;
		g[s].push_back(P(t,w));
		g[t].push_back(P(s,w));
	}

	dfs(0,0);
	mx=0;
	for(int i=0;i<n;i++) vis[i]=0;
	v=vx;
	dfs(v,0);

	cout << mx << endl;

	return 0;
}

Measured memory_bytes: 10172
from collections import deque

n,m,k = map(int,input().split())
next = [[] for i in range(n)]
num_next= [0]*n
block = [[] for i in range(n)]
for i in range(m):
  x,y = map(int,input().split())
  next[y-1].append(x-1)
  next[x-1].append(y-1)
  num_next[x-1] += 1
  num_next[y-1] += 1
  
for j in range(k):
  x,y = map(int,input().split())
  block[y-1].append(x-1)
  block[x-1].append(y-1)
friend = []
num = {}  
mark = ['t']*n
for i in range(n):
  if mark[i] == 't':
    
    mark[i] = i
    s = 1
    que = deque([i])
    while que:
      p = que.popleft()
      for x in next[p]:
        if mark[x] == 't':
          mark[x] = mark[p]
          s += 1
          que.append(x)
    num[i] = s      

ans = []
for i in range(n):
  l = num[mark[i]] -1-num_next[i]
  for y in block[i]:
    if mark[y] == mark[i]:
      l -= 1
  ans.append(str(l))    
      
print(' '.join(ans))    
      

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

int main(){
    long long n, x, y, t, ans = 0; 
    cin >> n >> x;
    x = min(x, n-x);
    y = n-x;
    while (x != 0)
    {
        ans += (y / x) * x * 3;
        t = x;
        x = y % x;
        y = t;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
using P = pair<int,int>;
using ll = long long;
using namespace std;
int main(void){
    string s;
    cin >> s;
    if(s[1] == 'B'){cout << "ARC";}
    else {cout << "ABC";}
    return 0;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
#define mp make_pair
#define F first
#define S second
#define pb push_back
#define pll pair<ll,ll>
#define pii pair<int,int>
#define all(v) v.begin(),v.end()
const ll INF = ll(1e9);
const int N = 1e5 + 5;
const ll mod = 1000000007 ;
using namespace std;

ll dp[3005][3005];

int main() {


	ios_base::sync_with_stdio(false);
	cin.tie(NULL), cout.tie(NULL);


	ll tc = 1;

	// cin >> tc;
	while (tc--) {

		ll n, i, j, a, b, c, k, W;

		string s, t;
		cin >> s >> t;
		ll lens = s.length();
		ll lent = t.length();

		string ans;

		for (i = 0; i <= lens; i++) {
			for (j = 0; j <= lent; j++) {
				if (i == 0 or  j == 0) dp[i][j] = 0;

				else if (s[i - 1] == t[j - 1]) {
					dp[i][j] = dp[i - 1][j - 1] + 1;

				}
				else {
					dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
				}
			}
		}

		i = lens, j = lent;

		while (i > 0 and j > 0) {
			if (s[i - 1] == t[j - 1]) {

				ans = s[i - 1] + ans;
				i--;
				j--;
			}

			else if (dp[i - 1][j] > dp[i][j - 1]) {
				i--;
			}

			else j--;
		}

		cout << ans << endl;
	}

}

Measured memory_bytes: 70784
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a,b;
  cin>>a>>b;
  int c = a;
  int ct=1;
  while(c<b)
  {
    c+=a-1;
    ct++;
  }
  if(b==1)
    ct = 0;
  cout<<ct;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
//#pragma region atcoder
/*#include <atcoder/dsu>
using namespace atcoder;*/
//using mint = modint998244353;
//These are for segment tree
/*int op(int a, int b){return max(a, b);}
int e(){return -1;}
bool f(int v){ return v < target;}
*/
#pragma endregion
#pragma region macros
using ll = long long;
using vi = vector<int>;
using vs = vector<string>;
using vl = vector<ll>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = n - 1; i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#pragma endregion
#pragma region debug for var, v, vv
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){cout << endl;int cnt = 0;for(const auto& v : vv){cout << cnt << "th : "; view(v); cnt++;} cout << endl;}
#pragma endregion

const ll mod = 1000000007;
const int inf = 1001001001;
const ll INF = 1001001001001001001;

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; }
ll modpow(ll a, ll p){ll ret = 1; while(p){if(p & 1){ret = ret * a % mod;} a = a * a % mod; p >>= 1;} return ret;}

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

/*-----------------------------------------------------------------------------------------------------*/
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, t; cin >> n >> t;
	vector<pair<int, int>> p(n);
	rep(i,n) cin >> p[i].first >> p[i].second;
	sort(all(p));
	vvi dp(n + 1, vi(t));
	rep(i,n){
		rep(j,t){
			chmax(dp[i + 1][j], dp[i][j]);
			if(j - p[i].first >= 0) chmax(dp[i + 1][j], dp[i][j - p[i].first] + p[i].second);
		}
	}
	int ans = 0;
	rep(i,n){
		ans = max(ans, dp[i][t - 1] + p[i].second);
	}
	cout << ans << endl;
}

Measured memory_bytes: 38540
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var S string
	fmt.Scanln(&S)

	former, _ := strconv.Atoi(S[0:2])
	latter, _ := strconv.Atoi(S[2:])

	if 1 <= former && former <= 12 && 1 <= latter && latter <= 12 {
		fmt.Println("AMBIGUOUS")
	} else if 1 <= former && former <= 12 {
		fmt.Println("MMYY")
	} else if 1 <= latter && latter <= 12 {
		fmt.Println("YYMM")
	} else {
		fmt.Println("NA")
	}
}


Measured memory_bytes: 512
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	int n = s.size();
	if(s[n-1] == '1' || s[0] == '0'){
		cout << -1 << endl;
		return 0;
	}
	rep(i,n-1){
		if(s[i] != s[n-2-i]){
			cout << -1 << endl;
			return 0;
		}
	}
	s[n-1] = '1';
	queue<int> que;
	rep(i,n){
		if(s[i] == '1') que.push(i+1);
	}
	rep(i,n-1){
		if(i+1 == que.front()) que.pop();
		cout << i+1 << " " << que.front() << endl;
	}
	return 0;
}


Measured memory_bytes: 3848
// AOJ 0301: Baton Relay Game
// 2017.10.31
// 2018.1.19

#include <stdio.h>

typedef struct { int pre, nxt, f; } T;
T tbl[200002];
int a[200002];

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

void calc(int m)
{
	int i, j, cur, pre, nxt;
	
	cur = 0;
	for (i = 0; i < m; i++) {
		j = a[i];
		if (j & 1) while (j--) cur = tbl[cur].pre;
		else       while (j--) cur = tbl[cur].nxt;
		tbl[cur].f = 0;
		pre = tbl[cur].pre, nxt = tbl[cur].nxt;
		tbl[pre].nxt = nxt, tbl[nxt].pre = pre;
		cur = nxt;
	}
}

int main()
{
	int n, m, q, i;

	n = in(), m = in(), q = in();

	for (i = 0; i < n; i++) tbl[i].nxt = i+1, tbl[i].pre = i-1, tbl[i].f = 1;
	tbl[0].pre = n-1, tbl[n-1].nxt = 0;

	for (i = 0; i < m; i++) a[i] = in();

	calc(m);

	while (q--) putchar('0' + tbl[in()].f), putchar('\n');
	return 0;
}



Measured memory_bytes: 4716
#include <stdio.h>

int main(void) {
  int n, i, a, b, c, x=0, y=0, z=0, tx, ty, tz, one, two;
  scanf("%d", &n);
  scanf("%d %d %d", &x, &y, &z);
  for(i=1;i<n;i++){
    scanf("%d %d %d", &a, &b, &c);
    one=y+a;
    two=z+a;
    if(one>two){
      tx=one;
    }else{
      tx=two;
    }
    one=x+b;
    two=z+b;
    if(one>two){
      ty=one;
    }else{
      ty=two;
    }
    one=x+c;
    two=y+c;
    if(one>two){
      tz=one;
    }else{
      tz=two;
    }
    x=tx;
    y=ty;
    z=tz;
  }
  if(x>y&&x>z){
    n=x;
  }else if(y>z){
    n=y;
  }else{
    n=z;
  }
  printf("%d", n);
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
using namespace std;
int main(){
  string str;
  int N;
  cin >>N;
  long long m,a,r,c,h;
  long long ans;
  m=a=r=c=h=0;
  int i;
  for(i=0;i<N;i++){
    cin>>str;
    if (str[0]=='M'){
      m+=1;
    }
    if (str[0]=='A'){
      a+=1;
    }
    if (str[0]=='R'){
      r+=1;
    }
    if (str[0]=='C'){
      c+=1;
    }
    if (str[0]=='H'){
      h+=1;
    }
  }
  ans =m*a*r+m*a*c+m*a*h+m*r*c+m*r*h+m*c*h+a*r*c+a*r*h+a*c*h+r*c*h;
  cout <<ans;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
//typedef vector<vector<ll> > Graph;
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 = 1e18;


//テンプレート
//辺の構築
template< typename T = int >
struct Edge {
  int from, to;
  T cost;
  int idx;

  Edge() = default;

  Edge(int from, int to, T cost = 1, int idx = -1) : from(from), to(to), cost(cost), idx(idx) {}

  operator int() const { return to; }
};

template< typename T = int >
struct Graph {
  vector< vector< Edge< T > > > g;
  int es;

  Graph() = default;

  explicit Graph(int n) : g(n), es(0) {}

  size_t size() const {
    return g.size();
  }

  void add_directed_edge(int from, int to, T cost = 1) {
    g[from].emplace_back(from, to, cost, es++);
  }

  void add_edge(int from, int to, T cost = 1) {
    g[from].emplace_back(from, to, cost, es);
    g[to].emplace_back(to, from, cost, es++);
  }

  void read(int M, int padding = -1, bool weighted = false, bool directed = false) {
    for(int i = 0; i < M; i++) {
      int a, b;
      cin >> a >> b;
      a += padding;
      b += padding;
      T c = T(1);
      if(weighted) cin >> c;
      if(directed) add_directed_edge(a, b, c);
      else add_edge(a, b, c);
    }
  }
};

template< typename T = int >
using Edges = vector< Edge< T > >;

int main(){
    int n,m;
    cin >> n >> m;
    Graph<int>g(n);
    g.read(m,-1,false,true);
    int s,t;
    cin >> s >> t;
    s--;t--;
    int dist[100010][3];
    rep(i,100010)rep(j,3)dist[i][j]=-1;
    queue<P>q;
    q.push(make_pair(s,0));
    dist[s][0]=0;
    while(!q.empty()){
        P p = q.front();q.pop();
        int v = p.first;
        int id = p.second;
        int nid = (id+1)%3;
        for(int x:g.g[v]){
            if(dist[x][nid]!=-1)continue;
            dist[x][nid]=dist[v][id]+1;
            q.push(make_pair(x,nid));
        }
    }
    if(dist[t][0]==-1){
        cout << -1 << endl;
    }
    else{
        cout << dist[t][0]/3 << endl;
    }
    return 0;
}

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

int main(){
    int N;
    cin >> N;
    int p[N] = {};
    for (int i = 0;i < N;i++) {
        cin >> p[i];
    }
    int flag = 0;
    for (int i = 0;i < N;i++){
        if (p[i] != i + 1){
            flag += 1;
        }
    }
    if (flag == 0 || flag == 2) cout << "YES" << endl;
    else cout << "NO" << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
const int MAXN = 2e5 + 10;
using namespace std;
int n;
int ans=0,sum=0;
int A[MAXN], B[MAXN], ta[MAXN], tb[MAXN], sa, sb, tot = 0, Do[MAXN], fa[MAXN];
int find(int x) {
    return fa[x] == x ? fa[x] : fa[x] = find(fa[x]);
}
int unionn(int x, int y) {
    fa[x] = y;
}
int main() {
    scanf("%d",&n);
    for(int i=1;i<=n;i++)scanf("%d",&A[i]),sa^=A[i];A[n+1]=sa;
    for(int i=1;i<=n;i++)scanf("%d",&B[i]),sb^=B[i];B[n+1]=sb;
    memcpy(ta,A,sizeof(A));memcpy(tb,B,sizeof(B));
    n++;sort(ta+1,ta+n+1);sort(tb+1,tb+n+1);
    for(int i=1;i<n;i++)if(ta[i]!=tb[i])return puts("-1"), 0;
    for(int i=1;i<=n;i++)
        if(A[i]!=B[i]||(i==n)){
            Do[++sum]=A[i]; 
			Do[++sum]=B[i];
            if(i<n)ans++;
        }
    if(ans==0)return puts("0"), 0;
    sort(Do+1,Do+sum+1);
    sum=unique(Do+1,Do+sum+1)-Do-1;
    for(int i=1;i<=sum;i++)fa[i]=i;
    for(int i=1;i<=n;i++)
        if(A[i]!=B[i]) {
            A[i]=lower_bound(Do+1,Do+sum+1,A[i])-Do;
            B[i]=lower_bound(Do+1,Do+sum+1,B[i])-Do;
            unionn(find(A[i]),find(B[i]));
        }
    for(int i=1;i<=sum;i++)ans+=(fa[i]==i);
    printf("%d", ans - 1);
 
    return 0;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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; }
using namespace std;

int main(){
    Init();
    ll n, m; cin >> n >> m;
    vector<pair<ll, ll>> ab(m);
    rep(i, m) cin >> ab[i].second >> ab[i].first;
    sort(all(ab));
    
    vi del;
    rep(i, m){
        ll a = ab[i].second;
        ll b = ab[i].first;
        if(lower_bound(all(del), a) == del.end()) del.emplace_back(b-1);
    }
    cout << del.size() << endl;
}

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

#define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define I insert
#define endl '\n'
#define all(x) x.begin(), x.end()

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

using vvll = vector< vector<ll> >;
using vll = vector<ll> ;

const ll maxs = 2e5+5;
const ll lmaxs = 20;
ll mod = 1e9+7;
ll oo = 1e15;


void pre(){



}

void solve(){
    
    ll N; 
    cin>>N;
    string ans;
    while(N>=1){
        ll rem = N%26;
        if(rem==0) rem = 26;
        ans.pb('a' + rem - 1);
        if(N==26) break;
        N -= rem;
        N/=26;
    }
    reverse(ans.begin(), ans.end());
    cout<<ans;
}

int main(){
    // #ifndef ONLINE_JUDGE
    // freopen("input00.txt","r",stdin);
    // #endif
    IOS;
    pre();
    ll T = 1;
    //cin>>T;
    while(T--){
        solve();   
    }
    return 0;
}

Measured memory_bytes: 3648
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

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

Measured memory_bytes: 4304
from collections import Counter

n=int(input())
a=list(map(int, input().split()))
a.sort()

m=a[-1]+1
dp=[True]*m
c=Counter(a)
ans=0
for x in a:
    if dp[x] and c[x]==1:
        ans+=1
    
    for j in range(2*x, m, x):
        dp[j]=False

print(ans)

Measured memory_bytes: 43268
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=300050;
//ここまでテンプレ
int main(){
	int N;
	cin>>N;
	string S;
	cin>>S;
	int E[SIZE]={},W[SIZE]={};
	for(int i=0;i<N;i++){
		if(S[i]=='E')
			E[i+1]++;
		else
			W[i+1]++;
	}
	for(int i=1;i<=N;i++){
		E[i]+=E[i-1];
		W[i]+=W[i-1];
	}
	int mini=INF;
	for(int i=0;i<N;i++){
		int temp=W[i]+(E[N]-E[i+1]);
		mini=min(temp,mini);
	}
	cout<<mini<<endl;
	return 0;
}

Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
// define
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (((a)%mod) * ((b)%mod)) % mod
#define rollcall cout << "I'm Sucu." << endl;
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define fi first
#define se second
// debug
template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p){
  os << "(" << p.first << "," << p.second << ")";return os;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  for (auto it = v.begin();it != v.end();++it){
    if(it != v.begin())os << " ";os << *it;
  }return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &mp){
  for(auto x: mp)os << "(" << x.first << "," << x.second << ")" << endl;
  return os;
}
template<typename T, int SIZE>
int array_length(const T (&)[SIZE]){return SIZE;}
template<typename T, int N>
void PRINTF(const T (&a)[N], int s = N, int t = -1, bool f = true){
	if(t == -1){rep(i,s){if(i)cout << " ";cout << a[i];}}
	else repi(i,s,t){if(i!=s)cout << " ";cout << a[i];}
	if(f)cout << "\n";
}
template<typename T, int N1, int N2>
void PRINTF(const T (&a)[N1][N2], int h = N1, int w = N2){
	rep(i,h){rep(j,w){cout << a[i][j] << " \n"[j==w-1];}}
}
string substr(const string &str, int S1, int S2 = -1){
  if(S2 == -1)return str.substr(S1);
  return str.substr(S1, S2-S1);
}
// typedef
typedef complex<double> Point;
typedef pair<int, int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;
// int sum = accumulate(a, a+n, 0LL);
// int mx = max_element(a, a+n);
// int mn = min_element(a, a+n);
// int cnt = count(a, a+n, k);

vector<int> ans;
int size = -1;
void rec(int n, int a, int b, int mask){
  if(n == 1){
    ans.pb(a);ans.pb(b);
    return;
  }
  int bit = (mask&(a^b)) & -(mask&(a^b));
  mask ^= bit;
  int c = a;
  rep(i,size)if(mask & 1<<i){c ^= 1<<i;break;}
  rec(n-1, a, c, mask);
  c ^= bit;
  rec(n-1, c, b, mask);
  return;
}

signed main(){
  int n, a, b, cnt = 0;
  cin >> n >> a >> b;
  size = n;
  rep(i,n)if((a^b) & 1<<i)cnt++;
  if(cnt%2 == 0){
    cout << "NO" << endl;
    return 0;
  }
  cout << "YES" << endl;
  rec(n, a, b, (1<<n)-1);
  cout << ans << endl;
  return 0;
}





Measured memory_bytes: 2164
#include <fstream>
#include <cstring>
#define nmax 200005
using namespace std;
char s[nmax];
int dp[nmax][2];

int main()
{
    int i, j;
    scanf("%s", &s);
    int n = strlen(s);

    if (n == 1) {
        printf("1\n");
        return 0;
    }

    dp[0][0] = 1;
    dp[1][1] = 1;

    if (s[0] != s[1])
        dp[1][0] = 2;

    for (i = 2; i < n; i++) {

        dp[i][0] = dp[i - 1][1] + 1;
        if (s[i] != s[i - 1])
            dp[i][0] = max(dp[i][0], dp[i - 1][0] + 1);


        dp[i][1] = dp[i - 2][0] + 1;
        if (s[i] != s[i - 2] || s[i - 1] != s[i - 3])
            dp[i][1] = max(dp[i][1], dp[i - 2][1] + 1);
    }
    printf("%d", max(dp[n - 1][0], dp[n - 1][1]));

    return 0;
}

Measured memory_bytes: 1920
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>
#include<queue>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> P;
typedef long long int ll;
typedef pair<ll,ll> LLP;
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
#define MOD 1000000007
#define ARRAY_MAX 3005

struct SegmentTree{

    int N;
    vector<int> node;
    const int INF = INT_MAX;

    void init(int siz){
        N = 1;
        while(N < siz){
            N *= 2;
        }
        node.resize(2*N-1,0);
    }

    void build(vector<int>& dat){
        for(int i = 0;i < dat.size();i++){
            node[i+N-1] = dat[i];
        }
        for(int i = N-2;i >= 0;i--){
            node[i] = max(node[2*i+1],node[2*i]+2);
        }
    }

    void update(int k,int x){
        k += N-1;
        node[k] = x;
        while(k > 0){
            k = (k-1)/2;//親
            node[k] = max(node[2*k+1],node[2*k+2]);
        }
    }

    int getMax(int a,int b,int k,int l,int r){
        if(r <= a || b <= l){
            return 0;
        }
        if(a <= l && r <= b){
            return node[k];
        }
        int vl = getMax(a,b,k*2+1,l,(l+r)/2);
        int vr = getMax(a,b,k*2+2,(l+r)/2,r);
        return max(vl,vr);
    }

    int getMax(int a,int b){
        return getMax(a,b,0,0,N);
    }
};


void compress(vector<int> &v) {
    vector<int> x = v;
    map<int,int> zip;
    sort(x.begin(), x.end());
    x.erase(unique(x.begin(), x.end()), x.end());
    for (int i = 0; i < x.size(); i++) {
        zip[x[i]] = i;
    }
    for (int i=0; i < v.size(); i++){
        v[i] = zip[v[i]];
    }
}

int main(){

    int n;
    cin >> n;
    vector<int> a(n);
    REP(i,n){
        cin >> a[i];
    }
    compress(a);

    SegmentTree sgmt;
    sgmt.init(n);

    REP(i,n){
        int maxi = sgmt.getMax(0,a[i]);
        sgmt.update(a[i],maxi+1);
    }
    cout << sgmt.getMax(0,n) << endl;




    return 0;
}


Measured memory_bytes: 8356
import java.util.Scanner;

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

    int N = scanner.nextInt();
    int A = scanner.nextInt();
    int B = scanner.nextInt();

    System.out.printf("%d %d\n", Math.min(A, B), Math.max(A + B - N, 0));
  }
}


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

bool is_prime(long N) {
  for (long i = 2; i * i <= N; i++) {
    if (N % i == 0) {
      return false;
    }
  }
  return N != 1;
}

int main() {

  int X;
  cin >> X;

  bool flg = false;

  while (flg == false) {
    flg = is_prime(X);
    if (!flg) {
      X++;
    }
  }

  cout << X << endl;

  return 0;

}

Measured memory_bytes: 256