akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>
 
int main(){
	int k;
	char str[105];
	
	scanf("%d", &k);
	getchar();
	scanf("%s", str);
	
	//subgoals
	// 1. cari panjang stringnya
	// 2. check apakah panjang string sesuai panjang maksimal
	// jika ya, langsung print stringnya
	// jika tidak, print sebanyak panjang maksimal ditambahkan 
	
	int len = strlen(str); // menampung banyak string 
	if(len <= k) {
	printf("%s\n", str);	
	} else {
		for(int i = 0; i < k; i++) {
			printf("%c", str[i]);
		}
		printf("...\n"); // ditambahkan
	}
	return 0;
}


Measured memory_bytes: 1600
import java.util.*;
import java.io.*;
public class Main {
	static final int MOD=998244353;
	public static void main(String[] args) throws IOException{
		BufferedReader in= new BufferedReader(new InputStreamReader(System.in));
		PrintWriter out= new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
		
		int x=Integer.parseInt(in.readLine());
		
		if(x==0)
			out.append(0+"\n");
		else {
			int happiness=(x/500)*1000;
			x=(x%500);
			happiness+=(x/5)*5;
			out.append(happiness+"\n");
		}
		
		
		out.flush();
		in.close();
		out.close();
	}
}     


Measured memory_bytes: 21204
s = input()
l = len(s)

def dfs(i, sentence):
    # 再起が最後まで終了した時
    if i == l - 1:
        return sum(list(map(int, sentence.split("+"))))
    return dfs(i+1, sentence + "+" + s[i+1]) + dfs(i+1, sentence+s[i+1])

print(dfs(0, s[0]))

Measured memory_bytes: 3060
#include <iostream>
#include <cmath>
using namespace std;
int count=0;
int prime(int x){
    if(x==2){
        count++;
    }
    if(x<2 || x%2==0){
        return false;
    }
    int j=3;
    while(j<=sqrt(x)){
        if(x%j==0){
            return false;
        }
        j=j+2;
    }
    return count++;
}

int main(){
    int n,x;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>x;
        prime(x);
    }
    cout<<count<<endl;
    return 0;
}


Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;
  
  if(S=="SUN")
    cout << 7 << endl;
  else if(S=="MON")
    cout << 6 << endl;
  else if(S=="TUE")
    cout << 5 << endl;
  else if(S=="WED")
    cout << 4 << endl;
  else if(S=="THU")
    cout << 3 << endl;
  else if(S=="FRI")
    cout << 2 << endl;
  else if(S=="SAT")
    cout << 1 << endl;
}

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

int main() {
    int n, m;
    cin >> n >> m;
    dsu uf(n);
    while (m--) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        uf.merge(a, b);
    }
    int ans = 0;
    rep(i, n) {
        if (uf.leader(i) == i) ans++;
    }
    cout << ans - 1 << endl;
} 

Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;cin>>s;
  string a;
  for(int i=0;i<s.size();i++){
   if(s[i]=='0')a+='0';
   else if(s[i]=='1')a+='1';
   else{
      if(a.size()!=0)a=a.erase(a.size()-1);
   }
  }
  cout<<a<<endl;
}




Measured memory_bytes: 256
N = gets.chomp.to_i


# 素数で割っていってカウントする
# ルートNまでの素数をまず列挙する
# それで順番に悪のを繰り返す
# それをハッシュにいれておく
# 最後に足す
# 2が3回とかだったらまた別の計算方法をする？

def fetch_prime_list(max)
  table = Array.new(max + 1,true)
  prime_list = []

  (2..max).each do |num|
    if table[num] == true
      prime_list << num
      k = num * num
      while k <= max
        table[k] = false
        k += num
      end
    end
  end
  return prime_list
end

pl = fetch_prime_list(Math.sqrt(N))

th = Math.sqrt(N)

p_list = []
p_list.push(pl)
p_list.flatten!

pl.each do |p|
  tmp = p
  while 1
    break if tmp*p > th

    tmp *= p

    p_list << tmp
  end
end

ans = 0
num = N
p_list.sort.each do |pi|
  # p pi
  # p num
  if num % pi == 0
    ans += 1
    num /= pi
  end
end

if num > th
  ans += 1
end

p ans


Measured memory_bytes: 25232
#include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<cstring>
#include<map>
#include<utility>
#include<cstdlib>
#include<vector>
#include<functional>
#include<string>
#include<set>
#include<map>
#define SIZE 100005
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int INF = 100000000;
const int MAX = 2000000;
char maze[20][25];
int ans=0,sx,sy,H,W;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

int k;
ll A[100005];

int main(){
	ll L=2ll,R=2ll;
	cin >> k;
	for(int i=0;i<k;i++) cin >> A[i];
	for(int i=k-1;i>=0;i--){
		L=(L+A[i]-1)/A[i]*A[i];
		R=R/A[i]*A[i]+A[i]-1;
	}
	if(L>R) cout <<"-1"<<endl;
	else cout <<L<<" "<<R<<endl;
	return 0;
}

Measured memory_bytes: 1024
n = int(input())
d, x = map(int, input().split())

a = list()
for i in range(n):
    a.append(int(input()))

ans = x

for i in range(1, d + 1):
    for j in range(n):
        if((i - 1) % a[j] == 0):
            ans += 1

print(ans)

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

int main(){
  int n;
  cin >> n;
  vector<ll> a(n);
  for(int i = 0; i< n; i++) cin >> a[i];
   sort(a.begin(), a.end());
 for(int i = 0; i< n-1; i++) {
     if(a[i]==a[i+1]){
           cout << "NO" << endl;
           return 0;
        }
    }
cout << "YES" << endl;
 return 0;
}

Measured memory_bytes: 4840
mday = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
youbi = ["Wednesday", "Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday"]

while True:
	month, day = map(int, input().split())
	if month == day == 0: break

	days = 0
	for m in range(12):
		if month-1 <= m: break
		days += mday[m]
	days += day

	print(youbi[days % 7])

Measured memory_bytes: 7564
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);(i)--)
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);(i)--)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T> inline istream& operator>>(istream& input, vector<T>& v) { for (auto& elemnt : v)input >> elemnt; return input; }

int main() {
    init();

    int w, h; char c;
    cin >> w >> h >> c;
    FOR(i, 0, h) {
        if (i == 0 || i == h - 1) {
            cout << '+';
            FOR(j, 1, w - 1)cout << '-';
            cout << "+\n";
        }
        else {
            cout << '|';
            FOR(j, 1, w / 2)cout << '.';
            cout << (i == h / 2 ? c : '.');
            FOR(j, w / 2 + 1, w - 1)cout << '.';
            cout << "|\n";
        }
    }
}


Measured memory_bytes: 3236
using System;

namespace CircleInRectangle
{
	class MainClass
	{
		public static void Main (string[] args)
		{
			int[] data = getInputdata (" ");
			bool judge = true;

			if (data [2] < data [4])
				judge = false;
			if (data [3] < data [4])
				judge = false;

			if (data [0] - data [4] < data [2])
				judge = false;
			if (data [1] - data [4] < data [3])
				judge = false;


			Console.WriteLine ( judge?"Yes":"No");
		}

		public static int[] getInputdata (string token)
		{
			string[] data = Console.ReadLine ().Split (token.ToCharArray ());
			int[] idata = new int[data.Length];

			for (int i = 0; i < data.Length; i++) {
				idata [i] = int.Parse (data [i]);
			}
			return idata;
		}

	}
}

Measured memory_bytes: 19568
#include<iostream>
using namespace std;
int main(){
  int q,d;
  int total=0;
  cin>>q;
  int problems[q];
  for(int i=0;i<q;i++){
  	cin>>problems[i];
  	total+=problems[i];
  }
  cin>>d;
  for(int i=0;i<d;i++){
  	int a,b;
  	cin>>a;
  	cin>>b;
  	cout<<total-problems[a-1]+b<<endl;
  }
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
 
const ll nmax = 1e9 + 7;
const ll Mod = 998244353;
const double PI = 2 * asin(1);

int N, A, X[51];
ll DP[51][51][2501];

int main(){
  scanf("%d%d", &N, &A);
  for (int i = 1; i <= N; i++) scanf("%d", X + i);
  DP[0][0][0] = 1;

  for (int i = 1; i <= N; i++){

    for (int j = 0; j <= N; j++){
      for (int k = 0; k <= A * N; k++){
        DP[i][j][k] = DP[i-1][j][k];
      }
    }

    for (int j = 0; j < N; j++){
      for (int k = 0; k <= A * N; k++){
        DP[i][j + 1][k + X[i]] += DP[i - 1][j][k];
      }
    }
  }
  
  ll ans = 0;
  for (int j = 1; j <= N; j++){
    ans += DP[N][j][j * A];
  }
  printf("%lld\n", ans);

  return 0;
}


Measured memory_bytes: 50048
import java.util.*;
import java.lang.*;
import java.math.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	
	class MCXI{
		int value;
		MCXI(String str){
			char[] ch = str.toCharArray();
			int digit=1;
			int ptr =0;
			value = 0;
			for(;;){
				if(ptr >= ch.length){
					break;
				}
				if(ch[ptr] == 'm'){
					value += digit*1000;
					digit = 1;
				}else if(ch[ptr] == 'c'){
					value += digit*100;					
					digit = 1;
				}else if(ch[ptr] == 'x'){
					value += digit*10;
					digit = 1;
				}else if(ch[ptr] == 'i'){
					value += digit;
					digit = 1;
				}else{
					digit = ch[ptr]-'0';
				}
				ptr++;
			}
		}
	}
	String getString(int num){
		String ret = "";
		int m = num/1000;
		int c = (num%1000)/100;
		int x = (num%100)/10;
		int i = num%10;
		if(m != 0){
			if(m != 1){
				ret+=m;
			}
			ret+="m";
		}
		if(c != 0){
			if(c != 1){
				ret+=c;
			}
			ret+="c";
		}
		if(x != 0){
			if(x != 1){
				ret+=x;
			}
			ret+="x";
		}
		if(i != 0){
			if(i != 1){
				ret+=i;
			}
			ret+="i";
		}
		return ret;
	}
	void run(){
		int n = sc.nextInt();
		for(int i = 0; i < n ;i++){
			MCXI a = new MCXI(sc.next());
			MCXI b = new MCXI(sc.next());
			int sum = a.value + b.value;
			System.out.println(getString(sum));
		}		
	}
	public static void main(String[] args){
		Main m = new Main();
		m.run();
	}
}

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

int main(){
  int n,m;
  std::cin >> n>>m;
  int sum=0;
  std::vector<int> a(n);

  rep(i,n){
    std::cin >> a[i];
    sum+=a[i];
  }

  int po=0;
  sort(a.rbegin(),a.rend());
  rep(i,n){
    if(a[i]>=sum*(1/(4.0*m)))po++;
  }

  if(po>=m)std::cout << "Yes" << '\n';
  else std::cout << "No" << '\n';





  return 0;
}


Measured memory_bytes: 3620
import sys
input = sys.stdin.readline


def main():
    N = int(input())
    D = list(map(int, input().split()))
    ans = 0
    for i in range(N):
        for j in range(i+1, N):
            ans += D[i] * D[j]
    print(ans)


if __name__ == '__main__':
    main()


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

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

    ll i,j,k,l,m,n,w,x,y,z,p,q,tmp,sum=0;
    ll f=0;
    string str;
    cin>>n;
    cin>>str;
    set<char> s;
    set<string> ss;

    set<string> ans;
    rep(i,str.length()-2){
        if(s.find(str[i])!=s.end()) continue;
            s.insert(str[i]);
        for(j=i+1;j<str.length()-1;j++){
            if(ss.find(str.substr(i,1).append(str.substr(j,1)))!=ss.end()) continue; 
            ss.insert(str.substr(i,1).append(str.substr(j,1)));
            for(k=j+1;k<str.length();k++){
                ans.insert(str.substr(i,1).append(str.substr(j,1)).append(str.substr(k,1)));
            }
        }
    }
    cout<<ans.size();
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
int main() {
    int N;
    long long K;
    cin >> N >> K;
    vector<int> A(N);
    for(int i = 0; i < N; ++i) {
        cin >> A.at(i);
    }

    long long ans = 0;

    for(int i = 0; i < N; ++i) {
        for(int j = i+1; j < N; ++j) {
            if(A.at(i) < A.at(j)) {
                ans += K * (K - 1) / 2;
                ans %= MOD;
            }
            if(A.at(i) > A.at(j)) {
                ans += (K + 1) * K / 2;
                ans %= MOD;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
using namespace std;
typedef string::const_iterator State;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 1e18
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define REP(i,n) for(long long i = 0;i < n;++i)    
#define seg_size 524288
#define int long long
long long powering(long long now, long long hoge) {
	long long ans = 1;
	while (hoge != 0) {
		if (hoge % 2 == 1) {
			ans *= now;
			ans %= MAX_MOD;
		}
		now *= now;
		now %= MAX_MOD;
		hoge /= 2;
	}
	return ans;
}
long long inv(long long now) {
	long long hoge = MAX_MOD - 2LL;
	long long ans = 1;
	while (hoge != 0) {
		if (hoge % 2 == 1) {
			ans *= now;
			ans %= MAX_MOD;
		}
		now *= now;
		now %= MAX_MOD;
		hoge /= 2;
	}
	return ans;
}
long long omote[30000];
long long gyaku[30000];
long long combination(long long a, long long b) {
	long long ans = omote[a];
	ans *= gyaku[b];
	ans %= MAX_MOD;
	ans *= gyaku[a - b];
	ans %= MAX_MOD;
	return ans;
}
long long hyper(long long a, long long b) {
	return combination(a + b - 1LL, a);
}
#undef int
int main() {
#define int long long
	omote[0] = 1;
	gyaku[0] = 1;
	for (long long i = 1; i < 30000; ++i) {
		omote[i] = omote[i - 1] * i;
		omote[i] %= MAX_MOD;
		gyaku[i] = inv(omote[i]);
	}
	int n, k;
	cin >> n >> k;
	for (long long i = 1; i <= k; ++i) {
		if (n-k+1 < i) {
			cout << 0 << endl;
			continue;
		}
		long long ans = combination(n - k + 1, i);
		ans *= hyper(k - i, i);
		ans %= MAX_MOD;
		cout << ans << endl;
	}
}


Measured memory_bytes: 768
def get_int_array
    gets.strip.split(' ').map(&:to_i)
end

h,w,k = get_int_array
input = h.times.map{|r| gets.strip }

tr = [1,2,4,8,16,32,64][0,h]
tc = [1,2,4,8,16,32,64][0,w]

pattern = 0
(2 ** h).times{|i|
    (2 ** w).times{|j|
        count = 0
        tr.each_with_index{|r, ri|
            if (i & r) > 0
                tc.each_with_index{|c, ci|
                    if (j & c) > 0
                        count += 1 if input[ri][ci] == '#'
                    end
                }
            end
        }
        pattern += 1 if count == k
    }
}

puts pattern

Measured memory_bytes: 14308
#include <stdio.h>
#include<iostream>
#include<string>
using namespace std;


int  main()
{
  long long int a,b,k;
  cin >>  a >> b >> k;
  cout << max((long long int)0,a-k) << " " << max((long long int)00,b+min(a-k,(long long int)00));
  return 0;
}

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

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

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


int main() {

	int n,k; cin >> n >> k;
	vector<ll>  h(n);
	rep(i,n) cin >> h[i];
    ll dp[110000];
	rep(i,100010) dp[i] = INF;
	dp[0] = 0;
	rep(i,n){
        for(int j = 1; j <= k; ++j){
    	//	dp[i + j] = min(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
        chmin(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
        }
	}	

	cout << dp[n-1] << endl;

	return 0;
}



Measured memory_bytes: 4804
use proconio::fastout;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;

#[fastout]
fn main() {
    input! {
        n: usize,
        k: usize,
    }
    let mut t = vec![true; n];
    for _ in 0..k {
        input! {
            d: usize,
            a: [Usize1; d],
        }
        for ai in a.into_iter() {
            t[ai] = false;
        }
    }
    let ans = t.into_iter().filter(|&ti| ti).count();
    println!("{}", ans);
}


Measured memory_bytes: 2156
import java.util.*;

class Main{

    public static void main(String[] args){

	Scanner sc = new Scanner(System.in);

	int N = sc.nextInt();

	int[] d = new int[N];

	for(int i=0; i<N; i++){

	d[i] = sc.nextInt();
  }

	int ans = 0;

	for(int i=1; i<N; i++){

	for(int j=0; j<i; j++){

	ans += d[i]*d[j];

  }

  }
	  
	System.out.println(ans);

 }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int maxn=1e6+10;
pair<long long ,int>seg[4*maxn];
pair<long long ,int>seg2[4*maxn];
int a[maxn];
long long  dp[2][maxn];
int n;
int e;
int d;
void update(int id,int l,int r,int l2,int r2,long long val){
if(l>=r2||r<=l2){
	return;
}	
if(l2<=l&&r<=r2&&r-l==1){
		seg[id]={val,l2};
		return ;
}
int mid=(l+r)>>1;
update(id<<1,l,mid,l2,r2,val);
update((id<<1)|1,mid,r,l2,r2,val);
seg[id]=min(seg[id<<1],seg[(id<<1)|1]);
}
pair<long long ,int>get(int id,int l,int r,int l2,int r2){
	if(l>=r2||r<=l2){
		return {(long long )1e18+10,100000};
	}
	if(l2<=l&&r<=r2){
		return seg[id];
	}
	int mid=(l+r)>>1;
	return min(get(id<<1,l,mid,l2,r2),get((id<<1)|1,mid,r,l2,r2));
}
void update2(int id,int l,int r,int l2,int r2,long long  val){
if(l>=r2||r<=l2){
	return;
}	
if(l2<=l&&r<=r2&&r-l==1){
		seg2[id]={val,l2};
		return ;
}
int mid=(l+r)>>1;
update2(id<<1,l,mid,l2,r2,val);
update2((id<<1)|1,mid,r,l2,r2,val);
seg2[id]=min(seg2[id<<1],seg2[(id<<1)|1]);
}
pair<long long ,int>get2(int id,int l,int r,int l2,int r2){
	if(l>=r2||r<=l2){
		return {(long long )1e18+10,100000};
	}
	if(l2<=l&&r<=r2){
		return seg2[id];
	}
	int mid=(l+r)>>1;
	return min(get2(id<<1,l,mid,l2,r2),get2((id<<1)|1,mid,r,l2,r2));
}
inline void input();
int32_t main(){
	ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	input();
}
inline void input(){
	cin>>n>>e>>d;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	for(int i=0;i<4*maxn;i++){
		seg[i]={(long long)1e18,(int)1e9};
		seg2[i]={(long long)1e18,(int)1e9};
	}
	for(int i=0;i<n;i++){
		if(i==0){
			dp[0][i]=a[i];
			dp[1][i]=a[i];
			dp[1][i]+=d;
		}
		else{
		int l=0;
		int r=i;
		while(l!=r-1){
			int mid=(l+r)>>1;
			if(2*(a[i]-a[mid])>=d){
				l=mid;
			}
			else{
				r=mid;
			}
		}
		if(2*(a[i]-a[0])<d){
			r=0;
		}
		if(2*(a[i]-a[i-1])>=d){
			l=i-1;
		}
	//	cout<<l<<": "<<r<<" "<<i<<endl;
		pair<long long,int>p=get(1,0,n,0,l+1);
		//cout<<l<<endl;
		pair<long long,int>w=get2(1,0,n,r,i);
		dp[0][i]=dp[1][i-1]+(a[i]-a[i-1]);
		dp[1][i]=(long long)1e18+10;
		if(2*(a[i]-a[0])>=d){
			dp[1][i]=(dp[0][p.second]+1ll*3*(a[i]-a[p.second]));
		}
		if(2*(a[i]-a[i-1])<d){
			dp[1][i]=min(dp[1][i],(long long)(dp[0][w.second]+d+1ll*1*(a[i]-a[w.second])));
		}
		if(dp[1][i-1]+a[i]-a[i-1]+d<=dp[1][i]){
			dp[1][i]=(long long)(dp[1][i-1]+a[i]-a[i-1]+d);
		}
	}
	//	cout<<dp[0][i]<<" "<<dp[1][i]<<endl;
		//cout<<i<<endl;
		update(1,0,n,i,i+1,(long long)(dp[0][i]+1ll*3*(e-a[i])));
		update2(1,0,n,i,i+1,(long long)(dp[0][i]+1ll*1*(e-a[i])));
	}
	cout<<dp[1][n-1]+(e-a[n-1]);
} 

Measured memory_bytes: 135168
// Brijesh Panara (201601074)
// DAIICT (India)
#include <bits/stdc++.h>
#include <time.h>
using namespace std;

#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

#define precision(x,d) cout<<fixed<<setprecision(d)<<x
#define minQueue priority_queue<ll,vector<ll>,greater<ll> > 
#define maxQueue priority_queue<ll,vector<ll>,less<ll> > 

#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define RFOR(i,a,b) for(ll i=a;i>b;i--)
#define FILL(a,b) memset((a),(b),sizeof((a)))

#define deb1(x) cout<<#x<<" : "<<x<<endl;
#define deb2(x,y) cout<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<endl;
#define deb3(x,y,z) cout<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<"\t"<<#z<<" : "<<z<<endl;

#define MOD 1000000007
#define NAX 200005
#define INF LONG_LONG_MAX
#define MINF LONG_LONG_MIN

void FAST()
{
    ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    //srand(time(NULL));
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);    

}

int main()
{
    FAST();

    ll n,a,b;
    cin>>n>>a>>b;

    ll mx = min(a,b);
    ll mn = max((ll)0,a+b-n);

    cout<<mx<<" "<<mn<<endl;    

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		String operator;

		if(a > b){
			operator=">";
		}else if(a < b){
			operator="<";
		}else{
			operator="==";
		}
		System.out.println("a " +operator+ " b");
		scan.close();
	}
}

Measured memory_bytes: 26316
import sys; input = sys.stdin.buffer.readline
from collections import defaultdict
con = 10 ** 9 + 7; INF = float("inf")

def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	N, K = getlist()
	A = getlist()
	if K <= 2 * (10 ** 5):
		loc = 0
		for i in range(K):
			loc = A[loc] - 1
		print(loc + 1)
		return

	loc = 0
	for i in range(2 * (10 ** 5)):
			loc = A[loc] - 1

	start = loc
	loop = [loc]
	loc = A[loc] - 1
	while loc != start:
		loop.append(loc)
		loc = A[loc] - 1

	M = len(loop)
	ans = loop[(K - 2 * (10 ** 5)) % M]
	print(ans + 1)
	
	




if __name__ == '__main__':
	main()

Measured memory_bytes: 100176
#include <stdio.h>
#include <math.h>

int natural(int);

int main(){
  int len,num,count=0,i;
  scanf("%d",&len);
  for(i=0;i<len; i++){
    scanf("%d",&num);
    count+=natural(num);
  }
  printf("%d\n",count);
  return 0;
}

int natural(int num){
  int i;
  if(num==2)return 1;

  if(num<2 || num%2==0) return 0;

  for(i=3;i<=sqrt(num);i++){
    
    if(num%i==0) break;
  }
  if(i>sqrt(num)) return 1;
  else return 0;
}



Measured memory_bytes: 2032
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

#define MOD 1000000007

void solve(int test_case) {//239///F.Sugoroku
	int n,k,q;
	cin>>n>>k>>q;
	vi sol(n,0);
	REP(i,0,q-1) {
		int a;
		cin>>a;
		sol[a-1]++;
	}
	REP(i,0,n-1) {
		if(sol[i]-q+k>0)cout<<"Yes\n";else cout<<"No\n";
	}
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 3728
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()

    var ans = 1L
    val baisuu = LongArray(n+1) { 1L }
    for (i in 2..n) {
        var j = i
        while(j <= n) {
            baisuu[j]++
            j += i
        }
        ans += i * baisuu[i]
    }
    println(ans)
}


Measured memory_bytes: 114800
using System;
using System.Text;
using System.Collections.Generic;
class Solve{
    public Solve(){}
    StringBuilder sb;
    public static int Main(){
        new Solve().Run();
        return 0;
    }
    void Run(){
        sb = new StringBuilder();
        Calc();
        Console.Write(sb.ToString());
    }
    void Calc(){
        string[] str = Console.ReadLine().Split(' ');
        int N = int.Parse(str[0]);
        int C = int.Parse(str[1]);
        long K = int.Parse(str[2]);
        long[] T = new long [N];
        for(int i=0;i<N;i++){
            T[i] = int.Parse(Console.ReadLine());
        }
        Array.Sort(T);
        long t = T[0];
        int c = 1;
        int count = 1;
        for(int i=1;i<N;i++){
            if(c < C && T[i] <= t + K){
                c++;
            }
            else{
                count++;
                c = 1;
                t = T[i];
            }
        }
        sb.Append(count+"\n");
    }
}

Measured memory_bytes: 17464
#include <bits/stdc++.h>
 
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e5)

#define PI (acos(-1))
#define print(x) cout << x << endl
 
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;

int main()
{
    ll N;
    cin >> N;
    print(3 * N * N);
    return 0;
}

Measured memory_bytes: 256
import Control.Applicative
import Control.Monad
import Control.Monad.ST
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import Data.Foldable (foldMap)
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Tuple
import Data.Array
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
 
readInt = read :: String -> Int
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
fnBin :: (b -> c -> d) -> (a -> b) -> (a -> c) -> a -> d
fnBin op f g x = op (f x) $ g x
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
modifyArray :: (Ix i, MArray a e m) => a i e -> i -> (e -> e) -> m ()
modifyArray arr ix f = readArray arr ix >>= writeArray arr ix . f
-- end of templete

route = cycle [0,1,2,3,4,5,6,7,8,9,5,4,3,2,1]

f s t = (s:) $ reverse $ takeWhile (/=s) $ (t:) $ reverse $ takeWhile (/=t) $ dropWhile (/=s) route


main = do
    n <- getInt
    replicateM_ n $ do
        getInts >>= putStrLn . sjoin . apply2 f 

Measured memory_bytes: 3696
#include<bits/stdc++.h>
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const int INF=1000000001;
const double PI=3.141592653589;


int main(){
  int a,b,c,d; cin>>a>>b>>c>>d;
  if(abs(a-b)<=d&&abs(b-c)<=d||abs(a-c)<=d)
  cout<<"Yes"<<endl;
  else
  cout<<"No"<<endl;
  return 0;
}


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

int main(){
    int n,q;
    cin>>n>>q;
    string s;
    cin>>s;
    vector<char> t(q),d(q);
    for(int i=0;i<q;i++) cin>>t[i]>>d[i];
    int lb=0;
    int ub=n+1;
    while(ub-lb>1){
        int mid=(ub+lb)/2;
        int pos=mid-1;
        for(int i=0;i<q;i++){
            if(s[pos]==t[i]){
                if(d[i]=='R') pos++;
                else pos--;
                if(pos<0 || pos>=n){
                    break;
                }
            }
        }
        if(pos<0) lb=mid;
        else ub=mid;
    }   
    int res=lb;
    lb=0;
    ub=n+1;
    while(ub-lb>1){
        int mid=(ub+lb)/2;
        int pos=mid-1;
        for(int i=0;i<q;i++){
            if(s[pos]==t[i]){
                if(d[i]=='R') pos++;
                else pos--;
                if(pos<0 || pos>=n){
                    break;
                }
            }
        }
        if(pos==n) ub=mid;
        else lb=mid;
    }
    res+=n-lb;
    cout<<n-res<<endl;
    return 0;
}

Measured memory_bytes: 1028
use std::io;
use std::cmp;
use std::collections::BinaryHeap;
use std::collections::HashMap;
use std::collections::HashSet;
use std::f64::consts::PI;

fn read_line() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    buf
}


fn main() {
    let line: Vec<u64> = read_line().split_whitespace().map(|s| s.parse().unwrap()).collect();
    let n = line[0];
    let k = line[1];

    let mut ans = 1;
    let mut tmp =  k;
    while n / tmp > 0 {
        tmp *= k;
        ans += 1;
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
r, c = map (int, input().split())

data = []

for y in range(r):
    row = list(map(int, input().split()))
    data.append(row)
    
colsum = [0 for i in range(c + 1)]
for y in range(r):
    data[y].append(sum(data[y]))
    for x in range(c + 1):
        colsum[x] += data[y][x]
    
data.append(colsum)

for y in range(r + 1):
    print(*data[y])

Measured memory_bytes: 8364
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

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

	string s;
	cin >> s;
	int n = (int)s.size();
	int emod = 0;
	if (s.front() == s.back()) emod = 1;
	else emod = 0;
	if ((n - emod) & 1) {
		cout << "First\n";
	} else {
		cout << "Second\n";
	}
}


Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
#include<numeric>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef pair<int, int>P;
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
typedef vector<vector<ll>> mat;
typedef vector<int> vec;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
const ll mod = 1000000007;
const ll INF = mod * mod;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
ll qp(ll a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };

void solve() {
    ll h, n;
    cin >> h >> n;
    string ans = "No";

    rep(i,n){
        ll a;
        cin >> a;
        h -= a;
        
        if(h <= 0) {
            ans = "Yes";
            break;
        }
    }

    cout << ans << endl;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    //cout << fixed << setprecision(10);
    solve();
    // stop
        return 0;
}

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

#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, int(n) + 1)
#define RREP(i, n) RFOR(i, 0, n)
#define RREP1(i, n) RFOR(i, 1, int(n) + 1)
#define ALL(c) begin(c), end(c)

int _ = (
#ifndef LOCAL
    std::cin.tie(nullptr), std::ios::sync_with_stdio(false),
#endif
    std::cout.precision(10), std::cout.setf(std::ios::fixed));

using ll = long long;
using ld = long double;
template <typename T> using vec = std::vector<T>;
using pii = std::pair<int, int>;
using namespace std;

int n, s;

struct solve {
  solve() {
    dfs(0, 0, -1);
    cout << answer << endl;
  }
  void dfs(int acc, int depth, int from) {
    if (acc > s || depth > n) {
      return;
    }
    if (depth == n && acc == s) {
      answer++;
      return;
    }
    for (int i = from + 1; i < 10; i++) {
        dfs(acc + i, depth + 1, i);
    }
  }
  int answer = 0;
};

int main() {
  for (;;) {
    cin >> n >> s;
    if (n == 0 && s == 0) {
      break;
    }
    solve();
  }
  return 0;
}



Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
const int MAX = 510000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
  cout << fixed << setprecision(10);
  COMinit();
  ll n,m;
  cin >> n >> m;
  ll ans = 1;
  ll tmp = m;
  for(int i=2; i*i<=tmp; i++){
    int count = 0;
    while(m%i==0){
      m/=i;
      count++;
    }
    ans=(ans*COM(count+n-1,count))%MOD;
  }
  if(m!=1){
    ans = ans*COM(1+n-1,1)%MOD;
  }
  cout << ans << endl;
}


Measured memory_bytes: 12160
# 街を基準に考える
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

ans = 0

for i in range(n):
    # 勇者が倒したあとに街に残っているモンスター
    tmp = a[i] - b[i]
    
    # n+1番目のモンスターにまで到達
    if tmp < 0 and -tmp <= a[i+1]:
        ans += b[i]
        a[i+1] += tmp
    # n+1番目のモンスターも駆逐
    elif tmp < 0 and -tmp > a[i+1]:
        ans += a[i]+a[i+1]
        a[i+1] = 0
    # n番目のモンスターで手一杯
    else:
        ans += b[i]

print(ans)

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

using namespace std;
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
//typedef pair<int, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
//const ll INF = 10e15;
const ll MINF = -10e10;
const int INF = INT_MAX;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)


//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

//typedef priority_queue<P, vector<P>, greater<P>> PQ_ASK;
const int mod = 1000000007;

int main() {
    char x, y;
    cin >> x >> y;

    if (x < y) {
        cout << '<' << endl;
    } else if (x == y) {
        cout << '=' << endl;
    } else {
        cout << '>' << endl;
    }

}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func myPow(x int, n int) int {
	result := 1
	for n != 0 {
		if n&1 == 1 {
			result *= x
			result %= 1000000007
		}
		x *= x
		x %= 1000000007
		n >>= 1
	}
	return result
}

func main() {
	maxA := 1000000

	N := readInt()
	A := make([]int, N)
	for i := 0; i < N; i++ {
		A[i] = readInt()
	}

	sieve := make([]int, maxA+1)
	sieve[0] = -1
	sieve[1] = -1
	for i := 2; i <= maxA; i++ {
		if sieve[i] != 0 {
			continue
		}
		sieve[i] = i
		for j := i * i; j <= maxA; j += i {
			if sieve[j] == 0 {
				sieve[j] = i
			}
		}
	}

	lcmFactors := map[int]int{}
	for i := 0; i < N; i++ {
		t := map[int]int{}
		a := A[i]
		for a != 1 {
			t[sieve[a]]++
			a /= sieve[a]
		}
		for k, v := range t {
			if lcmFactors[k] < v {
				lcmFactors[k] = v
			}
		}
	}

	lcm := 1
	for k, v := range lcmFactors {
		for i := 0; i < v; i++ {
			lcm *= k
			lcm %= 1000000007
		}
	}

	result := 0
	for i := 0; i < N; i++ {
		result += lcm * myPow(A[i], 1000000007-2)
		result %= 1000000007
	}
	fmt.Println(result)
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}


Measured memory_bytes: 11136
#include <stdio.h>
#include <string.h>
int main()
{   char s[6];
    scanf("%s",s);
    for(int i=0;i<6;i++)if(s[i]=='A'&&s[i+1]=='C'){
        printf("Yes");
        return 0;
    }
    printf("No");
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O0")
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
const ll mod = 1e9+7;
const ll INF = 1e18;
#define All(a) (a).begin(),(a).end()
#define Pi acos(-1)

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << setprecision(15) << fixed;
  chrono::system_clock::time_point start,end;
  start = chrono::system_clock::now();

  ll n;
  cin >> n;
  vector<ll> a(n+1);
  a[n] = INF;
  rep(i,n) cin >> a[i];
  sort(All(a));
  ll cnt = 1;
  ll ans = 0;
  rep(i,n) {
    if (a[i] == a[i+1]) {
      ++cnt;
    }
    else {
      ans += cnt%2;
      cnt = 1;
    }
  }
  cout << ans << '\n';

  end = chrono::system_clock::now();
  auto elapsed = chrono::duration_cast< chrono::milliseconds >(end - start).count();
  cerr << elapsed << "ms" << '\n';
}

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

using namespace std;

#define LL long long
#define DD double
#define Pb push_back
#define Bp pop_back
#define Pf push_front
#define Fp pop_front
#define Ub upper_bound
#define Lb lower_bound
#define In insert
#define All(x) x.begin(), x.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define fast ios_base::sync_with_stdio(0);cin.tie(0)
#define X first
#define Y second
#define mx1 10
#define mx2 110
#define mx3 1010
#define mx4 10010
#define mx5 100010
#define mx6 1000010

typedef vector<LL> Vl;
typedef vector<DD> Vd;
typedef vector<bool> Vb;
typedef vector<Vl> VVl;
typedef pair<LL, LL> Pll;
typedef pair<DD, DD> Pdd;
typedef vector<Pll> Vpl;
typedef vector<Pdd> Vpd;
typedef queue<LL> Ql;
typedef stack<LL> Sl;
typedef deque<LL> Dl;

LL _set(LL N, LL pos) {return N = N | (1 << pos);}
LL _reset(LL N, LL pos) {return N = N & ~(1 << pos);}
bool _check(LL N, LL pos) {return (bool)(N & (1 << pos));}
bool _upper(char a) {return a >= 'A' && a <= 'Z';}
bool _lower(char a) {return a >= 'a' && a <= 'z';}
bool _digit(char a) {return a >= '0' && a <= '9';}

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

///**************************DONE****************************///

int main()
{
    int n;
    DD t, a;
    cin >> n >> t >> a;

    int h, id;
    DD ans = 100000000.0;
    for(int i = 0; i < n; i++){
        cin >> h;

        DD aa = t - h * 0.006;
        if(abs(aa - a) < ans)
            ans = abs(aa - a), id = i + 1;
    }

    cout << id << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c,d;
    cin >> a >> b >> c >>d;
    while(true){
        c -= b;
        if(c<=0){
            cout << "Yes";
            break;
        }
        a -= d;
        if(a<=0){
            cout << "No";
            break;
        } 
    }
}


Measured memory_bytes: 3636
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
#include<fstream>
#include<set>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define out(str) cout << str << endl
#define ALL(a) (a).begin(),(a).end()
#define INF (1<<29)

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

ll N,K,cnt;
 
int main(){
    cin>>N>>K;
    if(K>(((N-1)*(N-2))/2)){
        out("-1");
        return 0;
    }
    out(N-1+((N-1)*(N-2))/2-K);
    rep(i,N-1){
        cout<<1<<" "<<i+2<<endl;
    }
    int aa=((N-1)*(N-2))/2-K,i=2,j=3;
    while(aa){
        cout<<i<<" "<<j<<endl;
        j++;
        if(j>N){
            i++;
            j=i+1;
        }
        aa--;
    }

    
    
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
  int n,m;
  scanf("%d%d",&n,&m);

  long h[n+1];
  int good[n];
  for(int i=1; i<=n; i++){
    scanf("%ld",&h[i]);
    good[i]=1;
  }

  int a,b;
  for(int i=0; i<m; i++){
    scanf("%d%d",&a,&b);
    if(h[a]>h[b]){
      good[b]=0;
    }else if(h[a]<h[b]){
      good[a]=0;
    }else{
      good[a]=0;
      good[b]=0;
    }
  }
  
  int count = 0;
  for(int i=1; i<=n; i++){
    count += good[i];
  }

  printf("%d",count);
    return 0;

}



Measured memory_bytes: 2896
#include "bits/stdc++.h"
#include<unordered_map>
#pragma warning(disable:4996)
using namespace std;

const int My_Inf=2147483647;
const long long int My_LInf=9223372036854775807;


template < class BidirectionalIterator >
bool next_combination(BidirectionalIterator first1,
	BidirectionalIterator last1,
	BidirectionalIterator first2,
	BidirectionalIterator last2)
{
	if ((first1 == last1) || (first2 == last2)) {
		return false;
	}
	BidirectionalIterator m1 = last1;
	BidirectionalIterator m2 = last2; --m2;
	while (--m1 != first1 && !(*m1 < *m2)) {
	}
	bool result = (m1 == first1) && !(*first1 < *m2);
	if (!result) {
		// ?
		while (first2 != m2 && !(*m1 < *first2)) {
			++first2;
		}
		first1 = m1;
		std::iter_swap(first1, first2);
		++first1;
		++first2;
	}
	if ((first1 != last1) && (first2 != last2)) {
		// ?
		m1 = last1; m2 = first2;
		while ((m1 != first1) && (m2 != last2)) {
			std::iter_swap(--m1, m2);
			++m2;
		}
		// ?
		std::reverse(first1, m1);
		std::reverse(first1, last1);
		std::reverse(m2, last2);
		std::reverse(first2, last2);
	}
	return !result;
}

template < class BidirectionalIterator >
bool next_combination(BidirectionalIterator first,
	BidirectionalIterator middle,
	BidirectionalIterator last)
{
	return next_combination(first, middle, middle, last);
}

struct color {
	double l;
	double a;
	double b;

	double dis(const color&c) {
		return pow(l-c.l,2) + pow(a - c.a, 2) + pow(b - c.b, 2);
	}
};
int main() {
	int N, M; cin >> N >> M;
	vector<color>cs;
	for (int i = 0; i < N; ++i) {
		double l, a, b; cin >> l >> a >> b;
		cs.push_back(color{ l,a,b });
	}
	vector<int>perm(N);
	iota(perm.begin(), perm.end(), 0);
	double ans = 0;
	do {
		double nowans = 0;
		for (int i = 0; i < M; ++i) {
			for (int j = i + 1; j < M; ++j) {
				nowans += cs[perm[i]].dis(cs[perm[j]]);
			}
		}
		ans = max(ans, nowans);

	} while (next_combination(perm.begin(), perm.begin() + M, perm.end()));
	cout <<fixed<<setprecision(22)<< ans << endl;
	return 0;
}

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

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

  int sumDiv = 0;

  int currentNum;
  int beforeNum;
  int currentIndex = 0;
  bool increasing;
  bool decidedIncreasing = false;

  for(int i = 0; i < n; ++i) {
    cin >> currentNum;

    if(currentIndex == 0) {
      beforeNum = currentNum;
      currentIndex = 1;
      continue;
    }

    if(!decidedIncreasing && currentNum == beforeNum) {
      continue;
    }

    if(!decidedIncreasing) {
      increasing = currentNum > beforeNum;
      decidedIncreasing = true;
      beforeNum = currentNum;
      continue;
    }

    if((increasing && currentNum >= beforeNum) || (!increasing && beforeNum >= currentNum)) {
      beforeNum = currentNum;
      continue;
    }

    decidedIncreasing = false;
    beforeNum = currentNum;
    ++sumDiv;
  }

  cout << sumDiv + 1;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>// 加法 S.size() s.substr(l,r=s.size()-l) -> l文字目からr文字分
#include<cmath>//三角関数,rad
#include<algorithm>//__gcd()　lower_bound(a+l,a+r,x)-a でindex
// 配列  -> min/max({}) 
// vector-> *min_element(a+l,a+r)  *忘れず lとrで[l,r) 
//reverse(a+l,a+r)   配列aの[l,r)を逆順に strはreverse(all(s))
//sort(a+l,a+r,greater <int>()) 配列aの[l,r)昇順sort,大きい順はgreater<type>()
//vectorならall(v)
#include<ctime>//"clock()/CLOCKS_PER_SEC で秒数
#include<vector>//v.push_back(x),v.pop_back()
#include<queue>//q.push(x),front()で先頭を返す,pop()で削除, size(),empty()
#include<functional>//vector,queueと併用でpriority_queue
//宣言は priority_queue< Type, vector<Type>, greater<Type>> Q1; 
// pq.push(x),top()で参照 pop()で削除   greaterで最小 lessで最大がtopに
using namespace std;
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define print(i) std::cout << (i) << '\n'
inline int ceildiv(int a, int b) { return (a+b-1)/b; }
typedef pair<int,int> P;
const int inf = 10e7;
//int |x|<=2*10**9     long |x|<= 9*10**18

void inlineprint(auto v){
    auto p=v.end()-1;
    for (auto y=v.begin();y<p;y++){cout<<*y<<" ";}
    cout<<*p<<"\n";
}
signed main(){
long long n,m,ans=0ll;cin>>n;m=n;

for (int i=2;i<=sqrt(m);i++){
    if (n%i==0){
        
        while (n%i==0){n/=i;}
        ;
        if (n%i==1){ans+=1;}
      long long h=m/n;
      if (h%m==1&&h!=n)ans++;
        n=m;
        }
}
long long jk=1;
n--;
for (int i=2;i<=sqrt(m-1);i++){
  if (n%i==0){
        long long cnt=0ll;
        while (n%i==0){n/=i;cnt++;}
 
        jk*=(cnt+1);
        }
}if (n!=1)jk*=2;

print(ans+jk);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define SCIN(s) string(s);cin >> (s)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<int,int>
#define I vector<int>
#define V vector
#define S set<int>
#define pb(v) push_back(v)
int main(){
    CIN(a);CIN(b);CIN(c);
    COUT(min({a+b,a+c,b+c}));
    return 0;
}


Measured memory_bytes: 256
#include<iostream>

#include<cmath>
using namespace std;
int main()
{int n,m[100000],a=0,b=0,i=0;
cin>>n;
for(i=0;i<n;i++)
cin>>m[i];
while(b==0){
for(i=0;i<n;i++){
	if(m[i]%2==1)b++;
	else m[i]=m[i]/2;
}
if(i==n)a++;
}
a--;
cout<<a;
    return 0;

}


Measured memory_bytes: 256
<?php
// Your code here!
fscanf(STDIN,"%d",$n);
for($i=0; $i<$n; $i++){
    $array[$i] = trim(fgets(STDIN));
}

$countValues = array_count_values($array);
$max = max($countValues);
$keysOfMax = array_keys($countValues, $max);
asort($keysOfMax);

echo implode("\n", $keysOfMax);

?>

Measured memory_bytes: 43500