akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define INF 1234567890
#define pii pair<int,int>
#define LL long long
using namespace std;

LL fpow(LL a, LL b) {
    LL ans = 1;
    while (b) {
        if (b & 1) {
            ans *= a;
            ans %= MOD;
        }
        a *= a;
        a %= MOD;
        b >>= 1;
    }
    return ans;
}

const int MAXN = 2000000;
LL fac[MAXN+5], inv[MAXN+5];

// don't forget to call this function
void precompute(LL x) {
    fac[0] = 1;
    inv[0] = 1;
    for (LL i=1;i<=x;i++) {
        fac[i] = fac[i-1] * i;
        fac[i] %= MOD;
        inv[i] = fpow(fac[i], MOD-2);
    }
}

LL c(LL n, LL k) {
    if (n < k) return 0;
    LL ret = fac[n];
    ret *= inv[k];
    ret %= MOD;
    ret *= inv[n-k];
    ret %= MOD;
    return ret;
}

LL d[500005];

int main () {
    //clock_t start = clock();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    // int cnt = 0;
    // int p = 7;
    // for (int i=1;i<=p;i++) {
    //     for (int j=1;j<=p;j++) {
    //         for (int k=1;k<=p;k++) {
    //             if (i == j || j == k || i == k) continue;
    //             if (i == 1 || j == 2 || k == 3) continue;
    //             cnt++;
    //         }
    //     }
    // }
    // cout << cnt << endl;
    precompute(MAXN);
    // LL anss = 0, nn = 5, t = 2;
    // for (int i=0;i<=t;i++) {
    //     if (i % 2 == 0) {
    //         anss += ((c(t, i) * fac[nn-i])%MOD * inv[nn-t])%MOD;
    //         anss %= MOD;
    //     } else {
    //         anss -= ((c(t, i) * fac[nn-i])%MOD * inv[nn-t])%MOD;
    //         anss %= MOD;
    //     }
    // }
    // cout << anss;

    // return 0;

    int n,m;
    cin >> n >> m;

    d[0] = 1;
    d[1] = 0;
    for (int i=2;i<=n;i++) {
        d[i] = d[i-1] * i;
        if (i % 2 == 0) d[i]++; else d[i]--;
        d[i] %= MOD;
    }

    LL ans = c(m,n) * fac[n];
    ans %= MOD;
    // ans *= c(m-1,n);
    // ans %= MOD;

    LL magic = 0;
    for (int i=0;i<=n;i++) {
        if (i % 2 == 0) {
            magic += ((c(n, i) * fac[m-i])%MOD * inv[m-n])%MOD;
            magic %= MOD;
        } else {
            magic -= ((c(n, i) * fac[m-i])%MOD * inv[m-n])%MOD;
            magic %= MOD;
            if (magic < 0) magic += MOD;
        }
    }
    ans *= magic;
    ans %= MOD;
    // ans *= d[n];
    // ans %= MOD;
    cout << ans << endl;
    //cerr << fixed << setprecision(3) << (clock()-start)*1./CLOCKS_PER_SEC << endl;
    return 0;
}

Measured memory_bytes: 38748
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define ll long long
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
ll MOD = 1000000007;

int main() {
    int n;
    int a[110];
    cin >> n;
    imfor(i, n) {
        cin >> a[i];
    }
    int ans = 99999999;
    for (int i = -100; i <= 100; i++) {
        int tmp = 0;
        imfor(j, n) {
            tmp += (a[j] - i) * (a[j] - i);
        }
        ans = min(ans, tmp);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE RankNTypes #-}
import qualified Data.ByteString.Lazy.Char8 as B
import Data.Maybe
-- import Data.List
-- import qualified Data.Vector.Unboxed as VU
-- import qualified Data.Vector.Unboxed.Mutable as VUM
-- import Control.Monad
-- import Control.Monad.ST
-- import Debug.Trace
-- trace _ = id

solve :: Int -> Int -> Int -> Int
solve a b k = lst !! (k-1)
  where
    g = gcd a b
    lst = [x | x <- [g,g-1..1], g `mod` x == 0]

readBInt :: B.ByteString -> Int
readBInt = fst . fromJust . B.readInt

tmain :: B.ByteString -> Int
tmain cont =
  let remLines0 = map B.words (B.lines cont)
      [bs_a,bs_b,bs_k]:remLines1 = remLines0
      a = readBInt bs_a
      b = readBInt bs_b
      k = readBInt bs_k
  in solve a b k

outAnswer :: Int -> IO ()
outAnswer = putStrLn . show

main :: IO ()
main = outAnswer . tmain =<< B.getContents


-------------------------------------------------------------------------------

inp1 = "8 12 2\n"
inp2 = "100 50 4\n"
inp3 = "1 1 1\n"
tv1 = tmain $ B.pack inp1
tv2 = tmain $ B.pack inp2
tv3 = tmain $ B.pack inp3
test1 = tv1 == 2
test2 = tv2 == 5
test3 = tv3 == 1
alltest = test1 && test2 && test3



Measured memory_bytes: 380
#include<bits/stdc++.h>
#define int long long
using namespace std;
int n,a,b;
int Abs(int x)
{
	if(x<0) return -x;
	return x;
}
signed main()
{
	scanf("%lld%lld%lld",&n,&a,&b);
	if(a>b) swap(a,b);
	if(a%2==b%2) printf("%lld\n",(b-a)/2);
	else
	{
		int an=a-1;
		int aa=b-a+1;
		an+=(aa-1)/2+1;
		int bn=n-b;
		int ab=a+(n-b);
		bn+=(n-ab)/2+1;
		printf("%lld\n",min(an,bn));
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <set>

using namespace std;

int N , M , Q;
int a[100010];
int x[100010];
int o[100010];
int c;
int f , e;

int main(){
	scanf("%d%d%d" , &N , &M , &Q);
	for(int i = 0 ; i < Q ; ++i){
		scanf("%d" , a + i);
	}
	c = 0;
	f = 0;
	e = 0;
	x[0] = N;
	for(int i = Q - 1 ; i >= 0 ; --i){
		if(o[a[i]] == 0){
			++e;
			o[a[i]] = e;
			while(o[c + 1] > 0) ++c;
			if(c < a[i]){
				f = e;
			}
		}
		if(x[o[a[i]] - 1] > x[o[a[i]]]) ++x[o[a[i]]];
	}
	for(int i = 1 ; i <= f ; ++i){
		if(x[i] < N){
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");
	return 0;
}


Measured memory_bytes: 1280
using System;

namespace test
{
    class Program
    {
        static void Main(string[] args){
            int a, b;
            string[] str = Console.ReadLine().Split(' ');
            a = int.Parse(str[0]);
            b = int.Parse(str[1]);
            Console.WriteLine("{0} {1}",a*b,a*2+b*2);
		}
    }
}

Measured memory_bytes: 9092
///...................SUBHASHIS MOLLICK...................///
///.....DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING....///
///.............ISLAMIC UNIVERSITY,BANGLADESH.............///
///....................SESSION-(14-15)....................///
#include<bits/stdc++.h>
using namespace std;
#define sf(a) scanf("%d",&a)
#define sf2(a,b) scanf("%d %d",&a,&b)
#define sf3(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define pf(a) printf("%d",a)
#define pf2(a,b) printf("%d %d",a,b)
#define pf3(a,b,c) printf("%d %d %d",a,b,c)
#define sfl(a) scanf("%lld",&a)
#define sfl2(a,b) scanf("%lld %lld",&a,&b)
#define sfl3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define pfl(a) printf("%lld",a)
#define pfl2(a,b) printf("%lld %lld",a,b)
#define pfl3(a,b,c) printf("%lld %lld %lld",a,b,c)
#define nl printf("\n")
#define   timesave              ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long
#define pb push_back
#define MPI map<int,int>mp;
#define fr(i,n) for(i=0;i<n;i++)
#define fr1(i,n) for(i=1;i<=n;i++)
#define frl(i,a,b) for(i=a;i<=b;i++)
#define tz 100000
/*primes in range 1 - n
1 - 100(1e2) -> 25 pimes
1 - 1000(1e3) -> 168 primes
1 - 10000(1e4) -> 1229 primes
1 - 100000(1e5) -> 9592 primes
1 - 1000000(1e6) -> 78498 primes
1 - 10000000(1e7) -> 664579 primes
large primes ->
104729 1299709 15485863 179424673 2147483647 32416190071 112272535095293 48112959837082048697
*/
//freopen("Input.txt","r",stdin);
//freopen("Output.txt","w",stdout);
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
main()
{
    timesave;
    int n;
    string s;
    while(cin>>n>>s)
    {
        int i,j,cnt=0;
        for(i=0;i<n;i++)
        {
            string s1;
            s1="";
            for(j=i;j<i+3&&j<n;j++)
            {
                s1+=s[j];
            }
            if(s1=="ABC")
                cnt++;
        }
        cout<<cnt<<endl;
    }
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <functional>
#include <queue>
#include <map>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
const int INF = 100000000;

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

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

    cout << count << endl;
}

Measured memory_bytes: 256
var
	s,t:double;
	i,n:longint;
	a:String[4];
begin
	readln(n);
	for i:=1 to n do begin
		readln(s,a);
		if a=' BTC'then s:=s*38e4;
		t:=t+s;
	end;
	writeln(t);
end.

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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  double d;
  cin >> d;
  double res = d * sqrt(2);
  for (double w = 1; w <= d; w += 1) {
    double h = sqrt(d * d - w * w);
    if (h < 1) {
      res = max(res, w + 1);
    }
  }
  cout << res << '\n';
}



Measured memory_bytes: 3308
/*
 * 16-7-31_AGC002_A.cpp
 *
 *  Created on: 2016/07/31
 *      Author: ryoma
 */

#include <iostream>

using namespace std;

long long  a,b;

int main(){
	cin >> a >> b;
	if (a*b <= 0)
		cout << "Zero" << endl;
	else if (a+b > 0)
		cout << "Positive" << endl;
	else {
		cout << (((b-a)&1)? "Positive":"Negative")<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<double>;
using VecS = vector<string>;
using VecVec = vector<Vec>;
using Tree = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T& b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T& b){if(a > b){a = b; return true;} return false;}
template <typename T>
void co(const T n){cout << n << endl;}
template <typename T>
void cosp(const T n){cout << n << ' ';}
void coVec(const Vec &v){for(ll i : v) cosp(i); cout << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const double PI = acos(-1);
const double EPS = 1e-9;

int main(void){
	char c;
	cin >> c;
	c += 1;
	co(c);

	return 0;
}


Measured memory_bytes: 256
import heapq as hq

def D_stra(N,connections,st):
    mxc=2**29
    cost =[mxc for i in range(N)]
    visited =[False for i in range(N)]
    cost[st]=0
    q=[]

    hq.heappush(q,(0,st))

    while q:
        c,node=hq.heappop(q)

        if visited[node]:
            continue
        visited[node]=True

        for connection in connections[node]:

            target,mc=connection
            if cost[target]>c+mc:
                cost[target]=c+mc
                hq.heappush(q,(c+mc,target))
    
    return cost



def resolve():
    N , X, Y = map(int,input().split())
    conections =[[[1,1]]]
    for i in range(1,N-1):
        conections.append([[i-1,1],[i+1,1]])
    conections.append([[N-2,1]])
    conections[X-1].append([Y-1,1])
    conections[Y-1].append([X-1,1])

    dist = [0 for i in range(N)]
    for i in range(N):
        cost = D_stra(N,conections,i)
        for j in cost[i:]:
            dist[j] += 1
    for i in dist[1:]:
        print(i)






if __name__ == "__main__":
    resolve()

Measured memory_bytes: 70192
a, b, c, x, y = map(int, input().split())
min_sum = 0

if (a + b) > (c * 2):
    if x > y:
        min_sum = y * (c * 2)
        if a > (c * 2):
            tankin = c * 2
        else:
            tankin = a
    else:
        min_sum = x * (c * 2)
        if b > (c * 2):
            tankin = c * 2
        else:
            tankin = b
    min_sum += abs(x - y) * tankin
else:
    min_sum = a * x + b * y

print(min_sum)


Measured memory_bytes: 3060
#include <stdio.h>
int S[1000000],n;
int binarySearch(int key){
  int left =0;
  int right,mid;
  right=n;
  while(left < right){
    mid = (left+right)/2;
    if(S[mid] == key)return 1;
    else if(key < S[mid])right =mid;
    else left=mid+1;
  }
  return 0;
}
int main(){
  int i,q,key,count=0;
    
  scanf("%d",&n);
  for(i=0;i < n;i++){
    scanf("%d",&S[i]);
  }
  scanf("%d",&q);
  for(i=0;i < q;i++){
    scanf("%d",&key);
    if(binarySearch(key))count++;
  }
  printf("%d\n",count);
  return 0;
}



Measured memory_bytes: 2104
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <limits>
#include <numeric>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <stack>

using namespace std;

#define INFint (1<<30)
#define BOUND 27182818284
#define MAT 2

typedef long long ll;
typedef long long int lli;
typedef pair<ll, ll> P;

ll MOD = 1000000007;
const ll INF = (1ll<<60);
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for(int i=int(a);i<int(b);++i)

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

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

// gcd
template<typename T>
T gcd(T a, T b) {
    if (a == 0)
        return b;
    return gcd(b % a, a);
}

int findGCD(int arr[], int n) {
    int result = arr[0];
    for (int i = 1; i < n; i++)
        result = gcd(arr[i], result);
    return result;
}

template<typename T>
T lcm(T m, T n) {
    // 引数に0がある場合は0を返す
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    fill((T *) array, (T *) (array + N), val);
}


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

// v.front() = -BOUND;
// v.back() = BOUND;

//struct edge{
//    int cost, to;
//
//    edge(int in_cost, int in_to){
//        cost=in_cost;
//        to=in_to;
//    }
//    bool operator<(const edge &a) const
//    {
//        return cost > a.cost;
//    }
//};
int main() {
    int n,a,b; cin >> n >> a >> b;

    vector<ll> X(n);
    ll ans=0LL;
    rep(i,n){
        cin >> X[i];
    }

    for(int i=0; i<n-1; i++){
        if( a*(X[i+1]-X[i]) > b){
            ans+=b;
        }else{
            ans+=a*(X[i+1]-X[i]);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <functional>
#include <cassert>
#include <utility>
#include <stack>
#include <queue>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef pair<int,int> Pi;
typedef long long int ll;
const int INF=(ll)(1<<30)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}


int main(){
	int n;
	cin>>n;
	int v[20];
	int c[20];
	int ans=0;
	for(int i=0;i<n;i++)
		cin>>v[i];
	for(int i=0;i<n;i++)
		cin>>c[i];
	for(int i=0;i<n;i++){
		if(v[i]-c[i]>0){
			ans+=(v[i]-c[i]);
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main(){double n,x,y,a,p=1.57079633;while(scanf("%lf",&n),n>0){for(x=1,y=0;--n;)a=atan2(y,x)+p,x+=cos(a),y+=sin(a);printf("%.2f\n%.2f\n",x,y);}return 0;}

Measured memory_bytes: 0
#include <bits/stdc++.h> 
using namespace std; 
  
// Function to traverse the DAG 
// and apply Dynamic Programming 
// to find the longest path 
void dfs(int node, vector<int> adj[], int dp[], bool vis[]) 
{ 
    // Mark as visited 
    vis[node] = true; 
  
    // Traverse for all its children 
    for (int i = 0; i < adj[node].size(); i++) { 
  
        // If not visited 
        if (!vis[adj[node][i]]) 
            dfs(adj[node][i], adj, dp, vis); 
  
        // Store the max of the paths 
        dp[node] = max(dp[node], 1 + dp[adj[node][i]]); 
    } 
} 
  
// Function to add an edge 
void addEdge(vector<int> adj[], int u, int v) 
{ 
    adj[u].push_back(v); 
} 
  
// Function that returns the longest path 
int findLongestPath(vector<int> adj[], int n) 
{ 
    // Dp array 
    int dp[n + 1]; 
    memset(dp, 0, sizeof dp); 
  
    // Visited array to know if the node 
    // has been visited previously or not 
    bool vis[n + 1]; 
    memset(vis, false, sizeof vis); 
  
    // Call DFS for every unvisited vertex 
    for (int i = 1; i <= n; i++) { 
        if (!vis[i]) 
            dfs(i, adj, dp, vis); 
    } 
  
    int ans = 0; 
  
    // Traverse and find the maximum of all dp[i] 
    for (int i = 1; i <= n; i++) { 
        ans = max(ans, dp[i]); 
    } 
    return ans; 
} 
  
// Driver Code 
int main() 
{ 
    int n,m;
    cin>>n>>m;
    vector<int> adj[n + 1]; 
    int x,y;
    for(int i=0;i<m;i++) 
    {
       cin>>x>>y;
       addEdge(adj,x,y); 
    }  
  
    cout << findLongestPath(adj, n); 
    return 0; 
} 

Measured memory_bytes: 9600
N = int(input())
A = list(map(int,input().split()))

A.sort()
ans = 1

for i in range(N):
    if A[i] == 0:
        ans = 0
        break
    ans = ans * A[i]
    if ans > 10**18:
        ans = -1
        break

print(ans)

Measured memory_bytes: 21580
#include<bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 5;
int n, W;
int w[105], v[105];

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

//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);

    cin >> n >> W;
    int sum = 0;
    for (int i = 1; i <= n; i++) {
        cin >> w[i] >> v[i];
        sum += v[i];
    }

//    vector<vector<bool>> dp(n + 1, vector<bool>(1001));
    vector<int> dp(100001, INF);
    dp[0] = 0;
    for (int i = 1; i <= n; i++) {
        for (int j = sum; j >= v[i]; j--) {
            dp[j] = min(dp[j], dp[j - v[i]] + w[i]);
        }
    }

    for (int j = sum; j >= 0; j--) {
        if (dp[j] <= W) {
            cout << j << '\n';
            break;
        }
    }

}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include<map>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) (x).begin(),(x).end()
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//vector<vector<要素の型>> 変数名(要素数1, vector<要素の型>(要素数2, 初期値));
//vector<vector<要素の型>> 変数名(要素数1, vector<要素の型>(要素数2));  // 初期値を省略


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	string ts="test";
	
	int n,k; cin >> n >> k;
	
	vector<long double> a(n);
	rep(i,n){
		
		cin >> a[i];
		a[i]++; a[i]/=2;
		//cout << a[i] << endl;
	}
	
	
	long double mx=0;
	
	rep(i,k) mx+=a[i];
	
	if(n==k){
		cout << mx << endl;
		return 0;
	}
	
	long double sum=mx;
	
	//rep(i,n) cout << a[i] << endl;
	
	//cout << endl << mx << endl;
	
	rep(i,n-k){
		sum+=a[i+k]-a[i];
		chmax(mx,sum);
		
	}


	cout<<fixed<<setprecision(20)<<mx<<"\n";
	
	
	return 0;
}



Measured memory_bytes: 3456
n = int(input())
s1 = input()
s2 = input()

if s1[0] == s2[0]:
    res = 3
    state = 'v'
else:
    res = 6
    state = 'h1'


for i in range(1, n):
    if s1[i] == s2[i]: # if vertical
        if state == 'v':
            res = 2 * res % 1000000007
        else:
            pass

        state = 'v'

    else: # if horizontal
        if state == 'h1':
            state = 'h2'

        elif state == 'h2':
            res = 3 * res % 1000000007
            state = 'h1'

        elif state == 'v':
            res = 2 * res % 1000000007
            state = 'h1'

print(res)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define REP(LoopVariable,numberOFend) for(int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)


int main(){

    int n,a,b;
    cin >> n >> a >> b;
    if((b-a)%2){
        cout << "Borys" << endl;
    }else{
        cout << "Alice" << endl;
    }
    return 0;
}

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

#define int long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)
 
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
#define YES puts("YES")
#define Yes puts("Yes")
#define NO  puts("NO")
#define No  puts("No")
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
 
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
 
 
#if 1
//-------------
// DUMPマクロ
// https://www.creativ.xyz/dump-cpp-652/
 
// vector
template <typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    for (T& x : vec) is >> x;
    return is;
}
// pair
template <typename T, typename U>
ostream& operator<<(ostream& os, pair<T, U>& pair_var) {
    os << "(" << pair_var.first << ", " << pair_var.second << ")";
    return os;
}
// vector
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    os << "{";
    for (int i = 0; i < vec.size(); i++) {
        os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
// map
template <typename T, typename U>
ostream& operator<<(ostream& os, map<T, U>& map_var) {
    os << "{";
    repi(itr, map_var) {
        os << *itr;
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
// set
template <typename T>
ostream& operator<<(ostream& os, set<T>& set_var) {
    os << "{";
    repi(itr, set_var) {
        os << *itr;
        itr++;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
 
#define DUMPOUT cerr
 
void dump_func() {
    DUMPOUT << endl;
}
template <class Head, class... Tail>
void dump_func(Head&& head, Tail&& ... tail) {
    DUMPOUT << head;
    if (sizeof...(Tail) > 0) {
        DUMPOUT << ", ";
    }
    dump_func(std::move(tail)...);
}
#ifdef DEBUG
#define DEB
#define dump(...)                                                              \
    DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
            << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
            << endl                                                            \
            << "    ",                                                         \
        dump_func(__VA_ARGS__)
#else
#define DEB if (false)
#define dump(...)
#endif
#endif


 
signed main() {
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    int x=tx-sx;
    int y=ty-sy;
    
    rep(i,y) cout << "U";
    rep(i,x) cout << "R";
    rep(i,y) cout << "D";
    rep(i,x) cout << "L";
    cout << "L";
    rep(i,y+1) cout << "U";
    rep(i,x+1) cout << "R";
    cout << "D";
    cout << "R";
    rep(i,y+1) cout << "D";
    rep(i,x+1) cout << "L";
    cout << "U" << endl;
    
    return 0;
}


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

int main() {
    string s;
    cin >> s;
    int A, Z;

    for(int i = 0; i < s.size(); ++i) {
        if(s[i] == 'A') {
            A = i; break;
        }
    }
    for(int i = s.size() - 1; i > 0; --i) {
        if(s[i] == 'Z') {
            Z = i; break;
        }
    }

    cout << Z - A + 1 << endl;
}

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

#if defined(DEBUG)

#include <unistd.h>
#include <sys/fcntl.h>
#define DLOG(...)        cerr << dbgFormat(__VA_ARGS__) << endl
#define DCALL(func, ...) func(__VA_ARGS__)

template <class... Args>
string dbgFormat(const char* fmt, Args... args) {
  size_t len = snprintf(nullptr, 0, fmt, args...);
  char buf[len + 1];
  snprintf(buf, len + 1, fmt, args...);
  return string(buf);
}

#else  // defined(DEBUG)

#define DLOG(...)
#define DCALL(func, ...)

#endif // defined(DEBUG)
// ----------------------------------------------------------------------

template<typename F>
class FixPoint : private F {
public:
  explicit constexpr FixPoint(F&& f) noexcept : F(forward<F>(f)) {}

  template<typename... Args>
  constexpr decltype(auto) operator()(Args&&... args) const {
    return F::operator()(*this, forward<Args>(args)...);
  }
};

template<typename F>
static inline constexpr decltype(auto) fix(F&& f) noexcept {
  return FixPoint<F>{forward<F>(f)};
}

// ----------------------------------------------------------------------
struct MyException : exception {};

int main(int argc, char *argv[]) {
#if defined(DEBUG)
  // GDB on Cygwin ignores redirection at run command.
  if (argc == 2) dup2(open(argv[1], 0), 0);
#else
  // For performance.  We should not use C-style stdio functions
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
#endif
  cout << setprecision(20);

  int N, M; cin >> N >> M;
  vector<vector<int>> nbr(N);
  for (int i = 0; i < M; i++) {
    int a, b; cin >> a >> b; a--; b--;
    nbr.at(a).push_back(b);
  }
  vector<bool> visited(N);
  vector<int> stack;
  unordered_set<int> stset;

  auto dfs = fix([&](auto f, int n) -> void {
    if (stset.find(n) != stset.end()) {
      int ssize = stack.size();
      vector<int> ord(N);
      for (int i = 0; i < ssize; i++) ord.at(stack.at(i)) = i;
      vector<int> diff(N, 1);
      int startIdx = 0;
      int idx = 0;
      while (1) {
	int x = stack.at(idx);
	int stp = 0;
	for (int z : nbr.at(x)) {
	  if (stset.find(z) == stset.end()) continue;
	  int ii = ord.at(z);
	  int d = ii - idx > 0 ? ii - idx : ii - idx + ssize;
	  stp = max(stp, d);
	}
	int nxtIdx = (idx + stp) % ssize;
	if (stp > diff.at(idx)) {
	  diff.at(idx) = stp;
	  startIdx = idx;
	}else if (nxtIdx == startIdx) {
	  break;
	}
	idx = nxtIdx;
      }
      vector<int> ans;
      idx = startIdx;
      while (1) {
	ans.push_back(stack.at(idx));
	idx = (idx + diff.at(idx)) % ssize;
	if (idx == startIdx) break;
      }
      cout << ans.size() << "\n";
      for (int k : ans) {
	cout << k+1 << "\n";
      }
      throw MyException();
    }
    if (visited.at(n)) return;
    visited.at(n) = true;
    int sz = stack.size();
    stack.push_back(n);
    stset.insert(n);
    for (int m : nbr.at(n)) {
      f(m);
    }
    auto it = stset.find(n);
    assert(it != stset.end());
    stset.erase(it);
    stack.resize(sz);
    });

  try {
    for (int i = 0; i < N; i++) {
      if (visited.at(i)) continue;
      dfs(i);
    }
    cout << -1 << endl;
  }catch(const MyException& e) {
  }

  return 0;
}



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

#define ll long long
#define pb push_back
#define mp make_pair
#define ull unsigned long long
#define rep(n) for(ll i = 0 ; i<n ; i++) 
#define repd(n) for(ll i = n-1 ; i>=0 ; i--)
#define MOD 1000000007
#define sz(a) a.size()
#define pii pair<ll,ll> 
#define nl "\n"
#define ff first
#define ss second
#define c(n) ll n; cin>>n;
#define ca(n) ll a[n]; rep(n) cin>>a[i];
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(a) a.begin(),a.end()
#define sort_stl(a) sort(a.begin(),a.end())
#define srt(a) sort(a,a+n)
#define fl(a,x) memset(a,x,sizeof(a))

typedef vector<ll> vll ;

int main(){
    
    fast;
    double n; cin>>n;
	double s = (double)n/3;
	cout << fixed << setprecision(12) << s*s*s;
	return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <cstdlib>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define REP(i,n) for(int i=0;i<n;i++)
#define REPS(i,n,s) for(int i=s;i<n;i++)
#define SORT(c) sort((c).begin(),(c).end())
#define ALL(a) (a).begin(),(a).end()

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

  int r,d,x;
  cin >> r >> d >> x;

  int before = r*x-d;
  cout << before << endl;
  REP(i, 9) {
    before = r*(before) -d;
    cout << before << 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 MAXN = 3000;
const ll MOD = 1e9+7;

int n;
char s[MAXN+10];
ll dp[MAXN+10][MAXN+10], ans;

int main()
{
    cin.tie(0); cout.tie(0);
    ios_base::sync_with_stdio(false);
    int i, j;

    scanf("%d%s", &n, s+2);

    dp[1][1]=1;
    for(i=2; i<=n; i++)
    {
        for(j=1; j<=i; j++)
        {
            if(s[i]=='<' && j==1) dp[i][j]=0;
            else if(s[i]=='>' && j==i) dp[i][j]==0;
            else
            {
                if(s[i]=='<') dp[i][j]=dp[i-1][j-1];
                else dp[i][j]=(dp[i-1][i-1]-dp[i-1][j-1]+MOD)%MOD;
            }
            dp[i][j]=(dp[i][j-1]+dp[i][j])%MOD;
        }
    }

    printf("%lld", dp[n][n]);
    return 0;
}


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

typedef long long ll;

int main(){
    ll n, a, b;
    cin >> n >> a >> b;

    ll ans = 0, before, now;
    cin >> before;
    for(int i = 1; i < n; i++){
        cin >> now;
        ans += min(b, (now-before)*a);
        before = now;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
data = [[[0 for r in range(10)] for f in range(3)] for b in range(4)]
n = int(input())
for _ in range(n):
    (b, f, r, v) = [int(i) for i in input().split()]
    data[b - 1][f - 1][r - 1] += v
  
for b in range(4):
    for f in range(3):
        for r in range(10):
            print('', data[b][f][r], end='')
        print()
    if b != 3:
        print('#' * 20)

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

int A,B;

int main()
{
	scanf("%d%d",&A,&B);
	if(A<=8&&B<=8)
	{printf("Yay!");return 0;}
	else
	{printf(":(");return 0;}
}

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

int main(void)
{
	char str[50000];
	int temp;
	int i, j;
	
	while (1){
		scanf("%[A-Za-z ]", str);
		getchar();
		
		if (strcmp(str, "END OF INPUT") == 0){
			break;
		}
		
		temp = i = 0;
		while (str[i] != ' ' && str[i] != '\0'){
			temp++;
			i++;
		}
		printf("%d", temp);
		
		if (str[i] != '\0'){
			if (str[i] == ' ' && str[i + 1] == ' '){
				printf("0");
				i++;
			}
			i++;
			
			while (str[i] != '\0'){
				temp = 0;
				while (str[i] != ' ' && str[i] != '\0'){
					temp++;
					i++;
				}
				printf("%d", temp);
				
				if (str[i] == '\0'){
					break;
				}
				
				if (str[i] == ' ' && str[i + 1] == ' '){
					printf("0");
					i++;
				}
				i++;
			}
		}
		printf("\n");
	}
	
	return (0);
}

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

int A, B, C, X, Y;

signed main() {
    cin.tie(0); ios::sync_with_stdio(false);
    cin >> A >> B >> C >> X >> Y;
    int ans = 1000000000;
    for (int i=0; i<=200100; i+=2) ans = min(ans, max(0ll, X-i/2)*A+max(0ll, Y-i/2)*B+i*C);
    cout << ans << endl;
}

Measured memory_bytes: 256
n = int(input())
tens = []
odd = []
for i in range(n):
	s = int(input())
	if s % 10 == 0:
		tens.append(s)
	else:
		odd.append(s)
ans = sum(tens)+sum(odd)
if ans % 10 == 0:
	if len(odd) == 0:
		ans = 0
	else:
		ans = ans-min(odd)

print(ans)

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<limits>

#ifndef  LLONG_MAX
#define LLONG_MAX 9223372036854775807
#endif

using namespace std;
typedef long long llong;

int N;
llong *v_list;
double tripartition;
	
llong BaumukuchenGetAnswer();
llong searchOne(int n0);
llong getMinV(int n0, int n1, int n2);
int findIndex(int from_n, int to_n, double target);

int main(){
	/*
	ifstream fin("input.txt");
	fin >> N;
	v_list = new llong[N+1];
	v_list[0] = 0;
	for(int n=1; n<N+1; n++){
		llong A;
		fin >> A;
		v_list[n] = v_list[n-1] + A;
	}
	fin.close();
	/*/
	cin >> N;
	v_list = new llong[N+1];
	v_list[0] = 0;
	for(int n=1; n<N+1; n++){
		llong A;
		cin >> A;
		v_list[n] = v_list[n-1] + A;
	}
	//*/
	cout << BaumukuchenGetAnswer() <<endl;
	delete[] v_list;
}


llong BaumukuchenGetAnswer(){
	tripartition = v_list[N] / 3.0;
	llong interm_maxV = -1;
	int n0_max = findIndex(0, N, tripartition);
	for (int n0 = 0; n0 <= n0_max; n0++){
		llong tmp = searchOne(n0);
		if (tmp > interm_maxV) interm_maxV = tmp;
	}
	return interm_maxV;
}

llong searchOne(int n0){
	int n1_left = findIndex(n0, N, tripartition + v_list[n0]);
	int n2_left = findIndex(n1_left, N, 2 * tripartition + v_list[n0]);
	llong V_ll = getMinV(n0, n1_left, n2_left);
	llong V_lr = getMinV(n0, n1_left, n2_left+1);
	llong V_rl = getMinV(n0, n1_left+1, n2_left);
	llong V_rr = getMinV(n0, n1_left+1, n2_left+1);
	return max( max(V_ll,V_lr), max(V_rl, V_rr));
}

llong getMinV(int n0, int n1, int n2){
	if (n1 == -1 || n2 == -1) return LLONG_MAX;
	else {
		llong V0 = v_list[n1] - v_list[n0];
		llong V1 = v_list[n2] - v_list[n1];
		llong V2 = v_list[n0] - v_list[n2] + v_list[N];
		return min(min(V0,V1),V2);
	}
}

int findIndex(int from_n, int to_n, double target){
	int n_left = from_n;
	int n_right = to_n;
	while (n_right - n_left != 1) {
		int n_mid = (n_right + n_left) / 2;
		if (v_list[n_mid] <= target) n_left = n_mid;
		else n_right = n_mid;
	}
	return n_left;
}

Measured memory_bytes: 1800
while True:
    n = input()
    if n == 0: break
    pb = None
    ans = 0
    for i in range(n):
        i, h, w = map(int, raw_input().split())
        bmi = w/((float(h)/100)**2)
        a = abs(22-bmi)
        if pb is None:
            pb = a
            ans = i
        elif pb is not None and a < pb:
            pb = a
            ans = i
    else:
        print ans

Measured memory_bytes: 4264
program pr2
  integer :: ab(3,2),i,j,pt(4)

  do i=1,3
     read(*,*) ab(i,:)
  enddo
  pt=0
  do i=1,3
     pt(ab(i,1))=pt(ab(i,1))+1
     pt(ab(i,2))=pt(ab(i,2))+1
  enddo
  j=0
  do i=1,4
     if(mod(pt(i),2).eq.1) then
        j=j+1
     endif
  enddo
  if(j.eq.2) then
     write(*,'(a)') 'YES'
  else
     write(*,'(a)') 'NO'
  endif
end program pr2


Measured memory_bytes: 256
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }

bool is_ok(ll ans, set<int>& D) {
    string S = to_string(ans);
    rep(i, S.size()) {
        if (D.count(S[i] - 0x30) > 0) {
            return false;
        }
    }
    return true;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N, K;
    cin >> N >> K;
    set<int> D;
    rep(i, K) {
        int d;
        cin >> d;
        D.insert(d);
    }

    ll ans = N;
    while (1) {
        if (is_ok(ans, D)) break;
        ans++;
    }

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

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

struct Edge{
	int a,b,c;
};
bool operator < (const Edge &a, const Edge &b){
	return a.c < b.c;
}
int n,m;

int uf[10010];
int get(int x){
	return x == uf[x] ? x : uf[x] = get(uf[x]);
}
int unite(int x,int y){
	if( rand() & 1 ) swap(x,y);
	uf[get(x)] = get(y);
}

vector<Edge> es;
int check(int lim){
	for(int i = 0 ; i < n ; i++) uf[i] = i;
	int need1 = 0;
	int need2 = 0;
	for(int i = 0 ; i < es.size() ; i++){
		auto &e = es[i];		
		if( get(e.a) != get(e.b) ){
			unite(e.a,e.b);
			if( e.c <= lim ){
				need1++;
			}else need2++;
		}
	}
	return need1 > need2;
}
int main(){
	while(cin >> n >> m && n){
		es.resize(m);
		for(int i = 0 ; i < m ; i++) cin >> es[i].a >> es[i].b >> es[i].c, es[i].a--, es[i].b--;
		sort(es.begin(),es.end());
		int l = 0 , r = 1000;
		while( l != r ){
			int lim = (l+r)/2;
			if( check(lim) ){
				r = lim;
			}else{
				l = lim+1;
			}
		}
		cout << l << endl;
	}
			
}

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

int main(){
  int n;
  cin >> n;
  vi c(n),s(n),f(n);
  rep(i,n-1) cin >> c[i] >> s[i] >> f[i];
  rep(i,n){
    int ans=0;
    for(int j=i;j<n-1;j++){
      if(ans<s[j]){
        ans=c[j]+s[j];
      }else{
        ans=c[j]+((ans-1)/f[j]+1)*f[j];
      }
    }
    cout << ans << "\n";
  }
  
  return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    int N; cin >> N;
    long double x[N]; string *u = new string[N];
    for (int i=0; i<N; i++) cin >> x[i] >> u[i];

    long double result;
    for(int i=0; i<N; i++) result += u[i] == "JPY" ? x[i] : x[i]*380000;

    cout << result << endl;
    return 0;
}

Measured memory_bytes: 888
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)){
			int n = sc.nextInt();
			long [] array = new long [n];
			long [] array2 = new long [n];
			for (int i=0; i<n; i++) {
				 array[i] = array2[i] = sc.nextLong();
			}
			int times = sc.nextInt();
			for (int i=0; i<times; i++) {
				int b = sc.nextInt();
				int m = sc.nextInt();
				int e = sc.nextInt();
				for (int k=0; k< e - b; k++) {
					int move = b + k;
					int target = b + ((k + (e-m)) % (e - b));
					//System.out.println(array2[target] + "  " +  array[move]);
					array2[target] = array[move];
				}
				for (int j=0; j<n; j++) array[j] = array2[j];
			}
			for (int i=0; i<n - 1; i++) System.out.print(array[i] + " ");
			System.out.println(array[n - 1]);
		}
	}
}


Measured memory_bytes: 36508
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        long t = 1L;
        int r = 0;
        while(true){
            if(n < t)break;
            t *= k;
            r++;
        }
        System.out.println(r);
        sc.close();

    }

}


Measured memory_bytes: 21716
#include<iostream>
#include<map>

std::pair<int, int> make_sf_pair(int n){
    int f;
    std::pair<int, int> cur;
    cur.second = n % 10;
    while(n != 0){
	f = n;
	n /= 10;
    }
    cur.first = f;
    return cur;
}

int main(void){
    int n;
    std::map<std::pair<int, int>, int> mp;

    std::cin >> n;

    for(int i = 0; i <= n; i++){
	std::pair<int, int> sf = make_sf_pair(i);
	mp[sf]++;
    }

    long long ans = 0;

    for(int i = 0; i <= n; i++){
	std::pair<int, int> sf = make_sf_pair(i);
	std::pair<int, int> fs = std::make_pair(sf.second, sf.first);

	ans += mp[fs];
    }

    std::cout << ans << std::endl;

    return 0;
}



Measured memory_bytes: 3584
#include<stdio.h>
#include<algorithm>
#include<functional>
#include<cmath>
using namespace std;
int main()
{
	long long X, Y, count = 0;
	scanf("%lld%lld", &X, &Y);
	while (X <= Y) {
		X *= 2;
		count++;
	}
	printf("%lld", count);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <cstring>

#define rep(a, b, c) for (int a = b; a < (c); a++)
#define repe(a, b, c) for (int a = b; a <= (c); a++)
#define repr(a, b, c) for (int a = b; a > (c); a--)
#define repre(a, b, c) for (int a = b; a >= (c); a--)

using namespace std;

int main() {
    int N;
    cin >> N;
    int mid;
    long long T[N], A[N];
    int max_index = 0;
    rep(i, 0, N){
        cin >> T[i];
        if (T[max_index] < T[i]) {
            max_index = i;
        }
    }
    int min_index = 0;
    rep(i, 0, N) {
        cin >> A[i];
        if (A[i] >= A[min_index]) {
            min_index = i;
        }
    }
    if (T[max_index] != A[min_index] || max_index > min_index) {
        cout << 0 << endl;
        return 0;
    }
    mid = max_index;
    long long unsigned counter = 1;
    long long rem = -1;
    long long unsigned mod = 1000000007;
    rep(i, 0, mid) {
        if (T[i] == rem) {
            counter = ((counter % mod) * (T[i] % mod)) % mod;
        } else {
            rem = T[i];
        }
    }
    rem = -1;
    repr(i, N - 1, mid) {
        if (A[i] == rem) {
            counter = ((counter % mod) * (A[i] % mod)) % mod;
        } else {
            rem = A[i];
        }
    }
    cout << counter << endl;

    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <stdlib.h>

#define INC(i, a, b) for(int (i) = (a); (i) < (b); ++(i))
#define DEC(i, a, b) for(int (i) = (a); (i) > (b); --(i))
#define REP(i, n)    INC(i, 0, n)
#define comp(a, b) int comp(const void *(a), const void *(b))

typedef unsigned int uint;
typedef unsigned long ul;
typedef long long  ll;
typedef unsigned long long ull;

const int MOD = 1e9 + 7;

using namespace std;

void TFprint(bool b, std::string T, std::string F){
    if(b){
        cout << T << endl;
    }else{
        cout << F << endl;
    }
}

int abs(int x){
    return x > 0? x : -x;
}

int max(int a, int b){
    return a > b? a : b;
}

int min(int a, int b){
    return a < b? a : b;
}


int main(){
    int a, b;
    cin >> a >> b;
    cout << max(max(a + b, a - b),  a * b) << endl;;
    return 0;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <cstring>
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <numeric>
#include <float.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef unsigned long long ll;
// 最大公約数求める関数
int my_gcd(int n , int m){
  if(n < m){
    int tmp = n;
    n = m;
    m = tmp;
  }
  int l  = n % m;
  while(l != 0){
    n = m;
    m = l;
    l = n % m;
}
return m;
}

//char⇒int関数
 int ctoi(char c) {
 	switch (c) {
		case '0': return 0;
		case '1': return 1;
		case '2': return 2;
		case '3': return 3;
		case '4': return 4;
		case '5': return 5;
		case '6': return 6;
		case '7': return 7;
		case '8': return 8;
		case '9': return 9;
		default: return 0;
	}
}



int main(){
int ans = 0;
int X; cin >> X;
int a = X / 100;
int b = X % 100;
rep(i,a){
  if((i+1) * 5 >= b) ans = 1;

}
cout << ans << endl;
  }

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>

int main() {
  uint32_t N = 0;
  std::cin >> N;

  std::cout << ((N % 1000 == 0) ? 0 : 1000-N%1000) << std::endl;

  return 0;
}

Measured memory_bytes: 3592
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int total = Integer.parseInt(sc.next());
        List<Integer> list = new ArrayList<>();
        loop:for(int x=1;x<=total;x++){
            int z = Integer.parseInt(sc.next());
            for(Integer y:list){
                if(z==y) {
                    continue loop;
                }
            }
            list.add(z);
        }
        System.out.println(list.size());
    }
}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1<<21;
const ll INF = 1LL << 60;
const ll mod = 1e9+7;

static const int MAX = 100002;

int n;
int K;
vector<P> G[MAX];
void BFS(int s, vector<int>& ans){
    queue<P> que;
    que.push(make_pair(s, 0));
    while(!que.empty()){
        int u = que.front().first;
        int pre = que.front().second;
        que.pop();
        int tmp = 0;
        rep(i, G[u].size()){
            int v = G[u][i].second;
            int index = G[u][i].first;
            tmp++;
            if(pre==tmp) tmp++;
            ans[index] = tmp;
            que.push(make_pair(v, tmp));
        }
        chmax(K, tmp);
    }
}

int main() {
    cin >> n;
    vector<P> hen;
    K=0;

    rep(i, n-1){
        int a, b;
        cin >> a >> b;
        a--; b--;
        G[a].push_back(make_pair(i, b));
    }
    vector<int> ans(n-1, 0);
    BFS(0, ans);

    cout << K << endl;
    rep(i, n-1){
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 5120
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
    int bj[11]={0},a;
    for(int i=1;i<=3;i++)
    {
    	cin>>a;
    	bj[a]++;
	}
	if(bj[5]==2&&bj[7]==1)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
}

Measured memory_bytes: 256
#define ll long long
#define INF 99999999
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#include<bits/stdc++.h>
using namespace std;
int main(){
    int x,a;
    cin >>x>>a;
    if(a>x)cout << "0" <<endl;
    else cout << "10" << endl;
    return 0;
}

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

int main()
{
    int x,a,b = 0;
    int sa,sb = 0;
    cin >> x >> a >> b;
    
    sa = abs(a-x);
    sb = abs(b-x);
    
    if(sa <sb){
        cout << "A" << endl;
        
    }
    else if(sa > sb){
        cout << "B" << endl;
    }
    
    return 0;
    

}

Measured memory_bytes: 256