akhauriyash/Code-Regression huggingface dataset:
use proconio::{input, fastout};
use std::cmp::max;

#[fastout]
fn main() {
    input! {
        n: usize,
        m: usize,
        k: i64,
        a: [i64; n],
        b: [i64; m],
    };

    let mut sum_a = vec![0i64; n+1];
    let mut sum_b = vec![0i64; m+1];
    for (i, &v) in a.iter().enumerate() {
        sum_a[i+1] = sum_a[i] + v;
    }
    for (i, &v) in b.iter().enumerate() {
        sum_b[i+1] = sum_b[i] + v;
    }

    let mut ans = 0;
    for i in (0..=n).filter(|&n| sum_a[n as usize] <= k) {
        let mut head = 0;
        let mut tail = m;
        let mut center = (head + tail) / 2;
        while  head <= tail {
            if sum_b[center] <= k - sum_a[i] {
                ans = max(ans, center+i);
                head = center + 1;
            } else {
                tail = center - 1;
            }
            center = (head + tail) / 2;
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 12412
package main

import (
	"fmt"
	"math"
)

func main() {
	var n, x int
	fmt.Scan(&n)

	fmt.Scan(&x)
	min := x
	for i := 0; i < 4; i++ {
		fmt.Scan(&x)
		if x < min {
			min = x
		}
	}

	fmt.Println(int(math.Ceil(float64(n)/float64(min))) + 4)
}


Measured memory_bytes: 512
#include<stdio.h>
int main(){
  int a,s,d,f;
  double g;
  scanf("%d%d",&a,&s);
  d=a/s;
  f=a%s;
  g=(double)a/(double)s;

  printf("%d %d %f\n",d,f,g);
 return 0;
}

Measured memory_bytes: 636
#include <bits/stdc++.h>
using namespace std;
int a[3], i;

int main(){
  cin>>a[0]>>a[1]>>a[2];
  sort(a,a+3);
  int res = 3;
  for(i=0;i<2;++i){
    if(a[i] - a[i+1] == 0){
      res--;
    }
  }
  cout<<res<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using bint = boost::multiprecision::cpp_int;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repSE(i,s,n) for (int i = (s); i < (n); i++)
#define rrepSE(i,s,e) for (int i = (s); i > (e); i--)
#define ssort(v) sort(v.begin(), v.end())
#define gsort(v) sort(v.rbegin(), v.rend())
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }
#define DEBUG_PRINT(var) std::cout << #var << " = " << var << "\n";

int main()
{
    ll n;
    cin >> n;
    ll ans = 0;
    if (n % 2 == 1) {
        ans = 0;
    }
    else {
        ll pow5x2 = 2;
        while (pow5x2 < n) {
            pow5x2 *= 5;
            ans += (n / pow5x2);
        }
    }
    cout << ans << "\n";
    return 0;
}


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

#define MAX 1100000


int main(){


  bool is_prime[MAX];
  for(int i=0; i<MAX; i++) is_prime[i] = true;
  is_prime[0] = is_prime[1] = false;

  for(int i=2; i<MAX; i++)
    if(is_prime[i])
      for(int j=2; i*j<MAX; j++)
	is_prime[i*j] = false;
  
  while(1){
    int a,d,n,i;
    cin >> a >> d >> n;
    if(!a and !d and !n) break;
    for( i=a; i<MAX; i+=d){
      if(is_prime[i]){
	n--;
	if(n==0) break;
      }
    }
    cout << i << endl;
  }
  

}

Measured memory_bytes: 2232
let () = Scanf.scanf "%d\n" @@ fun n ->
  let tas = Array.init n @@ fun _ -> Scanf.scanf "%d %d\n" @@ fun t a -> t, a in
  let x, y =
    Array.fold_left (fun (x, y) (t, a) ->
      let i = (x + t - 1) / t in
      let j = (y + a - 1) / a in
      (t * max i j, a * max i j)) tas.(0) tas in
  Printf.printf "%d\n" @@ x + y


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

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

typedef   long long  int ll;
typedef  long double ld;
typedef std::vector<ll> vi;
typedef std::vector<std::vector<ll> > vv;

#define MOD 1000000007
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fo(i,a,b) for(i=a;i<b;i++)
#define mp make_pair
#define pb(x) push_back(x)
#define fi first
#define se second
#define print(vec,a,b) for(ll i=a;i<b;i++) cout<<vec[i]<<" ";cout<<endl;
#define all(a) a.begin(),a.end()
#define input(vec,a,b) for(ll i = a;i<b;i++) cin>>vec[i];
#define ms(a,val) memset(a,val,sizeof(a))
using namespace std;

const int N = 1e5 + 5;


void solve(){
            ll i,j,n,m,k;
            cin>>n>>m;
            ll ans[n+1][m+1];
            ms(ans,0);
            char a[n][m];
            fo(i,0,n)
            {
				fo(j,0,m)
				{
					cin>>a[i][j];
				}
			}
			ans[1][1] = 1;
			fo(i,1,n+1)
			{
				fo(j,1,m+1)
				{
					if(i==1&&j==1)
					 continue;
			
					if(a[i-1][j-1]!='#')
					{
						ans[i][j] = (ans[i-1][j] + ans[i][j-1])%MOD;
					}
				}
			}
			cout<<ans[n][m]<<endl;
			
				    
            
        
    
            
						            









}

int main()
{
    IO;
      ll t=1;
      //cin>>t;


      while(t--)
      {

          solve();
      }
    return 0;
}


Measured memory_bytes: 12436
#include<bits/stdc++.h>
using namespace std;
int a[505];
int ans[505];
vector<int> vec;
int main(){
    int n,k,sum=0;
    cin>>n>>k;
    for(int i=1;i<=n;i++) cin>>a[i],sum+=a[i];
    for(int i=1;i*i<=sum;i++){
        if(sum%i==0){
            if(i*i!=sum) vec.push_back(sum/i);
            vec.push_back(i);
        }
    }
    sort(vec.begin(),vec.end(),greater<int>());
    //for(int i=0;i<vec.size();i++) cout<<vec[i]<<" ";
    //cout<<endl;
    for(int x:vec){
        vector<int> b;
        for(int i=1;i<=n;i++) b.push_back(a[i]%x);
        sort(b.begin(),b.end());
        ans[0]=0;
        for(int i=1;i<=n;i++) ans[i]=ans[i-1]+b[i-1];
        for(int i=1;i<=n;i++){
            if(ans[i]==(n-i)*x-(ans[n]-ans[i])){
                if(k>=ans[i]){
                    cout<<x<<endl;
                    return 0;
                }
            }
        }
    }
    return 0;
}


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

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

void replace_a(int x, int y, string& s)
{
  for(int i = x; i < y; i++)
    {
      if(s[i] == '?')
	{
	  s[i] = 'a';
	}
    }
}

int main()
{
  string s, t, ans = "UNRESTORABLE";
  cin >> s >> t;
  if(s.length() < t.length())
    {
      cout << ans << endl;
      return 0;
    }
  for(int i = s.length() - t.length(); i >= 0; i--)
    {
      bool flag = true;
      rep(j, t.length())
	{
	  if(s[i + j] == '?')
	    {
	      continue;
	    }
	  if(s[i + j] != t[j])
	    {
	      flag = false;
	      break;
	    }
	}
      if(flag == true)
	{
	  ans = s;
	  replace_a(0, i, ans);
	  replace_a(i + t.length(), ans.length(), ans);
	  rep(j, t.length())
	    {
	      ans[i+j] = t[j];
	    }
	  break;
	}
    }
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#define ll long long
#define mod 1000000007
#define maxn 100010
inline ll read()
{
	ll x=0; char c=getchar(),f=1;
	for(;c<'0'||'9'<c;c=getchar())if(c=='-')f=-1;
	for(;'0'<=c&&c<='9';c=getchar())x=x*10+c-'0';
	return x*f;
}
inline void write(ll x)
{
	static int buf[20],len; len=0;
	if(x<0)x=-x,putchar('-');
	for(;x;x/=10)buf[len++]=x%10;
	if(!len)putchar('0');
	else while(len)putchar(buf[--len]+'0');
}
inline void writeln(ll x){write(x); putchar('\n');}
inline void writesp(ll x){write(x); putchar(' ');}
struct edge{
	int to,nxt;
}e[2*maxn];
int fir[maxn],val[maxn];
int n,k,tot;
inline void add_edge(int x,int y){e[tot].to=y; e[tot].nxt=fir[x]; fir[x]=tot++;}
void dfs(int now,int fa)
{
	int cnt=k-1;
	if(now!=1)--cnt;
	for(int i=fir[now];~i;i=e[i].nxt)
		if(e[i].to!=fa){
			val[e[i].to]=cnt--;
			dfs(e[i].to,now);
		}
}
int main()
{
	n=read(); k=read();
	memset(fir,255,sizeof(fir)); tot=0;
	for(int i=1;i<n;i++){
		int x=read(),y=read();
		add_edge(x,y); add_edge(y,x);
	}
	val[1]=k;
	dfs(1,-1);
	ll ans=1;
	for(int i=1;i<=n;i++)
		ans=ans*val[i]%mod;
	writeln(ans);
	return 0;
}

Measured memory_bytes: 6016
#include <iostream>
#include <vector>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define TOP 0 
#define BOTTOM 1
#define FRONT 2
#define BACK 3
#define RIGHT 4
#define LEFT 5

vector< vector<string> > check;

void z(vector<string> &dice){
	string to[6];
	to[BACK] = dice[TOP];
	to[BOTTOM] = dice[BACK];
	to[FRONT] = dice[BOTTOM];
	to[TOP] = dice[FRONT];

	to[LEFT] = dice[LEFT];
	to[RIGHT] = dice[RIGHT];

	rep(i,6)dice[i] = to[i];

}

void x(vector<string> &dice){
	string to[6];
	to[FRONT] = dice[LEFT];
	to[LEFT] = dice[BACK];
	to[BACK] = dice[RIGHT];
	to[RIGHT] = dice[FRONT];
	
	to[BOTTOM] = dice[BOTTOM];
	to[TOP] = dice[TOP];
	
	rep(i,6)dice[i] = to[i];
}

void y(vector<string> &dice){
	string to[6];
	to[TOP] = dice[LEFT];
	to[LEFT] = dice[BOTTOM];
	to[BOTTOM] = dice[RIGHT];
	to[RIGHT] = dice[TOP];
	
	to[FRONT] = dice[FRONT];
	to[BACK] = dice[BACK];
	
	rep(i,6)dice[i] = to[i];
}

bool isunique(vector<string> data){

	rep(l1,4)rep(l2,4)rep(l3,4){
	
		vector<string> t(6);
		
		rep(j,6)t[j] = data[j];

		rep(j,l1)x(t);
		rep(j,l2)y(t);
		rep(j,l3)z(t);
		
		rep(i,check.size()){
			bool flag = true;
			rep(j,6)if(t[j] != check[i][j])flag = false;
			if(flag)return false;
		}

	}
	return true;
}

int main(){
	int n;
	string c[6];
	while(cin >> n, n){
		check.clear();
		rep(i,n){
			rep(j,6)cin >> c[j];
			string d[6] =  {c[0],c[5],c[1],c[4],c[2],c[3]};
			vector<string> dice(6);
			rep(j,6)dice[j] = d[j];
			
			if( isunique(dice) ){
				check.push_back(dice);
			}
		}
		cout << n-check.size() << endl;
	}
}

Measured memory_bytes: 940
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

// 入力
int N;
long long a[100010][3]; // a[i], b[i], c[i] をそれぞれまとめて a[i][0], a[i][1], a[i][2] にしてしまう

// DP テーブル
long long dp[100010][3];

int main() {
    int N; cin >> N;
    for (int i = 0; i < N; ++i) for (int j = 0; j < 3; ++j) cin >> a[i][j];

    // 初期化は既に 0 に初期化される
    // 初期条件も既に 0 で OK

    // ループ
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < 3; ++j) {
            for (int k = 0; k < 3; ++k) {
                if (j == k) continue;
                dp[i+1][k]=max(dp[i + 1][k], dp[i][j] + a[i][k]);
            }
        }
    }

    // 答え
    long long res = 0;
    for (int j = 0; j < 3; ++j) chmax(res, dp[N][j]);
    cout << res << endl;
}


Measured memory_bytes: 4992
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <tuple>
#include <vector>
using namespace std;
using ll = int64_t;
#define rep(i, j, n) for (int i = j; i < (int)n; ++i)
#define rrep(i, j, n) for (int i = (int)n - 1; j <= i; --i)

template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T>& a) {
  os << "{";
  for (size_t i = 0; i < a.size(); ++i) os << (i > 0 ? "," : "") << a[i];
  return os << "}";
}

constexpr ll MOD = 1000000007;
constexpr int INF = 0x3f3f3f3f;
constexpr ll INFL = 0x3f3f3f3f3f3f3f3fLL;

int main() {
  int h, w;
  cin >> h >> w;
  int sy, sx, gy, gx;
  cin >> sy >> sx >> gy >> gx;
  --sy, --sx, --gy, --gx;
  vector<string> g(h);
  rep(i, 0, h) cin >> g[i];

  vector<vector<ll>> d(h, vector<ll>(w, INFL));
  d[sy][sx] = 0;
  using tup = tuple<ll, int, int>;
  priority_queue<tup, vector<tup>, greater<tup>> q;
  q.emplace(0, sy, sx);
  ll c;
  int y, x;
  int dy[4]{0, 0, -1, 1};
  int dx[4]{1, -1, 0, 0};
  while (q.size()) {
    tie(c, y, x) = q.top();
    q.pop();
    if (d[y][x] < c) continue;
    // hutuu idou
    rep(i, 0, 4) {
      int ny = y + dy[i];
      int nx = x + dx[i];
      if (0 <= ny && ny < h && 0 <= nx && nx < w && g[ny][nx] == '.' &&
          d[ny][nx] > d[y][x]) {
        d[ny][nx] = d[y][x];
        q.emplace(d[ny][nx], ny, nx);
      }
    }

    rep(ny, y - 2, y + 3) rep(nx, x - 2, x + 3) {
      if (0 <= ny && ny < h && 0 <= nx && nx < w && g[ny][nx] == '.' &&
          d[ny][nx] > d[y][x] + 1) {
        d[ny][nx] = d[y][x] + 1;
        q.emplace(d[ny][nx], ny, nx);
      }
    }
  }
  if (d[gy][gx] == INFL)
    cout << -1 << endl;
  else
    cout << d[gy][gx] << endl;
  return 0;
}

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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using P = pair<int, int>;

constexpr int INF = 1e9;
constexpr ll INFLL = 1e18;
constexpr int MOD = 1e9 + 7;
const ld PI = acosl(-1);

#define rep(i,n) for(int i=0; i<(n); ++i)
#define all(n) n.begin(),n.end()

int main(){
    ios::sync_with_stdio(false); cin.tie(nullptr);
    //cout << fixed << setprecision(6);
    int n; cin >> n;
    vi a(n);
    rep(i, n) cin >> a[i];
    int q; cin >> q;
    vi b(q), c(q);
    rep(i, q) cin >> b[i] >> c[i];

    vi num(1e5+2, 0);
    ll ans = 0;
    for(int t : a){
        num[t]++;
        ans += t;
    }
    rep(i, q){
        ans += num[b[i]] * (c[i] - b[i]);
        cout << ans << endl;
        num[c[i]] += num[b[i]];
        num[b[i]] = 0;
    }
    return 0;
}

Measured memory_bytes: 4752
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
    tmp = input.split("\n");
    tmp1 = tmp[0].split(" ");
    N = tmp1[0];
    T = tmp1[1];
    answer = 9999;


    for(i=1;i < N+1;i++){
        tmp2 = String(tmp[i]).split(" ");
        c = Number(tmp2[0]);
        t = Number(tmp2[1]);
        if(t <= T){
            if(c < answer){
            answer = c;
            }
        }
    }

    if(answer == 9999){
        console.log("TLE");
    }else{
        console.log(answer);
    }

        

    //console.log(answer);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7612
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define nn 65536*4
#define mod 998244353
vector<ll> v[nn];ll cnt[nn];
ll aa[nn];ll n,k;
void out(vector<ll> b){
	for(int i=0;i<b.size();i++) printf("%lld ",b[i]);
	exit(0);
}
void bbb(){
	for(int i=1;i<=k;i++){
		v[i]=v[i-1];
		for(int j=1;j<=n;j++){
			if(cnt[aa[j]]) {
				cnt[aa[j]]=0;
				while(1){
					ll u=v[i][v[i].size()-1];v[i].pop_back();
					cnt[u]=0;
					if(u==aa[j]) break;
				}
			}
			else{
				cnt[aa[j]]=1;
				v[i].push_back(aa[j]);
			}
		}
		if(i==k) out(v[i]);
	}
}
ll pos[nn];ll app[nn],lst[nn];
int main(){
	cin>>n>>k;for(int i=1;i<=n;i++) scanf("%lld",&aa[i]);
	if(n*k<=1e7)  bbb();
	memset(app,0x3f,sizeof app);
	for(int i=n;i>=1;i--){
		lst[i]=app[aa[i]];
		app[aa[i]]=i;
	}

	ll a=-1,b=-1;
	vector<ll> cir;ll x=1;memset(pos,-1,sizeof pos);cir.push_back(1);pos[1]=0;vector<ll> lop;
	lop.push_back(0);ll yy=0;
	for(int i=1;i<n+n;i++){
		ll t=lst[x];
		if(t>1e8) t=app[aa[x]],++yy;
		x=t+1;if(x>n) x=1,++yy;
		cir.push_back(x);lop.push_back(yy);
		if(pos[x]==0) {
			a=pos[x],b=i;
			break;
		}
		pos[x]=i;

	}

	if(lop[b]==1)return puts(""),0;

	k%=(lop[b]);
	while(lop[a+1]<k and a+1<=b) a++;
	k-=lop[a];//cout<<k<<"\n";
//	cout<<k;
	for(int i=1;i<=k;i++){
		v[i]=v[i-1];
		for(int j=(i==1?cir[a]:1);j<=n;j++){
			if(cnt[aa[j]]) {
				cnt[aa[j]]=0;
				while(1){
					ll u=v[i][v[i].size()-1];v[i].pop_back();
					cnt[u]=0;
					if(u==aa[j]) break;
				}
			}
			else{
				cnt[aa[j]]=1;
				v[i].push_back(aa[j]);
			}
		}
	}
		 out(v[k]);
	return 0;
}

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

int main()
{
    int n;
    cin >> n;
    
    vector<int> a(n), tab(n, 1e9);
    
    for( int i = 0; i < n; i++ )
        cin >> a[i];
        
    tab[0] = 0;
    
    for ( int i = 0; i < n; i++ ){
        for( int j = i + 1 ; j <= i + 2; j++ ){
            if ( j < n )
                tab[j] = min( tab[j], abs( a[i] - a[j] ) + tab[i] );
        }    
    }
    
    cout << tab[n - 1] << endl;
    return 0;
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"
#define fi first
#define se second
#define all(x) x.begin(), x.end()
using namespace std;
using ull = unsigned long long;
using ll = long long;


int main() {
    int N;
    cin >> N;
    vector<int> V(N);
    vector<int> C(N);
    for(int i = 0; i < N; i++){
        cin >> V[i];
    }
    for(int i = 0; i < N; i++){
        cin >> C[i];
    }
    int sum = 0;
    for(int i = 0; i < N; i++){
        if(V[i] > C[i]){
            sum += V[i] - C[i];
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

int main() {
    int a, b;
    cin >> a >> b;
    cout << (a - 1) * (b - 1) << endl;

    return 0;
}


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

int up_bound(vector<int> &A, int x) // A[i] <= xとなる最大のiを求める
{
    int ok = -1;
    int ng = A.size();
    while(abs(ok-ng)>1) {
        int mid = (ok + ng)/2;
        if(A[mid] <= x) ok = mid;
        else ng = mid;
    }
    return ok;
}

bool solve() {
    int n, m;
    cin >> n >> m;
    if(n == 0 && m == 0) return false;

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

    sort(a.begin(), a.end());
    //for(auto &p : a) cout << p << " ";
    //cout << endl;
    int res = -1;

    // 尺取りか二分探索
    for(int i = 0; i < n; ++i) {
        if(a[i] >= m) continue;
        int j = up_bound(a, m - a[i]);
        if(i >= j) continue;
        //cout << i << " " << j << endl;
        res = max(res, a[i] + a[j]);
    }

    if(res == -1) cout << "NONE" << endl;
    else cout << res << endl;

    return true;
}

int main() {
    while(solve()) ;
    return 0;
}


Measured memory_bytes: 3168
use proconio::{input, fastout};
use proconio::marker::{Chars};
use proconio::marker::Usize1;
use std::cmp::*;

macro_rules! debug {
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

#[fastout]
fn main() {
    input!{
        n: usize,
        mut s: [usize;n],
    }
    s.sort();
    let mut sum = 0;
    for i in 0..n {
        sum += s[i];
    }
    
    if sum%10!=0 {
        println!("{}", sum);
        return;
    }
    
    for i in 0..n {
        if s[i]%10==0 {
            continue;
        } else {
            sum -= s[i];
            println!("{}", sum);
            return;
        }
    }

    debug!(sum);
    println!("0");
}


Measured memory_bytes: 2140
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,k;
  cin>>a>>b>>k;
  for(int i=min(a,b);i>=1;i--){
    if(a%i==0&&b%i==0) k--;
    if(k==0){
      cout<<i<<endl;
      break;
    }
  }
}

Measured memory_bytes: 3640
//I am so vegetable
//#define err
#pragma GCC optimize(2)
#include <bits/stdc++.h>
#define FIO ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define pb push_back
#define in insert
#define er erase
#define ct count
#define ep empty
#define _for(i,a,b) for(int i = (a);i<(b);++i)
#define _rfor(i,a,b) for(int i = (a);i>(b);--i)
#define _sfor(p,st) for(auto &p:st)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9+7;
const double eps = 1e-6;
const double pi = acos(-1.0);
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll qpow(ll x, ll y) { ll ans = 1; for (; y > 0; y >>= 1) { if (y & 1)ans *= x; x *= x; }return ans; }
ll qpow(ll x, ll y, int MOD) { ll ans = 1; for (; y > 0; y >>= 1) { if (y & 1)ans = ans*x%MOD; x = x*x%MOD; }return ans; }
void exgcd(ll a,ll b,ll &x,ll &y){
    if(!b){x=1;y=0;return;}
    exgcd(b,a%b,x,y);
    ll X=x;
    x=y; y=X-a/b*y;
}
ll inv(ll x, int mod = MOD) { return qpow(x, mod - 2,mod); }
ll m_m(ll a){ return (a%MOD+MOD)%MOD; }


const int MAX=100005;
ll a[MAX<<1+5],inva[MAX<<1+5];
ll C(ll n,ll m){
    return a[n]*inva[m]%MOD*inva[n-m]%MOD;
}
signed main() {
    //ifstream cin("E:\\acm dream\\in.in");
	//ofstream cout("E:\\acm dream\\out.out");
	FIO;
    #ifdef err
	double be = clock();
    #endif

    a[0]=1;
    _for(i,1,MAX<<1+1)a[i]=a[i-1]*i%MOD;
    inva[0]=1;
    inva[MAX<<1]=inv(a[MAX<<1]);
    _rfor(i,(MAX<<1)-1,0)inva[i]=inva[i+1]*(i+1)%MOD;
    ll n,m;cin>>n>>m;
    ll x,y;cin>>x>>y;
    ll ans=0;
    _for(i,y+1,m+1){
        ans+=C(n-x+i-2,i-1)*C(x+m-i-1,m-i)%MOD;
        ans%=MOD;
    }
    cout<<ans;

    #ifdef err
	double en = clock();
    cout<<"time: "<<fixed<<setprecision(8)<<en-be;
    #endif
	return 0;
}

Measured memory_bytes: 8244
const main = (input) => {
  const [a, b, c] = input.split(' ').map(n => Number(n))
  let result = 'win'
  if (22 <= a+b+c) {
    result = 'bust'
  }
  console.log(result)
                               
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'))

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

int main(){
    long long int x1,y1,x2,y2;
    cin>>x1>>y1>>x2>>y2;
    long long int n;
    cin>>n;
    vector<long long int> x(n);
    vector<long long int> y(n);
    for(int i=0;i<n;i++){
        cin>>x[i]>>y[i];
        if(x2<x1) x[i]=-x[i];
        if(y2<y1) y[i]=-y[i];
    }

    if(x2<x1){
        x2=-x2;
        x1=-x1;
    }
    if(y2<y1){
        y2=-y2;
        y1=-y1;
    }
    vector<long long int> px,py;
    for(int i=0;i<n;i++){
        if(x1<=x[i] && x[i]<=x2 && y1<=y[i] && y[i]<=y2){
            px.push_back(x[i]);
            py.push_back(y[i]);
        }
    }
    
    int s=px.size();
    vector<pair<long long int,long long int>> pxy(s);

    for(int i=0;i<s;i++){
        pxy[i]={px[i],py[i]};
    }
    sort(pxy.begin(),pxy.end());
    const long long int INF=1e9;
    vector<int> dp(s+1,INF);
    long long int cnt=0;
    dp[0]=-INF;
    for(int i=0;i<s;i++){
        long long int val=pxy[i].second;
        auto it=lower_bound(dp.begin(),dp.end(),val);
        *it=val;
        cnt=max(cnt,(long long int)(it-dp.begin()));
    }

    const long double PI=acos(-1.0L);
    long double cut=20-PI*5;
    long double dis=PI*10-20;
    long long int ccnt=cnt;
    long long int dcnt=0;
    if(cnt==min(x2-x1,y2-y1)+1){
        ccnt--;
        dcnt++;
    }
    long double res=100LL*(x2-x1+y2-y1)-ccnt*cut+dcnt*dis;
    cout<<setprecision(15)<<fixed;
    cout<<res<<endl;

    return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<vector<int>> node(n);
    for (int i = 0; i < n-1; i++){
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        node[a].push_back(b);
        node[b].push_back(a);
    }
    vector<int> f_distance(n);
    vector<bool> f_check(n, true);
    queue<int> que;
    que.push(0);
    f_distance[0] = 0;
    f_check[0] = false;
    while (que.size() > 0){
        int x = que.front(); que.pop();
        int y = (int)node[x].size();
        for (int i = 0; i < y; i++) {
            if (f_check[node[x][i]]){
                f_check[node[x][i]] = false;
                f_distance[node[x][i]] = f_distance[x] + 1;
                que.push(node[x][i]);
            }
        }
    }

    vector<int> s_distance(n);
    vector<bool> s_check(n, true);
    que.push(n-1);
    s_distance[n-1] = 0;
    s_check[n-1] = false;
    while (que.size() > 0){
        int x = que.front(); que.pop();
        int y = (int)node[x].size();
        for (int i = 0; i < y; i++) {
            if (s_check[node[x][i]]){
                s_check[node[x][i]] = false;
                s_distance[node[x][i]] = s_distance[x] + 1;
                que.push(node[x][i]);
            }
        }
    }

    int ans = 0;
    for (int i = 0; i < n; i++){
        if (f_distance[i] <= s_distance[i]) ans++;
    }
    if (ans * 2 > n) cout << "Fennec" << endl;
    else cout << "Snuke" << endl;
}

Measured memory_bytes: 6528
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807

int n;
int dp[152][102][80];//何列目の何個目の石で残り何回
vector<pair<int,int> > stone[150];

int solve(int now, int k, int m){
    if(now == n-1) return 0;
    if(now == n-2 && m > 0) return 0;
    if(dp[now][k][m] != -1) return dp[now][k][m];

    int ans = INT_MAX;
    for(int i=0; i<stone[now+1].size(); i++){
        int cost = abs(stone[now][k].first - stone[now+1][i].first) * (stone[now][k].second + stone[now+1][i].second);
        ans = min(ans, cost + solve(now+1, i, m));
    }
    if(m > 0){
        for(int i=0; i<stone[now+2].size(); i++){
            int cost = abs(stone[now][k].first - stone[now+2][i].first) * (stone[now][k].second + stone[now+2][i].second);
            ans = min(ans, cost + solve(now+2, i, m-1));
        }
    }
    return dp[now][k][m] = ans;
}

int main(){
    iostream::sync_with_stdio(false);
    START:
    int m;
    cin >> n >> m;
    if(n == 0 && m == 0) return 0;
    for(int i=0; i<n; i++){
        int k;
        cin >> k;
        stone[i].clear();
        for(int j=0; j<k; j++){
            int a, b;
            cin >> a >> b;
            stone[i].push_back(make_pair(a, b));
            for(int l=0; l<=m; l++){
                dp[i][j][l] = -1;
            }
        }
    }

    int ans = INT_MAX;
    for(int i=0; i<stone[0].size(); i++){
        ans = min(ans, solve(0, i, m));
    }
    if(m > 0){
        for(int i=0; i<stone[1].size(); i++){
            ans = min(ans, solve(1, i, m-1));
        }
    }
    cout << ans << endl;

    goto START;
    
    return 0;
}


Measured memory_bytes: 4052
import random
N=int(input())
A=[int(i) for i in input().split()]
B=[int(i) for i in input().split()]
a=[0 for i in range(N+1)]
b=[0 for i in range(N+1)]
for i in range(N):
    a[A[i]]+=1
    b[B[i]]+=1
if max([a[i]+b[i] for i in range(1,N+1)])<=N:
    print("Yes")
else:
    print("No")
    exit()
B=B[::-1]
point=0
for i in range(N):
    if A[i]==B[i]:
        point+=1
while(point>0):
    x=random.randrange(N)
    y=random.randrange(N)
    if x==y:
        continue
    before=0
    after=0
    if A[x]==B[x]:
        before+=1
    if A[y]==B[y]:
        before+=1
    if A[x]==B[y]:
        after+=1
    if A[y]==B[x]:
        after+=1
    if before>after:
        B[x],B[y]=B[y],B[x]
        point=point+after-before
print(*B)


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

int main(){
    int n, k; string s; cin >> n >> k >> s;
    bool left; int tmp, ans = 0;
    while(k > 0) {
        left = (s[0] == 'L'); tmp = 0;
        vector<pair<int, int>> cnt;
        for (auto i = 0; i < n; i++) {
            if((left and s[i] == 'L') or (not left and s[i] == 'R')) {
                tmp++; if(i == n - 1) cnt.emplace_back(tmp, i);
            }
            else cnt.emplace_back(tmp, i - 1), left = not left, tmp = 1;
        }
        if(cnt.size() <= 2) { cout << n - 1 << endl; return 0; }
        for (auto i = 1; i < (int) cnt.size() - 1; i += 2) {
            for (auto j = 0; j < cnt[i].first; j++)
                s[cnt[i].second - cnt[i].first + 1 + j] = s[cnt[i].second - cnt[i].first];
            k--;
            if (k == 0) break;
        }
    }
    left = (s[0] == 'L'); tmp = 0;
    for (auto i = 0; i < n; i++) {
        if((left and s[i] == 'L') or (not left and s[i] == 'R')) {
            tmp++; if(i == n - 1) ans += (tmp - 1);
        }
        else ans += (tmp - 1), left = not left, tmp = 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4448
import pdb
a,b,c = map(int, raw_input().strip().split(' '))
if a==b==c:
    if a%2==0:
        print -1
    else:
        print 0
elif a%2!=0 or b%2!=0 or c%2!=0:
    print 0
else:
    Flag = True
    cnt = 0
    for i in range(100000):
        tmp1,tmp2=a,b
        a = b/2+c/2
        b = tmp1/2+c/2
        c = tmp1/2+tmp2/2
        cnt += 1
#         pdb.set_trace()
        if a%2!=0 or b%2!=0 or c%2!=0:
            Flag = False
            break
    if Flag:
        print -1
    else:
        print cnt
            


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

int main() {
  int L, R, d;
  int count = 0;
  cin >> L >> R >> d;
  
  for(int i = L; i <= R; i++){
    if(i % d == 0) {
      count++;
    }
  }
  
  cout << count << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <cassert>
#include <bitset>
#include <list>
#include <cmath>
using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	int ans = -1;
	for (int i = 0; i < 10000; ++i) {
		if (floor(i * 0.08) == a && floor(i * 0.1) == b) {
			ans = i;
			break;
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] a = new long[n];
        for(int i=0; i<n; i++) {
            a[i] = sc.nextLong();
        }

        long res = 0;
        int negc = 0;
        long absmin = Integer.MAX_VALUE;

        for(int i=0; i<n; i++) {
            absmin = Math.min(absmin, Math.abs(a[i]));
            res +=  Math.abs(a[i]);
            if (a[i] < 0) {
                negc++;
            }
        }

        if(negc % 2 == 1) {
            res -= absmin * 2;
        }

        System.out.println(res);

    }


}


Measured memory_bytes: 50452
S = str(input())
if len(S) % 2 != 0:
  ans = 'No'
else:
  h = int(len(S) / 2)
  s = [[S[2 * i - 2], S[2 * i -1]] for i in range(h)]
  hi = s.count(['h', 'i'])
  if h == hi:
    ans = 'Yes'
  else:
    ans = 'No'
print(ans)

Measured memory_bytes: 3064
import sys

fin = sys.stdin.readline
n = int(fin())
d_list = [int(elem) for elem in fin().split()]

sort_d = sorted(d_list)
middle_d = int(n / 2)

if sort_d[middle_d] == sort_d[middle_d - 1]:
    print(0)
else:
    print(sort_d[middle_d] - sort_d[middle_d-1])


Measured memory_bytes: 52764
macro_rules! scan {
    ( $( $x:ident ),*; $t:ty ) => {
        let mut buf = String::new();
        let mut itr = {
            while buf.trim().len() == 0 {
                buf = String::new();
                std::io::stdin().read_line(&mut buf).unwrap();
            }
            buf.split_whitespace().map(|n| n.parse::<$t>().unwrap())
        };
        $(
            let $x = itr.next().unwrap();
        )*
    };
}

fn main() {
    scan!(n; usize);
    scan!(s, t; String);
    let s = s.chars().collect::<Vec<char>>();
    let t = t.chars().collect::<Vec<char>>();

    for i in 0..n {
        print!("{}{}", s[i], t[i]);
    }

    println!("");
}


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

int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  vector<int> a(3); for(int &e : a) cin >> e;
  sort(begin(a), end(a));
  int x;
  cin >> x;
  a[2] <<= x;
  cout << a[0] + a[1] + a[2] << endl;
}


Measured memory_bytes: 256
// Problem : E - This Message Will Self-Destruct in 5s
// Contest : AtCoder - AtCoder Beginner Contest 166
// URL : https://atcoder.jp/contests/abc166/tasks/abc166_e
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define all(x) begin(x),end(x)

int mod = 1e9+7;
int inf = 4e18;
const int N = 5e5+5;

signed main()
{
    io
    int tt = 1;
    //cin>>tt;
    while(tt--)
    {
		int n;
		cin>>n;
		int arr[n+1];
		for(int i=1;i<=n;++i)
		cin>>arr[i];
		unordered_map<int,int> mpadd,mpsub;
		for(int i=1;i<=n;++i)
		{
			mpsub[i-arr[i]]++;
			mpadd[i+arr[i]]++;
		}
		int ans = 0;
		for(auto x:mpsub)
		{
			ans+= (mpsub[x.first]*mpadd[x.first]);
		}
		cout<<ans;    	
    }
    return 0;
}



Measured memory_bytes: 27920
import java.io.*;
import java.math.BigDecimal;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    
    int n = Integer.parseInt(br.readLine());
    int[] an = new int[n];
    String[] data = br.readLine().split(" ");
    
    for (int i=0; i<n; i++){
      an[i] = Integer.parseInt(data[i]);
    }
    BigDecimal[] results = new BigDecimal[n-1];
    BigDecimal temp = new BigDecimal(0);
    BigDecimal sum = new BigDecimal(0);
    for (int i=0; i<n; i++){
      sum = sum.add(new BigDecimal(an[i]));
    }
    BigDecimal min = BigDecimal.valueOf(2 * Math.pow(10, 9));
    BigDecimal temp2;
    for (int i=0; i<n-1; i++){
      temp = temp.add(new BigDecimal(an[i]));
      temp2 = sum.subtract(temp.multiply(new BigDecimal(2))).abs();
      if (min.compareTo(temp2)>0){
        min = temp2;
      }
    }
    System.out.println(min.toPlainString());
  }
}


Measured memory_bytes: 65960
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
int main()
{
    int n;
    cin>>n;
    ll a[n];
    for(int i=0;i<n;i++) cin>>a[i];
    ll mx=a[0];
    ll ans=0;
    for(int i=1;i<n;i++)
    {
          mx=max(mx,a[i]);
          ans+=mx-a[i];
    }
    cout<<ans<<endl;
}

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

typedef long long ll;
typedef complex<double> Vec;

ll K, X;

int main() {
  cin >> K >> X;
  bool first = true;
  for (ll i = X - (K - 1); i <= X + (K - 1); ++i) {
    cout << (first ? "" : " ") << i;
    first = false;
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int n, m, c[22], dp[50007];
int main() {
	cin >> n >> m;
	for(int i = 0; i < m; i++) cin >> c[i];
	sort(c, c + m);
	for(int i = 1; i <= n; i++) {
		dp[i] = 999999999;
		for(int j = 0; j < m && i >= c[j]; j++) dp[i] = min(dp[i], dp[i - c[j]] + 1);
	}
	cout << dp[n] << endl;
}

Measured memory_bytes: 3352
n, m = list(map(int, input().split()))
a = [0] * (n+1)
for _ in range(m):
    a[int(input())] = -1

MOD = 10**9 + 7
res = [0] * (n+1)
res[0] = 1
res[1] = 0 if a[1] == -1 else 1

for i in range(2, n+1):
    if a[i] == -1:
        continue

    # 到達不可能
    if res[i-1] == 0 and res[i-2] == 0:
        break

    res[i] = (res[i-1] + res[i-2]) % MOD

print(res[-1])


Measured memory_bytes: 7668
#include <iostream>
using namespace std;
int main() {
    int x;
    cin >> x;
    int fiveHundreds = x / 500;
    x -= fiveHundreds * 500;
    int fives = x / 5;
    int happiness = fiveHundreds * 1000 + fives * 5;
    cout << happiness;
    return 0;
}

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

int h, w, n, a[100005], posx, posy, fid[102][102];

signed main()
{
    cin >> h >> w >> n;
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    for(int i = 0; i < n; i++){
        for(int j = 0; j < a[i]; j++){
            if(posx % 2 == 0){
                fid[posx][posy] = i + 1;
                posy++;
                if(posy % w == 0){
                    posx++;
                    posy = w - 1;
                }
            }
            else{
                fid[posx][posy] = i + 1;
                posy--;
                if(posy == -1){
                    posx++;
                    posy = 0;
                }
            }
        }
    }
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            printf("%lld ", fid[i][j]);
        }
        printf("\n");
    }

    return 0;
}


Measured memory_bytes: 384
import collections
N = int(input())
tree = [[] for i in range(N+1)]
hen = []
tyouten = [0 for i in range(N+1)]
zisuu = []
for i in range(N-1):
    a, b = map(int, input().split())
    tree[a].append(b)
    tree[b].append(a)
    hen.append([a,b])
c = list(map(int, input().split()))
c.sort(reverse = True)

for i in range(1,N+1):
    zisuu.append([len(tree[i]),i])

zisuu.sort(reverse = True)

queue = collections.deque()
queue.append(zisuu[0][1])
count = 1
tyouten[zisuu[0][1]] = c[0]
while len(queue) > 0:
    now = queue.popleft()
    for next in tree[now]:
        if tyouten[next] == 0:
            tyouten[next] = c[count]
            count += 1
            queue.append(next)



ans = 0
for i in range(N-1):
    ans += min(tyouten[hen[i][0]], tyouten[hen[i][1]])

print(ans)
print(" ".join(map(str, tyouten[1:])))

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

int main(){
	int a,b,f=1;
	scanf("%d %d",&a,&b);

		if((a+b)%2==0)
		{
			printf("%d\n",(a+b)/2);
			f=0;
		}
	if(f){
		printf("IMPOSSIBLE\n");
	}
}

Measured memory_bytes: 256
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
    int n, m, i, j, tmp, count = 0;
    int[] t = new int[200];

    n = sc.nextInt();
    for(i = 0;i < n;i++)t[count++] = sc.nextInt() * 60 + sc.nextInt();
    m = sc.nextInt();
    for(i = 0;i < m;i++)t[count++] = sc.nextInt() * 60 + sc.nextInt();
    for(i = 0;i < count - 1;i++)for(j = 0;j < count - 1 - i;j++)
      if(t[j] > t[j + 1]){ tmp = t[j]; t[j] = t[j + 1]; t[j + 1] = tmp; }

    out.printf("%d:%02d", t[0] / 60, t[0] % 60);
    for(i = 1;i < count;i++)if(t[i] != t[i - 1])
      out.printf(" %d:%02d", t[i] / 60, t[i] % 60);
    out.println();

    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
}

Measured memory_bytes: 28216
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#include <boost/rational.hpp>
*/
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
#define INF1  INT_MAX;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;
#define MOD 1000000007;
/*
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using Real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using Real1024 = mp::number<mp::cpp_dec_float<1024>>;
// 有理数型
using Rat = boost::rational<Bint>;
*/



int main() {
int N;
cin>>N;
int A[N+1];
rep3(i,N){
    cin>>A[i];
}
int table[1000002];
rep3(i,1000000){
    table[i]=0;
}
rep3(i,N){
    if(table[A[i]]!=0){
        table[A[i]]++;
    }
    else{
        for(int j=A[i];j<=1000000;j+=A[i]){
            table[j]++;
        }

        
    }
}
int count=0;
rep3(i,N){
    if(table[A[i]]==1){
        count++;
    }

}
cout<<count<<endl;
return 0;
}

Measured memory_bytes: 8264
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,L,R;
string S,T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;

int main(){
    cin>>S>>K;
    ll ans = 1;
    rep(i,S.size()){
        if(i >= K) break;
        if(S[i] != '1'){
            ans = S[i]- '0';
            break;
        }
    }
    cout<<ans<<endl;
}


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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int MOD = 1000000009;
const long long INF = 1LL << 60;

int main() {
    vector<int> ABC(3);
    cin >> ABC[0] >> ABC[1] >> ABC[2];
    sort(ABC.begin(), ABC.end());
    int A = ABC[0], B = ABC[1], C = ABC[2];
    int res = 0;
    if ((C-B)%2 == 0 && (C-A)%2 == 0) {
        res += (C-B)/2 + (C-A)/2;
    } else if ((C-B)%2 == 0 && (C-A)%2 == 1 || (C-B)%2 == 1 && (C-A)%2 == 0) {
        res += (C-B)/2 + (C-A)/2 + 2;
    } else {
        res += (C-B)/2 + (C-A)/2 + 1;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3652
A, B, N = gets.chomp.split.map(&:to_i)

def cul(x)
  ((A * x).to_f / B).floor - A * (x.to_f / B).floor
end

if B == 1
  p 0
  exit
end

if N < B
  p cul(N)
  exit
end

t = N / B

p [cul(B * t - 1), cul(N)].max


Measured memory_bytes: 14304
#include<bits/stdc++.h>
using namespace std;
#define ios ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define endl '\n'
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
bool sortbysec(const pair<int,int>&a,const pair<int,int>&b)
{
    return (a.second<b.second);
}
int main()
{
    ios;
    ll n;
    cin>>n;
    string res="zabcdefghijklmnopqrstuvwxy";
    string ans;
    while(n)
    {
        ans.pb(res[n%26]);
        n=ceil(n/26.0)-1;
    }
    reverse(ans.begin(),ans.end());
    cout<<ans<<endl;

}


































Measured memory_bytes: 3664
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from functools import reduce
from bisect import bisect_left, insort_left
from heapq import heapify, heappush, heappop

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())
MAP = lambda: map(int, INPUT().split())
S_MAP = lambda: map(str, INPUT().split())
LIST = lambda: list(map(int, INPUT().split()))
S_LIST = lambda: list(map(str, INPUT().split()))
ZIP = lambda: zip(*(MAP() for _ in range(n)))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def main():
    A, B, C = MAP()
    K = INT()

    cnt = 0
    while True:
        if A < B: break
        B *= 2
        cnt += 1

    while True:
        if B < C: break
        C *= 2
        cnt += 1

    print("Yes" if cnt <= K else "No")


if __name__ == '__main__':
    main()


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

int main(){
	int n;
  	cin>>n;
  	long long sum = 0;
  	for(int i=1;i<=n;i++){
    	if(i%3!=0 && i%5!=0) sum+=i;
    }
  	cout<<sum;
  	return 0;
}

Measured memory_bytes: 3616
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

#[allow(unused_macros)]
macro_rules! max {
    ($x:expr) => {
      $x
    };
    ($x:expr, $($xs:tt)+) => {
      max($x,max!($($xs)+))
    };
  }

#[allow(unused_macros)]
macro_rules! min {
    ($x:expr) => {
      $x
    };
    ($x:expr, $($xs:tt)+) => {
      min($x,min!($($xs)+))
    };
  }

use std::ascii::AsciiExt;
use std::cmp;
use std::collections::VecDeque;
use std::io::Write;
use std::iter::Iterator;

fn main() {
    input! {
        x:i64,
        y:i64,
    }

    let mut cnt = 0;
    let mut current = x;

    while current <= y {
        current = current * 2;
        cnt += 1;
    }

    println!("{}", cnt);
  

}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <cmath>

using namespace std;

int main()
{
  int A, B;
cin >> A >> B;
cout << (A + B) % 24 << endl;  

  return 0;
}


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

int main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int n, d;
  std::cin >> n >> d;
  std::vector<int> a(n);
  for (int i = 0; i < n; ++i) std::cin >> a[i];
  std::vector<int> p(n + 1);
  p[0] = d;
  for (int i = 0; i < n; ++i) {
    if (a[i] <= p[i]) {
      p[i + 1] = p[i] - a[i];
    } else if (a[i] <= p[i] + p[i] - 1) {
      p[i + 1] = a[i] - p[i];
    } else {
      p[i + 1] = p[i];
    }
  }
  std::vector<int64_t> dp(n + 1);
  dp[n] = 0;
  for (int i = n - 1; i >= 0; --i) {
    if (a[i] > 2 * dp[i + 1] + 1) dp[i] = dp[i + 1];
    else dp[i] = dp[i + 1] + a[i];
  }
  int q; std::cin >> q;
  while (q--) {
    int i;
    std::cin >> i;
    if (p[n] == 0 && p[i - 1] <= dp[i]) {
      std::cout << "NO\n";
    } else {
      std::cout << "YES\n";
    }
  }
  return 0;
}


Measured memory_bytes: 9728