akhauriyash/Code-Regression huggingface dataset:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

k = inp()
if k < 10:
    print(k)
    quit()

q = deque()
for i in range(9):
    q.append(i+1)
cnt = 10
while True:
    x = q.popleft()
    xx = int(str(x)[-1])
    for i in [-1,0,1]:
        if 0 <= xx+i < 10:
            tmp = x * 10 + xx+i
            if cnt == k:
                print(tmp)
                quit()
            q.append(tmp)
            cnt += 1

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

#define pb push_back
#define sz(X) ((int)(X).size())
#define all(X) (X).begin(),(X).end()
#define ll long long
#define pi pair<int,int>
const int N=1e5+5,MOD=100;

using namespace std;
int n,k;
string a;
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin>>n>>k>>a;

	for(int i=0;i<n;i++){
		if(i==(k-1)){
			if(a[i]=='A')a[i]='a';
			else if(a[i]=='B')a[i]='b';
			else a[i]='c';
		}
	}

	cout<<a<<endl;
}


Measured memory_bytes: 256
using System;
using System.Linq;

class Program
{
    static void Main()
    {
        int[] n = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int X = n[0];
        int A = n[1];
        int B = n[2];
        int t = -A + B;
        if (t <= 0)
        {
            Console.WriteLine("delicious");
        }
        else if (t <= X)
        {
            Console.WriteLine("safe");
        }
        else
        {
            Console.WriteLine("dangerous");
        }
    }
}

Measured memory_bytes: 13268
using System;
using System.Collections.Generic;
using System.Linq;

static class SwitchingRailroadCars
{
    static void Main()
    {
        RepeatInfinite<Func<string>>( Console.ReadLine )
            .Select( x => x() )
            .TakeWhile( x => x != null )
            .Select( int.Parse )
            .Aggregate(
                new { st = new Stack<int>(), sq = new List<int>() },
                (x, y) => {
                    if ( y > 0 )
                        x.st.Push( y );
                    else
                        x.sq.Add( x.st.Pop() );
                    return new { st = x.st, sq = x.sq };
                    },
                x => x.sq )
            .ForEach( Console.WriteLine );
    }

    static IEnumerable<TSource> RepeatInfinite<TSource>(TSource value)
    {
        while ( true )
            yield return value;
    }
}

Measured memory_bytes: 6204
#include <bits/stdc++.h>
#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << "\n"
using namespace std;
using ll = long long; using pint = pair<int, int>; using pll = pair<ll, ll>;
template<typename T> auto compare = [](T x, T y) -> bool{return (x < y);};
const int MOD = 1000000007;

ll N;
ll A[200010];

signed main(){
    cin >> N;
    ll sum = 0;
    REP(i, N){
        cin >> A[i];
        sum = sum ^ A[i];
    }
    REP(i, N){
        cout << (sum ^ A[i]);
        if(i == N - 1) cout << endl;
        else cout << " ";
    }
    return 0;
}

Measured memory_bytes: 5196
import java.io.*;
import java.util.*;
public class Main {
	public static void main (String args[]){
	Scanner sc=new Scanner(new InputStreamReader(System.in));
	int w=sc.nextInt();
	int h=sc.nextInt();
	int x=sc.nextInt();
	int y=sc.nextInt();
	int r=sc.nextInt();
	sc.close();
	if(x-r>=0&&x+r<=w&&y-r>=0&&y+r<=h){
		System.out.println("Yes");
	}
	else{
		System.out.println("No");
	}
	}
}

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

using namespace std;

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

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

    int b[n];
    b[0] = a[0] + k - a[n-1];
    for (int i = 0; i < n-1; i++)
    {
        b[i+1] = a[i+1] - a[i];
    }

    int m = b[0];
    for (int i = 1; i < n; i++)
    {
        if (m < b[i])
        {
            m = b[i];
        }
    }

    k -= m;
    cout << k << endl;

    return 0;
}

Measured memory_bytes: 1792
s = list(input())
ls = len(s)
key = "keyence"
if "".join(s) == key:
    print("YES")
    exit()
f = False
for l in range(ls):
    for r in range(l + 1, ls):
        f |= "".join(["".join(s[:l]), "".join(s[r:])]) == key

print("YES" if f else "NO")


Measured memory_bytes: 9028
#include <iostream>
#include <vector>
#include <cmath>
#include <set>
#include <queue>
#include <map>
#include <cstdio>
#include <cstring>
#include <string>
#include <stack>
#include <algorithm>
#include <limits.h>
#include <bits/stdc++.h>
#define fw(x) freopen("x.txt","w",stdout)
#define For(i,a,b,c) for(int i = a;i < b;i+=c)
#define REP(i,n) for(int i = 0;i < n;++i)
#define REP1(i,n) for(int i = 1; i<=n;i++)
#define mem(a,s) memset(a,s,sizeof a)
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL)
#define pf printf
#define sc scanf
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define all(v) v.begin(),v.end()
#define vii vector<int>
#define vll vector<ll>
#define vss vector<string>
#define debug(x)  cout<<#x"="<<(x)<<endl
#define pb push_back


using namespace std;


// moves

//int dx[]= {0,0,1,-1};/*4 side move*/
//int dy[]= {-1,1,0,0};/*4 side move*/
//int dx[]= {1,1,0,-1,-1,-1,0,1};/*8 side move*/
//int dy[]= {0,1,1,1,0,-1,-1,-1};/*8 side move*/
//int dx[]={1,1,2,2,-1,-1,-2,-2};/*knight move*/
//int dy[]={2,-2,1,-1,2,-2,1,-1};/*knight move*/


//big_mod

//ll bigmod(ll a,ll b,ll m)
//{if(b == 0) return 1%m;ll x = bigmod(a,b/2,m);x = (x * x) % m;if(b % 2 == 1) x = (x * a)% m;return x;}
//ll BigMod(ll B,ll P,ll M){ ll R=1%M; while(P>0) {if(P%2==1){R=(R*B)%M;}P/=2;B=(B*B)%M;} return R;} /// (B^P)%M

//ll getBit(ll num, int idx) {return ((num >> idx) & 1ll) == 1ll;}
//ll setBit1(ll num, int idx) {return num or (1ll<<idx);}
//ll setBit0(ll num, int idx) {return num & ~(1ll<<idx);}
//ll flipBit(ll num, int idx) {return num ^ (1ll<<idx);}

const int mod = 1000000007;
ll qpow(ll n,ll k)
{
    ll ans=1;
    assert(k>=0);
    n%=mod;
    while(k>0)
    {
        if(k&1)
            ans=(ans*n)%mod;
        n=(n*n)%mod;
        k>>=1;
    }
    return ans%mod;
}
double dp[3000][3000];
int main()
{
    fast;
    int n;
    cin>>n;
    double arr[n+1];
    REP1(i, n) cin>>arr[i];
    REP(i, n+1){
      REP1(j, n){
        if(i>j) dp[i][j] = 0;
        else if(i==0&&j==1) dp[i][j] = 1.0 - arr[j];
        else if(i==1&&j==1) dp[i][j] = arr[j];
        else{
          dp[i][j] = 0;
          if(i>0&&j>0) dp[i][j] = dp[i-1][j-1]*arr[j];
          if(j>0){
             dp[i][j] += (dp[i][j-1] * (1.0-arr[j]));
          }
        }
      }
    }
    double ans = 0;
    for(int i=n/2+1; i<=n; i++) ans += dp[i][n];
    printf("%.9f\n", ans);
    return 0;
}


Measured memory_bytes: 74076
/**********************************************
#code by --> @ { shadat </> sk40 [ o_o  ^_^ ] } }
**********************************************/
#include<bits/stdc++.h>
#include<algorithm>
#include<queue>
#include<list>
#include<map>
#include <math.h>
#include<numeric>
using namespace std;
#define tezz ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
#define ull unsigned long long int
#define doub long double
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define pii pair<int , int>
#define pdd pair<double , double>
#define pll pair<long long int,long long int>
#define vpl vector<pll >
#define vll vector<ll >
#define mod 1000000007
#define stp setprecision(20)
string s;
string dd={'a','e','i','o','u','y'};
ll count1[1<<20];
ll total[1<<20];
bool contains(char c,string f){
	for(int i=0;i<f.length();i++){
		if(c==s[i]){
			return true;
		}
	}
	return false;
}
const int maxi=1e5;
 
int main() {
	int n,i;
	vector<long long> d;
	long long j,k,a[505],sum=0,ds;
	cin >> n >> k;
	for(i=0;i<n;i++){
		cin >> a[i];
		sum+=a[i];
	}
	for(j=1;j<=sqrt(sum);j++){
		if(sum%j==0){
			if(j*j!=sum){
				d.push_back(j);
				d.push_back(sum/j);
			} else {
				d.push_back(j);
			}
		}
	}
	sort(d.begin(),d.end());
	ds=d.size();
	for(j=ds-1;j>=0;j--){
		long long e=d[j],sume=0,min;
		int ms;
		vector<long long> m;
		for(i=0;i<n;i++){
			if(a[i]%e!=0) m.push_back(a[i]%e);
			sume+=a[i]%e;
		}
		ms=m.size();
		if(ms==0){
			cout << e << endl;
			return 0;
		}
		sort(m.begin(),m.end());
		min=e*ms-sume;
		long long summ=0,sumr,memo;
		for(i=1;i<=ms;i++){
			summ+=m[i-1];
			sumr=e*(ms-i)-sume+summ;
			if(summ>=sumr) memo=summ;
			else memo=sumr;
			if(min>memo) min=memo;
			if(min<=k){
				cout << e << endl;
				return 0;
			}
		}
	}
	return 0;
}
int maa() {
	long long n, l, i, j;
	cin >> n >> l;

	long long *a = new long long[n];
	for (i = 0; i < n; i++) {
		cin >> a[i];
	}

	long long min = a[0];
	long long min_location = 0;
	
	for (i = 1; i < n; i++) {
		if (min > a[i]) {
			min = a[i];
			min_location = i;
		}
		
		cout << min << " ";
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <iomanip>
#include <functional>
#include <bitset>
#include <limits>
#include <cstdio>
#include <cmath>
#include <cassert>
#include <random>

#ifdef DEBUG
#include "library/Utility/debug.cpp"
#else
#define debug(...)
#endif

#define rep(i,n) for(int i=0;i<(n);++i)
#define EL '\n'
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
using lnt = long long;
struct FIO{FIO(){std::cin.tie(0);std::cout.tie(0);std::ios_base::sync_with_stdio(0);std::cout<<std::fixed<<std::setprecision(15);}}fIO;
/*-*/

int main() {
	int n;
	std::cin >> n;
	std::string s;
	std::cin >> s;
	lnt count=0;
	rep(i,n) if(s[i]=='R') count++;
	int ans=0;
	rep(i,count) {
		if(s[i]=='W') ans++;
	}
	print(ans);
}


Measured memory_bytes: 3772
// #include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <set>
#include <queue>
#include <cstdio>
using namespace std;
#define rep(i, n) for(int i=0;i<n;i++)
#define irep(i, n) for(int i=n-1;i>=0;i--)
#define lrep(i, n) for(long long i=0;i<n;i++)
typedef long long ll;
typedef vector<long long> llv;
typedef vector<vector<long long> > llvv;

int dp[50];

int fib(int n){
    if (n == 0 | n == 1) return dp[n] = 1;
    if (dp[n] != -1) return dp[n];
    return dp[n] = fib(n-2) + fib(n-1);
}

int main(){
    int n;
    cin >> n;
    for (int i=0;i<=50;i++) dp[i] = -1;
    cout << fib(n) << endl;
}


Measured memory_bytes: 3104
n, m = map(int, input().split())
mod = 10 ** 9 + 7
dp = [-1 for i in range(n + 1)]
dp[0], dp[1] = 1, 1
for _ in range(m):
    dp[int(input())] = 0
for i in range(2, n + 1):
    if dp[i] != 0:
        dp[i] = (dp[i - 1] + dp[i - 2]) % mod
print(dp[n])

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

using namespace std;

using ll = long long;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORE(i, a, b) for (int i = (a); i <= (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repe(i, n) for (int i = 0; i <= (n); ++i)
#define all(v) (v).begin(), (v).end()
#define sp cout << fixed << setprecision(10)
typedef pair<int, int> P;
const int inf = (int)1e9;
const int mod = (int)1e9 + 7;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

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

    int a, b;
    cin >> a >> b;

    if (a == b) {
        rep(i, a) { cout << a; }
        cout << endl;
    } else if (a > b) {
        rep(i, a) { cout << b; }
        cout << endl;
    } else {
        rep(i, b) { cout << a; }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
using namespace std;
string rev(string s){
  reverse(s.begin(),s.end());
  return s;
}
int main(){
  int t;
  cin>>t;
  while(t--){
    set<string> tbl;
    string s;
    cin >> s;
    for(int i=1;i<s.length();++i){
      string a = s.substr(0,i);
      string b = s.substr(i,s.length()-i);
      for(int i=0;i<4;++i){
	string c=a,d=b;
	if(i&1) c = rev(c);
	if(i>=2) d = rev(d);
	tbl.insert(c+d);
	tbl.insert(d+c);
      }
    }
    cout << tbl.size() << endl;
  }
  return 0;
}

Measured memory_bytes: 1292
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPS(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)

#define INF (3e15)

using namespace std;

int N;
int df[100005];
int ds[100005];
vector<int> e[100005];

void bfs(queue<int>& q, int d[])
{
    while (!q.empty())
    {
        int v = q.front(); q.pop();
        for (int i = 0; i < e[v].size(); ++i)
        {
            int to = e[v][i];
            if (d[to] > 0) continue;
            d[to] = d[v] + 1;
            q.push(to);
        }
    }
}

signed main()
{
    cin >> N;

    REP(i,N-1)
    {
        int a, b;
        cin >> a >> b;
        e[a].push_back(b);
        e[b].push_back(a);
    }

    queue <int> qf;
    qf.push(1);
    bfs(qf, df);

    queue <int> qs;
    qs.push(N);
    bfs(qs, ds);

    int sunuke = 0;
    int fennec = 0;
    REPS(i, N)
    {
        ds[i] < df[i] ? sunuke++ : fennec++;
    }
    sunuke >= fennec ? cout << "Snuke" << endl : cout << "Fennec" << endl;
    return 0;
}

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

const long MOD = 1000000007;

bool duplicated(vector<int>& A) {
  return adjacent_find(A.begin(), A.end()) != A.end();
}

void abort() {
  cout << 0 << endl;
  exit(0);
}

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> A(N), B(M);
  for (int& a : A) cin >> a;
  for (int& b : B) cin >> b;
  sort(A.begin(), A.end(), greater<>());
  sort(B.begin(), B.end(), greater<>());
  if (duplicated(A) || duplicated(B)) abort();

  long ans = 1;
  int ai = 0, bi = 0;
  for (int x = N * M; 0 < x; x--) {
    int num_filled = N * M - x;
    bool fa = ai < N && A[ai] == x;
    bool fb = bi < M && B[bi] == x;
    ai += fa; bi += fb;
    if (fa && fb) continue;
    else if (!fa && !fb) {
      if (ai * bi < num_filled + 1) abort();
      ans *= ai * bi - num_filled;
    } else {
      if (fa) ans *= bi;
      if (fb) ans *= ai;
    }
    ans %= MOD;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
int main()
{
	ll n;
	cin>>n;
	vector<ll> vec(n,0);
	ll a=1,b=0;
	for(ll i=0;i<n;i++){
		cin>>vec[i];
		if(vec[i]==a){
			a++;b++;
		}
	}
	if(b==0) cout<<-1<<endl;
	else cout<<(n-b)<<endl;
}

Measured memory_bytes: 1792
n, k = map(int, input().split())
lr = [list(map(int, input().split())) for _ in range(k)]
mod = 998244353

# 解説AC
dp, acc = [0] * (n + 1), [0] * (n + 1)
dp[1], acc[1] = 1, 1
for i in range(2, n + 1):
    for l, r in lr:
        accl, accr = max(i - (r + 1), 0), max(i - l, 0)
        dp[i] += acc[accr] - acc[accl]
    dp[i] %= mod
    acc[i] = (dp[i] + acc[i - 1]) % mod
print(dp[n])


Measured memory_bytes: 77424
<?php
$liner = "####################";
$info_count = intval(trim(fgets(STDIN)));
$array_all_buildings = array();
for( $i = 0 ; $i < 4 ; ++ $i ){
    $array_bulding = array();
    for ( $j = 0 ; $j < 3 ; ++ $j){
        $array_rooms = array();
        for ($k=0;$k<10;$k++){
            $array_rooms[$k]=0;
        }
        $array_bulding[$j] = $array_rooms ;
    }
    $array_all_buildings[$i] = $array_bulding;
}
for ( $i = 0 ; $i < $info_count ; ++ $i ) {
    fscanf( STDIN , '%d %d %d %d' , $building_num , $floor_num , $room_num , $residents );
    $array_all_buildings[$building_num-1][$floor_num-1][$room_num-1] += $residents;
}
for ($i = 0; $i <4 ; ++ $i ){
    for ($j =0 ; $j<3 ; ++ $j){
        echo " ",join(' ',$array_all_buildings[$i][$j]),PHP_EOL;
    }
    if($i!==3){
        echo $liner,PHP_EOL;
    }
}

Measured memory_bytes: 15436
package main

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

var stdInScanner = bufio.NewScanner(os.Stdin)

func nextInt() int {
	stdInScanner.Scan()
	i, _ := strconv.Atoi(stdInScanner.Text())
	return i
}

func main() {
	stdInScanner.Split(bufio.ScanWords)

	X := nextInt()

	coin500 := X / 500
	X %= 500
	coin5 := X / 5

	fmt.Println(coin500*1000 + coin5*5)
}


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

using namespace std;

int main(){
	int n;
	double sum = 0;
	string temp;
	cin >> n;
	map<string, double> num;
	for(int i = 0; i < n; i++){
		cin >> temp;
		if(num.find(temp) != num.end()){
			if(num[temp] == 0)
				num[temp] = 1;
			else
				num[temp] = 0;
		}
		else{
			num[temp] = 1;
		}
	}
	for(map<string, double>::iterator it = num.begin(); it != num.end(); it++){
		sum += it -> second;
	}
	cout << sum;
	
	return 0;
} 

Measured memory_bytes: 12544
n, t = gets.split.map(&:to_i)
d = []
n.times{|i|
  c, tt = gets.split.map(&:to_i)
  d << {
    :cost => c,
    :time => tt
  }
}
d.sort!{|a, b|
  v = -1 if a[:cost] < b[:cost]
  v = 1 if a[:cost] > b[:cost]
  v = 0 if a[:cost] == b[:cost]
  v
}
d.each{|dd|
  if dd[:time] <= t
    puts dd[:cost]
    exit
  end
}
puts "TLE"


Measured memory_bytes: 3836
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int A = sc.nextInt();
        int B = sc.nextInt();

        int ans = 0;
        for(int i = 1; i <= N; i++){
            //数字iの各桁の和を算出
            int tmp = i;
            int sum = 0;
            while(tmp > 0){
                sum += tmp % 10;
                tmp /= 10;
            }
          	//数字iの各桁の和がA以上B以下ならば加算
            if(sum >= A && sum <= B) ans += i;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 21332
k=input()
K=int(k)
array=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(array[K-1])


Measured memory_bytes: 2940
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main(void) {
	int A, B, T;
  	int n;
	int biscuit;
	scanf("%d %d %d",&A, &B, &T);
	n = T / A;
  	biscuit = B * n;
	printf("%d\n", biscuit);
	return 0;
}

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

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		String[] s = new String[n];
		int[] c = {0,0,0,0};
		String[] j = {"AC", "WA", "TLE", "RE"};
		
		for(int i=0;i<n;i++){
			s[i] = scan.next();
			if(s[i].equals(j[0])) {
				c[0]++;
			}else if(s[i].equals(j[1])) {
				c[1]++;
			}else if(s[i].equals(j[2])) {
				c[2]++;
			}else {
				c[3]++;
			}
		}
		
		for(int i=0;i<4;i++) {
			System.out.println(j[i]+" x "+c[i]);
		}
	}

}


Measured memory_bytes: 64428
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>

using namespace std;

int main(void) {
	long long n, i, j, time;
	long long c[1000005], s[10000005], f[10000005];

	cin >> n;

	for (i = 1;i < n;i++) {
		cin >> c[i] >> s[i] >> f[i];
	}

	for (i = 1;i <= n;i++) {
		time = 0;
		for (j = i;j < n;j++) {
			if (time <= s[j]) {
				time = s[j];
				time += c[j];
			}
			else {
				if (((time - s[j]) % f[j]) != 0) {
					time += f[j] - ((time - s[j]) % f[j]);
				}
				time += c[j];
			}
		}
		cout << time << endl;
	}
	return 0;
}

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

typedef long long ll;

string rotation(string s, int times)
{
    if (times < 0)
    {
        return s;
    }

    return s.substr(s.length() - times, times) + s.substr(0, s.length() - times);
}

int main()
{
    string S, T;
    cin >> S >> T;

    for (int i = 0; i < S.length(); i++)
    {
        if (rotation(S, i) == T)
        {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;
}

Measured memory_bytes: 3632
#include<stdio.h>
int main()
{
	int a[3], i, temp, sum, j;
	for(i=0;i<3;i++)
	{
		scanf("%d", &a[i]);
	}
	for(i=0;i<3;i++)
	{
		for(j=i+1;j<3;j++)
		{
			if(a[i] > a[j])
			{
				temp = a[i];
				a[i] = a[j];
				a[j] = temp;
			}
		}
	}
	sum = a[2]-a[0];
	printf("%d\n", sum);

}


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

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

using ll  = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define rep1r(i, n) for (int i = ((int)(n)); i > 0; --i)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
// #define SORT(v, n) stable_sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

#define MAX 2000000
int H, A[MAX + 1];

void maxHeapify(int i) {
    int l, r, largest;
    l = 2 * i;
    r = 2 * i + 1;

    // 左の子、自分、右の子で値が最大のノードを選ぶ。
    if (l <= H && A[l] > A[i])
        largest = l;
    else
        largest = i;
    if (r <= H && A[r] > A[largest]) largest = r;

    if (largest != i) {
        swap(A[i], A[largest]);
        maxHeapify(largest);
    }
}

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

    cin >> H;
    rep1(i, H) cin >> A[i];
    rep1r(i, H / 2) maxHeapify(i);
    rep1(i, H) cout << " " << A[i];
    cout << endl;

    return 0;
}



Measured memory_bytes: 5132
#include <iostream>
#include <cstdio>
#include <string>
#include <queue>
using namespace std;

int main(void){
	while(1){
		int n;
		vector<int> num;
		cin >> n;
		if(n == 0) break;

		for(int i=0; i<n; i++){
			int t;
			cin >> t;
			num.push_back(t);
		}

		int a = 32;
		int i=0;
		while(1){
			a -= (a-1)	% 5;
			if(a <= 0) {
				cout << 0 << endl;
				break;
			}
			cout << a << endl;
			a -= num[i % num.size()];
			i++;
			if(a <= 0) {
				cout << 0 << endl;
				break;
			}
			cout << a << endl;
		}

	}


	return 0;
}

Measured memory_bytes: 1208
#include <cstdio>
#include <algorithm>
#define maxn 200010
using namespace std;
int a[maxn],b[maxn],sum;
int main(){
	int n,m,k,i,j,ans;
	scanf("%d%d%d",&n,&m,&k);
	for(i=1;i<=n;i++)scanf("%d",&a[i]);
	for(i=1;i<=m;i++)scanf("%d",&b[i]);
	i=j=1;
	while(i<=n&&sum+a[i]<=k)sum+=a[i],i++;
	while(j<=m&&sum+b[j]<=k)sum+=b[j],j++;
	i--,j--;
	ans=i+j;
	while(i){
		sum-=a[i],i--;
		j++;
		while(j<=m&&sum+b[j]<=k)sum+=b[j],j++;
		j--;
		ans=max(ans,i+j);
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 3248
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<limits>

using namespace std;

using uint = unsigned int;
using ll = long long;

// #define OUTPUT_LOG

void getLeftPos(vector<ll>& B, uint& l, uint& c) {
  ll cval = B[c];
  ll pre_diff = abs((B[l - 1] - 0) - (cval - B[l - 1]));
  ll lsum, rsum;

#ifdef OUTPUT_LOG
  cout << "search left pos" << endl;
  cout << l - 1 << ":" << pre_diff << endl;
#endif

  while(l < c) {
    lsum = B[l] - 0;
    rsum = cval - B[l];

#ifdef OUTPUT_LOG
    cout << l << ":" << abs(lsum - rsum) << endl;
#endif

    if (lsum - rsum > 0) {
      if (pre_diff < abs(lsum - rsum)) {
        --l;
      }
      return;
    }

    ++l;
    pre_diff = abs(lsum - rsum);
  }

  --l;
  return;
}

void getRightPos(vector<ll>& B, uint& r, uint& c) {
  uint len = B.size() - 1;
  ll cval = B[c];
  ll eval = B[len];
  ll pre_diff = abs((B[r - 1] - cval) - (eval - B[r - 1]));
  ll lsum, rsum;

#ifdef OUTPUT_LOG
  cout << "search right pos" << endl;
  cout << r - 1 << ":" << pre_diff << endl;
#endif

  while(r < len) {
    lsum = B[r] - cval;
    rsum = eval - B[r];

#ifdef OUTPUT_LOG
    cout << r << ":" << abs(lsum - rsum) << endl;
#endif

    if (lsum - rsum > 0) {
      if (pre_diff < abs(lsum - rsum)) {
        --r;
      }
      return;
    }
    ++r;
    pre_diff = abs(lsum - rsum);
  }

  --r;
  return;
}

ll getVal(vector<ll>& B, uint l, uint c, uint r) {
  vector<ll> sum(4);
  sum[0] = B[l] - 0;
  sum[1] = B[c] - B[l];
  sum[2] = B[r] - B[c];
  sum[3] = B[B.size() - 1] - B[r];
#ifdef OUTPUT_LOG
  cout << "l: " << l << ", c: " << c << ", r: " << r << endl;
  cout << "sum[0]: " << sum[0] << endl;
  cout << "sum[1]: " << sum[1] << endl;
  cout << "sum[2]: " << sum[2] << endl;
  cout << "sum[3]: " << sum[3] << endl;
#endif
  ll maxval = *max_element(sum.begin(), sum.end());
  ll minval = *min_element(sum.begin(), sum.end());

  return maxval - minval;
}

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

  uint N;
  cin >> N;

  vector<ll> B(N+1);
  B[0] = 0;
#ifdef OUTPUT_LOG
  cout << "B: 0, ";
#endif
  ll buf;
  for (int i = 1; i <= N; ++i) {
    cin >> buf;
    B[i] = B[i-1] + buf;

#ifdef OUTPUT_LOG
    cout << B[i] << ", ";
#endif

  }

#ifdef OUTPUT_LOG
  cout << endl;
#endif

  ll minval = numeric_limits<ll>::max();
  uint l = 1, r = 3;
  for (uint c = 2; c <= N - 2; ++c) {
    if (r <= c) r = c + 1;

    getLeftPos(B, l, c);
    getRightPos(B, r, c);
    
    ll val = getVal(B, l, c, r);
    if (val < minval) minval = val;
  }

  cout << minval << endl;

  return 0;
}

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

int n;
//それまでの文字列＋n番目の文字
//n文字の標準形を出力する
void dfs(string s, char mx){
  if(s.size() == n){
    cout << s << endl;
    return;
  }
  //n-1までの文字列＋n番目の文字
  //mx:確定した文字列の最大
  for(char c = 'a'; c <= mx+1; c++){
    string t = s;
    t += c;
    dfs(t, max(mx, c));  // 確定した文字列と、新しい文字列のどっちが最大か
  }
}

int main(){
  cin >> n;
  dfs("",'a'-1);
  return 0;
}


Measured memory_bytes: 1536
H,W = map(int,input().split())
grid = []
for i in range(H):
    grid.append(input())

current = (0,0)
good = True
for y in range(H):
    for x in range(W):
        if grid[y][x] == "#":
            count = 0
            aboveCount = 0
            if W-1>x and grid[y][x+1] == "#":
                count+=1
            if H-1>y and grid[y+1][x] == "#":
                count+=1
            if x>0 and grid[y][x-1] == "#":
                aboveCount+=1
            if 0<y and grid[y-1][x] == "#":
                aboveCount+=1
            if (aboveCount==0 and y+x!=0) or (count!=1 and y+x!=H+W-2):
                good = False
                break
if good:
    print("Possible")
else:
    print("Impossible")


Measured memory_bytes: 3064
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cctype>

#include <algorithm>
#include <random>
#include <bitset>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <vector>
#include <chrono>
#include <iostream>
#include <limits>
#include <numeric>

#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

template <class T>
istream& operator>>(istream& is, vector<T>& v) {
  for (T& x : v)
    is >> x;
  return is;
}

template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  if (!v.empty()) {
    os << v.front();
    for (int i = 1; i < v.size(); ++i)
      os << ' ' << v[i];
  }
  return os;
}

int main() {
#ifdef LBT
  freopen("test.in", "r", stdin);
  int nol_cl = clock();
#endif
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  int m, d;
  cin >> m >> d;
  if (m == 2)
    cout << (d == 28);
  else if (m == 1 || m == 3 || m == 5 || m == 7 || m == 8 || m == 10 || m == 12)
    cout << (d == 31);
  else
    cout << (d == 30);

#ifdef LBT
  LOG("Time: %dms\n", int ((clock()
          -nol_cl) / (double)CLOCKS_PER_SEC * 1000));
#endif
  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        String s1 = scan.next();
        String s2 = scan.next();
        int mode = 0;
        char[] d1 = s1.toCharArray();
        char[] d2 = s2.toCharArray();
        int current = 0;
        long answer = 1;
        long MOD = 1000000007;
        while (current < N) {
            if(d1[current] == d2[current]) {
                if (mode == 0) {
                    answer *= 3;
                } else if (mode == 1) {
                    answer *= 2;
                } else {
                    answer *= 1;
                }
                answer %= MOD;
                mode = 1;
                current += 1;
            } else {
                if (mode == 0) {
                    answer *= 6;
                } else if (mode == 1) {
                    answer *= 2;
                } else {
                    answer *= 3;
                }
                mode = 2;
                answer %= MOD;
                current += 2;
            }
        }
        System.out.println(answer);
    }
}


Measured memory_bytes: 23764
using System;

class BComparingStrings {
    static void Main(string[] args) {
        string[] line = System.Console.ReadLine().Trim().Split(' ');
        if (int.Parse(line[0]) < int.Parse(line[1])) {
            System.Console.WriteLine(new String(line[0][0], int.Parse(line[1])));
        } else {
            System.Console.WriteLine(new String(line[1][0], int.Parse(line[0])));
        }
    }
}


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

using namespace std;

typedef long long int li;
typedef vector<li> vi;
typedef pair<li,li> pi;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define B begin()
#define E end()
#define f(i,l,r) for(li i=l;i<=r;++i)
#define fr(i,l,r) for(li i=l;i>=r;--i)
#define u_map unordered_map

li fastpow(li base,li exp,li M) 
{
    li res=1;
    while(exp>0) {
        if(exp&1)
            res=(res*base)%M;

        base=(base*base)%M;
        exp>>=1;
    }
    return res;
}
    
int main()
{    
    ios_base::sync_with_stdio(false);
        cin.tie(NULL);

        li n;

        cin>>n;

        li a[n];

        for(li i=0;i<n;i++)
            cin>>a[i];

        li ans=0;

        f(i,0,n-1)
        {
            f(j,i+1,n-1)
            {
                ans+=(a[i]*a[j]);
            }
        }

        cout<<ans;

    return 0;
}

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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

int main()
{
  int N, L; scanf("%d %d", &N, &L);
  vector<string> S(N);
  for (int i = 0; i < N; ++i) {
    cin >> S[i];
  }
  sort(S.begin(), S.end());
  string ans;
  for (int i = 0; i < N; ++i) {
    ans += S[i];
  }
  printf("%s\n", ans.c_str());
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdio>

#define Maxn 100010

using namespace std;

inline int read() {
    int x = 0, f = 1;
    char c = getchar();
    while(c < '0' || c > '9') {
        if(c == '-') f = -1;
        c = getchar();
    }
    while('0' <= c && c <= '9') {
        x = x * 10 + c - '0';
        c = getchar();
    }
    return x * f;
}

int n, m, height[Maxn];
bool isgood[Maxn];

int main() {
    n = read(); m = read();
    for(int i = 1; i <= n; ++i) height[i] = read();
    int u, v;
    memset(isgood, true, sizeof(isgood));
    for(int i = 1; i <= m; ++i) {
        u = read(); v = read();
        if(height[u] < height[v]) isgood[u] = 0;
        if(height[u] > height[v]) isgood[v] = 0;
        if(height[u] == height[v]) isgood[u] = isgood[v] = 0;
    }
    int ans = 0;
    for(int i = 1; i <= n; ++i) {
        if(isgood[i]) ++ans;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4072
H, W, D = map(int, input().split())
A = []
N = (H * W)
indices = [None] * (N + 1)
for h in range(H):
    tmp = list(map(int, input().split()))
    A.append(tmp)
    for w in range(W):
        indices[tmp[w]] = (h, w)

d = [0] * (N + 1)
for i in range(D+1, N+1):
    y1, x1 = indices[i]
    y2, x2 = indices[i-D]
    d[i] = d[i-D] + abs(y1 - y2) + abs(x1 - x2)

Q = int(input())
for _ in range(Q):
    l, r = map(int, input().split())
    print(d[r] - d[l])

Measured memory_bytes: 17888
n = gets.chomp.to_i
nums = gets.chomp.split.map(&:to_i)

count = 0
n.times do |i|

   minIndex = i

   for j in i..(n-1) do

      if nums[j] < nums[minIndex]
         minIndex = j
      end

   end

   if minIndex != i
      temp = nums[i]
      nums[i] = nums[minIndex]
      nums[minIndex] = temp
      count += 1
   end

end

puts nums.join(' ')
puts count

Measured memory_bytes: 8652
from math import gcd

N=int(input())
A=list(map(int,input().split()))
B=[]
for i in range(N):
  if A[i]!=1:
    B.append(A[i])
F1=1
F2=0
X=A[0]
for i in range(N):
  X=gcd(X,A[i])
if X==1:
  F2=1
def f(x):
  r=[]
  for i in range(2,int(x**0.5)+1):
    if x%i==0:
      r.append(i)
      while x%i==0:
        x//=i
  if x!=1:
    r.append(x)
  return r

D=dict()
if len(B)>=80000:
  if F2:
    print('setwise coprime')
  else:
    print('not coprime')
  exit()
for i in range(len(B)):
  B[i]=f(B[i])
  for j in range(len(B[i])):
    if D.get(B[i][j],0):
      F1=0
      break
    D[B[i][j]]=1
  if F1==0:
    break
if F1:
  print('pairwise coprime')
elif F2:
  print('setwise coprime')
else:
  print('not coprime')

Measured memory_bytes: 209108
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef pair<int, int> P;
const int MAX_N = 5010;
const int MAX_M = 5 * 100010;
const int MAX_Y = MAX_N + MAX_M * 2;
const int MAX_W = MAX_N + MAX_M * 2;

int H, W, N, M, tsx[MAX_N], tsy[MAX_N];
vector<int> X, Y;

void init_number(){
  set<int> Ys, Xs;
  REP(i, N){ Xs.insert(tsx[i]); Ys.insert(tsy[i]); }
  Ys.insert((1e9 + 10) * -1);
  Ys.insert(1e9 + 10);
  Xs.insert((1e9 + 10) * -1);
  Xs.insert(1e9 + 10);
  X = vector<int>(Xs.begin(), Xs.end());
  Y = vector<int>(Ys.begin(), Ys.end());
  W = X.size();
  H = Y.size();
}

void init(vector< vector<int> > &v, vector< vector<int> > &E){
  E[0][0] = v[0][0];
  FOR(i, 1, H) E[i][0] = E[i - 1][0] + v[i][0];
  FOR(i, 1, W) E[0][i] = E[0][i - 1] + v[0][i];
  FOR(y, 1, H)
    FOR(x, 1, W)
    E[y][x] = v[y][x] + E[y - 1][x] + E[y][x - 1] - E[y - 1][x - 1];
}

int calc(int Y1, int X1, int Y2, int X2, vector< vector<int> > &E){
  int ret = E[Y2][X2];
  if(X1 - 1 >= 0) ret -= E[Y2][X1 - 1];
  if(Y1 - 1 >= 0) ret -= E[Y1 - 1][X2];
  if(X1 - 1 >= 0 && Y1 - 1 >= 0) ret += E[Y1 - 1][X1 - 1];
  return ret;
}

int main() {
  cin >>N >>M;
  REP(i, N) cin >>tsx[i] >>tsy[i];
  init_number();
  vector< vector<int> > v(H, vector<int>(W, 0)), E(H, vector<int>(W, 0));
  REP(i, N){
    int y = lower_bound(Y.begin(), Y.end(), tsy[i]) - Y.begin();
    int x = lower_bound(X.begin(), X.end(), tsx[i]) - X.begin();
    v[y][x] += 1;
  }
  init(v, E);
  REP(i, M){
    int x1, y1, x2, y2; cin >>x1 >>y1 >>x2 >>y2;
    x1 = lower_bound(X.begin(), X.end(), x1) - X.begin();
    y1 = lower_bound(Y.begin(), Y.end(), y1) - Y.begin();
    x2 = upper_bound(X.begin(), X.end(), x2) - X.begin() - 1;
    y2 = upper_bound(Y.begin(), Y.end(), y2) - Y.begin() - 1;
    cout <<calc(y1, x1, y2, x2, E) <<endl;
  }
  return 0;
}

Measured memory_bytes: 196896
#include <stdio.h>
int main(){
    int S,h,m,s, T;
    scanf("%d",&S);
    
    h=S/3600;
    T=S%3600;
    m=T/60;
    s=T%60;
    
    printf("%d:%d:%d\n",h,m,s);
    
    return 0;
}



Measured memory_bytes: 2100
#include <bits/stdc++.h>
using namespace std;
// nichijou
#define REP(i,a,b) for (int i(a), _B(b); i < _B; ++i)
#define RP(i,n) REP(i,0,n)
#define PER(i,a,b) for(int i((a)-1), _B(b); i >= _B; --i)
#define PR(i,n) PER(i,n,0)
#define REP1(i,a,b) REP(i,a,(b)+1)
#define RP1(i,n) REP1(i,1,n)
#define PER1(i,a,b) PER(i,(a)+1,b)
#define PR1(i,n) PER1(i,n,1)
#define DO(n) REP(__i,0,n)
template<typename T>
void cmax(T & a, T b) {a = max(a, b);}
template<typename T>
void cmin(T & a, T b) {a = min(a, b);}

// data type
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define F first
#define S second

// STL container
typedef vector<int> vi;
typedef vector<ll> vll;
#define SZ(a) ((int)a.size())
#define ALL(a) a.begin(), a.end()
#define CLR(a) a.clear()
#define BK(a) (a.back())
#define FT(a) (a.front())
#define DB(a) a.pop_back()
#define DF(a) a.pop_front()
#define PB push_back
#define EB emplace_back

/* I gave you my heart and then you turned around. */
void _BG(const char * s) {}
template<typename T, typename ... TT>
void _BG(const char * s,T a, TT...b)
{
	for (int c = 0; *s && (c || *s != ','); ++s) {
		cerr<<*s;
		switch (*s) {
		case '(':
		case '[':
		case '{':
			++c;
			break;
		case ')':
		case ']':
		case '}':
			--c;
			break;
		}
	}
	cerr<<" = "<<a;
	if (*s) {
		cerr<<", ";
		_BG(++s,b...);
	} else
		cerr<<endl;
}
#define BG(...) do { \
	cerr << __PRETTY_FUNCTION__ << ':' << __LINE__ << ": "; \
	_BG(#__VA_ARGS__,__VA_ARGS__); \
} while(0)

/* Reading input is now 20% cooler! */
bool RD(void) {return true;}
bool RD(char & a) {return scanf(" %c", &a) == 1;}
bool RD(char * a) {return scanf("%s", a) == 1;}
bool RD(double & a) {return scanf("%lf", &a) == 1;}
bool RD(int & a) {return scanf("%d", &a) == 1;}
bool RD(ll & a) {return scanf("%lld", &a) == 1;}

template<typename T, typename ... TT>
bool RD(T & a, TT & ...  b) {return RD(a) && RD(b...);}

/* Do princesses dream of magic sheep? */
#define RI(a) int a; RD(a)
#define RII(a,b) RI(a); RI(b)
#define RIII(a,b,c) RI(a); RII(b,c)
#define RIIII(a,b,c,d) RI(a); RIII(b,c,d)

/* For it's time for you to fulfill your output. */
void PT(const char a) {putchar(a);}
void PT(const char * a) {fputs(a, stdout);}
void PT(char * a) {fputs(a, stdout);}
void PT(const double a) {printf("%.16f", a);}
void PT(const int a) {printf("%d", a);}
void PT(const ll a) {printf("%lld", a);}

/* The line will last forever! */
template<char sep = ' ',char end = '\n'>
void PL(void) {if (end) PT(end);}
template<char sep = ' ',char end = '\n',typename T, typename ... TT>
void PL(const T a, const TT ...  b) {PT(a); if (sizeof...(b) && sep) PT(sep); PL<sep,end>(b...);}

/* Good Luck && Have Fun ! */
const int N = 1e5 + 87;
int h[N];
int main()
{
	RIII(n,a,b);
	a -= b;
	int lo = 1, hi = 1;
	RP(i,n) RD(h[i]), cmax(hi,(h[i]+b-1)/b);
	while (lo <= hi) {
		ll k = (lo + hi) / 2, c = 0;
		RP(i,n)
			if (h[i] >= k * b)
				c += (h[i] - k * b + a - 1) / a;
		if (c > k)
			lo = k + 1;
		else
			hi = k - 1;
	}
	PL(lo);
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define MOD 1000000007
#define PI 3.141592653589793
const int INF = 100000000;
int dx[] = {0,1,-1,0,1,-1,1,-1};
int dy[] = {1,0,0,-1,1,-1,-1,1};

int main(){
    int n, m;
    cin >> n >> m;
    vector<tuple<int, int, int, int>> v;
    for(int i = 1; i <= m; i++){
        int p, y, x = 0;
        cin >> p >> y;
        v.emplace_back(p, y, x, i);
    }
    sort(v.begin(), v.end());
    int tmp = 0;
    int num = 1;
    for(auto &t: v){
        if(get<0>(t) != tmp){
            tmp = get<0>(t);
            num = 1;
            get<2>(t) = num;
            num++;
        }else{
            get<2>(t) = num;
            num++;
        }
    }
    vector<tuple<int, int, int, int>> ans(m+1);
    for(auto t: v)
        ans[get<3>(t)] = t;
    for(auto t: ans){
        if(get<0>(t) == 0) continue;
        printf("%06d%06d\n", get<0>(t), get<2>(t));
    }
}


Measured memory_bytes: 4848
#include<iostream>
using namespace std;
#define MAX 2000000

int H, A[MAX + 1];

void maxHeapify(int i) {
int l, r, largest;
 l = 2 * i;
 r = 2 * i + 1;

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

 if (largest != i) {
   swap(A[i], A[largest]);
   maxHeapify(largest);
 }
}

int main() {
  cin >> H;

  for (int i = 1; i <= H; i ++) cin >> A[i];

  for (int i = H/2; i >= 1; i --) maxHeapify(i);

  for (int i = 1; i <= H; i ++) {
    cout << " " << A[i];
  }
  cout << endl;
}


Measured memory_bytes: 4936
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifdef LOCAL
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;
#else
#define debug(x) ;
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int log2(ll p, ll q, bool f = true){
  int counter = 0;
  int cc = !!(p % q) * 2;
  ll v = p / q;
  while(v >= 2){
    if(v % 2) cc++;
    v /= 2;
    counter++;
  }
  debug(p); debug(q); debug(cc);
  return counter + (cc >= 1) * f;
}

int log2(ll v){
  int counter = 0;
  int cc = 0;
  while(v){
    if(v % 2) cc++;
    v /= 2;
    counter++;
  }
  return counter + (cc > 1);
}

ll pow2(int x) {
  ll res = 1;
  for(int i=0;i<x;i++) res *= 2;
  return res;
}

int main(){
  int n;
  ll a[SIZE], dp1[SIZE], dp2[SIZE];

  scanf("%d", &n);

  for(int i=0;i<n;i++){
    scanf("%lld", a+i);
  }

  ll calc1 = 0, calc2 = 0;

  stack<pair<ll,int> > st, st2;
  st.push({LLINF, 0});
  st2.push({LLINF, n-1});

  dp1[0] = 1;
  ll prev = a[0] * 2;
  for(int i=1;i<n;i++){
    ll now = a[i] * 2;

    if(prev < now){
      ll r = (log2(now, prev) + 1) / 2 * 2;
      debug(log2(now, prev));
      prev *= pow2(r);
      while(r){
        auto p = st.top(); st.pop();
        ll r2 = min(p.first, r);
        r -= r2;
        p.first -= r2;
        calc1 += (ll)r2 * (i - p.second);
        if(p.first > 0) st.push(p);
      }
    }

    ll e = log2(prev, now, false) / 2 * 2;
    
    if(e){
      st.push({e, i});
    }

    dp1[i] = calc1 + i + 1;
    debug(dp1[i]);
    prev = now;
  }


  dp2[n] = dp2[n-1] = 0;
  prev = a[n-1];
  for(int i=n-2;i>=0;i--){
    ll now = a[i];

    if(prev < now){
      ll r = (log2(now, prev) + 1) / 2 * 2;
      debug(log2(now, prev));
      prev *= pow2(r);
      while(r){
        auto p = st2.top(); st2.pop();
        ll r2 = min(p.first, r);
        r -= r2;
        p.first -= r2;
        calc2 += (ll)r2 * (p.second - i);
        if(p.first > 0) st2.push(p);
      }
    }

    ll e = log2(prev, now, false) / 2 * 2;
    
    if(e){
      st2.push({e, i});
    }

    dp2[i] = calc2;
    prev = now;
  }


  ll ans = dp2[0];
  
  for(int i=0;i<n;i++){
    ans = min(ans, dp1[i] + dp2[i+1]);
    //cerr << dp1[i] << " + " << dp2[i+1] << endl;
  }

  cout << ans << endl;
  
  return 0;
}


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

int sumofd (int i){
  int sum = 0;
  while(i>0){
    sum = sum + i%10;
    i = i/10;
  }
  return sum;
}

int main(){
  int N;
  cin >> N;
  int sum = sumofd(N);
  if(N%sum == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
}
  


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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
#define MOD (ll)(1e9+7)
#define INF (ll)1e15
ll N,A,B;
pll pp[101010];
ll dp[5050][10101],ans;
ll i, j;
ll aaa(const ll& a,const ll& b ){
    return a - 1 == b * 2 ? 0 : a - 1 < b * 2 ? B : A;
}

int main(){
    scanf("%lld%lld%lld", &N,&A,&B);
    fornum(i,0,N){
        ll p;
        scanf("%lld", &p);
        pp[i] = {p,i};
    }
    sort(pp, pp + N);
    fornum(i,0,N){
        ll minn = INF;
        fornum(j,0,N*2+1){
            if(j%2){
                dp[i + 1][j] = minn + aaa(j, pp[i].second);
                if(dp[i][j]<minn){
                    minn = dp[i][j];
                }
            }else{
                if(dp[i][j]<minn){
                    minn = dp[i][j];
                }
                dp[i + 1][j] = minn + aaa(j, pp[i].second);
            }
        }
    }
    ans = INF;
    fornum(i,0,N*2+1){
        if(dp[N][i]<ans){
            ans = dp[N][i];
        }
    }
    printf("%lld", ans);

    return 0;
}

Measured memory_bytes: 397440
#[allow(unused_imports)]
use std::cmp::{Ordering};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get { 
    ([$t: ty]) => { 
        { 
            let mut line = String::new(); 
            stdin().read_line(&mut line).unwrap(); 
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        { 
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn solve() {
    let (n,a,b,c,d) = get!(isize, isize, isize, isize, isize);

    let goal = b-a;
    for x in 0..n-1 {
        let y1 = d*(n-1-x)-c*x;
        let y2 = c*(n-1-x)-d*x;
        if (y1 >= goal && y2 <= goal) || (-y1<=goal && -y2>=goal) {
            println!("YES");
            return;
        }
    }
    println!("NO");
}


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

int n;
int c[200005];

int main(){

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

    cin>>n;
    for(int i=1;i<n;i++){
        int a;
        cin>>a;
        c[a]++;
    }
    for(int i=1;i<=n;i++){
        cout<<c[i]<<'\n';
    }

    return 0;
}

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

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

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N, L; cin >> N >> L;
    int ans = N*(L + L+(N-1))/2;
    //LからL+N-1で一番絶対値が小さい物
    int mn = mod;
    for(int i = L; i <= L+N-1; i++){
        if(abs(i) < abs(mn)) mn = i;
    }
    cout << ans-mn << endl;
    return 0;
}

Measured memory_bytes: 256