akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
#include <vector>
#include <numeric>
#include <map>
#include <cmath>
#include <iomanip>
#include <set>
#include <queue>
using ll =long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vs = vector<string>;
using vvs = vector<vs>;


ll mod = 1000000000 + 7;

int main(){
    ll N, M;
    cin >> N >> M;
    vl A(N);
    priority_queue<ll> ans;

    for (int i = 0; i < N; ++i) {
        cin >> A.at(i);
        ans.push(A.at(i));
    }

    while(M > 0){
        ll a = ans.top();
        a = a/2;
        ans.pop();
        ans.push(a);
        M--;
    }

    ll sum = 0;
    for(int i=0; i<N; i++){
        sum += ans.top();
        ans.pop();
    }

    cout << sum << endl;
}

Measured memory_bytes: 2168
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define vi vector<int>
#define vii vector<vector<int>>
#define vpi vector<pair<int,int>>
#define w(t) int t;cin>>t;while(t--)
#define pi pair<int,int>
#define mii map<int,int>
#define pb push_back
#define ff first
#define ss second
#define FOR(i,t,n) for(int i=t;i<n;i++)
#define SCI(x)  scanf("%d",&x)
#define SCL(x) scanf("%lld",&x)

ll factor(ll c){
	ll d  =  1 + 4*c ;
	ll ans =(sqrt(d) - 1 );
//	cout<<ans<<endl;
	return ans/2;
}

map<ll,ll> m;

void primeFactor(ll n){
	for(ll i = 2;i*i 	< n; i++){
		if(n%i == 0){
			ll c = 0;
			while(n%i == 0){
				c++;
				n = n/i;
			}

			m[i] = c;
		}
	}
	if(n > 1){
		m[n] = 1;
	}
}

void solve(){
	ll n;
	cin>>n;
	primeFactor(n);
	ll ans = 0;
	for(auto it : m){
		ans += factor(2*it.ss);
	}
	cout<<ans<<endl;
}


int main()
{

	solve();

//	cout<<factor(8)<<endl;
}

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

void solve(long long N, long long K, long long X, long long Y){
    if (N > K) cout <<  K * X + (N - K) * Y << '\n';
    else cout << N * X << '\n';
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    long long X;
    scanf("%lld",&X);
    long long Y;
    scanf("%lld",&Y);
    solve(N, K, X, Y);
    return 0;
}


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

using namespace std;

using ll = long long;

int n, m, root;
vector<vector<int>> adj;
vector<int> par, in_deg;

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

    cin >> n >> m;
    adj.resize(n);
    par.resize(n, -1);
    in_deg.resize(n);

    for (int i = 0; i < n + m - 1; ++i) {
        int u, v;
        cin >> u >> v;
        adj[u - 1].push_back(v - 1);
        ++in_deg[v - 1];
    }

    for (int v = 0; v < n; ++v) {
        if (in_deg[v] == 0) {
            root = v;
            break;
        }
    }

    queue<pair<int, int>> que;
    que.push(make_pair(-1, root));
    while (!que.empty()) {
        const auto cur = que.front(); que.pop();
        const int v = cur.second, p = cur.first;
        if (v != root) {
            par[v] = p;
            --in_deg[v];
        }
        if (in_deg[v] == 0) {
            for (auto u : adj[v])
                que.push(make_pair(v, u));
        }
    }

    for (int v = 0; v < n; ++v)
        cout << (par[v] == -1 ? 0 : par[v] + 1) << '\n';

    return 0;
}


Measured memory_bytes: 7040
function main(input) {
  const inputList = input.split(/\s/).map(inp => formatNum(inp));
  const apple = inputList[0];
  var ajiList = [];
  for (var i = 1; i <= apple; i++) {
    ajiList.push(inputList[1] - 1 + i);
  }
  const hoseiList = ajiList.map(aji => Math.abs(aji));
  var result = 0;
  const sum = ajiList.reduce((ac, cu) => ac + cu);
  const hoseiRet = Math.min(...hoseiList);
  if (sum >= 0) {
    result = sum - hoseiRet
  } else {
    result = sum + hoseiRet
  }
  console.log(result);
};

// 文字列を数値に変換
function formatNum(str) {
  return Number(str);
};

main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
#include <stdio.h>
    int main(){
    	int N,k,i,x,ans=0;
    	scanf("%d %d",&N,&k);
    	ans = (N-1)/(k-1);
    	if( (N-1)%(k-1)>0){
    		ans++;
    	}
    	printf("%d",ans);
    	return 0;
    }

Measured memory_bytes: 128
#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(non_upper_case_globals)]


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<_>>()
    };

    ($next:expr, [$t:tt]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $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")
    };
}


#[cfg(debug_assertions)]
macro_rules! mydbg {
    //($arg:expr) => (dbg!($arg))
    ($arg:expr) => (println!("{:?}",$arg));
}


#[cfg(not(debug_assertions))]
macro_rules! mydbg {
    ($($arg:expr),*) => {};
}


use std::cmp;
use std::collections::HashMap;


static INF_I64 :i64 = 9223372036854775807;
static INF_I32 : i32 = 2147483647;




fn main() {

    input! { 
       n: usize,
       x: i64,
       a: [ i64;n],
    }

    //let mut ans = vec![0;n];
    let mut a = a;

    let mut sum1= a[0];
    a[0] = cmp::min(x,a[0]);
    let mut sum2 = a[0];
    

    for i in 1..n{
        sum1+= a[i];
        a[i] = if a[i-1] + a[i] < x { a[i] } else { x - a[i-1] };
        sum2+=a[i];
    }
    
    
    println!("{}",sum1-sum2);


}


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

using namespace std;

#define loop(i,a,b) for(int i=(a); i<int(b); i++)
#define rep(i,b) loop(i,0,b)
#define all(c) (c).begin(),(c).end()
#define iter(it,c) for(auto it=c.begin(); it!=c.end(); ++it)

typedef vector<int> vi;
typedef vector<vi> vvi;

struct team {
    team(){}
    team(int id) : id(id), pena(0), solved(0){
        rep(i,20) submit[i].clear();
    }
    int id;
    int pena;
    vi submit[20];
    int solved;
};

int main(){
    int T,P,R;
    while(cin>>T>>P>>R, T|P|R){
        vector<team> ts(T);
        rep(i,T){
            ts[i] = i+1;
        }
        rep(i,R){
            int who, prob, when;
            string res;
            cin >> who >> prob >> when >> res;
            team & t = ts[who-1];
            t.submit[prob].push_back(when);
            if(res[0]=='C'){
                t.solved++;
                t.pena += (t.submit[prob].size()-1) * 1200 + when;
            }
        }

        sort(all(ts),[](team const& a, team const& b){
                if(a.solved != b.solved) return a.solved > b.solved;
                if(a.pena != b.pena) return a.pena < b.pena;
                return a.id < b.id;
            });

        iter(it, ts){
            printf("%d %d %d\n",
                   it->id,
                   it->solved,
                   it->pena);
        }
    }
}

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

int main(){
	int w,h,n ;
	cin >> w >> h >> n ;
	vector<vector<bool>> graph(h,vector<bool>(w,true)) ;
	for(int i=0;i<n;i++){
		int x,y,a ;
		cin >> x >> y >> a ;
		if(a==1){
			for(int j=0;j<h;j++){
				for(int k=0;k<x;k++){
					graph.at(j).at(k) = false ;
				}
			}
		}else if(a==2){
			for(int j=0;j<h;j++){
				for(int k=x;k<w;k++){
					graph.at(j).at(k) = false ;
				}
			}
		}else if(a==3){
			for(int j=0;j<y;j++){
				for(int k=0;k<w;k++){
					graph.at(j).at(k) = false ;
				}
			}
		}else{
			for(int j=y;j<h;j++){
				for(int k=0;k<w;k++){
					graph.at(j).at(k) = false ;
				}
			}
		}
	}
	int ans = 0 ;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(graph.at(i).at(j)) ans++ ;
		}
	}
	cout << ans << endl ;
}

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

int M, N, K;
int jt[1010][1010];
int ot[1010][1010];
int it[1010][1010];

int main() {
  cin >> M >> N >> K;
  for (int i=1; i<=M; i++) {
    int hj = 0, ho = 0, hi = 0;
    for (int j=1; j<=N; j++) {
      char c; cin >> c;

      jt[i][j] = jt[i-1][j] + hj;
      ot[i][j] = ot[i-1][j] + ho;
      it[i][j] = it[i-1][j] + hi;

      if (c == 'J') { jt[i][j]++; hj++; }
      if (c == 'O') { ot[i][j]++; ho++; }
      if (c == 'I') { it[i][j]++; hi++; }
    }
  }

  for (int i=0; i<K; i++) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    cout << jt[c][d] - jt[a-1][d] - jt[c][b-1] + jt[a-1][b-1] << " "
         << ot[c][d] - ot[a-1][d] - ot[c][b-1] + ot[a-1][b-1] << " "
         << it[c][d] - it[a-1][d] - it[c][b-1] + it[a-1][b-1] << "\n";
  }
  return 0;
}

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n,k; cin>>n>>k;
	vector<int>px(1,0),mx;
	for(int i=0;i<n;++i){
		int x; cin>>x;
		if(x>0)px.emplace_back(x);
		else mx.emplace_back(-x);
	}
	mx.emplace_back(0);
	reverse(mx.begin(),mx.end());
	int64_t ans=1e18;
	for(int i=min(k,max(0,(int)px.size()-1)),j=k-i;i>=0&&j<mx.size();--i,++j){
		ans=min(ans,min(1L*px.at(i)*2+mx.at(j),1L*px.at(i)+mx.at(j)*2));
	}
	cout<<ans<<"\n"s;
}


Measured memory_bytes: 3984
import math
n = int(input())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
d = [1, 2, 3, 4]
D = [0.0]*5
for i in d:
    if i == 1:
        D[i] = sum((abs(x[j] - y[j]) for j in range(n)))
    elif i == 2:
        D[i] = math.sqrt(sum((x[j] - y[j])**2 for j in range(n)))
    elif i == 3:
        D[i] = (sum(abs(x[j] - y[j])**3 for j in range(n)))**(1.0/3)
    else:
        D[i] = max(abs(x[j] - y[j]) for j in range(n))
    print('%.6f' % D[i])


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

int main(void)
{
  char s1[10],s2[10],s3[10],ans[10];
  
  scanf("%s",s1);
  scanf("%s",s2);
  scanf("%s",s3);  
  
  ans[0]=s1[0];
  ans[1]=s2[1];
  ans[2]=s3[2];
  ans[3]='\0';
  
  printf("%s",ans);    
  
  return 0; 
}

Measured memory_bytes: 128
#-swank
(unless (member :child-sbcl *features*)
  (quit
   :unix-status
   (process-exit-code
    (run-program *runtime-pathname*
                 `("--control-stack-size" "128MB"
                   "--noinform" "--disable-ldb" "--lose-on-corruption" "--end-runtime-options"
                   "--eval" "(push :child-sbcl *features*)"
                   "--script" ,(namestring *load-pathname*))
                 :output t :error t :input t))))
(defmacro dp (name args memo-size &body body)
  (let ((memo (gensym)))
    `(let ((,memo (make-array ,memo-size :initial-element nil)))
       (defun ,name ,args
         (or (aref ,memo ,@args)
             (setf (aref ,memo ,@args)
                   ,@body))))))

(defun split (x str)
  (let ((pos (search x str))
        (size (length x)))
    (if pos
        (cons (subseq str 0 pos)
              (split x (subseq str (+ pos size))))
        (list str))))

(defmacro collect-times (time body)
  `(loop repeat ,time collect ,body))

(defun read-times (time)
  (collect-times time (read)))

(defun binary-search (l r f &aux (m (ash (+ l r) -1)))
  "f の結果がtになる最小の値を見つけます"
  (if (= l r)
      l
      (if (funcall f m)
          (binary-search l m f)
          (binary-search (1+ m) r f))))

(defmacro aif (expr then else)
    `(let ((it ,expr))
       ,then
       ,else))

(defun main (a b &aux (dis (abs (- a b))))
  (- (ash (* dis (1+ dis)) -1) (max a b)))

#-swank
(princ (main (read) (read)))


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

int count(int &a, int &b){
	
	
	if(b==1){
		return 0;
	}
	
	if(a==b || a>b){
		return 1;
	}
	
	b = b-a;
	int count = 1 ;
	a=a-1;
	
	while(b>0){
		b = b-a;
		count++;
		
	}
	return count;
}

int main(){
	int s,t;
	cin>>s>>t;
	cout<<count(s,t);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,i = 0;
  string S;
  string ans = "Three";
  cin >> N;
  while (i < N){
    cin >> S;
    if (S == "Y"){
        ans = "Four";
        break;
        }
    ++i;
    }
  cout << ans << endl;
}

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

int main()
{
    ll n,i,j,t,sz,dp[100];
    string s;
    while(cin>>s)
    {

       if(s[0]==s[1]&&s[2]==s[1]&&s[3]&&s[1]||s[0]==s[1]&&s[0]==s[2]||s[1]==s[2]&&s[1]==s[3])
       printf("Yes\n");
       else printf("No\n");


    }
}


Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
#include<string>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#include <iomanip>
#pragma region Macros
#define int long long
#define double long double
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define LAST(x) x[x.size()-1]
#define ALL(x) (x).begin(),(x).end()
#define swap(a,b) (a += b,b = a - b,a -= b)
#define CEIL(a,b) ((a+b-1)/b)
int FACT(int a) {
	if (a == 0)
		return 1;
	else
		return a * FACT(a - 1);
}
int nPr(int n, int r) {
	int s = n - r + 1;
	int sum = 1;
	for (int i = s; i <= n; i++)
		sum *= i;
	return sum;
}
//int nCr(int n, int r)
int nCr2(int n, int r) {
	return FACT(n) / (FACT(r) * FACT(n - r));
}
int GCD(int a, int b) // assuming a,b >= 1
{
	if (a < b)
		swap(a, b);
	if (b == 0)
		return a;
	if (a % b == 0)
		return b;
	return GCD(b, a % b);
}
int LCM(int a, int b) // assuming a,b >= 1
{
	return  a * b / GCD(a, b);
}
double LOG(int a, int b) {
	return log(b) / log(a);
}
inline bool BETWEEN(int x, int min, int max) {
	if (min <= x && x <= max)
		return true;
	else
		return false;
}
inline bool PRIMEOR (int x) {
	if (x ==1)
		return false;
	if (x == 2)
		return true;
	if (x%2==0)
		return false;
	double sqrtx = sqrt(x);
	for (int i = 3; i <= sqrtx; i += 2) {
		if (x % i == 0)
			return false;
	}
	return true;
}

using namespace std;
#pragma endregion

signed main() {
	int N,A,B,z=0;
	cin >> N >> A >> B;
	cout << min(A,B) << " " <<max(z,(A+B)-N);
}

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

int main()
{
    int n,l;
    cin >> n >> l;
    vector<string>v;
    for(int i=0;i<n;i++)
    {
        string str;
        cin >> str;
        v.push_back(str);
    }
    sort(v.begin(),v.end());
    for(int i=0;i<n;i++)
        cout << v[i];

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//関数
const long INF=1000000000000000;

int main(void){
    long N,K;
    cin>>N>>K;
    
    long S=(N-1)*(N-2)/2-K;
    if(S<0){
        cout<<-1<<endl;
        return 0;
    }
    
    cout<<N-1+S<<endl;
    
    for(int i=2;i<=N;i++){
        cout<<1<<" "<<i<<endl;
    }
    
    long count=0;
    
    for(int i=2;i<N;i++){
        for(int j=i+1;j<=N;j++) {
            if(count>=S) return 0;
            cout<<i<<" "<<j<<endl;
            count++;
        }
    }
}

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

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

signed main(void){
    int n;
    vector<int> x,y;
    cin>>n;
    REP(i,n){
        int temp;
        cin>>temp;
        x.push_back(temp);
        y.push_back(temp);
    }
    sort(y.begin(),y.end());
    int m1=y[n/2-1];
    int m2=y[n/2];
    for(int p : x){
        if (p<=m1)cout<<m2<<endl;
        else if(p>=m2)cout<<m1<<endl;
    }
}


Measured memory_bytes: 5476
import numpy as np
cnt=0
N=int(input())
S=np.zeros((10,10),dtype=int)
#print(S)
for i in range(1,N+1):
  T=str(i)
  A=int(T[0])
  B=int(T[-1])
  S[A][B]+=1
#print(S)
for i in range(1,10):
  for j in range(1,10):
    cnt=cnt+S[i][j]*S[j][i]
print(cnt)

Measured memory_bytes: 12424
#include <stdio.h>
int main(){

  int i,n,m,p,k,x[101];
  int sum,s,re;
  while(1){
    scanf("%d%d%d",&n,&m,&p);
    if(n==0&&m==0&&p==0) break;
    sum=0; 
    for(i=1;i<=n;i++){
      scanf("%d",&x[i]);
      sum+=x[i];
      if(i==m) {
        k=x[i];
      }
    }
    re=(double)100*sum*(100-p)/100;
    if(k!=0)re/=k;
    else re=0;
    //    re=sum*(100-p)/100;
    printf("%d\n",re);
    // s=(double)p/(double)100;
    //re*=s;
   

    //  re = sum * p;

    // printf("%d\n",re/k);
    /*
   if(k>0){
     re/=k;
     printf("%d\n",(int)re);
    }
    else{
      printf("%d\n",0);
    }
    */
  }

  return 0;
}

Measured memory_bytes: 596
import java.util.*;
import java.awt.*;
import java.awt.event.*;
public class Main {
	static Scanner sc = new Scanner(System.in);
	static int n, ans;
	static double p[];
	static double[] count = new double[10500];
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		ans = 0;
		while(read()){
			slove();
		}

	}
	static boolean read(){
		n = sc.nextInt();
		if(n == 0)
			return false;
		
		return true;
	}
	static void slove(){
		Prime(n);
		System.out.println((int)count[n]);
	}
	static void Prime(int a){
		p = new double[110000+1];
		int j = 1;
		count[0] = 0;
		for(int i = 0; i < p.length; i++)
			p[i] = 1;
		for(double i = 2; i < p.length; i++){
			if(p[(int)i] == 1){//ツ素ツ青板づーツ個ゥツづつつッツつスツづつォ
				//System.out.println(i);
				count[j] = (int)i + count[j-1];
				j++;
				for(double k = i; k*i < p.length; k++)
					p[(int)(i*k)] = 0;
			}
		}
		//System.out.println("j = "+j);
	}

}

Measured memory_bytes: 17000
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define MAXN	100000
struct edge
{
  int v,n;
  ll w;
  edge():v(0),w(0),n(0){}
  edge(int vv, ll ww, int nn):v(vv),w(ww),n(nn){}
};
edge E[MAXN<<1];
int nE;
int front[MAXN+1];
void add_edge(int u, int v, ll w)
{
  int ne = ++nE;
  E[ne] = edge(v,w,u[front]);
  u[front] = ne;
}
int solid[MAXN+1];
ll d[MAXN+1];
void dijstra(int s)
{
  set< pair<ll,int> > q;
  memset(solid,0,sizeof(solid));
  memset(d, -1, sizeof(d));
  d[s] = 0; solid[s] = 1;
  q.insert(make_pair(0ll,s));
  while(!q.empty())
  {
    auto p = q.begin();
    int u = p->second;
    solid[u] = 1;
    q.erase(p);
    for(int e=u[front];e;e = E[e].n)
    {
      int v = E[e].v; ll w = E[e].w;
      if((!solid[v]) && ((-1 == d[v]) || (d[u]+w < d[v])))
      {
        q.erase(make_pair(d[v],v));
        d[v] = d[u]+w;
        q.insert(make_pair(d[v],v));
      }
    }
  }
}
int main(void)
{
  int N = 0;
  int a = 0, b = 0;
  ll c = 0;
  scanf("%d", &N);
  while(--N)
  {
    scanf("%d %d %lld", &a, &b, &c);
    add_edge(a,b,c);
    add_edge(b,a,c);
  }
  int Q = 0, K = 0;
  int x = 0, y = 0;
  scanf("%d %d", &Q, &K);
  dijstra(K);
  while(Q--)
  {
    scanf("%d %d", &x, &y);
    printf("%lld\n", d[x]+d[y]);
  }
  return 0;
}


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

typedef long long ll;
#define REP(i,n) for(ll i=0; i<(ll)(n); i++)
#define REPM(i,n) for(ll i=(n-1); 0=<i; i--)
#define VI vector<int>
#define VL vector<ll>
#define VD vector<double>
#define VS vector<string>
#define V_SORT_U(x) sort(x.begin(), x.end());
#define V_SORT_D(x) sort(x.begin(), x.end(),greater<int>());
#define V_SUM(x) accumulate(x.begin(), x.end(), 0)
#define STR_TRANS_UP(x) transform(x.begin(), x.end(), x.begin(), ::toupper);
#define STR_TRANS_LOW(x) transform(x.begin(), x.end(), x.begin(), ::tolower);

int main(void){
    ll S, W;
    cin >> S >> W;

    if( S <= W)
    {
        cout << "unsafe" << endl;
    }
    else{
        cout << "safe" << endl;
    }

    return 0;
}

Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {

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

        int n = scanner.nextInt();
        boolean denided = false;
        for (int i = 0; i < n; i++) {
            int a = scanner.nextInt();
            if (a % 2 == 0) {
                if (a % 3 != 0 && a % 5 != 0) {
                    denided = true;
                    break;
                }
            }
        }
        System.out.println(denided ? "DENIED" : "APPROVED");
    }
}

Measured memory_bytes: 23892
#include<bits/stdc++.h>
#define eps 1e-9
#define MOD 998244353
#define INV_10 299473306
#define INF 1000000000
using namespace std;
int main()
{
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int k;
	string s;
	cin >> k >> s;
	for(int i = 0; i < min(k, (int)(s.length())); i++)
		cout << s[i];
	if(s.length() > k)
		cout << "...";
}

Measured memory_bytes: 3612
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author TM
 */


#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <cmath>
#include <numeric>
#include <iterator>

#define SIZE 100005
#define MOD 1000000007
#define INF 100000000
#define PI 3.14159265358979323846264338

using namespace std;

class DWaterBottle {
public:
    void solve(std::istream &cin, std::ostream &cout) {
        double a, b, x;
        cin >> a >> b >> x;
        double border = a * a * b / 2;
        if (border <= x) {
            double tmp = a * a * b - x;
            double ttmp = 2 * tmp / a;
            double ans = 180.0 * atan(ttmp / a / a) / PI;
            printf("%.12f\n", ans);
        } else {
            double tmp = 2.0 * x / (a * b);
            double ans = 180.0 * (atan(b / tmp) / PI);
            printf("%.12f\n", ans);
        }
    }
};


int main() {
    DWaterBottle solver;
    std::istream &in(std::cin);
    std::ostream &out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 256
import sys, bisect, math, itertools, heapq, collections
from operator import itemgetter
# a.sort(key=itemgetter(i)) # i番目要素でsort
from functools import lru_cache
# @lru_cache(maxsize=None)
sys.setrecursionlimit(10**8)
input = sys.stdin.readline
INF = float('inf')
mod = 10**9 + 7
eps = 10**-7


def inp():
    '''
    一つの整数
    '''
    return int(input())


def inpl():
    '''
    一行に複数の整数
    '''
    return list(map(int, input().split()))


def str_inp():
    '''
    文字列をリストとして読み込む
    '''
    return list(input()[:-1])


n, m, k = inpl()
a = inpl()
b = inpl()
tmp = 0
for i in range(len(a)):
    tmp += a[i]
    a[i] = tmp
tmp = 0
for i in range(len(b)):
    tmp += b[i]
    b[i] = tmp
ans = 0
a_start = bisect.bisect_right(a, k)
ans = bisect.bisect_right(b, k)
for a_amount in range(a_start, 0, -1):
    new_k = k - a[a_amount - 1]
    b_amount = bisect.bisect_right(b, new_k)
    ans = max(ans, a_amount + b_amount)
print(ans)


Measured memory_bytes: 107772
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
#include <cassert>
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) (int)(x).size()
using namespace std;
using ll = long long;
constexpr ll INF = 3000000000000000000;

int main() {
    int N;
    cin >> N;
    string S;
    cin >> S;
    
    map<pair<string, string>, int> mp;
    REP(bit, 1 << N) {
        string s, t;
        REP(i, N) {
            if ((bit >> i) & 1) s.push_back(S[N + i]);
            else t.push_back(S[N + i]);
        }
        reverse(ALL(t));
        ++mp[{s, t}];
    }
    
    ll ans = 0;
    REP(bit, 1 << N) {
        string s, t;
        REP(i, N) {
            if ((bit >> i) & 1) s.push_back(S[i]);
            else t.push_back(S[i]);
        }
        reverse(ALL(t));
        ans += mp[{t, s}];
    }
    
    cout << ans << "\n";
    
    return 0;
}


Measured memory_bytes: 60968
n = int(input())
alp = "abcdefghijklmnopqrstuvwxyz"
d = {i+1:s for i, s in enumerate(alp)}
s = ""
while True:
    q, mod = divmod(n, 26)
    if mod == 0:
        s = "z" + s
        n = q-1
    else:
        s = d[mod] + s
        n = q
    if n == 0:
        break
print(s)

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

int main()
{
  int n;
  ll sum,pro,ans;

  cin>>n;
  vector<ll>arr(n),arans(n);
  sum=0;ans=0;
  for(int i=0;i<n;i++){
    cin>>arr[i];
    sum+=arr[i];
    arans[i]=sum;
  }
  for(int i=0;i<n;i++){
    pro = (arr[i]*((arans[n-1]-arans[i])%mod))%mod;
    ans+=pro;
    ans = ans%mod;
  }
  cout<<ans<<endl;


    return 0;
}




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

// ユークリッドの互除法
long long gcd(long long a, long long b) {
    long long x = max(a, b);
    long long y = min(a, b);

    if(x % y == 0) return y;
    return gcd(y, x % y);
}

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


int main() {
    long long a, b;
    cin >> a >> b;
    cout << lcm(a, b) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <fstream>
#include <vector>
#include <bitset>
#include <unordered_map>
#include <algorithm>
#include <queue>
#include <math.h>
#include <iomanip>
 
using namespace std;
  
/********** TEMPLATE STARTS HERE ***********/
    
#define IOS ios::sync_with_stdio(false), cin.tie(0);
#define all(v) v.begin(), v.end()
#define F first
#define S second
#define pb push_back
#define test int t; cin >> t; while(t--)
#define skip continue
#define stop break
#define sz(v) (int)v.size()
#define endl '\n'
#define PI 3.1415926535897932384626433832795
#define EPS 1e-9
#define gcd __gcd 
#define mp make_pair
#define debug(a) cout << #a << ": " << a << endl
#define debug1(a, l, r) FR(i, l, r) cout << a[i] << " "; cout << endl
#define SET(a, b) memset(a, b, sizeof(a));
#define refresh fflush(stdout);
#define digits(n) (int)(log10(n) + 1)
  
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <int> vi;
typedef vector <long long> vl;
typedef vector <pii> vii;
typedef vector <pll> vll;
    
const int INF = 0x3f3f3f3f;
const int LINF = 0x3f3f3f3f3f3f3f3f;
    
template <typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template <typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
   
/*********** TEMPLATE ENDS HERE *************/

main()
{
	IOS
	
	string s;
	cin >> s;
	
	for(auto i : s)
		if(i == '1')
			cout << 9;
		else
			if(i == '9')
				cout << 1;
			else
				cout << i;
}

Measured memory_bytes: 768
using System;

namespace ABC131
{
    class C
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            long a = long.Parse(input[0]);
            long b = long.Parse(input[1]);
            long c = long.Parse(input[2]);
            long d = long.Parse(input[3]);

            long lcm = (c * d) / CalGcd(c, d);

            long res = (b - a + 1) - (b / c - (a - 1) / c) - (b / d - (a - 1) / d) + (b / lcm - (a - 1) / lcm);

            Console.WriteLine(res);

        }

        static long CalGcd(long a, long b)
        {
            if (b == 0) { return a; }
            return CalGcd(b, a % b);
        }
    }
}





Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll=long long;
using P = pair<int,int>;
using LP=pair<ll,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
const ll MOD=1000000007,MOD2=998244353;



int main() {
    int A,B,C;
    cin>>A>>B>>C;
    cout<<min(C,B/A)<<endl;
}

Measured memory_bytes: 3636
#include <stdio.h>
#include <string.h>
#define MAX 21

void init(int);
void move(int);

int n, x, y;
char fld[MAX][MAX];

int main(void) {
    int m;
    while(~scanf("%d", &n), n) {
        init(n);
        scanf("%d", &m);
        move(m);
        printf("%s\n", n ? "No" : "Yes");
    }
    return 0;
}

void init(int i) {
    int a, b;
    x = y = 10;
    memset(fld, 0, sizeof(fld));
    while(i--) {
        scanf("%d %d", &a, &b);
        fld[b][a] = 1;
    }
}

void move(int i) {
    int a, d;
    char buf[2];
    while(i--) {
        scanf("%1s %d", buf, &a);
        switch(buf[0]) {
          case 'N':
            d = 0;
            break;
          case 'E':
            d = 1;
            break;
          case 'S':
            d = 2;
            break;
          case 'W':
            d = 3;
            break;
        }
        while(a--) {
            d % 2 ? ~-d ? x-- : x++ : d ? y-- : y++;
            if(fld[y][x]) {
                fld[y][x] = 0;
                n--;
            }
        }
    }
}

Measured memory_bytes: 584
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("filed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let h:usize = read();
    let w:usize = read();
    let mut grid:Vec<Vec<char>> = vec![Vec::new(); h];
    for i in 0..h {
        grid[i] = read::<String>().chars().collect();
    }
    let mut ans = vec![vec![0; w]; h];
    for i in 0..h {
        for j in 0..w {
            if grid[i][j] == '#' {
                ans[i][j] = -1;
                for dy in vec![-1isize, 0, 1] {
                    for dx in vec![-1isize, 0, 1] {
                        let ny = (i as isize + dy) as usize;
                        let nx = (j as isize + dx) as usize;
                        if ny >= h || nx >= w {
                            continue;
                        }
                        if grid[ny][nx] == '#' {
                            continue;
                        }
                        ans[ny][nx] += 1;
                    }
                }
            }
        }
    }
    for i in 0..h {
        for j in 0..w {
            if ans[i][j] == -1 {
                print!("#");
            } else {
                print!("{}", ans[i][j]);
            }
        }
        println!("");
    }
}


Measured memory_bytes: 2188
import math , sys

N = int(input())
Ns = int(math.sqrt(N))+1
if N == 1:
    print(1)
    sys.exit()
if N == 2:
    print(5)
    sys.exit()
if N == 3:
    print(11)
    sys.exit()
if N == 4:
    print(23)
    sys.exit()
if N == 5:
    print(33)
    sys.exit()  

ans = [ 2 for _ in range(N+1)]
ans[0]=0
ans[1]=1
for i in range(2,Ns):
    num=i
    while num < N+1:
        if math.sqrt(num)<i:
            flag=True
        elif num == i**2:
            ans[num]+=1
        else:
            ans[num]+=2
        num+=i
tot = 0
for i in range(N+1):
    tot+=i*ans[i]
print(tot)

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

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

    	while((input = br.readLine()) != null){
    		if(input.equals("0")) break;
    		char[] cArray = input.toCharArray();
    		for(char c : cArray){
    			total += Character.getNumericValue(c);
    		}
    		System.out.println(total);
    		total = 0;
    	}
    }
}

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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


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


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define lli long long int
using namespace std;

vector<lli> T;

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

lli gcd_vector(vector<lli>& a, lli b) {
    lli ma = 1;
    for(int i=0; i<T.size(); i++)
        ma = ma*T[i]%b;
    return gcd(b, ma);
}

lli qpow(lli a, lli b) {
	lli res = 1;
	while (b) {
		if (b & 1) res = res * a % 1000000007;
		a = 1ll * a * a % 1000000007;
		b >>= 1;
	}
	return res; 
}
const int N = 11111;
int n, a[N]; 
int main() {
	cin >> n; 
	for (int i = 1; i <= n; i++) cin >> a[i];
	
    lli answer = 1;
    for(int i=1; i<=n; i++) {
        lli factor = a[i]/gcd_vector(T, a[i]); 
        T.push_back(factor);
        answer = (answer*factor)%1000000007;
    }
	lli ans = 0; 
for (int i = 1; i <= n; i++) ans = (ans + 1ll * answer * qpow(a[i], 1000000005) % 1000000007) % 1000000007;
	cout << ans << endl;
}

Measured memory_bytes: 512
class UnionFind:
    # 初期化
    def __init__(self, n):
        # 根なら-size, 子なら親の頂点
        self.par = [-1] * n
        # 木の高さ
        self.rank = [0] * n

    # 検索
    def find(self, x):
        if self.par[x] < 0:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    # 併合
    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        # 異なる集合に属する場合のみ併合
        if x != y:
            # 高い方をxとする。
            if self.rank[x] < self.rank[y]:
                x,y = y,x
            # 同じ高さの時は高さ+1
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            # yの親をxとし、xのサイズにyのサイズを加える
            self.par[x] += self.par[y]
            self.par[y] = x

    # 同集合判定
    def same(self, x, y):
        return self.find(x) == self.find(y)

    # 集合の大きさ
    def size(self, x):
        return -self.par[self.find(x)]


import operator

n = int(input())
z = [list(map(int, input().split())) for i in range(n)]

for i in range(n):
    z[i].append(i)

u = UnionFind(n)
z.sort()
for i in range(1,n):
    if z[i][0]==z[i-1][0]:
        u.unite(z[i][2],z[i-1][2])

z.sort(key=operator.itemgetter(1))
for i in range(1,n):
    if z[i][1]==z[i-1][1]:
        u.unite(z[i][2],z[i-1][2])

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

z.sort(key=operator.itemgetter(2))
for i in range(n):
    l[u.find(i)].append(z[i])

ans = 0
for i in range(n):
    if l[i]!=[]:
        x = set()
        y = set()
        for a in l[i]:
            if a[0] not in x:
                x.add(a[0])
            if a[1] not in y:
                y.add(a[1])
        ans += len(x)*len(y)-len(l[i])
print(ans)


Measured memory_bytes: 112344
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long

signed main(){

  int n; cin >> n;
  vector<int> p(n),order(n);
  for(int i = 0; i < n; i++){
    cin >> p[i];
    p[i]--;
    order[p[i]] = i;
  }

  multiset<int> st;
  st.insert(-1);
  st.insert(-1);
  st.insert(n);
  st.insert(n);
  int ans = 0;
  for(int i = n-1; i >= 0; i--){
    auto p = st.lower_bound(order[i]);
    int r = *p++;
    int rr = *p--;
    p--;
    int l = *p--;
    int ll = *p;
    int res = (order[i] - l) * (rr - r) + (r - order[i]) * (l - ll);
    ans = (ans + res * (i+1));
    st.insert(order[i]);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 6528
#include<iostream>
#include<algorithm>
#include<iomanip>
#include<string>
#include<vector>

typedef unsigned long long ULL;
typedef long long LL;

using namespace std;

int main(){
    int A,B;
    int ans;
    int count = 0;
    cin >> A >> B;
    ans = 1;
    while( ans < B){
        ans += A - 1;
        count++;
    }

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


Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      double[] x = new double[n];
      String[] u = new String[n];
      double sum = 0;
      for(int i = 0;i < n;i++){
      	x[i] = sc.nextDouble();
        u[i] = sc.next();
        if(u[i].equals("JPY")){
        	sum += x[i];
        }else if(u[i].equals("BTC")){
        	sum += x[i]*380000;
        }
      }
      System.out.println(sum);
    }
}

Measured memory_bytes: 22740
#include <bits/stdc++.h>
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define INF 9000000000000000000  //  9.0 * 10^18
#define MOD 1000000007
#define PAI 3.14159265358979
// ver1.7
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm

signed main() {
  cout << fixed << setprecision(14);
  map<int,int> kind;
  int n;
  cin >> n;
  int memo;
  rep(i,0,n){
    cin >> memo;
    kind[memo]++;
  }
  int ans=0;
  
  for (auto p : kind) {
    auto v = p.second;
    if(v%2==1) ans++;
  }
  
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 6528
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define drep(i,a,b) for(ll i=(a);i>=(b);--i)
#define SIZE(a) int((a).size())
#define out(a) cout<<(a)<<endl;
const int INF=INT_MAX;
const int MAX = 510000;
const ll MOD = 1000000007;
ll fac[MAX], finv[MAX], inv[MAX];
ll gcd(ll a,ll b){
   if (a%b == 0){
        return(b);
    }
   else{
       return(gcd(b, a%b));
    }
}
vp factorize(ll n) {
    vp res;
    for (ll i = 2; i * i <= n; i++) {
        if (n % i != 0) continue;
        res.emplace_back(i,0);
        while (n % i == 0) {
            n /= i;
            res.back().second++;
        } 
    }
    if (n != 1) res.emplace_back(n,1);
    return res;
}
int main(){
  ll a,b;cin>>a>>b;
  ll t=gcd(a,b);
  vp ans=factorize(t);
  cout<<ans.size()+1<<endl;
}



Measured memory_bytes: 3576
n, m, r = map(int, input().split())
R = tuple(map(lambda x: int(x)-1, input().split()))
INF = 10**9
dp = [[INF]*n for _ in range(n)]

for _ in range(m):
    a, b, c = map(int, input().split())
    a -= 1
    b -= 1
    dp[a][b] = c
    dp[b][a] = c

for k in range(n):
    for i in range(n):
        for j in range(n):
            dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j])

from itertools import permutations
ans = INF
for p in permutations(R):
    dist = 0
    for i in range(r-1):
        dist += dp[p[i]][p[i+1]]
    ans = min(ans, dist)
print(ans)

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

#define _ << " _ " <<
#define TRACE(x) cout << #x << " = " << x << endl



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

    int n;
    cin >> n;

    for (int k = 0; k < 1e4; k++)
        if (k * (k - 1) / 2 == n) {
            vector<vector<int>> s(k);

            int a = 1;

            for (int i = 0; i < k; i++)
                for (int j = i + 1; j < k; j++) {
                    s[i].push_back(a);
                    s[j].push_back(a);
                    a++;
                }

            cout << "Yes\n" << k << "\n";

            for (auto S : s) {
                cout << S.size() << " ";
                for (int i : S) cout << i << " ";
                cout << "\n";
            }

            return 0;
        }

    cout << "No\n";

    return 0;
}



Measured memory_bytes: 2304
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <cassert>

const int N = 1e5 + 7;

int n, m, q;
int a[N];
int visit[N], b[N];
std::vector<int> queue[N];

int main() {
	scanf("%d %d %d", &n, &m, &q);
	for (int i = 1; i <= q; i++) {
		scanf("%d", &a[i]);
	}
	for (int i = 1; i <= n; i++) {
		queue[0].push_back(i);
	}
	for (int i = 1; i <= m; i++) {
		visit[i] = -1;
	}
	int cur = 0;
	for (int i = q; i >= 1; i--) {
		int num = a[i];
		if (visit[num] != -1) {
			int pos = visit[num];
			if (queue[pos - 1].size()) {
				int back = queue[pos - 1].back();
				queue[pos - 1].pop_back();
				queue[pos].push_back(back);
			}
		} else {
			visit[num] = ++cur;
			assert(queue[cur - 1].size());
			int back = queue[cur - 1].back();
			queue[cur - 1].pop_back();
			b[cur] = num;
			queue[cur].push_back(back);
		}
	}
	for (int i = cur + 1, ptr = 1; i <= m; i++) {
		while (visit[ptr] != -1) {
			ptr++;
		}
		b[i] = ptr;
		visit[ptr] = i;
	}
	/*
	printf("b = \n");
	for (int i = 1; i <= m; i++) {
		printf("%d ", b[i]);
	}
	puts("");
	*/
	int least = cur;
	for (int i = 0; i <= cur; i++) {
		if (queue[i].size()) {
			least = i;
			break;
		}
	}
	//printf("%d\n", least);
	for (int i = least + 1; i < m; i++) {
		if (b[i] > b[i + 1]) {
			puts("No");
			return 0;
		}
	}
	puts("Yes");
	return 0;
}


Measured memory_bytes: 7288
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using  namespace std;
class Edge {
  public:
  int u, v, w;
  Edge(int u, int v, int w) : u(u), v(v), w(w) {}
};
#define MAXN 2500
const int Inf = 1000000000;
vector<Edge> edges;
int ans[MAXN];
int n;
bool tof;

void check(queue<int>& que, vector<vector<int>> edge, bool *flag) {
  flag[que.front()] = true;
  while (!que.empty()) {
    int u = que.front();
    que.pop();
    for (int v : edge[u]) {
      if (flag[v] == false) {
        que.push(v);
        flag[v] = true;
      }
    }
  }
}

void bellman_ford(int count) {
  for (int i = 1; i < n; ++i) ans[i] = -Inf;
  rep(i, count - 1) {
    for (Edge tmp : edges) {
      int u, v, w;
      u = tmp.u; v = tmp.v; w = tmp.w;
      if (ans[v] < ans[u] + w) ans[v] = ans[u] + w;
    }
  }
}

int main() {
  int m, p;
  cin >> n >> m >> p;
  int a[m], b[m], c[m];
  rep(i, m) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--; b[i]--; c[i] -= p;
  }

  vector<vector<int>> nor(n), rev(n);
  rep(i, m) {
    nor[a[i]].push_back(b[i]);
    rev[b[i]].push_back(a[i]);
  }
  bool fn[n] = {};
  bool fr[n] = {};
  queue<int> que;
  que.push(0);
  check(que, nor, fn);
  que.push(n-1);
  check(que, rev, fr);

  bool f[n] = {};
  int count = 0;
  rep(i, n) {
    if (f[i] = (fn[i] & fr[i]) ) count++;
  }
 
  rep(i, m) {
    if (f[a[i]] && f[b[i]]) {
      Edge tmp(a[i], b[i], c[i]);
      edges.push_back(tmp);
    }
  }

  bellman_ford(count);
  
  for (Edge tmp : edges) {
    int u, v, w;
    u = tmp.u; v = tmp.v; w = tmp.w;
    if (ans[v] < ans[u] + w) {
      tof = true;
      break;
    }
  }

  if (ans[n-1] < 0) ans[n-1] = 0;
  if (tof) ans[n-1] = -1;
  cout << ans[n-1] << endl;
  return 0;
}

Measured memory_bytes: 768
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include <cmath>
#include <limits>
#include <utility>
#include <map>
#include <iomanip>


#define rep(p,q) for(int i = p;i < q;i++)
#define ll long long

using namespace std;

const int CONS = 1e9 + 7;
const ll INF = 1e16 + 7;

//64C
int main(void) {
	int n;
	cin >> n;
	int colors[9]{ 0 };
	rep(0, n) {
		int a;
		cin >> a;
		if (a < 400)colors[0]++;
		else if (a < 800)colors[1]++;
		else if (a < 1200)colors[2]++;
		else if (a < 1600)colors[3]++;
		else if (a < 2000)colors[4]++;
		else if (a < 2400)colors[5]++;
		else if (a < 2800)colors[6]++;
		else if (a < 3200)colors[7]++;
		else colors[8]++;
	}
	int colorCount = 0;
	rep(0, 8) {
		if (colors[i] > 0)colorCount++;
	}
	int multiCount = colors[8];
	if (colorCount == 0) cout << 1 << " " << multiCount << endl;
	else cout << colorCount << " " << colorCount + multiCount << endl;
}


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

int main()
{
    int n;
    cin>>n;
    long long int a[n];

    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a,a+n);
    int s=0,i=1;
    long long int cum=a[0];
    while(i!=n){
        if(2*cum>=a[i]){
            cum+=a[i];
            i++;
            //s++;
        }
        else{
            cum+=a[i];
            s=i;
            i++;
        }
    }
    cout<<n-s;
return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    string ans = c-b==b-a?"YES":"NO";
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      	String a = sc.next();
      	String b = sc.next();
      	String c = sc.next();
      
      	if(a.charAt(a.length()-1)==b.charAt(0) && b.charAt(b.length()-1)==c.charAt(0)){
        	System.out.println("YES");
        }else{
        	System.out.println("NO");
        }
    }
}

Measured memory_bytes: 35636
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <math.h>
using namespace std;

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

int main(){

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

    string s,t;
    cin>>s>>t;
    int cnt=0;

    rep(i,3){
        if(s[i]==t[i]){
            cnt++;
        }
    
    }
    cout<<cnt<<endl;
    return 0;

}


Measured memory_bytes: 256
n, x, m = map(int, input().split())

ans = 0
a = [0]
id = [0]*(m+1)
l = 1
while id[x] == 0:
    a.append(x)
    id[x] = l
    ans += x
    l += 1
    x = x**2 % m

c = l - id[x]
s=0

for i in range(id[x],l):
    s += a[i]

if n <= l-1:
    ans = 0
    for i in range(1,n+1):
        ans += a[i]
else:
    n -= l
    n += 1
    ans += s*(n//c)
    n %= c
    for i in range(n):
        ans += a[id[x] + i]
print(ans)

Measured memory_bytes: 13372
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;

double D(double x, double y){
	return sqrt(x * x + y * y);
}

double inp(double x1, double x2, double y1, double y2){
	return x1 * x2 + y1 * y2;
}

int main(){
	int x1, y1, x2, y2, x3, y3, x4, y4, r;
	while( cin >> x1 >> y1 , x1 || y1 ){
		cin >> x2 >> y2 >> x3 >> y3 >> x4 >> y4 >> r;
		x1 -= x4; x2 -= x4; x3 -= x4;
		y1 -= y4; y2 -= y4; y3 -= y4;
		
		double d = max(D(x1, y1), max(D(x2, y2), D(x3, y3)));
		if( d <= r ){
			puts("b");
		}else{
			double d1, d2, d3;
			if(D(x1, y1) < inp(x1, x2, y1, y2) || D(x2, y2) < inp(x1, x2, y1, y2) ){
				d1 = D(x1, y1);
			}else{
				d1 = fabs(x1 * y2 - y1 * x2) / D(x2 - x1, y2 - y1);
			}
			if(D(x2, y2) < inp(x2, x3, y2, y3) || D(x3, y3) < inp(x2, x3, y2, y3) ){
				d2 = D(x2, y2);
			}else{
				d2 = fabs(x2 * y3 - y2 * x3) / D(x3 - x2, y3 - y2);
			}
			if(D(x3, y3) < inp(x3, x1, y3, y1) || D(x1, y1) < inp(x3, x1, y3, y1) ){
				d3 = D(x3, y3);
			}else{
				d3 = fabs(x3 * y1 - y3 * x1) / D(x1 - x3, y1 - y3);
			}
			double d = min(d1, min(d2, d3));
			int t = (x1 * y2 > y1 * x2) + (x2 * y3 > y2 * x3) + (x3 * y1 > y3 * x1);
			bool in = !(t && (t-3));
			
			if( in ){
				if( d < r ){
					puts("c");
				}else{
					puts("a");
				}
			}else{
				if( d <= r ){
					puts("c");
				}else{
					puts("d");
				}
			}
		} 
	}
}

Measured memory_bytes: 1116
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
//ll mod = 998244353;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    int n, m;
    cin >> n;
    map<string, int> mp;
    rep(i, n) {
        string s;
        cin >> s;
        ++mp[s];
    }
    cin >> m;
    rep(i, m) {
        string s;
        cin >> s;
        if (mp.count(s) != 0 && mp[s] > 0) {
            --mp[s];
        }
    }
    int ans = 0;
    for (auto p: mp) {
        ans = max(ans, p.second);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3608