akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
int Ismin(int i);
int a[15];
int main()
{
	int n,k,t;
	scanf("%d %d",&n,&k);
	for(int i = 0;i < k; i++)
	{
		scanf("%d",&t);
		a[t] = 1;
	}
	for(int i = n;;i++)
	{
		if(Ismin(i))
		{
			printf("%d\n",i);
			break;
		}
	}
	return 0;
}


int Ismin(int i)
{
	int x;
	while(i)
	{
		x = i % 10;
		if(a[x])
			return 0;
			i /= 10;
	}
	return 1;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#define PI acos(-1)
using namespace std;

struct Point
{
    double x;
    double y;
};

void koch(int n,Point a,Point b)
{
    if(n==0)
        return ;
    Point s,u,t;
    double theta=PI*60.0/180.0; //???位：度->弧度

    s.x=(2.0*a.x+1.0*b.x)/3.0;
    s.y=(2.0*a.y+1.0*b.y)/3.0;
    t.x=(1.0*a.x+2.0*b.x)/3.0;
    t.y=(1.0*a.y+2.0*b.y)/3.0;
    u.x=s.x+(t.x-s.x)*cos(theta)-(t.y-s.y)*sin(theta);
    u.y=s.y+(t.x-s.x)*sin(theta)+(t.y-s.y)*cos(theta);

    koch(n-1,a,s);
    printf("%.8f %.8f\n",s.x,s.y);
    koch(n-1,s,u);
    printf("%.8f %.8f\n",u.x,u.y);
    koch(n-1,u,t);
    printf("%.8f %.8f\n",t.x,t.y);
    koch(n-1,t,b);
}

int main()
{
    int n;
    scanf("%d",&n);
    Point a,b;
    a.x=0.0;
    a.y=0.0;
    b.x=100.0;
    b.y=0.0;
    printf("%.8f %.8f\n",a.x,a.y);
    koch(n,a,b);
    printf("%.8f %.8f\n",b.x,b.y);
    return 0;
}

Measured memory_bytes: 3160
#include<iostream>
using namespace std;
int main() {
    int cnt = 0, cnt1 = 0, cnt2 = 0, cnt3 = 0;
    while (1) {
        int a, b, c;
        cin >> a >> b >> c;
        if (a > b) {
            swap(a, b);
        }
        if (b > c) {
            swap(b, c);
        }
        double d = (double)(a * a + b * b - c * c) / (2 * a * b);
        if (d <= -1 || d >= 1) {
            cout << cnt << " " << cnt1 << " " << cnt2 << " " << cnt3 << endl;
            return 0;
        } else if (d == 0) {
            cnt++;
            cnt1++;
        } else if (0 < d && d < 1) {
            cnt++;
            cnt2++;
        } else {
            cnt++;
            cnt3++;
        }
    }
 }



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

bool isPrime(int t)
{
    if(t==2) return 1;
    if(t<2 || t%2==0) return 0;
    for(int i=3; i*i<=t; i+=2)
    {
        if(t%i==0)
            return 0;
    }
    return 1;
}
int main()
{
    int n, t, ans = 0;
    scanf("%d", &n);
    for(int i=0; i<n; i++)
    {
        scanf("%d", &t);
        if(isPrime(t)) ans++;
    }
    printf("%d\n", ans);
    return 0;
}



Measured memory_bytes: 3200
n,m = map(int,input().split())
py = [list(map(int,input().split())) +[i] for i in range(m)]
py.sort(key=lambda x: [x[0], x[1]])
ans_list = [0]*m
tmp = py[0][0]
cnt = 0
for p,y,idx in py:
    if tmp == p:
        cnt +=1
    else:
        cnt = 1
        tmp = p
    ans_list[idx] = format(p ,'06') + format(cnt, '06')

for ans in ans_list:
  print(ans)

Measured memory_bytes: 34332
#include<iostream>
#include<stack>
#include<vector>
using namespace std;
stack<int>S; int a; vector<int>t;
int main() {
	cin >> a;
	S.push(a);
	while (cin >> a) {
		if (a == 0) {
			t.push_back(S.top());
			S.pop();
		}
		else {
			S.push(a);
		}
	}
	for (int i = 0; i < t.size(); i++) {
		cout << t[i] << endl;
	}
}

Measured memory_bytes: 1220
#include <stdio.h>

using namespace std;

int main() {
  int a,b,c,first,second;

scanf("%d %d %d",&a,&b,&c);

first=b-a;
second=c-b;

  if(first==second)
  {

      printf("YES\n");
  }

else
      printf("NO\n");

  return 0;
}





Measured memory_bytes: 888
array=gets.chomp.split(" ")
a =["1","3","5","7","8","10","12"]
b =["4","6","9","11"]
if a.include?(array[0])== true then
  x = 1
elsif b.include?(array[0]) == true then
  x=2
else x=3
end
if a.include?(array[1]) == true then
  y = 1
elsif b.include?(array[1]) == true  then
  y=2
else y=3
end

if x == y then
  puts("Yes")
else
  puts("No")
end

Measured memory_bytes: 1788
import fractions
n,m = map(int, input().split(' '))
s = input()
t = input()
g = fractions.gcd(n, m)
Flag = True
for i in range(n):
    if (m*i)%n == 0:
        if s[i] != t[int((i*m)/n)]:
            Flag = False
if Flag:
    print(int((n*m)/g))
else:
    print('-1')

Measured memory_bytes: 5432
import math
import collections

from operator import mul
from functools import reduce

n,m = list(map(int,input().split()))

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 100 + n
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )



def prime_factorize(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

c = collections.Counter(prime_factorize(m))
#print(c)
ans = 1
for i,j in c.items():
    ans *= cmb(n+j-1,j,mod) % mod
print(int(ans%mod))


Measured memory_bytes: 15908
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp15
{
    class Class341
    {
        static void Main()
        {
            var AB = Console.ReadLine().Split().Select(long.Parse).ToArray();
            long A = AB[0], B = AB[1];
            var gcd = GCD(A, B);
            int count = 1;
            for(int i = 2; i <= (long)Math.Sqrt(gcd); i++)
            {
                if (gcd % i == 0)
                {
                    count++;
                    while (gcd % i == 0)
                        gcd /= i;
                }
            }
            if (gcd != 1) count++;
            Console.WriteLine(count);
        }
        static long GCD(long A, long B) => A == 0 ? B : GCD(B % A, A);
        
    }
}


Measured memory_bytes: 13268
using System;
using System.Collections.Generic;
using System.Linq;
using static AtCoder.Io;

namespace AtCoder
{
    class Program
    {
        static void Main()
        {
            var mod = (long)Math.Pow(10, 9) + 7;
            var n = ReadInt();

            var primes = new[] { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31 };
            var exponents = new Dictionary<int, int>();
            for (int i = 1; i <= n; i++)
            {
                var value = i;
                foreach (var prime in primes)
                {
                    var count = 0;
                    while (value % prime == 0)
                    {
                        count++;
                        value /= prime;
                    }
                    if (count != 0)
                    {
                    }
                    if (!exponents.ContainsKey(prime)) exponents.Add(prime, 0);
                    exponents[prime] += count;
                }
                if (value != 1)
                {
                    if (!exponents.ContainsKey(value)) exponents.Add(value, 0);
                    exponents[value]++;
                }
            }

            long ans = 1;
            foreach (var exponent in exponents)
            {
                ans = ans * (exponent.Value + 1) % mod;
            }
            Console.WriteLine(ans);
        }
    }

    public static class Io
    {
        public static string ReadString() => Console.ReadLine();
        public static string[] ReadStringArray() => ReadString().Split(' ');
        public static int ReadInt() => int.Parse(ReadString());
        public static long ReadLong() => long.Parse(ReadString());
        public static int[] ReadIntArray() => ReadStringArray().ParseInt().ToArray();
        public static long[] ReadLongArray() => ReadStringArray().ParseLong().ToArray();
        public static IEnumerable<int> ParseInt(this IEnumerable<string> source) => source.Select(int.Parse);
        public static IEnumerable<long> ParseLong(this IEnumerable<string> source) => source.Select(long.Parse);
    }
}


Measured memory_bytes: 11220
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace A
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var abcd = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            var ab = Math.Abs(abcd[0] - abcd[1]) <= abcd[3];
            var bc = Math.Abs(abcd[1] - abcd[2]) <= abcd[3];
            var ac = Math.Abs(abcd[0] - abcd[2]) <= abcd[3];
            Console.WriteLine(ac || ab && bc ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 13396
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <iomanip>
using ll = long long;
using uint = unsigned int;
using graph = std::vector<std::vector<ll>>;
using wGraph = std::vector<std::vector<std::pair<ll,ll>>>;
#define rep(i,n) for (int i=0; i < int(n); i++)

using namespace std;
ll MOD7 = 1000000007;
ll MOD9 = 1000000009;
vector<ll> InputVec(ll N){
    vector<ll> A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    return A;
}
void OutputVec(vector<ll> A){
    for (int i = 0; i < A.size(); ++i) {
        cout << A[i] << ",";
    }
    cout << endl;
}
vector<vector<ll>> InputVec2d(ll H,ll W){
    vector<vector<ll>> A(H);
    for (int yi = 0; yi < H; ++yi) {
        A[yi] = vector<ll>(W);
    }
    for (int yi = 0; yi < H; ++yi) {
        for (int xi = 0; xi < W; ++xi) {
            cin >> A[yi][xi];
        }
    }
    return A;
}
vector<vector<char>> InputVec2dStr(ll H,ll W){
    vector<vector<char>> A(H);
    for (int yi = 0; yi < H; ++yi) {
        A[yi] = vector<char>(W);
    }
    for (int yi = 0; yi < H; ++yi) {
        string S;
        cin >> S;
        for (int xi = 0; xi < W; ++xi) {
            A[yi][xi] = S[xi];
        }
    }
    return A;
}
void OutputVec2d(vector<vector<ll>> A){
    for (int yi = 0; yi < A.size(); ++yi) {
        for (int xi = 0; xi < A[yi].size(); ++xi) {
            cout << A[yi][xi] << ",";
        }
        cout << endl;
    }
}
graph InputGraph(ll N,ll M){
    graph G(N);
    for (int i = 0; i < M; ++i) {
        ll a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    return G;
}
graph InputDGraph(ll N,ll M){
    graph G(N);
    for (int i = 0; i < M; ++i) {
        ll a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
    }
    return G;
}
void OutputGraph(graph G){
    for (int i = 0; i < G.size(); ++i) {
        cout << i << ":";
        for (int j = 0; j < G[i].size(); ++j) {
            cout << G[i][j]<< ",";
        }
        cout << endl;
    }
}
void OutputAnswerBool(bool b,bool isUpperCase = false){
    if(b){
        if(isUpperCase){
            cout << "YES" << endl;
        }else{
            cout << "Yes" << endl;
        }
    }else{
        if(isUpperCase){
            cout << "NO" << endl;
        }else{
            cout << "No" << endl;
        }
    }
}

int main() {
    ll X;
    cin >> X;
    ll M = 1;
    for (int i = 1; i < 50; ++i) {
        for (int j = 2; j < 10; ++j) {
            ll tmp = 1;
            for (int k = 0; k < j; ++k) {
                tmp *= i;
            }
            if(tmp <= X){
                M = max(M,tmp);
            }
        }
    }
    cout << M << endl;
}


Measured memory_bytes: 256
abcd = input()
a, b, c, d = list(map(int, [x for x in abcd]))
A = a + b + c + d
B = a - b + c + d
C = a + b - c + d
D = a + b + c - d
E = a - b - c + d
F = a - b + c - d
G = a + b - c - d
H = a - b - c - d
if A == 7:
  ans = f"{a}+{b}+{c}+{d}=7"
elif B == 7:
  ans = f"{a}-{b}+{c}+{d}=7"
elif C == 7:
  ans = f"{a}+{b}-{c}+{d}=7"
elif D == 7:
  ans = f"{a}+{b}+{c}-{d}=7"
elif E == 7:
  ans = f"{a}-{b}-{c}+{d}=7"
elif F == 7:
  ans = f"{a}-{b}+{c}-{d}=7"
elif G == 7:
  ans = f"{a}+{b}-{c}-{d}=7"
elif H == 7:
  ans = f"{a}-{b}-{c}-{d}=7"
print(ans)

Measured memory_bytes: 9224
#include <iostream>
#include <stdio.h>

using namespace std;

void Output(int H[3][10]){
    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 10; j++){
            printf(" %d",H[i][j]);
        }
        printf("\n");
    }
}


int main(int argc, const char * argv[]){
    int H1[3][10], H2[3][10], H3[3][10], H4[3][10], n, h_num, f_num, r_num, div_num;
    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 10; j++){
            H1[i][j] = H2[i][j] = H3[i][j] = H4[i][j] = 0;
        }
    }
    scanf("%d", &n);
    for(int i = 0; i < n; i++){
        scanf("%d %d %d %d", &h_num, &f_num, &r_num, &div_num);
        switch(h_num){
        case 1:
            H1[f_num-1][r_num-1] += div_num;
            break;
        case 2:
            H2[f_num-1][r_num-1] += div_num;
            break;
        case 3:
            H3[f_num-1][r_num-1] += div_num;
            break;
        case 4:
            H4[f_num-1][r_num-1] += div_num;
            break;
        }
    }
    Output(H1);
    printf("####################\n");
    Output(H2);
    printf("####################\n");
    Output(H3);
    printf("####################\n");
    Output(H4);
    return 0;
    
}



Measured memory_bytes: 3200
#include<bits/stdc++.h>
#define ll long long
#define pa pair<int,int>
using namespace std;
char s[100004];
int c[100004];
int p[100004];
int l;
int main(){
    scanf("%s",s+1);
    l=strlen(s+1);
    int co=0;
    for(int i=1;i<=l;i++){
        if(s[i]=='R')continue;
        else{
            int gp=1;
            for(int j=i-1;s[j]=='R';j--){
                p[j]=i-gp;
                gp^=1;
            }
        }
    }
    for(int i=1;i<=l;i++){
        if(s[i]=='L')continue;
        else{
            int gp=1;
            for(int j=i+1;s[j]=='L';j++){
                p[j]=i+gp;
                gp^=1;
            }
        }
    }
    for(int i=1;i<=l;i++)c[p[i]]++;
    for(int i=1;i<=l;i++)printf("%d ",c[i]);puts("");
    return 0;
}


Measured memory_bytes: 1280
import collections


def solve():

    N, M = map(int, input().split())

    a = []
    for i in range(N):
        tmp = list(map(int, input().split()))
        # 先頭のKは除外
        a += tmp[1:]

    # Counter({3: 3, 1: 2, 2: 2})になる
    c = collections.Counter(a)
    ans = 0
    for val in c.values():
        # 個数が一致したらプラス
        if val == N:
            ans += 1

    print(ans)


if __name__ == "__main__":
    solve()


Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main(){
	int n,m;
	cin >> n >> m;
	n--;
	int a[m],b[m];
	REP(i,m){
		cin >> a[i] >> b[i];
		a[i]--;
		b[i]--;
	}
	bool mid[n] = {};
	REP(i,m){
		if(a[i] == 0) mid[b[i]] = true;
		if(b[i] == 0) mid[a[i]] = true;
	}
	REP(i,m){
		if(a[i] == n && mid[b[i]] == true){
			cout << "POSSIBLE" << endl;
			return 0;
		}
		if(b[i] == n && mid[a[i]] == true){
			cout << "POSSIBLE" << endl;
			return 0;
		}
	}
	cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 2048
#include <stdio.h>
int main(){
    int a, b, d, r;
    double f;
    scanf("%d %d", &a, &b);
    d = a / b;
    r = a % b;
    f = (double)a / (double)b;
    printf("%d %d %f\n", d, r, f);
    return 0;
}

Measured memory_bytes: 636
#include<stdio.h>
int tamanho( char vetor[101]){
    int acont =0;
    for(int x=0; x < 101; x++){
        if(vetor[x] == '\0')
            return acont;
        acont += 1;
    }
}
int main(){
    char a[101], b[101], c[101];
    int ta=0, tb=0;
    scanf("%s %s %s", a,b,c);
    ta = tamanho(a);
    tb = tamanho(b);
    if ((a[ta-1] == b[0]) && (b[tb-1] == c[0]))
        printf("YES\n");
    else
        printf("NO\n");
    return 0;
}


Measured memory_bytes: 128
import bisect
import copy
import heapq
import math
import sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
sys.setrecursionlimit(500000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

h,w,k=map(int,input().split())
c=[input() for i in range(h)]
ans=0
for gyo in product(range(2),repeat=h):
    for retsu in product(range(2),repeat=w):
            cnt=0
            # print(gyo)
            # print(retsu)
            for i in range(h):
                for j in range(w):
                    if gyo[i]==0 and retsu[j]==0 and c[i][j]=="#":
                        cnt+=1
            if cnt==k:
                ans+=1
print(ans)
# print(64*64*36)

Measured memory_bytes: 69448
import Data.IORef
import Control.Monad(forM_, when)
import qualified Data.ByteString.Char8 as BC
import Data.Maybe(fromJust)
  
main :: IO()
main = BC.getLine >> BC.getContents >>= solve.map (fst.fromJust.BC.readInt).BC.lines >>= print
  
solve :: [Int] -> IO Int
solve (x : y : xs) = do
                a <- newIORef (y - x)
                b <- newIORef (if x < y then x else y)
                forM_ xs $ \z -> do
                    a' <- readIORef a
                    b' <- readIORef b
                    when (z - b' > a') $ writeIORef a (z - b')
                    when (z < b')      $ writeIORef b z
                readIORef a

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

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


Measured memory_bytes: 3600
#include<stdio.h>
#define MAX 100
int number[MAX] = {0};
void insertionSort(int *, int);

int main(){
    int n, i;

    scanf("%d\n", &n);

    for(i = 0; i < n; i++) {
        scanf("%d ", number+i);  
    }
    for(i = 0; i < n - 1; i++) {
        printf("%d ", number[i]);
    }
    printf("%d\n", number[n-1]);

    insertionSort(number, n);
}

void insertionSort(int *c, int n){

    int i, j, k;
    int v;

    for(i = 1; i < n; i++) {
        v = *(c+i);
        j = i - 1;
        while((j >= 0) && (*(c+j) > v)) {
            *(c + j + 1) = *(c + j);
            j--;
        }
        *(c + j + 1) = v;
        for(k = 0; k < n - 1; k++) {
            printf("%d ", *(c + k));
        }
        printf("%d\n", *(c + n - 1));
    }

}


Measured memory_bytes: 2020
/*   ꧁༒☬महाकाल☬༒꧂ ꧁༒ঔमहाकालঔ༒꧂
                   
                   ঔৣ۝महाकालᴳᵒᵈ۝ঔৣ            
 
 */ 
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template <typename T, typename cmp=less<T>> using oset =tree<T, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define ll long long 
#define mod 1000000007
#define inf 100000000000000000
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define _it iterator
#define all(_x) _x.begin(),_x.end()
#define f first
#define s second
#define pb push_back
void mahakal(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	freopen("error.txt","w",stderr);
	#endif
}
const ll maxN=2e5+5;
ll n  , a , b ;
array<ll,2> A[maxN] , B[maxN];
void solve(){
	string s , t ;
	cin>>  s >> t ;
	ll ans=0;
	for(ll i=0;i<s.length();i++){
		if(s[i]!=t[i])ans++;
	}
	cout<<ans<<endl;
}

int main(){
	//mahakal(),fast;
	ll t=1;
	// cin>>t ;
	while(t--)solve();

	return 0;
}

Measured memory_bytes: 3924
// [Tag]
// #

#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <string>
#include <deque>
#include <map>
using namespace std;

#define fi     	first    
#define se     	second  

/** Type Define **/
typedef long long int           ll;
typedef pair<int, int>          pii;
typedef pair<ll, ll>            pll;
typedef vector<string>          vs;
typedef vector<bool>            vb;
typedef vector<int>             vi;
typedef vector<long long>		vl;
typedef vector<vi>              vvi;
typedef vector<vl>				vvl;
typedef vector<char>            vch;
typedef unsigned char           uchar;
typedef unsigned int            ui;
typedef unsigned long long int  ull;

constexpr int               inf = 2123456789;
constexpr long long 		INF = 9123456789123456789;
constexpr long long         MOD = 1000000007LL;

template<class T>
using MaxHeap = priority_queue<T>;
template<class T>
using MinHeap = priority_queue<T, vector<T>, greater<T> >;


template<class T>
ostream& operator << (ostream& os, const vector<T>& vec) {
    for (int i = 0; i < vec.size(); i++) {
        os << vec[i];
        if (i + 1 < vec.size())os << ' ';
    }
    return os;
}
template<class T>
istream& operator >> (istream& is, vector<T>& vec) {
    for (int i = 0; i < vec.size(); i++)is >> vec[i];
    return is;
}


/*************************************************/
ll M;
vl Sum;
int N;
vi A;

ll solve(int mid) {
	//Pair합이 mn이상인 짝이 몇개인지 반환하는 함수.
	int p2 = N - 1;
	ll cnt = 0;
	//ll n_if(0);
	for (int p1 = 0; p1 < N; p1++) {
		while (p2 >= 0 && A[p1] + A[p2] < mid) p2--;
		cnt += p2 + 1;
	}
	//cout << "count by " << n_if << "\n";
 	return cnt;
}

ll calc(int mid) {
	int p2 = N - 1;
	ll cnt = 0;
	ll ans = 0;

	for (int p1 = 0; p1 < N; p1++) {
		while (p2 >= 0 && A[p1] + A[p2] <= mid) p2--;
		if (p2 >= 0) {
			ans += Sum[p2] + 1LL * (p2 + 1) * A[p1];
		}
		cnt += p2 + 1;
	}
	ans += 1LL * (M - cnt) * mid;
	return ans;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(); cout.tie();
    /*INPUT*/
    cin >> N >> M;
    A.resize(N);
    Sum.resize(N + 1);
    for (auto& a : A)
        cin >> a;

	sort(A.begin(), A.end(), greater<int>());
    Sum[0] = A[0];
    for (int i = 1; i < N; i++)
        Sum[i] = Sum[i - 1] + A[i];

	int lb = 0;         //lower bound
	int ub = 2e5 + 1;   //upper bound
	//int d = 1;
	while (ub - lb > 1) {   
        //lb == ub가 되는 순간을 찾는다.
        //이 때의 lb는 M개의 짝을 찾게 되는 순간의 Pair합이다.
		//cout << d << "-th mid : "; d++;
		int mid = (lb + ub) / 2;
		//cout << mid << ".\n";
		if (solve(mid) >= M) lb = mid;
		else ub = mid;
	}

	cout << calc(lb) << '\n';
    return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvvl vector<vvl>
#define vvl vector<vector<ll>>
#define VV(a, b, c, d) vector<vector<d>>(a, vector<d>(b, c))
#define VVV(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

struct BIT{
  ll M=1;
  vector<ll> dat;
  BIT(ll N){
    while(N>M) M*=2;
    dat.resize(M*2-1, 0);
  }
  void update(ll x, ll k){
    for(int i=k+1;i<=M;i+=(i&(-i))){
      dat[i] += x;
    }
  }
  ll sum(ll r){
    ll ret = 0;
    for(int k=r;k>0;k-=(k&(-k))) ret += dat[k];
    return ret;
  }

  ll query(ll l, ll r){
    return sum(r) - sum(l);
  }
};

int main(int argc, char const *argv[]) {
  ll n, q;std::cin >> n >> q;
  vll c(n);
  vvl x = VV(n, 0, 0, ll);
  re(i, n) {
    std::cin >> c[i];
    c[i]--;
    x[c[i]].push_back(i);
  }
  BIT seg(n+1);
  vll ans(q, 0);
  vector<vector<pair<ll, ll>>> d(n);
  for(int i=0;i<q;i++){
    ll l, r;std::cin >> l >> r;
    l--, r--;
    d[r].push_back(pair<ll, ll>(l, i));
  }
  for(int i=0;i<n;i++){
    ll now = c[i];
    auto itr = lower_bound(all(x[now]), i);
    ll pre = 0;
    if(itr!=x[now].begin()){
      itr--;
      pre = (*itr) + 1;
    }
    seg.update(1, i);
    if(pre!=0) seg.update(-1, pre-1);
    for(auto v:d[i]){
      ll l = v.first;
      ll idx = v.second;
      ans[idx] = seg.query(l, i+1);
    }
  }
  re(i, q) std::cout << ans[i] << endl;
  return 0;
}


Measured memory_bytes: 72044
#include <iostream>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>

using namespace std;

#define MOD 1000000007
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
typedef pair<ll, ll> P;
const long long INF = 1LL << 60;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


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

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


	ll n;
	cin >> n;
	Array l(n, 0);
	REP(i, n)cin >> l[i];
	sort(all(l), greater<ll>());
	
	ll ans = 0;
	for (int i = 0; i < n-2; i++) {
		for (int j = i + 1; j < n-1; j++) {
			ll le = j;
			ll r = n;
			ll k = n;

			while (r-le>1 ) {
				ll mid = le + r>>1;
				if (l[i] < l[j] + l[mid]) {
					//cout << l[j] << " " << l[i] + l[mid] << endl;
					//cout << "aa" << endl;
					k = mid;
					le = mid;
				}
				else {
					//cout << "bb" << endl;
					r = mid;
				}
				
			}
			if (k != n) ans += k - j;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream &operator << (ostream& out,const pair<S,T>& o){
    out << "(" << o.first << "," << o.second << ")"; return out;
}

/*
<url:https://arc086.contest.atcoder.jp/tasks/arc086_b>
問題文============================================================
 すぬけ君は長さ N の数列 a を持っています。a の (1-indexedでの) i 番目の数は ai です。
 
 すぬけ君は以下の操作を何度でも行うことができます。
 
 操作：1 以上 N 以下の整数 x,y を選び、ay に ax を加算する。
 すぬけ君はこの操作を 0 回以上 2N 回以下行って a が下記の条件を満たすようにしたいです。
 そのような操作手順の一例を示してください。
 なお、この問題の制約下で、条件を満たすような操作の手順が必ず存在することが証明できます。
 
 条件：a1≤a2≤…≤aN
=================================================================

解説=============================================================

================================================================
*/

void solve(){
    ll N; cin >> N;
    vector<ll> a(N); for(auto &in:a) cin >> in;
    cout << 2*N-1 << endl;
    ll absmax = -1; bool Sign = false; ll loc = -1;
    for(int i = 0; i < N;i++){
        if(abs(a[i]) > absmax){
            absmax = abs(a[i]);
            Sign = (a[i] >= 0)?true:false;
            loc = i+1;
        }
    }
    for(int i = 1; i <= N; i++){
        cout << loc << " " << i << endl;
    }
    if(Sign){
        for(int i = 1; i < N;i++){
            cout << i << " " << i + 1 << endl;
        }
    }else{
        for(int i = N; i > 1; i--){
            cout << i << " " << i - 1 << endl;
        }
    }
}
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    solve();
	return 0;
}


Measured memory_bytes: 256
n = gets.to_i
a = [0] + gets.split.map(&:to_i) + [0]

all = 0
(n+1).times{|i|
  all += (a[i] - a[i+1]).abs
}

b = Array.new(n, 0)

n.times{|i|
  b[i] = ((a[i+1] - a[i]).abs + (a[i+2] - a[i+1]).abs) - (a[i] - a[i+2]).abs
}

n.times{|i|
  p all - b[i]
}

Measured memory_bytes: 17924
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
typedef long long ll;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

int main () {

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

    for (int i = a; i <= min(b, a+k-1); i++) {
        cout << i << endl;
    }
    for (int i = max(b-k+1, a+k); i <= b; i++) {
        cout << i << endl;
    }

    return 0;
}



Measured memory_bytes: 888
def FindSumOfDigits(n):
    Sum=0
    while(n>0):
        Sum+=(int(n%10))
        n=n/10
    return Sum

N,A,B=map(int,input().split())
ans=0
#ans_list=[]
#sumlist=[]
for i in range(1,N+1):
    #sumlist.append(FindSumOfDigits(i))
    if A<=FindSumOfDigits(i)<=B:
        ans+=i
        #ans_list.append(i)
print(ans)
#print(ans_list)
#print(sum_list)

Measured memory_bytes: 3060
int main() {
  int x,y ,a;
  scanf("%d %d",&x,&y);

  while(x != 0 || y !=0) {
    if(x > y) {
      a = x;
      x =y;
      y = a;
    } 
    printf("%d %d\n",x , y);
    scanf("%d %d" ,&x,&y);
 
  }
  return 0;
}


Measured memory_bytes: 2104
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int k = a + b;
        if(k%2==0)
            System.out.println(k/2);
        else
            System.out.println("IMPOSSIBLE");
    }
}

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

const int inf = 1e9;
const ll linf = 1e18;

using P = pair<int, int>;

int main()
{
    int n, m; cin >> n >> m;
    vector<P> ab(m);
    for (int i = 0; i < m; i++) cin >> ab[i].second >> ab[i].first;
    sort(ab.begin(), ab.end());

    int ans = 0;
    int t = 0;
    for (auto& e : ab) {
        if (t <= e.second) {
            ans++; t = e.first;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	ll a, b, k;
	cin >> a >> b >> k;
	
	if( a >= k ) cout << a - k << " " << b << endl;
	else cout << 0 << " " << max(0LL, b - (k - a)) << endl;
	
	return 0;
}


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

int main() {
  int a, b;
  cin >> a >> b;
  if (a == b) {
    cout << "Draw" << endl;
  } else if (a == 1) {
    cout << "Alice" << endl;
  } else if (b == 1) {
    cout << "Bob"<< endl;
  } else if (a > b) {
    cout << "Alice" << endl;
  } else {
    cout << "Bob"<< endl;
  }
  return 0;
}


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

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


	int dp[n] = {0};

	for(int i=1 ; i<n ; i++){
		if(i>=2){
			dp[i] = min(dp[i-1] + abs(arr[i]-arr[i-1]), dp[i-2] + abs(arr[i]-arr[i-2]) );			
		}
		else{
			dp[i] = dp[i-1] + abs(arr[i]-arr[i-1]);	
		}
	}
	cout << dp[n-1] << "\n";
	return 0;
}

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

int main()
{
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    int ans = min(k, a);
    k -= ans;
    k -= min(k, b);
    ans -= k;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
const int N = 1e5 + 5;
const long long inf = 1e18;
using namespace std;

typedef pair <int, int> ii;
vector <ii> adj[N];
int n, m, d[N];
long long X, L = -inf, R = inf, ans[N];
bool ck = 0;

void dfs(int u, int p){
    if ((d[u]&1)^1) L = max(L, -ans[u]);
    else R = min(R, ans[u]);

    for (auto p : adj[u]){
        int v = p.first, cost = p.second;
        if (!d[v]){
            d[v] = d[u] + 1;
            ans[v] = cost - ans[u];
            dfs(v, u);
        }
        else{
            if ((d[u]&1) != (d[v]&1)){
                if (cost != ans[u] + ans[v]){
                    cout << "0";
                    exit(0);
                }
            }
            else{
                if (d[u]&1) {
                    if (!ck) X = (ans[u] + ans[v]) - cost, ck = 1;
                    if (ck && X != (ans[u] + ans[v] - cost)){
                        cout << 0;
                        exit(0);
                    }
                }
                else {
                    if (!ck) X = cost - (ans[u] + ans[v]), ck = 1;
                    if (ck && X != cost - (ans[u] + ans[v])){
                        cout << 0;
                        exit(0);
                    }
                }
            }
        }
    }
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n >> m;
    for (int i = 1; i <= m; i++){
        int u, v, cost;
        cin >> u >> v >> cost;
        adj[u].push_back(ii(v, cost));
        adj[v].push_back(ii(u, cost));
    }
    dfs(1, 1);
    if (ck){
        if (X % 2 != 0) return cout << 0, 0;
        X /= 2;
        if (X <= L || X >= R) return cout << 0, 0;
        cout << 1;
        return 0;
    }
    cout << max(R-L-1, 0LL);
}


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

void print_v (vector<int> A){
    for(auto iter_A = A.begin(); iter_A != (A.end()-1); iter_A++){
        cout << *iter_A << " ";
    }
    cout << *(A.end()-1) << "\n";
}

// code
vector<int> bubbleSort(vector<int> A, int N){

    bool flag = true;
    int i = 0;
    int count = 0;

    while(flag){
        flag = false;
        for (int j = N-1; j > i; --j){
            //cout << "j: " << j << "\n";
            if(A[j] < A[j-1]){
                count++;
                swap(A[j], A[j-1]);
                flag=true;
            }
        }
        i++;
    }

    print_v(A);
    cout << count << "\n";

    return A;
}

// main
int main(){
    // input
    int n;
    cin >> n;
    vector<int> v;
    int x;
    for(int i = 0; i < n; ++i){
        cin >> x;
        v.push_back(x);
    }

    bubbleSort(v, n);

    return 0;
}


Measured memory_bytes: 3172
def examA():
    abc = LI()
    abc.sort()
    if abc[0]+abc[1]==abc[2]:
        ans = "Yes"
    else:
        ans ="No"
    print(ans)


import sys
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examA()

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <numeric>

using namespace std;
int a[5][110];

int main(){
   int n,k;
   cin>>n>>k;
   if(n>=2*k-1)cout<<"YES"<<endl;
   else cout<<"NO"<<endl;
   
}

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

int main()
{
  char num[4];
  for(int i = 0; i < 4; i++) cin >> num[i];
  
  if(num[1] != num[2]){
    cout << "No" << endl;
    return 0;
  }
  
  if(num[0] == num[1] || num[2] == num[3]){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>


using namespace std;


int main(void){
    int H=0,W=0;
  
        
    while(true){
        cin>>H>>W;
          if(H==0&&W==0)
              break;
        for(int j=0;j<W;++j){
            cout<<"#";
          
        }
          cout<<'\n';
        for(int i=1;i<H-1;++i){
            cout<<"#";
           for(int j=1;j<W-1;++j){
               cout<<".";
           }
            cout<<"#";
            cout<<'\n';
        }
        for(int j=0;j<W;++j){
            cout<<"#";
        
        }
          cout<<'\n';
        cout<<'\n';
       }
    
    
    return 0;
}




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

int main() {
	map< pair<char, char>, int> count;
	int n; cin >> n;
	
	for(int i = 1; i <= n; i++){
		string i_str = to_string(i);
		int length = i_str.size();
		
		count[{i_str[0], i_str[length - 1]}]++;
	}
	
	map< pair<char, char>, int>::iterator it;
	long long ans = 0;
	for(it = count.begin(); it != count.end(); it++){
		pair<char, char> key = it->first,
						reversedKey = { key.second, key.first };
						
		if(count.find(reversedKey) != count.end())
			ans += it->second * count[reversedKey];
		
	}
	
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	ll n,i,j,mini=1000000000,tmp,tmp1,tmp2;
  	string s;
    cin>>n>>s;
  
  	vector<pair<ll,ll>> a(n);
  	for(i=0;i<n;i++){
      if(i!=0){
      a[i].first=a[i-1].first;
      a[i].second=a[i-1].second;
      }
		if(s[i]=='#'){
          a[i].first++;
        }else{
          a[i].second++;
        }
    }


  
   for(i=0;i<n;i++){
       if(s[i]=='#'){
         if(i==n-1){
		    tmp=a[n-2].first;
         }else if(i==0){
            tmp=a[n-1].second;
         }else{
           	tmp=a[i-1].first+min(a[n-1].second-a[i].second,a[n-1].first-a[i-1].first);
         }
         if(tmp<mini){
			mini=tmp;
         }
       
       }
   }

  	if(a[n-2].first==0){
		mini=0;
    }
  
  	cout<<mini<<endl;

  	
}

Measured memory_bytes: 3716
K = int(input())
L = [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(L[K-1])


Measured memory_bytes: 38384
// https://atcoder.jp/contests/agc002/tasks/agc002_c

#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <tuple>
#include <vector>
using namespace std;

typedef long long ll;
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, l, pos = -1;
    cin >> n >> l;
    vector<int> v(n);
    for (int i = 0; i < n; i++) {
        cin >> v[i];
        if (pos == -1 && i >= 1) {
            if (v[i - 1] + v[i] >= l) {
                pos = i;
            }
        }
    }
    // 最後に隣り合う2つの和がL以上になるようにロープをほどく
    if (pos == -1) {
        cout << "Impossible" << '\n';
    } else {
        cout << "Possible" << '\n';
        for (int i = 1; i < pos; i++) {
            cout << i << '\n';
        }
        for (int i = n - 1; i > pos; i--) {
            cout << i << '\n';
        }
        cout << pos << '\n';
    }

    return 0;
}

Measured memory_bytes: 1280
#include <iostream>

using namespace std;

int main() {
  int A, B, C;
  cin >> A >> B >> C;

  const char* res = "NO";
  if (((A == 7) && (B == 5) && (C == 5)) ||
      ((A == 5) && (B == 7) && (C == 5)) ||
      ((A == 5) && (B == 5) && (C == 7))) {
    res = "YES";
  }

  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

using lint = long long;
using P = pair<int, int>;
using LLP = pair<long long, long long>;

#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = (int)(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = (int)(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
#define REVERSE(x) reverse((x).begin(), (x).end())
#define TWINS(x) cout << ((x) ? "Yay!" : ":(") << '\n'
#define endl '\n'

constexpr int IINF = (1 << 30) - 1;
constexpr long long LLINF = 1LL << 61;
constexpr double EPS = 1e-10;

constexpr int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
constexpr int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

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

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

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

    int n;
    cin >> n;

    vector<int> l(n);
    rep(i, n){
        cin >> l[i];
    }
    SORT(l);

    lint ans = 0;
    rep(i, n){
        rep(j, i){
            ans += lower_bound(l.begin() + j + 1, l.begin() + i, l[i] + l[j]) - upper_bound(l.begin() + j + 1, l.begin() + i, l[i] - l[j]);
        }
    }

    cout << ans << endl;

    cout << flush;

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using std::max;
const int N=1e5+3;
int i,n,k,a[N];
long long x,r,l[N],s[N];
int main()
{
	scanf("%d%d",&n,&k);
	for(i=1;i<=n;++i)
	{
		scanf("%d",a+i);
		s[i]=s[i-1]+a[i];
		l[i]=l[i-1]+max(0,a[i]);
	}
	for(i=n;i>=k;x+=max(0,a[i--]))
		r=max(r,x+l[i-k]+max(0ll,s[i]-s[i-k]));
	for(i=0;i<20000;++i)for(k=0;k<i;++k);
	printf("%lld",r);
}

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

int main(){
  int n,k,val;
  int i;
  int count=0;
  scanf("%d %d",&n,&k);
  
  for(i=0;i<100;i++){
    val=n-pow(k,i);
    if(val<0){
    printf("%d\n",i);
    break;
    }
    if(val=0){
      count++;
    printf("%d\n",i);
    }
  }
  
  return 0;
}



Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <cstdio>
using namespace std;
string num[3], num2[3];
bool add(string a, string b, string res) {
    //if (a[0]=='0'||b[0]=='0'||res[0]=='0') return false;
    string ret="";
    int as=a.size(),bs=b.size();
    int c=0;
    for (int i=0; i<max(as,bs); i++) {
        int t=c;
        if (i<as) t+=a[as-i-1]-'0';
        if (i<bs) t+=b[bs-i-1]-'0';
        c=t/10;
        t%=10;
        ret+=t+'0';
    }
    if (c) ret+='1';
    reverse(ret.begin(), ret.end());
    return ret==res;
}
int main() {
    string alpha;
    while (cin>>alpha) {
        num[0]=""; num[1]=""; num[2]="";
        int pos=0;
        for (int i=0; i<alpha.length(); i++) {
            if (alpha[i]=='+'||alpha[i]=='=') {
                pos++;
            } else {
                num[pos]+=alpha[i];
            }
        }
        int res=-1;
        for (int i=0; i<=9; i++) {
            num2[0]=num[0]; num2[1]=num[1]; num2[2]=num[2];
            for (int j=0; j<3; j++) {
                for (int k=0; k<num2[j].length(); k++) {
                    if (num2[j][k]=='X') num2[j][k]=(i+'0');
                }
            }
            if (add(num2[0],num2[1],num2[2])) {
                res=i;
            }
        }
        if (res==-1) puts("NA");
        else printf("%d\n",res);
    }
}

Measured memory_bytes: 0
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef vector<pair<ll,ll> > vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
const int INF=1e9+7;

int main(){
  ll n,k;double sum=0;cin>>n>>k;
  rep(i,1,n+1){
    ll ten=i;double coin=1.0/n;
    while(ten<k){
      ten*=2;coin/=2;
    }
    sum+=coin;
  }
  cout<<fixed<<setprecision(12)<<sum<<endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    int n,makichankawaiikakikukeko;
    cin>>n>>makichankawaiikakikukeko;
    int s[n],t[n],c[n];
    for(int i=0;i<n;i++){
        cin>>s[i]>>t[i]>>c[i];
    }
    int a[200002],b[200002];
    memset(b,0,sizeof(b));
    for(int i=1;i<=makichankawaiikakikukeko;i++){
        for(int j=0;j<200002;j++)a[j]=0;
        for(int j=0;j<n;j++)if(c[j]==i){a[s[j]*2-1]++,a[t[j]*2]--;}
        for(int j=1;j<200002;j++)a[j]+=a[j-1];
        for(int j=0;j<200002;j++)if(a[j]>0)b[j]++;
    }
    int ans=0;
    for(int i=0;i<200002;i++)ans=max(ans,b[i]);
    cout << ans<<endl;
    return 0;
}

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

using namespace std;

int main() {
  int h, w;
  cin >> h >> w;
  int tr[10][10];
  for (int i = 0; i < 10; ++i) {
    for (int j = 0; j < 10; ++j) {
      cin >> tr[i][j];
    }
  }
  for (int k = 0; k < 10; ++k) {
    for (int i = 0; i < 10; ++i) {
      for (int j = 0; j < 10; ++j) {
        if (tr[i][j] > tr[i][k] + tr[k][j]) {
          tr[i][j] = tr[i][k] + tr[k][j];
        }
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      int s;
      cin >> s;
      ans += tr[s][1];
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	
	public static class Ret{
		boolean ret;
		ArrayList<Integer> rev;
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		ArrayList<Integer> b = new ArrayList<Integer>();
		for(int i=0;i<N;i++) {
			int nb = sc.nextInt();
			if(nb > i+1) {
				System.out.println(-1);
				return;
			}
			b.add(nb);
		}
		if(b.get(0) != 1) {
			System.out.println(-1);
			return;
		}
		ArrayList<Integer> rev = new ArrayList<Integer>();
		Ret ret = func(b,rev);
		if(ret.ret) {
			LinkedList<Integer> lis = new LinkedList<Integer>(ret.rev);
			for(int i=0;i<N;i++) {
				System.out.println(lis.remove());
			}
			return;
		}
		System.out.println(-1);
	}
	
	public static Ret func(ArrayList<Integer> b, ArrayList<Integer> rev) {
		Ret ret = new Ret();
		if(b.size() == 1 && b.get(0)==1) {
			rev.add(1);
			ret.ret = true;
			ret.rev = rev;
			return ret;
		}
		for(int i=b.size()-1;i>=0;i--) {
			//System.out.println(4);
			if(b.get(i)==i+1) {
				ArrayList<Integer> newb = new ArrayList<Integer>(b);
				newb.remove(i);
				Ret prev = func(newb,rev);
				if(prev.ret) {
					prev.rev.add(i+1);
					return prev;
				}
			}
		}
		ret.ret = false;
		return ret;
	}

}


Measured memory_bytes: 22612
import java.io.*;
import java.util.*;
import static java.lang.System.out;

public class Main{
    static MyReader in = new MyReader();

    public static void main(String[] args){
        String s = in.s();
        char[] t = new char[s.length()];
        Arrays.fill(t, 'x');
        out.println(t);
    }

    static class MyReader extends BufferedReader{
        MyReader(){
            super(new InputStreamReader(System.in));
        }

        String s(){
            try{return readLine();}catch(IOException e){return "";}
        }

        String[] ss(){
            return s().split(" ");
        }

        int i(){
            return Integer.parseInt(s());
        }

        int[] ii(){
            String[] ss = ss();
            int[] ii = new int[ss.length];
            for(int j = 0; j < ss.length; j++) ii[j] = Integer.parseInt(ss[j]);
            return ii;
        }

        ArrayList<Integer> li(){
            String[] ss = ss();
            ArrayList<Integer> li = new ArrayList<>();
            for(int j = 0; j < ss.length; j++) li.add(Integer.parseInt(ss[j]));
            return li;
        }

        long l(){
            return Long.parseLong(s());
        }

        long[] ll(){
            String[] ss = ss();
            long[] ll = new long[ss.length];
            for(int j = 0; j < ss.length; j++) ll[j] = Long.parseLong(ss[j]);
            return ll;
        }
    }
}


Measured memory_bytes: 23124