akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>

// ===============================================================

using namespace std;
using ll = long long;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using vs = vector<string>;
using vc = vector<char>;
using vcc = vector<vector<char>>;
using vm = vector<short>;
using vmm = vector<vector<short>>;
using pii = pair<int, int>;
using psi = pair<string, int>;
using ld = long double;
using ull = unsigned long long;

// ===============================================================

ll gcd(ll a, ll b) //最大公約数
{
	if (a % b == 0)
	{
		return(b);
	}
	else
	{
		return(gcd(b, a % b));
	}
}

ll lcm(ll a, ll b) //最小公倍数
{
	return a * b / gcd(a, b);
}

ll box(double a) //doubleの切り捨て
{
	ll b = a;
	return b;
}

ll fff(double a) //doubleの四捨五入
{
	ll b = a + 0.5;
	return b;
}

ll sum(ll n) { //整数sまでの合計
	if (n == 0) {
		return 0;
	}

	int s = sum(n - 1);  
	return s + n;  
}

bool prime(ll num)//素数判定、primeならtrue,違うならfalse
{
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false; 
	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	// 素数である
	return true;
}

//だから私は～
//#define int long long
// ===============================================================

/*signed*/int main() {
	ll a, b;
	cin >> a >> b;
	if (a == b) {
		cout << a * 2 << endl;
	}
	else {
		cout << max(a, b) * 2 - 1 << endl;
	}
}

Measured memory_bytes: 3680
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "iomanip"
#include "cmath"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;

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

	cin >> N >> M;
	cout << (N + M + 1) / 2 << endl;

	return 0;
}

Measured memory_bytes: 256
#define taskname "test"

#include <bits/stdc++.h>

using namespace std;

#define sz(x) (int)x.size()
#define fi first
#define se second

typedef long long lli;
typedef pair<int, int> pii;

const int maxn = 2e5 + 5;

int n, T;
int t[maxn];

void read_input()
{
    cin >> n >> T;
    for(int i = 1; i <= n; ++i)
        cin >> t[i];
}

void solve()
{
    lli ans = T;
    for(int i = 2; i <= n; ++i)
    {
        if(t[i] - t[i - 1] > T) ans += T;
        else ans += t[i] - t[i - 1];
    }
    cout << ans << '\n';
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    read_input();
    solve();
}



Measured memory_bytes: 1024
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    N = int(rl())
    s = input()
    MOD = 10 ** 9 + 7
    
    dp = [[0] * N for _ in range(N)]
    for i in range(N):
        dp[0][i] = 1
    acc = [i for i in range(1, N + 1)]
    
    for i in range(1, N):
        for j in range(N - i + 1):
            if s[i - 1] == '<':
                dp[i][j] = (acc[N - i] - acc[j]) % MOD
            else:
                dp[i][j] = acc[j]
        acc[0] = dp[i][0]
        for j in range(1, N):
            acc[j] = (acc[j - 1] + dp[i][j]) % MOD
    print(dp[-1][0])


if __name__ == '__main__':
    solve()


Measured memory_bytes: 112092
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define ll long long
#define IOS ios::sync_with_stdio(false)
#define For(i, x, y) for(int i = x; i <= y; i++)
#define For_(i, x, y) for(int i = x; i >= y; i--)
const int inf = 0x3f3f3f3f;
const ll Inf = 1e18;
const int maxn = 2e3 + 5;

int t[maxn];

int main(void)
{
	int n, x, y;
	cin >> n >> x >> y;
	For(i, 1, n) {
		For(j, i + 1, n) {
			int v = min(j - i, abs(x - i) + abs(j - y) + 1);
			t[v]++;
		}
	}
	For(i, 1, n - 1) cout << t[i] << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,m,k,a[200001],b[200001],A,ans,L;
vector<ll> v,u;
int main(void){
    cin>>n>>m>>k;
    for(int i=0;i<n;i++)cin>>a[i];
    for(int i=0;i<m;i++)cin>>b[i];
    v.push_back(0);
    u.push_back(0);
    for(int i=0;i<n;i++){
        v.push_back(v[i]+a[i]);
    }
    for(int i=0;i<m;i++){
        u.push_back(u[i]+b[i]);
    }
    for(ll i=0LL;i<=n;i++){
        A=k-v[i];
        //cout<<A<<endl;
        if(A<0)continue;
        L=upper_bound(u.begin(),u.end(),A)-u.begin();
        //cout<<i<<" "<<L<<endl;
        ans=max(ans,i+L-1);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 11092
#include <stdio.h>
#include <string.h>
#include <ctype.h>

int main(void)
{
    long i;
    int cnt = 0;
    char word[11];
    char text[1001];

    scanf("%s", word);

    while (1){
        scanf("%s", text);
        if (strcmp(text, "END_OF_TEXT") == 0){
            break;
        }else{
            for (i = 0; i < (long)strlen(text); i++){
                text[i] = tolower(text[i]);
            }
            if (strcmp(text, word) == 0){
                cnt++;
            }
        }
    }
    
    printf("%d\n", cnt);

    return 0;
}

Measured memory_bytes: 552
# coding: utf-8
# Your code here!
n=int(input())
x=[0]*n
y=[0]*n
cnt=1
for l in range(1,n+1):
    cnt*=l
for i in range(n):
    x[i],y[i]=map(int,input().split())
    ###
ans=0
for j in range(n):
    for k in range(n):
        ans+=((((x[j]-x[k])**2)+((y[j]-y[k])**2))**(1/2))
ans/=2
ans*=(cnt//n)*2
print(ans/cnt)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e7+50;
ll a[maxn],n;
void init()
{
	for(int i=2;i<=5*1e6;++i)
	{
		for(int j=2;j*i<=1e7;++j)
		{
			a[i*j]++;
		}
	}
}
int main()
{
	
	for(int i=2;i<=1e7;++i) a[i]=2;
	a[1]=1;
	init();
	cin>>n;
	ll sum=0;
	for(ll i=1;i<=n;++i) sum+=a[i]*i;
	cout<<sum<<endl; 
	return 0;
}

Measured memory_bytes: 81728
while True:
    a, op, b = (x for x in input().split())
    if op == '?':
        break
    
    a = int(a)
    b = int(b)

    if op == '+':
        print(a + b)
    elif op == '-':
        print(a - b)
    elif op == '*':
        print(a * b)
    else:
        print(int(a / b))


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

using namespace std;

typedef long long ll;
const ll inf = 0x3f3f3f3f;
#define case(i) "Case #" << i << ": "
 
template <typename S, typename T>
ostream& operator<<(ostream& out, pair<S, T> const& p) {
    out << '(' << p.first << ", " << p.second << ')';
    return out;
}
template <typename T>
ostream& operator<<(ostream& out, vector<T> const& v) {
    ll l = v.size();
    for (ll i = 0; i < l - 1; i++) out << v[i] << ' ';
    if (l > 0) out << v[l - 1];
    return out;
}

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

    int n;
    cin >> n;
    string s;
    cin >> s;

    int ans = 0;

    for(int i = 0; i + 2 < n; ++i) {
        if(s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C') ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#define N 200
 
int F[N];
 
main(){
  int n, F;
 
  scanf("%d",&n);
  F = fibonacci(n);
  printf("%d\n",F);
  return 0;
}

int fibonacci(int n)
{
  if(n == 0 || n == 1){
    return F[n] = 1;
  }

  if(F[n]!=NULL){
    return F[n];
  }
  else{
	return F[n] = fibonacci(n - 2) + fibonacci(n - 1);
  }
}

Measured memory_bytes: 596
require 'prime'

n = gets.to_i
mod = 10**9 + 7
h = Hash.new(0)

2.upto(n) do |i|
  i.prime_division.each { |p, e| h[p] += e }
end

puts n == 1 ? 1 : h.values.map(&:succ).inject { |x, y| x * y % mod }

Measured memory_bytes: 14312
#include <stdio.h>


int main(void) {

	// 1_4-D Min,Max and Sum

	int n;
	long a;
	long min,max,sum;
	int i;
	
	scanf("%d\n",&n);
	min = 1000000;
	max = -1000000;
	sum = 0;

	for(i=0; i<n; i++){
		scanf("%ld",&a);
		if(a<min){
			min = a;
		}
		if(max<a){
			max = a;
		}
		sum = sum + a;
		
	}
	if(n == 0){
		min = 0;
		max = 0;
	}

	printf("%ld %ld %ld\n",min,max,sum);
        return 0;
}

Measured memory_bytes: 1032
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*
cout<<setprecision(20)
cin.tie(0);
ios::sync_with_stdio(false);
*/
const llint mod=998244353;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
llint LBI(vector<llint>&ar,llint in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
llint UBI(vector<llint>&ar,llint in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,i,j,K;cin>>n>>K;
	vector<int>ten(n);
	for(i=0;i<n;i++){int p;cin>>p;ten[p-1]=i;}
	//挿入ソート
	vector<int>rink(n+1,-1);//自分の次の数が何か を記録する
	for(i=0;i<=n;i++){rink[i]=i;}
	set<int>kazu;//挿入を記録する
	kazu.ins(-mod);
	kazu.ins(mod);
	for(i=0;i<n;i++){
		//ten[i]以上ten[i]+K未満の数を消す
		auto itr=kazu.lower_bound(ten[i]+K);
		while(*prev(itr)>ten[i]){
			int ter=*prev(itr);
			swap(rink[ten[i]],rink[ter]);
			kazu.erase(prev(itr));
		}
		kazu.ins(ten[i]);
	}
	auto itr=prev(kazu.end());
	while(*prev(itr)>-9999){
		int ter=*prev(itr);
		swap(rink[n],rink[ter]);
		kazu.erase(prev(itr));
	}
	vector<int>ans(n);
	int gen=n;
	for(i=0;i<n;i++){
		gen=rink[gen];
		ans[gen]=i+1;
	}
	for(i=0;i<n;i++){cout<<ans[i]<<endl;}
	return 0;
}


Measured memory_bytes: 30976
from collections import defaultdict
def main():
    n, k = list(map(int, input().split()))
    d = defaultdict(int)
    for _ in range(n):
        a, b = list(map(int, input().split()))
        d[a] += b
    A = sorted(d.items(), key = lambda x: x[0])
    count = 0
    for a in A:
        count += a[1]
        if count >= k:
            print(a[0])
            exit()

if __name__ == '__main__':
    main()


Measured memory_bytes: 55640
#include<bits/stdc++.h>
            using namespace std;
            #define rep(i,b) for(i=0;i<b;++i)
            #define repp(i,a,b) for(i=a;i<b;++i)
            #define endl "\n"
            //#define LLONG_MAX 99999999999999
            typedef long long int lli;
            int main(){
                lli t,n,i,j,k,m;
                cin>>n;
                vector<lli> a(n);
                vector<lli> b(n);
                vector<lli> c(n);
                rep(i,n)cin>>a[i]>>b[i]>>c[i];
                vector<lli> aa(n);
                vector<lli> bb(n);
                vector<lli> cc(n);
                aa[0]=max(b[0],c[0]);
                bb[0]=max(a[0],c[0]);
                cc[0]=max(a[0],b[0]);
                repp(i,1,n){
                    aa[i]=max(bb[i-1],cc[i-1])+a[i];
                    bb[i]=max(aa[i-1],cc[i-1])+b[i];
                    cc[i]=max(aa[i-1],bb[i-1])+c[i];
                }
                cout<<max(max(aa[n-1],bb[n-1]),cc[n-1])<<endl;

                return 0;



            }


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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = long long;
using P = std::tuple<int,int>;

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

std::string A;
std::vector<std::tuple<int, int>> v;
int dp[200100], nexts[200100];
char cs[200100];

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

    std::cin >> A;
    
    int N = A.size();
    for(int i=0;i<N;++i){
        v.emplace_back(A[i] - 'a', i);
    }

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

    fill(dp, dp+N, 1001001);
    fill(nexts, nexts+N+1, -1);
    dp[N] = 1;
    cs[N] = 'a';
    
    for(int i=N-1;i>=0;--i){
        for(int j=25;j>=0;--j){
            int ne = lower_bound(v.begin(), v.end(), std::make_tuple(j, i)) - v.begin();
            
            if(ne == N || fst(v[ne]) != j){
                dp[i] = 1;                
                cs[i] = 'a' + j;
                nexts[i] = -1;
                continue;
            }

            ne = snd(v[ne]) + 1;

            if(dp[i] >= dp[ne] + 1){
                dp[i] = dp[ne] + 1;
                nexts[i] = ne;
                cs[i] = 'a' + j;
            }
        }
    }

    // for(int i=0;i<N;++i){
    //     std::cout << A[i] << " " << dp[i] << " " << nexts[i] << " " << cs[i] << std::endl;
    // }
    
    int pos = 0;
    while(pos != -1){
        std::cout << cs[pos];
        pos = nexts[pos];
    }

    std::cout << std::endl;
}


Measured memory_bytes: 3976
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T

main :: IO ()
main = do
  (h : w : _) <- map unsafeTextToInt . T.words <$> T.getLine :: IO [Int]
  let
    (a, b) = h `divMod` 2
    (c, d) = w `divMod` 2
  print $ if h == 1 || w == 1 then 1 else (2 * a + b) * c + (a + b) * d

unsafeTextToInt :: T.Text -> Int
unsafeTextToInt s = case T.signed T.decimal s of
  Right (n, _) -> n


Measured memory_bytes: 508
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1001001001;
const int mod = 1000000007;

struct mint {
	ll x;
	mint() :x(0) {}
	mint(ll x) :x((x% mod + mod) % mod) {}
	// mint(ll x):x(x){}
	mint& fix() { x = (x % mod + mod) % mod; return *this; }
	mint operator-() const { return mint(0) - *this; }
	mint operator~() const { return mint(1) / *this; }
	mint& operator+=(const mint& a) { if ((x += a.x) >= mod) x -= mod; return *this; }
	mint& operator-=(const mint& a) { if ((x += mod - a.x) >= mod) x -= mod; return *this; }
	mint& operator*=(const mint& a) { (x *= a.x) %= mod; return *this; }
	mint& operator/=(const mint& a) { (x *= a.pow(mod - 2).x) %= mod; return *this; }
	mint operator+(const mint& a)const { return mint(*this) += a; }
	mint operator-(const mint& a)const { return mint(*this) -= a; }
	mint operator*(const mint& a)const { return mint(*this) *= a; }
	mint operator/(const mint& a)const { return mint(*this) /= a; }
	mint pow(ll t) const {
		if (!t) return 1;
		mint res = pow(t / 2);
		res *= res;
		return (t & 1) ? res * x : res;
	}
	bool operator<(const mint& a)const { return x < a.x; }
	bool operator==(const mint& a)const { return x == a.x; }
};

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, k;
	cin >> n >> k;
	mint ans = 0;
	for (ll i = k; i <= n + 1; ++i) {
		mint mx = (n - i + n + 1) * i / 2;
		mint mn = i * (i - 1) / 2;
		ans += mx - mn + 1;
	}
	cout << ans.x << endl;
	return 0;
}


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

int main() {
  int K;
  string str;
  cin >> K;
  cin >> str;
  
  int n = str.size();
  
  if (n <= K){
    cout << str << endl;
  }
  else {
    for (int i=0; i<K; i++) {
      if (i == K-1) {
        cout << str.at(i) << "..." << endl;
        break;
      }
      cout << str.at(i);
    }
  }
      
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, K;
  cin >> N >> K;
  vector<int> V(N + 2, 0);
  for (int i = 1; i <= N; i++)
    cin >> V[i];
  int res = 0;
  for (int a = 0; a <= min(N, K); a++) {
    for (int b = 0; b <= min(N - a, K - a); b++) {
      int v = 0;
      vector<int> minus;
      int k = K - (a + b);
      for (int i = 1; i <= a; i++) {
        v += V[i];
        if (V[i] < 0) minus.push_back(-V[i]);
      }
      for (int i = N; i > N - b; i--) {
        v += V[i];
        if (V[i] < 0) minus.push_back(-V[i]);
      }
      sort(minus.begin(), minus.end(), greater<int>());
      minus.insert(minus.begin(), 0);
      for (int i = 0; i < min(k + 1, (int)minus.size()); i++)
        v += minus[i];
      res = max(res, v);
    }
  }
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector <tuple<string,int,int>> score(N);
 for(int i=0; i<N; i++){
    string s; //shi no namae
    int a; //tokuten
    cin >> s >> a;
    score.at(i) = make_tuple(s,-a,i+1); //ookiijun nanode "a" ni "-" wo tsukeru
  }
  sort(score.begin(),score.end());
  for(int i=0; i<N; i++){
    string s;
    int a,b;
    tie(s,a,b) = score.at(i);
    cout << b << endl;
  }
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {

  public static void main(String[] args) throws IOException {

    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    
    String[] in = br.readLine().split(" ");
    long n = Long.parseLong(in[0]);
    long p = Long.parseLong(in[1]);

    br.close();

    Map<Long, Integer> prime = new HashMap<>();

    for(long i = 2; i * i <= p; i++){
      int cnt = 0;
      while(p % i == 0){
        p /= i;
        cnt++;
      }
      if(cnt > 0){
        prime.put(i, cnt);
      }
    }

    if(p > 1) prime.put(p, 1);

    long ans = 1;

    for(Map.Entry<Long, Integer> e : prime.entrySet()){
      int t = e.getValue();
      while(t >= n){
        ans *= e.getKey();
        t -= n;
      }
    }

    System.out.println(ans);
  }
}

Measured memory_bytes: 21204
a,b=map(int,input().split())

def factorization(n):
    a=[]
    while n%2==0:
        a.append(2)
        n//=2
    f=3
    while f*f<=n:
        if n%f==0:
            a.append(f)
            n//=f
        else:
            f+=2
    if n!=1:
        a.append(n)
    return a

s_a=set(factorization(a))
s_b=set(factorization(b))
ans_arr=s_a&s_b
print(len(ans_arr)+1)

Measured memory_bytes: 9224
from math import sqrt


def diff_square(x1, x2):
    return (x1 - x2) ** 2


N, D = map(int, input().split(' '))
X = []
for _ in range(N):
    X.append(list(map(int, input().split(' '))))

count = 0
for i in range(N):
    for j in range(i, N):
        if i != j:
            distance = sqrt(sum(map(diff_square, X[i], X[j])))
            if distance.is_integer():
                count += 1

print(count)


Measured memory_bytes: 3064
fn main(){
    let mut sc = Scanner::new();
    while sc.read() {
        let a = (sc.next::<i32>() - 2 + 13) % 13;
        let b = (sc.next::<i32>() - 2 + 13) % 13;
        println!("{}", if a < b { "Bob" } else if a == b { "Draw" } else { "Alice" });
    }
}

#[allow(dead_code)]
struct Scanner {
    buf: Vec<u8>, i: usize, next: Option<String>,
}

#[allow(dead_code)]
impl Scanner {
    fn new() -> Scanner {
        Scanner { buf: vec![], i: 0, next: None, }
    }

    fn next<T: std::str::FromStr>(&mut self) -> T {
        self.wrapped::<T>().unwrap()
    }

    fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        let mut res = Vec::<T>::with_capacity(n);
        for _ in 0..n { res.push(self.next()) }
        res
    }

    fn wrapped<T: std::str::FromStr>(&mut self) -> Option<T> {
        self.read();
        self.next.take().and_then(|s| s.parse::<T>().ok())
    }

    fn read(&mut self) -> bool {
        if self.next.is_some() { return true }
        let mut s = String::with_capacity(16);
        while let Some(c) = self.get_char() {
            if !c.is_whitespace() { s.push(c); }
            else if !s.is_empty() { break; }
        }
        self.next = if !s.is_empty() { Some(s) } else { None };
        self.next.is_some()
    }

    fn get_char(&mut self) -> Option<char> {
        if self.i >= self.buf.len() {
            use std::io::BufRead;
            let reader = std::io::stdin();
            let mut buffer = reader.lock();
            let len = match buffer.fill_buf() {
                Ok(bytes) => {
                    self.buf.resize(bytes.len(), b'\0');
                    self.buf.copy_from_slice(bytes);
                    Some(bytes.len())
                },
                Err(_) => None,
            };
            self.i = 0;
            if len.is_some() { buffer.consume(len.unwrap()); }
            if len.is_none() || len.unwrap() == 0 { return None }
        }
        self.i += 1;
        Some(self.buf[self.i - 1] as char)
    }
}


Measured memory_bytes: 4352
#include <stdio.h>

int main(void){
	int n,i,j,primenum=0,x;
	scanf("%d",&n);
	primenum=n;
	for(i=0;i<n;++i){
		scanf("%d",&x);
		for(j=2;j*j<=x;j++){
			if(x%j==0){
				primenum--;
				break;
			}
		}
	}
	printf("%d\n",primenum);
	return 0;
}

Measured memory_bytes: 596
#include <stdio.h>

int main(void) {
	// your code goes here
	int a,b;
	while(1){
		scanf("%d %d",&a,&b);
		if(a==0&&b==0)break;
		if(a<b){
			printf("%d %d\n",a,b);
		}else{
			printf("%d %d\n",b,a);
		}
	}

	return 0;

}


Measured memory_bytes: 2040
//AtCoder
//AGC013B Hamiltonish Path

#include<iostream>
#include<vector>

using namespace std;

const int MAXN=100000+10;
vector<int> edge[MAXN];
vector<int> path1,path2;
int n,m;
int vis[MAXN];

void dfs(int t)
{
	vis[t]=1;
	
	path1.push_back(t);
	
	for(int i=0;i<edge[t].size();++i)
		if(!vis[edge[t][i]])
		{
			dfs(edge[t][i]);
			return;
		}
}

int main()
{
	ios_base::sync_with_stdio(false);
	
	cin>>n>>m;
	
	int x,y;
	for(int i=0;i<m;++i)
	{
		cin>>x>>y;
		
		edge[x].push_back(y);
		edge[y].push_back(x);
	}
	
	dfs(1);
	swap(path1,path2);
	dfs(1);
	
	cout<<int(path1.size()+path2.size()-1)<<endl;
	
	for(int i=int(path2.size()-1);i>0;--i)
		cout<<path2[i]<<' ';
	for(int i=0;i<path1.size();++i)
		cout<<path1[i]<<' ';
	cout<<endl;
	
	return 0;
}

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

typedef struct {
    int x;
    int y;
} squr_t;

int sort(const void *a, const void *b){
    if ( ((squr_t*)a)->x - ((squr_t*)b)->x >0 ) {
        return 1;
    }
    if ( ((squr_t*)a)->x - ((squr_t*)b)->x <0 ) {
        return -1;
    }
    if ( ((squr_t*)a)->x - ((squr_t*)b)->x ==0 ) {
        if ( ((squr_t*)a)->y - ((squr_t*)b)->y >=0 ) {
            return 1;
        }
        if ( ((squr_t*)a)->y - ((squr_t*)b)->y <0 ) {
            return -1;
        }
    }
    return 0;
}

int main(void){
    int h,w,n,a,b,count=0;
    scanf("%d%d%d",&h,&w,&n);
    squr_t s[n*9];
    for (int i=0; i<n; i++){
        scanf("%d%d",&a,&b);
        a--;
        b--;
        for (int j=-1; j<2; j++){
            if(a+j>=1 && a+j<h-1){
                for (int k=-1; k<2; k++){
                    if (b+k>=1 && b+k<w-1){
                        s[count].x=a+j;
                        s[count].y=b+k;
                        count++;
                    }
                }
            }
        }
    }
    qsort (s,count,sizeof(squr_t),sort);
    long long ans[10],am=0;
    for (int i=0; i<10; i++){
        ans[i]=0;
    }
    for (int i=0; i<count; i++){
        if (i==0){
            am++;
        } else if (s[i].x==s[i-1].x && s[i].y==s[i-1].y){
            am++;
        } else {
            ans[am]++;
            am=1;
        }
        if (i==count-1){
            ans[am]++;
        }
    }
    ans[0]=(h-2)*(w-2);
    for (int i=1; i<10; i++){
        ans[0]-=ans[i];
    }
    for (int i=0; i<10; i++){
        printf("%lld\n",ans[i]);
    }

    
	return 0 ;
}

Measured memory_bytes: 14204
"""
Writer: SPD_9X2
https://atcoder.jp/contests/agc004/tasks/agc004_c
i = 0は全て青
i = H-1は全て赤に塗る

それ以外に関して、
j % 2 == 0なら全て青、
j % 2 == 1なら全て赤に塗れば、あとはどこを紫にしても連結条件が保たれる

あとは紫にするポイントを紫にしてしまえば終わり!

"""

H,W = map(int,input().split())

a = []
for i in range(H):
    A = list(input())
    a.append(A)

ans1 = [["."] * W for i in range(H)]
ans2 = [["."] * W for i in range(H)]

for i in range(H):

    for j in range(W):

        if i == 0:
            ans1[i][j] = "#"
            continue
        if i == H-1:
            ans2[i][j] = "#"
            continue

        if a[i][j] == "#":
            ans1[i][j] = "#"
            ans2[i][j] = "#"
        elif j % 2 == 0:
            ans1[i][j] = "#"
        else:
            ans2[i][j] = "#"

for i in ans1:
    print ("".join(i))
print ("")
for i in ans2:
    print ("".join(i))
        
            


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

b = [1] * n
r = [1] + [0] * (n-1)

for _ in range(m):
    x, y = map(int, input().split())
    x, y = x-1, y-1
    
    if r[x] == 1:
        
        if b[x] == 1:
            r[x] = 0
            r[y] = 1
            b[x] -= 1
            b[y] += 1

        else:
            r[y] = 1
            b[x] -= 1
            b[y] += 1

    else:
        b[x] -= 1
        b[y] += 1

print(sum(r))
        

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

using namespace std;

const int maxn = 1e5 + 5;
const int INF = 0x7f7f7f7f;

typedef long long ll;



ll a[maxn];
ll sum[maxn];
vector <ll> vt;

bool cmp(int a , int b) {
	return a > b;
}

int main() {
	ll n , m , v , p;
	ios::sync_with_stdio(0);
	cin >> n >> m >> v >> p;
	vt.push_back(0); 
	for(int i = 1 ; i <= n ; i++) {
		cin >> a[i];
	}
	sort(a + 1 , a + n + 1, cmp);
	int ans = p;
	for(int i = 1 ; i <= n ; i++) {
		sum[i] = sum[i - 1] + a[i];
	} 
	for(int i = p + 1 ; i <= n ; i++) {
		if(a[i] + m < a[p]){
			break;
		}
		else {
			if(m * v <= (p - 1) * m + (n - i + 1) * m+ (a[i] + m) * (i - p) - (sum[i - 1] - sum[p - 1])) {
				ans ++;
			}
			else {
				break;
			}
		}
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,b) FOR(i,0,b)
#define BE(c) c.begin(),c.end()
#define PB push_back
#define F first
#define S second
#define BEB(s) s
using namespace std;
int main(){
    string s;
    getline(cin, s);
    for(int i=0; i<s.size(); i++){
        //小文字なら大文字に 
        if(islower(s[i])) s[i]=toupper(s[i]);
    }
     
    cout<<s<<endl;
 
    return 0;
}

Measured memory_bytes: 1176
def gcd(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    c = a % b
    return gcd(b, c)

def lcm(a, b):
    return (a * b) // gcd(a, b)

def cmp(x, y, l):
	if len(x) < len(y):
		x, y = y, x
	lx = int(l/len(x))
	ly = int(l/len(y))
	lc = lcm(lx,ly)
	lt = [i*lc for i in range(int(l/lc))]
	for i in lt:
		if i%lc == 0 and x[int(i/lx)] != y[int(i/ly)]:
			return False
	return True

def cmp2(x, y, l):
	if len(x) < len(y):
		x, y = y, x
	lx = int(l/len(x))
	ly = int(l/len(y))
	for i in range(l):
		if i%lx == 0 and i%ly == 0 and x[int(i/lx)] != y[int(i/ly)]:
			return False
	return True


if __name__ == '__main__':
	N, M = list(map(int, input().split()))
	S = input()
	T = input()
	L = lcm(N,M)
	if not cmp(S,T,L):
		print(-1)
	else:
		print(L)


Measured memory_bytes: 4340
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <vector>

using namespace std;

int a[50],b[50];

int main(){

	int w,h;
	cin>>w>>h;
	for (int i = 0; i < h; i++)
	{
		char c;
		cin>>a[i]>>c>>b[i];
		a[i]--; b[i]--;
	}

	vector<int> v(w);
	for (int i = 0; i < w; i++)
	{
		v[i] = i+1;
	}

	for (int i = 0; i < h; i++)
	{
		swap(v[a[i]],v[b[i]]);
	}

	for (int i = 0; i < w; i++)
	{
		cout << v[i] << endl;
	}


	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int main() {
	int x, y;
	cin >> x >> y;
	int count = 0;
	for (int i = 0; i < x; i++) {
		string str;
		cin >> str;
		for (int j = 0; j < y; j++) {
			count += str[j] == '#';
		}
	}
	cout << (count == x + y - 1 ? "Possible" : "Impossible") << endl;
	return 0;
}

Measured memory_bytes: 3628
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        
        int[] ae = new int[5]; 
        for(int i = 0; i < 5; i++){
            ae[i] = sc.nextInt();
        }
        int k = sc.nextInt();
        
        if( ae[4] - ae[0] > k ){
            System.out.println(":(");
        } else {
            System.out.println("Yay!");
        }
    }
}


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

using namespace std;
typedef long long ll;
#define int ll

template<typename T1,typename T2> inline void chmin(T1 &a, T2 b){ if(a > b) a = b; }
template<typename T1,typename T2> inline void chmax(T1 &a, T2 b){ if(a < b) a = b; }

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
const int MAX_N = 100010;

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

    int K, X;
    cin >> K >> X;
    if(500 * K >= X) {
        printf("Yes\n");
    }
    else {
        printf("No\n");
    }

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include<algorithm>
#include <cstdio>
#include <cstring>
#include <vector>
#include <string>
using namespace std;


int main()
{
	long long int n,a,b,c;
	a = 1;
	b = 1;
	c = 1;
	scanf("%lld", &n);
	for (int i = 0; i < n; i++)
	{
		a =(a* 10) % (1000000000 + 7);
		b =(b* 9) % (1000000000 + 7);
		c =(c*8) % (1000000000 + 7);
	}
	b =(b* 2) % (1000000000 + 7);
	long long int sum = (a - b + c + (1000000000 + 7)) % (1000000000 + 7);
	
	printf("%lld", sum);
	
}

Measured memory_bytes: 1700
#include<bits/stdc++.h>
using namespace std;
const int N=2005;
int n,m,ans,s[N][N],x[N][N],z[N][N],y[N][N];
char a[N][N];
int main()
{
	cin>>n>>m;
	for(int i=1;i<=n;i++)cin>>a[i]+1;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
		{
			if(a[i][j]=='#')continue;
			if(i==1)
			{
				s[i][j]=1;
				continue;
			}
			s[i][j]=s[i-1][j]+1;
		}
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
		{
			if(a[i][j]=='#')continue;
			if(j==1)
			{
				z[i][j]=1;
				continue;
			}
			z[i][j]=z[i][j-1]+1;
		}
	for(int i=n;i;i--)
		for(int j=m;j;j--)
		{
			if(a[i][j]=='#')continue;
			if(i==n)
			{
				x[i][j]=1;
				continue;
			}
			x[i][j]=x[i+1][j]+1;
		}
	for(int i=n;i;i--)
		for(int j=m;j;j--)
		{
			if(a[i][j]=='#')continue;
			if(j==m)
			{
				y[i][j]=1;
				continue;
			}
			y[i][j]=y[i][j+1]+1;
		}
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			ans=max(ans,s[i][j]+x[i][j]+z[i][j]+y[i][j]-3);
	cout<<ans;
}

Measured memory_bytes: 66944
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
#define P pair<ll, ll>
using ll = long long;
#define ALL(v) (v).begin(),(v).end()
#define endl "\n"
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define co(x) cout << x << endl
#define coel cout << endl
#define pb push_back
#define sz(v) ((ll)(v).size())
using namespace std;  
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define pp pair<ll, pair<ll, ll>> 




////////////////////////////////////////////////////////

set<ll> a, b;

void PrimeFactorization(ll n, set<ll> &see){
    Rep(i, 2, sqrt(n)){
        while(n%i == 0){
            see.insert(i);
            n /= i;
        }
        if(n == 1) break;
    }
    if(n != 1) see.insert(n);
}


int main() {
    ll x, y;
    cin >> x >> y;
    PrimeFactorization(x, a);
    PrimeFactorization(y, b);
    ll ans = 0;
    for(auto s : a){
        ll bf = sz(b);
        b.insert(s);
        if(bf == sz(b)) ans++;
    }
    co(ans+1);

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdint>
#include <cassert>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

template <intmax_t X = 943681729, intmax_t MOD = 1000000007>
class rolling_hash {
  std::vector<intmax_t> hash, offset;

public:
  rolling_hash(const std::string& s): hash(s.length()+1), offset(s.length()+1) {
    for (size_t i = 0; i < s.length(); ++i)
      hash[i+1] = (hash[i]*X+s[i]) % MOD;

    offset[0] = 1;
    for (size_t i = 1; i <= s.length(); ++i)
      offset[i] = offset[i-1] * X % MOD;
  }

  intmax_t get_base() const { return X; }
  intmax_t get_mod() const { return MOD; }

  intmax_t prefix(size_t i) const {
    // hash of prefix s[0..i-1] (inclusive)
    assert(0 < i);
    return hash[i];
  }

  intmax_t substr(size_t i, size_t j) const {
    // hash of substring s[i..j-1] (inclusive)
    assert(i < j);
    intmax_t res = hash[j];
    res = (res - offset[j-i]*hash[i]) % MOD;
    if (res < 0) res += MOD;
    return res;
  }

  intmax_t inserted(size_t i, int ch) const {
    intmax_t res = 0;
    if (i > 0) res += prefix(i);
    res = (res*X + ch) % MOD;
    size_t n = hash.size()-1;
    if (i < n) res = (res*offset[n-i] + substr(i, n)) % MOD;
    return res;
  }

  void inspect() const {
    for (size_t i = 0; i < hash.size(); ++i)
      fprintf(stderr, "%jd%c", hash[i], i+1<hash.size()? ' ':'\n');
  }
};

int main() {
  char buf[1048576];
  scanf("%s", buf);
  std::string s = buf;

  scanf("%s", buf);
  std::string p = buf;

  rolling_hash<100> rls(s), rlp(p);
  size_t m = p.length();
  for (size_t i = m; i <= s.length(); ++i) {
    if (rls.substr(i-m, i) == rlp.prefix(m))
      printf("%zu\n", i-m);
  }
}



Measured memory_bytes: 20484
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
using namespace std;
using ll = long long;
#define MAX_N 1000001
#define MAX_M 100010
const long long mod = 1e9 + 7;
#define vec vector<int>
#define vecll vector<ll>
#define vecllvec vector<vector<ll>>
#define vecb vector<bool>
#define vecBvec vector<vector<bool>>
#define vecst vector<string>
#define veche vector<char>
#define vecd vector<double>
#define vecvec vector<vector<int>>
#define vecDvec vector<vector<double>>
#define vecHvec vector<vector<char>>
#define all(x) (x).begin(),(x).end()
#define ent cout<<endl
#define printvec(vec) for(int aqw=0;aqw<vec.size();aqw++){cout<<vec[aqw]<<" ";}ent;
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define REP(i,m,n) for(int i=m;i<(int)n;++i)
#define INF 1e+9
#define P pair<int, int>;
#define MAX_V 1000
#define PI 3.141592653589793
// cout << setprecision(15) << std::fixed;

int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	map<int, int> q;
	q[a]++;
	q[b]++;
	q[c]++;
	if (q[5] == 2 && q[7] == 1) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cassert>
#define ll long long
using namespace std;
inline ll read(){
    ll re=0,flag=1;char ch=getchar();
    while(ch>'9'||ch<'0'){
        if(ch=='-') flag=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9') re=(re<<1)+(re<<3)+ch-'0',ch=getchar();
    return re*flag;
}
ll n,K,cnt,a[200010],b[200010],tmp[500010],seg[500010],L[200010],R[200010],dp[200010],sum[200010];
void push(ll num){
    if(!seg[num]) return;
    seg[num<<1]=seg[num<<1|1]=seg[num];
    seg[num]=0;
}
void change(ll l,ll r,ll ql,ll qr,ll num,ll val){
    if(ql>qr) return;
    if(l>=ql&&r<=qr){seg[num]=val;return;}
    push(num);
    ll mid=(l+r)>>1;
    if(mid>=ql) change(l,mid,ql,qr,num<<1,val);
    if(mid<qr) change(mid+1,r,ql,qr,num<<1|1,val);
}
ll query(ll l,ll r,ll num,ll pos){
    if(l==r) return seg[num];
    push(num);
    ll mid=(l+r)>>1;
    if(mid>=pos) return query(l,mid,num<<1,pos);
    else return query(mid+1,r,num<<1|1,pos);
}
ll ask(ll pos){
    ll choose=query(1,cnt,1,pos);
    if(!choose) return 0;
    return (dp[choose]+(tmp[L[choose]]-tmp[pos]+K)%K);
}
ll erfen(ll val){
    ll l=1,r=cnt,mid;
    while(l<r){
        mid=(l+r)>>1;
        if(tmp[mid]>=val) r=mid;
        else l=mid+1;
    }
    assert(val==tmp[l]);
    return l;
}
int main(){
    n=read();K=read();ll i;
    for(i=1;i<=n;i++) {
        a[i]=read();b[i]=read();
        sum[i]=(sum[i-1]+a[i]);
        if(b[i]==2) continue;
        if(2*a[i]>K){
            puts("-1");return 0;
        }
    }
    for(i=n;i>=1;i--){
        if(b[i]==1){
            L[i]=(-2ll*sum[i-1]%K+K)%K;
            R[i]=(-2ll*sum[i]%K+K)%K;
        }
        else L[i]=0,R[i]=K-1;
        tmp[++cnt]=L[i],tmp[++cnt]=R[i];
    }
    sort(tmp+1,tmp+cnt+1);
    cnt=unique(tmp+1,tmp+cnt+1)-tmp-1;
    for(i=n;i>=1;i--){
        L[i]=erfen(L[i]);
        R[i]=erfen(R[i]);
        dp[i]=ask(L[i]);
        if(L[i]>R[i]) change(1,cnt,R[i]+1,L[i]-1,1,i);
        else change(1,cnt,1,L[i]-1,1,i),change(1,cnt,R[i]+1,cnt,1,i);
    }
    ll ans=dp[1];
    for(i=cnt;i>=1;i--) ans=min(ans,ask(i));
    printf("%lld\n",ans+sum[n]*2ll);
}

Measured memory_bytes: 15872
N = int(input())
Hs = list(map(int, input().split()))
res = [0] * N

for index, h in enumerate(Hs):
    l = 0
    if index > 0:
        l = max(res[index - 1] - 2, 0)

    tmp = h
    while index + l + 1 < N and tmp >= Hs[index + l + 1]:
        tmp = Hs[index + l + 1]
        l += 1
    res[index] = l

print(max(res))

Measured memory_bytes: 14224
#include<stdio.h>
 
int A[500001];
int n;
 
int left(int);

int right(int);

void maxHeapify(int);

void buildMaxHeap(void);
 
int main(){
 
  int i;

  scanf("%d", &n);

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

    scanf("%d", &A[i]);

  }

  buildMaxHeap();

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

    printf(" %d", A[i]);

  }

  printf("\n");

  return 0;

}

int left(int x){

  return (2 * x);

}
 
int right(int x){
  
  return (2 * x + 1);

}

void maxHeapify(int i){

  int l, r, largest, tmp;

  l = left(i);

  r = right(i);

  if((l <= n) && (A[l] > A[i]))
    largest = l;
  else
    largest = i;

  if((r <= n) && (A[r] > A[largest]))
    largest = r;

  if(largest != i){

    tmp = A[i];

    A[i] = A[largest];

    A[largest] = tmp;

    maxHeapify(largest);

  }

}
 
void buildMaxHeap(){

  int i;

  for(i = (n / 2); i >= 1; i--){

    maxHeapify(i);

  }

}

Measured memory_bytes: 2552
#include <stdio.h>
#include <stdlib.h>

int comp(const void *c1, const void *c2){
  int tmp1 = *(int *)c1;
  int tmp2 = *(int *)c2;

  if( tmp1 < tmp2 )  return -1;
  if( tmp1 == tmp2 ) return  0;
  if( tmp1 > tmp2 )  return  1;
}

void solve(n, m){
  int d1[n], d2[m], t1 = 0, t2 = 0, differ;
  int i, j;

  for(i = 0; i < n; i++){
    scanf("%d", &d1[i]);
    t1 += d1[i];
  }
  for(i = 0; i < m; i++){
    scanf("%d", &d2[i]);
    t2 += d2[i];
  }

  differ = t1 - t2;
  if(differ < 0){
    if ((differ * -1) %2 == 1){
      printf("-1\n");
      return;
    }
  }
  else{
    if(differ % 2 == 1){
      printf("-1\n");
      return;
    }
  }
  
  qsort(d1, n, sizeof(int), comp);
  qsort(d2, m, sizeof(int), comp);
  differ /= 2;
  for(i = 0; i < n; i++){
    for(j = 0; j < m; j++){
      if(d1[i] - differ == d2[j]){
	printf("%d %d\n", d1[i], d2[j]);
	return;
      }
    }
  }
  printf("-1\n");
  return;
}

int main(void){
  int n, m;
  
  while(1){
    scanf("%d %d", &n, &m);
    if(n == 0 && m == 0)
      return 0;
    else 
      solve(n, m);
  }
}


Measured memory_bytes: 616
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> pii;

int n;
double ans;

int main() {
    cin.sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        ans += (double)1/x;
    }
    
    ans = 1/ans;
    cout << ans << '\n';
}

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

int main() {
	long long N;
	cin >> N;
	vector<pair<long long, long long>> factor;
	for (long long i = 1; i * i <= N; i++) {
		if (N % i == 0) {
			auto x = make_pair(i, N / i);
			factor.push_back(x);
		}
	}

	auto x = factor.at((int)factor.size() - 1);
	long long ans = x.first + x.second - 2;
	cout << ans << endl;
}

Measured memory_bytes: 384
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <math.h>

//#define MOD (int)(1e5 + 7)
#define MOD (100007)

void invalid(void)
{
	printf("-1\n");
	exit(0);
}

static inline int *readNint(int n)
{
	int *a = calloc(sizeof(int), n);
	for (int i = 0; i < n; i++)
		scanf("%d", &a[i]);
	return a;
}

int main(int argc, char **argv)
{
	uint64_t H;
	scanf("%ld", &H);
	uint64_t m = 1;
	uint64_t n = 0;
	for (;;) {
		if (H == 1) {
			n += m;
			break;
		}
		n += m;
		m *= 2;
		H /= 2;
	}
	printf("%ld\n", n);
	return 0;
}


Measured memory_bytes: 128
import java.util.ArrayList;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc=new Scanner(System.in);
		
		int n=sc.nextInt();		//すぬけ人数
		int k=sc.nextInt();		//お菓子種類
	
		ArrayList<Integer>array=new ArrayList<>();
		
		for(int i=0;i<k;i++) {
			int d=sc.nextInt();		//お菓子の種類
			
			for(int m=0;m<d;m++) {		
				int sunu=sc.nextInt();
				if(!array.contains(sunu)) {
					array.add(sunu);
				}
			}
		}
		System.out.println(n-array.size());
		sc.close();
	}

}

Measured memory_bytes: 37412
#include<iostream>
typedef float f;f a,b,c,d,h,i,e,g;f r(f k,f l,f m,f n){m-=k;n-=l;k=e-k;l=g-l;return m*l-n*k?m*l-n*k>0?1:-1:0;}int main(){for(;!(std::cin>>a>>b>>c>>d>>h>>i>>e>>g).eof();)puts(r(a,b,c,d)==r(c,d,h,i)&&r(a,b,c,d)==r(h,i,a,b)?"YES":"NO");}

Measured memory_bytes: 0
import java.util.*

fun main(args: Array<String>) {
    val k = readLine()!!.toInt()
    val queue = ArrayDeque<Long>()
    for (i in 1..9L) queue.addLast(i)

    repeat(k - 1) {
        val x = queue.removeFirst()
        if (x % 10 != 0L) queue.addLast(x * 10 + x % 10 - 1)
        queue.addLast(x * 10 + x % 10)
        if (x % 10 != 9L) queue.addLast(x * 10 + x % 10 + 1)
    }

    println(queue.removeFirst())
}


Measured memory_bytes: 38676
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define MT make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define RT return
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;

const int MA = 100005;
vi G[MA], tree[MA];
vector<pii> ans;
bool vis[MA];
int deg[MA];

void dfs(int u, int p) {
    vis[u] = true;
    each(v, G[u])if (v != p) {
        if (vis[v]) {
            if (v > u) {
                ans.emplace_back(u, v);
                deg[u] = 1 - deg[u];
            }
        } else {
            tree[u].push_back(v);
            tree[v].push_back(u);
            dfs(v, u);
        }
    }
}

void rec(int u, int p) {
    each(v, tree[u]) if (v != p) {
        rec(v, u);
    }
    if (u == 1)return;
    if (deg[u]) {
        ans.emplace_back(u, p);
    } else {
        ans.emplace_back(p, u);
        deg[p] = 1 - deg[p];
    }
}

void solve() {
    int N, M;
    cin >> N >> M;
    rep(i, M) {
        int u, v;
        cin >> u >> v;
        G[u].push_back(v);
        G[v].push_back(u);
    }

    dfs(1, 0);

    rec(1, 0);

    if (deg[1])cout << -1 << endl;
    else {
        each(e, ans)cout << e.first << ' ' << e.second << endl;
    }
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}

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

using namespace std;
using ll = long long;

vector<ll> prime_factorize(ll n){
  vector<ll> res;
  for(ll p = 2; p*p <= n; p++){
    if(n % p != 0) continue;
    int num = 0;
    while(n % p == 0){
      num++;
      n /= p;
    }
    res.push_back(num);
  }
  
  if(n != 1) res.push_back(1);
  return res;
}

int main() {
  ll n;
  cin >> n;
  auto pf = prime_factorize(n);
  ll ans = 0;
  for(auto p : pf){
    ll ex = 1;
    while(p >= ex){
      p -= ex;
      ex++;
      ans++;
    }
  }
  cout << ans << endl;
}
  

Measured memory_bytes: 3604
#include<iostream>
#include <algorithm>
#include<string>
using namespace std;
int main()
{
	long long   a, b, c, d, e, ans = 0,n,
		M = 0, A = 0, R = 0, C = 0, H = 0;
	
	 //long long int a,  c, d, e, f = 0, ans = 0, n,m;
	//int b;
	// 整数の入力
	int num[100000];
	unsigned long long x, y;
	
	// 文字列の入力
	string s;
	cin >> n ;
	b = 0;
	for ( a = 0; a < n; a++)
	{
		cin >> s;
		if (s[0] == 'M')
		{
			M++;
		}
		else if (s[0] == 'A')
		{
			A++;
		}
		else if (s[0] == 'R')
		{
			R++;
		}
		else if (s[0] == 'C')
		{
			C++;
		}
		else if (s[0] == 'H')
		{
			H++;
		}
	}
	a = 0;
	a += M*A*R;
	a += M*A*C;
	a += M*A*H;
	a += M*R*C;
	a += M*R*H;
	a += M*C*H;
	a += A*R*C;
	a += A*R*H;
	a += A*C*H;
	a += R*C*H;
	/*cout << M << endl;
	cout << A << endl;
	cout << R << endl;
	cout << C << endl;
	cout << H << endl;*/
	cout <<a<< endl;

	


	
	// 出力
	return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define ROOP(i, N) for(int i=0; i<N; i++)
#define RVROOP(i, N) for(int i=N; i>=0; i--)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main() {
  string S,T; cin>>S>>T;
  cout<<T<<S<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cctype>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template<typename key, typename val>
//using ordered_tree =
//  tree<key, val, std::less<>, rb_tree_tag, tree_order_statistics_node_update>;
using namespace std;
typedef long long int64;
typedef unsigned long long uint64;
typedef complex<double> comp;
const double pi = 3.14159265358979323846;
const int inf = (int)1e+9 + 2;
const int64 inf64 = (int64)1e+18 + 2;
const double dinf = 1e+20;
const int mod = 1'000'000'007;//*/998244353;
const int base = 2187;
const double eps = 1e-9;
const int N = 300'000;
const int LOGN = 19;

int n, m, k;

void solve(int) {
  string s;
  cin >> s;
  int c = count(begin(s), end(s), 'A');
  if (c == 0 || c == 3) {
    cout << "No\n";
  } else {
    cout << "Yes\n";
  }
}

void precalc() {
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  precalc();
  int test = 1;
  //cin >> test;
  //auto start = chrono::high_resolution_clock::now();
  for (int i = 1; i <= test; ++i) {
    solve(i);
  }
  //cerr << chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - start).count() << '\n';
  return 0;
}



Measured memory_bytes: 768