akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i, n) for (int i = 0; i < ((int)(n)); i++) // 0-indexed昇順

int main()
{
  string A, B, C;
  cin >> A >> B >> C;
  cout << (char)toupper(A[0]) << (char)toupper(B[0]) << (char)toupper(C[0]) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()




int main(){
    int k; cin>>k;
    if(k%2==0) cout<<k*k/4<<endl;
    else cout<<(k+1)*(k-1)/4<<endl;
}

Measured memory_bytes: 256
# abc119_b.py
# https://atcoder.jp/contests/abc119/tasks/abc119_b

# B - Digital Gifts /
# 実行時間制限: 2 sec / メモリ制限: 1024 MB
# 配点 : 200点

# 問題文
# 高橋くんは N人の親戚からお年玉をもらいました。
# N個の値 x1,x2,...,xN と N 個の文字列 u1,u2,...,uN が入力されます。
# 各文字列 ui は JPY または BTC であり、xi と ui が i人目の親戚からのお年玉の内容を表します。
# 例えば、x1=10000, u1= JPY であれば 1 人目の親戚からのお年玉は 10000 円であり、x2= 0.10000000, 
# u2= BTC であれば 2 人目の親戚からのお年玉は 0.1ビットコインです。
# ビットコインを 1.0BTC あたり 380000.0円として換算すると、高橋くんがもらったお年玉は合計で何円に相当するでしょうか？

# 制約
#     2≤N≤10
# ui=JPY または BTC
# ui=JPY のとき xi は整数であり、1≤xi≤10^8
# ui=BTC のとき xi は小数点以下の桁を 8 桁持つ小数であり、0.00000001≤xi≤100.00000000

# 入力
# 入力は以下の形式で標準入力から与えられる。
# N
# x1 u1
# x2 u2
# :
# xN uN

# 出力
# 高橋くんが受け取ったお年玉が合計で Y円に相当するとき、値 Y(整数とは限らない) を出力せよ。
# 出力は、ジャッジの出力との絶対誤差または相対誤差が 10−5以下のとき正解と判定される。

# 入力例 1
# 2
# 10000 JPY
# 0.10000000 BTC

# 出力例 1
# 48000.0

# 1人目の親戚からのお年玉は 10000 円です。
# 2 人目の親戚からのお年玉は 0.1 ビットコインであり、1 BTC あたり 380000.0 円として換算すると 38000.0 円となります。
# これらの合計は 48000.0円です。

# なお、48000、48000.1 などと出力しても正解と判定されます。

# 入力例 2
# 3
# 100000000 JPY
# 100.00000000 BTC
# 0.00000001 BTC

# 出力例 2
# 138000000.0038

# この場合、138001000、1.38e8 などと出力しても正解と判定されます。


def calculation(lines):
    # line = lines[0]
    N = int(lines[0])
    # N, M = list(map(int, lines[0].split()))
    # values = list(map(int, lines[1].split()))
    # values = list()
    # for i in range(N):
    #     values.append(int(lines[i+1]))

    result = 0
    for i in range(N):
        line = lines[i+1]
        if 'JPY' in line:
            result += int(line.replace(' JPY', ''))
        else:
            result += float(line.replace(' BTC', ''))*380000.0

    return [result]


# 引数を取得
def get_input_lines():
    line = input()
    N = int(line)
    lines = list()
    lines.append(line)
    for _ in range(N):
        lines.append(input())
    return lines


# テストデータ
def get_testdata(pattern):
    if pattern == 1:
        lines_input = ['2', '10000 JPY', '0.10000000 BTC']
        lines_export = [48000.0]
    if pattern == 2:
        lines_input = ['3', '100000000 JPY', '100.00000000 BTC', '0.00000001 BTC']
        lines_export = [138000000.0038]
    return lines_input, lines_export


# 動作モード判別
def get_mode():
    import sys
    args = sys.argv
    if len(args) == 1:
        mode = 0
    else:
        mode = int(args[1])
    return mode


# 主処理
def main():
    import time
    started = time.time()
    mode = get_mode()
    if mode == 0:
        lines_input = get_input_lines()
    else:
        lines_input, lines_export = get_testdata(mode)

    lines_result = calculation(lines_input)

    for line_result in lines_result:
        print(line_result)

    # if mode > 0:
    #     print(f'lines_input=[{lines_input}]')
    #     print(f'lines_export=[{lines_export}]')
    #     print(f'lines_result=[{lines_result}]')
    #     if lines_result == lines_export:
    #         print('OK')
    #     else:
    #         print('NG')
    # finished = time.time()
    # duration = finished - started
    # print(f'duration=[{duration}]')


# 起動処理
if __name__ == '__main__':
    main()


Measured memory_bytes: 8812
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, n , m) for(int i = n; i <= m; i++)
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
const int mod = 1000000007; 
long long inv[200000],fact[200000],ifact[200000];
long long comb(ll n, ll k){
	if(n<k)return 0;
	else if (n<0||k<0) return 0;
	else return fact[n] * ifact[k] % mod * ifact[n-k] % mod;
}
 
 
int main(){
	ios::sync_with_stdio(false);cin.tie(0);
	/*inv[1] = fact[0] = fact[1] = ifact[0] = ifact[1] = 1; for (int i=2;i<200000;i++){ inv[i] = (mod - mod / i) * inv[mod % i] % mod; fact[i] = fact[i-1] * i % mod;ifact[i] = ifact[i-1] * inv[i] % mod;
	}*/ //nCr
	
	ll N,C;
	cin>>N>>C;
	ll s[N],t[N],c[N];
	rep(i,N){
		cin>>s[i]>>t[i]>>c[i];
		s[i]--;
	}
	ll ruiseki[100007];
	rep(i,100007){
			ruiseki[i]=0;
	}
	reps(i,1,30){
		ll sub[100007];
		ll ruisub[100007];
		rep(j,100007){
			sub[j]=0;
			ruisub[j]=0;
		}
		rep(j,N){
			if(c[j]==i){
				sub[s[j]]++;
				sub[t[j]]--;
			}
		}
		
		rep(j,100005){
		ruisub[j+1]=ruisub[j]+sub[j];
	    }
		rep(j,100005){
		if(ruisub[j]==2)ruisub[j]--;
	    }
		rep(j,100005){
		ruiseki[j]+=ruisub[j];
	    }
		
		
	}
	
	
	/*ll sub[100007];
	ll ruiseki[100007];
	rep(i,100007){
	    ruiseki[i]=0;
	    sub[i]=0;
	}
	rep(i,N){
		sub[s[i]]++;
		sub[t[i]]--;
	}*/
	

	//rep(i,100005){
	//	ruiseki[i+1]=ruiseki[i]+sub[i];
	//}
	ll ans=0;
	rep(i,100005){
	    ans=max(ans,ruiseki[i]);
	}
	//rep(i,100){
	//    cout<<ruiseki[i]<<endl;
	//    cout<<sub[i]<<endl<<endl;
	//}
	cout<<ans<<endl;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
long Gcd(long m, long n){
	long temp;
	while (m % n != 0)
	{
		temp = n;
		n = m % n;
		m = temp;
	}
	return n;
}
int main(){
    long n,m;
    cin>>n>>m;
    string s,t;
    cin>>s>>t;
    if(s[0]!=t[0]){
        cout<<"-1";
        return 0;
    }
    long g = Gcd(n,m);
    g = (m*n)/g;
    if(n>m){
        for(int i=1; i<m; i++){
            if((i*g/m)%(g/n)==0){
                if(t[i]!=s[i*g/m/(g/n)]){
                    cout<<"-1";
                    return 0;
                }
            }
        }
    }
    else{
        for(int i=1; i<n; i++){
            if((i*g/n)%(g/m)==0){
                if(s[i]!=t[i*g/n/(g/m)]){
                    cout<<"-1";
                    return 0;
                }
            }
        }
    }
    cout<<g;
}

Measured memory_bytes: 512
# N人の子ども
# 1人目には1個, 2人目には2個...N人目にはN個
# 必要なキャンディーの個数の合計を出力

# 入力された値を数値に変換
N = int(input())

# 1〜Nまでの範囲の整数の和
print(N * (N+1) // 2)

Measured memory_bytes: 9084
#include<bits/stdc++.h>
using namespace std;
#define int long long 
typedef long long ll;
 
signed main(void){ 
 
  int a,b,c; cin >> a >> b >> c; 
  if( a == b && a != c ){ cout << "Yes" << endl; return 0;}
  if( a == c && a != b ){ cout << "Yes" << endl; return 0;} 
  if( b == c && a != b ){ cout << "Yes" << endl; return 0;}
  else{ cout <<"No" << endl;}
  return 0;
} 

Measured memory_bytes: 384
#include "bits/stdc++.h"

using namespace std;

long long get(long long num, long long d)
{
      return num / d;
}

int main()
{
      long long A, B, C, D;
      cin >> A >> B >> C >> D;
      long long lcm = C / __gcd(C, D) * D;
      long long ans = get(B, C) - get(A-1, C) + get(B, D) - get(A-1, D) - get(B, lcm) + get(A-1, lcm);
      ans = B - A + 1 - ans;
      cout << ans << endl;
}


Measured memory_bytes: 256
import std.stdio;
import std.algorithm;
import std.array;
import std.conv;
import std.string;
import std.math;

void main() {
  int N;
  N = readln.chomp.to!int;

  auto s = [0, 0, 0];
  bool is_reach = true;

  for (int i = 0; i < N; ++i) {
    auto g = readln.chomp.split.map!(to!int).array;
    int t = g[0] - s[0], dist = abs(g[1] - s[1]) + abs(g[2] - s[2]);

    if (!(t >= dist && (t - dist) % 2 == 0)) {
      is_reach = false;
    }

    s = g;
  }

  if (is_reach) {
    writeln("Yes");
  }
  else {
    writeln("No");
  }

  return;
}

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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) ((a+b-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<Pii> VPii;
typedef vector<string> Vs;

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;}
template<class T> void YesNo(T a) {cout<<(a?"Yes":"No")<<endl;}
template<class T> void YESNO(T a) {cout<<(a?"YES":"NO")<<endl;}
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;}
void uniq(Vi &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());}
//const int MOD=1000000007;
const int MOD=2019;
const int INF=LLONG_MAX/2;

bool check(int n){
    int m = sqrt(n);
    if ( m*m == n ) {
        return true;
    } else {
        return false;
    }
}

signed main() {cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    int n,d,ans=0;
    cin>>n>>d;
    VVi x(n,Vi(d));
    REP(i,0,n) REP(j,0,d) cin>>x[i][j];
    REP(i,0,n){
        REP(j,i+1,n){
            int dist=0;
            REP(k,0,d){
                dist += (x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
            }
            if(check(dist)) ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  string s;
  vi t(1001), v(1001);
  while (getline(cin, s), s.size()) {
    int c, d;
    char gomi;
    istringstream(s) >> c >> gomi >> d;
    t[c]++;
    v[c] = 1;
  }
  while (getline(cin, s)) {
    int c, d;
    char gomi;
    istringstream(s) >> c >> gomi >> d;
    t[c]++;
    if (v[c] == 1) v[c] = 2;
  }
  rep(i, v.size()) if (v[i] == 2) cout << i << ' ' << t[i] << endl;
}

Measured memory_bytes: 3024
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define BUFSIZE 10000000
typedef long long ll;
#define WDSIZE 10000

char s[BUFSIZE];
char u[BUFSIZE];
int a=0;

int main(void){
  scanf("%s",s);
  s[3] ='8';
  printf("%s",s);


}


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

int main (void)
{
    char a[6], b[6];
    char c[6];
    int x = 0;
    char i, j, k;

    scanf("%s %s", a, b);

    c[5] = '\0';

    for (i = '1'; i <= '9'; i++) {
        for (j = '0'; j <= '9'; j++) {
            for (k = '0'; k <= '9'; k++) {
                c[0] = i; c[1] = j; c[2] = k; c[3] = j; c[4] = i;
                if (strcmp(a, c) <= 0 && strcmp(b, c) >= 0) x++;
            }
        }
    }

    printf("%d\n", x);
}

Measured memory_bytes: 128
from collections import Counter
R = lambda: map(int, input().split())
n, k = R()
a = list(R())
r = k * sum(a[i] < a[j] for i in range(n) for j in range(i))
r = n*(n-1)//2 - sum(x*(x-1)//2 for x in Counter(a).values())
r = r * k*(k-1)//2 + k * sum(a[i] < a[j] for i in range(n) for j in range(i))
print(r % (10**9 + 7))


Measured memory_bytes: 3564
import heapq

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

pre = [0]*(n+1)
pre_list = [e for e in A[:n]]
heapq.heapify(pre_list)
pre_sum = sum(pre_list)
pre[0] = pre_sum
for i in range(n, 2*n):
    small = heapq.heappushpop(pre_list, A[i])
    pre_sum += A[i] - small
    pre[i-n+1] = pre_sum

suf = [0]*(n+1)
suf_list = [-e for e in A[2*n:]]
heapq.heapify(suf_list)
suf_sum = -sum(suf_list)
suf[-1] = suf_sum
for i in range(2*n-1, n-1, -1):
    large = -heapq.heappushpop(suf_list, -A[i])
    suf_sum += A[i] - large
    suf[i-n] = suf_sum

# print(pre)
# print(suf)

print(max([pre[i] - suf[i] for i in range(n+1)]))


Measured memory_bytes: 120976
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace std;
#define MuhammedAly ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(x) (x).begin(),(x).end()
#define allr(x) (x).rbegin(),(x).rend()
#define pb push_back
#define eb emplace_back
#define popc(x) __builtin_popcount(x)
#define LLMX 1e18
#define NotinRange(n,m) i<0||i>=(n)||j<0||j>=(m)
#define mem(x,y) memset((x),(y),sizeof (x))
#define sz(a) (int)(a).size()
#define inFile(s) freopen((s),"r",stdin)
#define	outFile(s) freopen((s),"w",stdout)
#define biEdge(v, a, b) (v)[(a)].pb((b)), (v)[(b)].pb((a))
#define pi (2 * acos(0))
#define X real()
#define Y imag()
#define cross(a, b) ((conj(a) * (b)).Y)
#define dot(a, b) ((conj(a) * (b)).X)
#define vec(a,b) ((b) - (a))
#define ll long long
typedef long double ld;
typedef complex<double>point;
typedef tuple<int, int, int> line;
typedef pair<point, point>segment;
typedef vector<point>polygon;
const int N = 1e5 + 5, M = 20 + 5, OO = 0x3f3f3f3f, mod = 1e9 + 7, base = 131, mod2 = 1000136437, mod3 = 998244353;
const double EPS = 1e-9;
ll n;
int ans = OO;

int get(int a, int b)
{
    int cnt1 = 0, cnt2 = 0;
    while(a)
        a /= 10, cnt1++;
    while(b)
        b /= 10, cnt2++;
    return max(cnt1, cnt2);
}
int main()
{
    MuhammedAly
    cin >> n;
    for(int i = 1 ; i <= sqrt(n) ; i++)
    {
        if(n % i == 0)
        {
            ans = min(ans, get(i, n / i));
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
import sys
#import numpy as np
#from collections import defaultdict
import math
#from collections import deque

#input = sys.stdin.readline
#import numpy as n
import bisect



def main():

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

    A = list(map(int,input().split()))
    B = list(map(int, input().split()))
    cumA=[0]*(len(A)+1)
    cumB = [0] * (len(B)+1)
    tempA=0
    for i in range(1,len(A)+1):
        cumA[i]=tempA+A[i-1]
        tempA+= A[i-1]
    tempB = 0
    for i in range(1,len(B)+1):
        cumB[i] = tempB + B[i-1]
        tempB+= B[i-1]
#    print(cumB)
    ans =0
    j = M
    for i in range(len(A)+1):
        res = K - cumA[i]
        if res<0:
            break
        while cumB[j] + cumA[i] > K:
            j -=1
        ans = max(ans, i + j)
 #       b_read = bisect.bisect_right(cumB,res)
#        ans =max( i + b_read,ans)
 #       print("b_read {}// i {}//ans {}".format(b_read,i,ans))

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 115484
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

bool isWhite(string s) {
    for (int i = 0; i < s.size(); i++)
    {
        if (s[i] != '.')
        {
            return false;
        }
    }
    return true;
}
int main() {
    int h,w; cin >> h >> w;
    vector<string> a(h);
    rep(i,h) cin >> a[i];
    vector<int> rowIndex(0);
    vector<int> colIndex(0);
    rep(i,h) {
        if (!isWhite(a[i]))
        {
            rowIndex.push_back(i);
        }
    }
    rep(j,w) {
        bool allWhite = true;
        rep(i,h) {
            if (a[i][j] != '.')
            {
                allWhite = false;
                break;
            }
        }
        if (!allWhite)
        {
            colIndex.push_back(j);
        }
    }
    for (int i = 0; i < rowIndex.size(); i++)
    {
        for (int j = 0; j < colIndex.size(); j++)
        {
            cout << a[rowIndex[i]][colIndex[j]]; 
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 256
object Main extends App {
  val in = new java.util.Scanner(System.in)
  val K, N = in.nextInt
  val As = Array.fill(N)(in.nextInt)
  val max = As.zip(As.tail).foldLeft(As(0) + K - As(N - 1)){case (max, (l, r)) => math.max(r - l, max)}
  println(K - max)
}

Measured memory_bytes: 70424
#include<bits/stdc++.h>
#define ll long long
#define modu int(1e9+7)
#define mp make_pair
using namespace std;

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

    int a,b,c;
    cin>>a>>b>>c;
    if(a==b&&a!=c||a==c&&a!=b||c==b&&a!=c) cout<<"Yes";
    else cout<<"No";
    return 0;
}


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

#define debug(x) cout << #x << " = " << x << endl
#define fori(i, ini, lim) for(int i = int(ini); i < int(lim); i++)
#define ford(i, ini, lim) for(int i = int(ini); i >= int(lim); i--)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;

const int MAX = 200 + 5;
const int INF = 1 << 29;
int memo[MAX][MAX][MAX];

int roll(int a, int b, int c) {
	if(a == b && b == c) {
		return 0;
	}
	else if(max({a, b, c}) >= MAX) {
		return INF;
	}
	int &ans = memo[a][b][c];
	if(~ans) {
		return ans;
	}
	ans = INF;
	ans = min({roll(a + 1, b + 1, c), roll(a + 1, b, c + 1), roll(a, b + 1, c + 1), roll(a + 2, b, c), roll(a, b + 2, c), roll(a, b, c + 2)}) + 1;
	return ans;
}


int main() {
	ios_base::sync_with_stdio(false);

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

	memset(memo, -1, sizeof memo);
	cout << roll(a, b, c) << '\n';

	return 0;
}


Measured memory_bytes: 33920
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int[] month = new int[]{31,29,31,30,31,30,31,31,30,31,30,31};
		while(sc.hasNextInt()){
			int a = sc.nextInt();
			int b = sc.nextInt();
			if(a == 0 && b == 0)break;
			int day = 0;
			for(int i = 0; i < a; i++)
				day += month[i];
			day -= month[a-1];
			day += b;
			day = day % 7;
			switch(day){
			case 0: System.out.println("Wednesday");
				break;
			case 1: System.out.println("Thursday");
				break;
			case 2: System.out.println("Friday");
				break;
			case 3: System.out.println("Saturday");
				break;
			case 4: System.out.println("Sunday");
				break;
			case 5: System.out.println("Monday");
				break;
			case 6: System.out.println("Tuesday");
			}
		}
	}
}

Measured memory_bytes: 17356
// 区間DPだな
// ICPC予選のだるま落としっていう問題に似ている、、
// でも Xの長さが200000だから、二次元配列は持てない
// "S...ST...T"になっている部分を探して、その長さを引けばよさそう、
// いや、"S S...ST...TS...ST...T T"の部分もまとめて落とせるし、
// ちょっとムズイですね、
#include <bits/stdc++.h>
using namespace std;

int main() {
    string X;
    cin >> X;
    stack<char> res;
    for (char ch : X) {
        if (res.size() == 0) {
            res.push(ch);
            continue;
        }

        if (ch == 'S') {
            res.push(ch);
        } else {
            if (res.top() == 'S') {
                res.pop();
            } else {
                res.push(ch);
            }
        }
    }
    cout << res.size() << endl;
    return 0;
}

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

using namespace std;

int main() {
  	int k;
  	cin >> k;
  	unordered_set<int> remset;
  	int sevens = 0;
  	int rem = 0;
  	while(1) {
  	    while(rem < k) {
  	        rem = rem*10 + 7;
  	        sevens++;
  	    }
  	    rem = rem % k;
  	    if(!rem) {
  	        cout << sevens;
  	        return 0;
  	    }
  	    if(remset.find(rem) == remset.end()) {
  	        remset.insert(rem);
  	    }
  	    else {
  	        cout << -1;
  	        return 0;
  	    }
  	}
	return 0;
}


Measured memory_bytes: 39372
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <stdio.h>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
//小数点以下　cout << fixed << setprecision(10) << num << endl;
//桁数はlog10(mid)でやれ　log(mid)/log(10)はWA
//long*long<0で判定するな
//開区間と閉区間
//アルファベットが何番目かは x=s[i]-'a'
//bfsはmain()内で　rep(i,h)rep(j,w)rep(i,4)でバグ
//切り上げ：(a+(b-1))/b
//32bit以上は 1ull<<j
// map 初期値0 for(auto itr=mp.begin();itr!=mp.end();++itr) itr->fi itr->se で全探索
// for(auto u:mp) u.fi u.se も可能
//n個のgcd,lcmは一つずつみて更新していく
//大きな数を扱うときは素因数分解した形で持っておく
// (l/a[i]) = l*powmod(a[i],MOD-2)%MOD;
//auto itr=lower_bound(ALL(a),key) a[itr-a.begin()]
const ll MOD = 1000000007;

signed main(){
    int n,c; cin >> n >> c;
    int d[c][c],e[n][n];
    int num[c][3];
    memset(num,0,sizeof(num));
    rep(i,c)rep(j,c) cin >> d[i][j];
    rep(i,n)rep(j,n){
        cin >> e[i][j];
        e[i][j]--;
        num[e[i][j]][(i+j+2)%3]++;
    }
    int ans=1001001001;
    rep(i,c){
        rep(j,c){
            if(i==j) continue;
            rep(k,c){
                if(i==k||j==k) continue;
                //i,j,kで塗る
                int res=0;
                rep(a,c){
                    if(i!=c) res+=num[a][0]*d[a][i];
                    if(j!=c) res+=num[a][1]*d[a][j];
                    if(k!=c) res+=num[a][2]*d[a][k];
                }
                chmin(ans,res);
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1280
if __name__ == '__main__':
    limit = int(input())

    data = []
    for i in range(3, limit+1):
        if (i % 3) == 0 or (i % 10 == 3) or '3' in str(i):
            data.append(str(i))

    txt = ' '.join(data)
    print(' {0}'.format(txt))

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

using namespace std;

int square(int x) {
	return x * x;
}

int main() {
	int n, m; 
	while (cin >> n >> m, n) {
		vector<int> c(m), x(n);
		for (int i = 0; i < m; ++i) cin >> c[i];
		for (int i = 0; i < n; ++i) cin >> x[i];
		vector<vector<int> > dp(n + 1, vector<int>(256, 1e9));
		dp[0][128] = 0;
		for (int i = 0; i < n; ++i) {
			for (int j = 0; j < m; ++j) {
				for (int k = 0; k <= 255; ++k) {
					int next = min(255, max(0, k + c[j]));
					dp[i + 1][next] = min(dp[i + 1][next], dp[i][k] + square(next - x[i]));
				}
			}
		}
		int ans = 1e9;
		for (int i = 0; i <= 255; ++i) ans = min(ans, dp[n][i]);
		cout << ans << endl;
	}

	return 0;
}


Measured memory_bytes: 23704
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<map>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define P pair<int,int>
#define ll __int64
#define ll long long
const ll M=1000000007;
ll F[111111];
ll IF[111111];

ll invl(ll a,ll b,ll m){//ap-2乗るを返す
	ll tmp=1;
	
	while(b){
		if(b&1){
			tmp=(tmp*a)%m;
		}
		a=(a*a)%m;
		b/=2;
	}

	return tmp%m;
}

void pow(ll m){
	F[0]=1;
	IF[0]=1;

	for(ll i=1;i<=110000;i++){
		F[i]=(F[i-1]*i)%m;
		IF[i]=invl(F[i],m-2,m)%m;//逆元を、フェルマーの小定理を利用して求める
	}
}

ll C(ll n,ll r,ll m){

	if(n<0||r<0||r>n)return (ll)0;
	if(r>n/2)r=n-r;
	
	//cout<<F[n]<<" "<<IF[r]<<" "<<IF[n-r]<<endl;
	ll ret=F[n]*IF[r]%m*IF[n-r]%m;
	return ret;
}

ll t[120000];
int cnt[120000];
int n;

int main(){
	pow(M);//init
	cin>>n;
	rep(i,n+1){
	cin>>t[i];
	cnt[t[i]]++;
	}

	int s=0;
	for(int i=1;i<=n;i++)if(cnt[i]==2)s=i;
	int l=-1,r=-1;
	
	rep(i,n+1){
		if(s==t[i]){
			if(l==-1)l=i;
			else r=i;
		}	
	}

	for(int i=1;i<=n+1;i++){
		ll ans;
		ans=(C(n+1,i,M)+M-C(n-r+l,i-1,M))%M;
		//ans=C(n+1,i,M);
		cout<<ans<<endl;
	}

	return 0;
}


Measured memory_bytes: 4096
#define _CRT_SECURE_NO_WARNINGS
#define REL

#pragma GCC target ("avx2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <iomanip>
#include <cstdio>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <string>
#include <set>
#include <bitset>
#include <cstdint>
#include <cstring>
#include <cassert>
#include <complex>
#include <stack> 
#include <random>

using namespace std;

typedef int64_t i64;
typedef long long LL;
typedef long long ll;
typedef long double LD;
typedef complex <LD> cld;
typedef unsigned int uint;
typedef complex <double> cd;
typedef unsigned long long ULL;

#define endl "\n"
#define dendl "\n\n"
#define mp make_pair
#define mt make_tuple
#define size(v) (int)v.size()
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

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

template <typename T>
T sqr(T a) {
	return a * a;
}

template <typename T>
int sign(T a) {
	if (a == 0)
		return 0;
	return (a > 0 ? 1 : -1);
}

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

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

template <typename T1, typename T2>
istream& operator >> (istream& in, pair<T1, T2>& p) {
	in >> p.first >> p.second;
	return in;
}

template <typename T1, typename T2>
ostream& operator << (ostream& out, pair<T1, T2>& p) {
	out << p.first << ' ' << p.second;
	return out;
}

mt19937_64 rnd(0);

const int LOG = 64;
const int N = (int)2e5 + 7;
const int MAXN = (int)1e6 + 7;
const int MOD = (int)1e9 + 7;
const int INF = (int)2e9 + 7;
const int CONST = 450;
const LL LINF = (i64)1e18;
const LD PI = 3.1415926535897932384626433832795;
const LD EPS = 1;

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

int n, a[N];

void solve() {
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	sort(a, a + n);
	LL ans = a[n - 1];
	map <int, int> rest;
	rest[n - 2] = 2;
	for (int i = n - 3; i >= 0; i--) {
		auto it = rest.end(); it--;
		auto p = *it;
		ans += a[p.first];
		rest[p.first]--;
		if (rest[p.first] == 0)
			rest.erase(p.first);
		rest[i] = 2;
	}
	cout << ans;
}

int main() {
	double start = clock();
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	cout << fixed << setprecision(20);
	cerr << fixed << setprecision(20);
#else
	cout << fixed << setprecision(20);
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	rnd.seed(time(0));
#endif

	int t = 1;
	for (int i = 0; i < t; i++) {
		solve();
	}

#ifdef _DEBUG
	cout << endl << "Time is " << (clock() - start) / 1000.0;
#endif
}

Measured memory_bytes: 9156
#include<iostream>
using namespace std;
int mod(int x) {
	if(x>0)
		return x;
	else
		return -x;
}
int main(){
	int n,i,a,b,delta;
	cin>>n;
	int t[n+1],x[n+1],y[n+1];
	t[0]=0;
	x[0]=0;
	y[0]=0;
	for(i=1;i<=n;i++){
		cin>>t[i]>>x[i]>>y[i];
	}
	bool flag=true;
	for(i=1;i<=n;i++)
	{
		a=mod(x[i]-x[i-1]);
		b=mod(y[i]-y[i-1]);
		delta = t[i]-t[i-1];
		if((delta>=a+b)&&((delta-a-b)%2==0))
			continue;
		else
		{
			flag=false;
			break;
		}
	}
	if(flag)
		cout<<"Yes";
	else
		cout<<"No";
}

Measured memory_bytes: 1408
#include <iostream>
using namespace std;
typedef long long ll;
int main()
{
    int n;
    cin>>n;
    int pre=0;
    ll ans=0;
    for(int i=1; i<=n; i++){
        int x;
        cin>>x;
        if(x<pre)ans+=pre-x,x=pre;
        pre=x;
    }
    cout<<ans<<endl;
    return 0;
}


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

int main() {
  int x1, y1, x2, y2, x3, y3, x4, y4;
  cin >> x1 >> y1 >> x2 >> y2;
  int delx = x2 - x1;
  int dely = y2 - y1;
  x3 = x2 - dely;
  y3 = y2 + delx;
  x4 = x1 + x3 - x2;
  y4 = y1 + y3 - y2;
  cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
}

Measured memory_bytes: 256
/**
 * All Numbers Lead to 6174
 */

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

import static java.lang.Integer.parseInt;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";

		while (!(line = br.readLine()).equals("0000")) {

			int N = parseInt(line), L, S;
			int k;
			int c = 0;

			outer:
			while (N != 6174) {

				//N
				byte[] nums = new byte[10];
				k = 1000;
				for (int i = 0; i < 4; i++) {
					int n = N / k;
					if (++nums[n] == 4) {
						c = -1;
						break outer;
					}
					N -= n * k;
					k /= 10;
				}

				//S
				byte[] numsS = Arrays.copyOf(nums, nums.length);
				k = 1000;
				S = 0;
				for (int i = 0; i < 10; i++) {
					while (numsS[i] > 0) {
						S += i * k;
						numsS[i]--;
						k /= 10;
					}
				}

				//L
				byte[] numsL = Arrays.copyOf(nums, nums.length);
				k = 1000;
				L = 0;
				for (int i = 9; i >= 0; i--) {
					while (numsL[i] > 0) {
						L += i * k;
						numsL[i]--;
						k /= 10;
					}
				}

				N = L - S;
				c++;
			}

			//ans.
			System.out.println(c > -1 ? c : "NA");
		}
	}
}

Measured memory_bytes: 38676
#include <bits/stdc++.h>
using namespace std;
using ld = long double;
using P = complex<ld>;

namespace std {
  bool operator < (const P& a, const P& b) {
    return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
  }
}

int N;
vector<P> ps;

double cross(const P& a, const P& b) {
  return imag(conj(a) * b);
}

double dot(const P& a, const P& b) {
  return real(conj(a) * b);
}

int ccw(P a, P b, P c) {
  b -= a; c -= a;
  if (cross(b, c) > 0)   return +1;
  if (cross(b, c) < 0)   return -1;
  if (dot(b, c) < 0)     return +2;
  if (norm(b) < norm(c)) return -2;
  return 0;
}

vector<P> convex_hull(vector<P> ps) {
  int n { (int)ps.size() }, k {};
  sort(ps.begin(), ps.end());
  vector<P> ch(n * 2);
  for (int i = 0; i < n; ch[k++] = ps[i++]) {
    while (k > 1 && ccw(ch[k - 2], ch[k - 1], ps[i]) <= 0) --k;
  }
  for (int i = n - 2, t = k; i >= 0; ch[k++] = ps[i--]) {
    while (k > t && ccw(ch[k - 2], ch[k - 1], ps[i]) <= 0) --k;
  }
  ch.resize(k - 1);
  return ch;
}

int main(int argc, char const* argv[])
{
  cin >> N;
  for (int i = 0; i < N; i++) {
    int x, y; cin >> x >> y;
    ps.push_back({ (ld)x, (ld)y });
  }

  if (N == 2) {
    for (int i = 0; i < 2; i++) cout << 0.5 << endl;
    return 0;
  }
  vector<P> ch { convex_hull(ps) };
  int M { (int)ch.size() };
  for (int i = 0; i < N; i++) {
    bool is_zero { true };
    int pv;
    for (int j = 0; j < M; j++) {
      pv = j;
      if (ps[i] == ch[j]) {
        is_zero = false;
        break;
      }
    }
    if (is_zero) {
      cout << 0.0 << endl;
    } else {
      P p { ch[pv] };
      P q { ch[(pv - 1 + M) % M] };
      P r { ch[(pv + 1) % M] };
      ld pi { acos(-1) };
      ld th { arg((r - p) / (q - p)) };
      cout << fixed << setprecision(7) << (pi + th) / (2.0 * pi) << endl;
    }
  }
  return 0;
}


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

int main(){
  int i,j,k,n;
  string log;

  cin >> n;
  
  for( i=0;i<n;i++ ){
    char train[52]={NULL};
    int m=25;
    cin >> log;
    train[m]=log[0];
    for( j=3;j<log.size();j+=3 ){
      if(log[j-1] == '>'){
	m++;
	train[m] = log[j];
      }else{
	m--;
	train[m] = log[j];
      }
    }
    for(k=0;k<52;k++){
      if(train[k] >= 'a' && train[k] <= 'z' ){
	cout << train[k];
      }
    }
    cout << endl;
    log.erase();
  }

  return 0;
}

Measured memory_bytes: 1196
#include <iostream>
#include <stack>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <map> 
#include<set>
#include<queue>

typedef long long ll;


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

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; }

const long long INF = 1000000000000000;
const ll inf = -1e18;
typedef pair<ll, ll> P;
ll ma = 1000000000 + 7;
ll mx = 1000003;
ll h, w, n,m,k; string s,t;
char maze[60][60];
int dis[101][101]; int graph[52][52]; bool vis[52];
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };
ll gcd(ll x, ll y) {
	if (x % y == 0) return y;
	return gcd(y, x % y);

}
ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
void comb(vector<vector <ll> >& v) {
	for (ll i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (ll k = 1; k < v.size(); k++) {
		for (int j = 1; j < k; j++) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j])%ma;
		}
	}
}

int main() {
	int n;
	cin >> n;
	if (n == 0) {
		cout << 0 << endl;
	}

	string s = "";

	while (n != 0) {
		if (n % 2 == 0) {
			s += '0';
		}
		else {
			s += '1';
			n--;
		}
		n = n / -2;
	}

	reverse(s.begin(), s.end());

	cout << s << endl;

	return 0;
}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
  char s[3];
  int a=0,b=0;
  cin>>s;
  for(int i=0;i<3;i++)
  {
    if(s[i]=='A'||s[i]=='a')
      a++;
    else if(s[i]=='B'||s[i]=='b')
      b++;
  }
  if(a==2 || b==2)
    cout<<"Yes";
  else
    cout<<"No";
  return 0;
}


Measured memory_bytes: 3624
#include <stdio.h>

int main()
{
	int n,k;
	scanf("%d%d",&n,&k);
	int ans=0;
	int h;
	for(int i=0;i<n;i++)
	{
		scanf("%d",&h);
		ans+=(h>=k);
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        final Scanner sc = new Scanner(System.in);

        final int N = sc.nextInt();
        final String S = sc.next();

        int cnt = 0;

        for (int i = 2; i < N; i++) {
            if (S.charAt(i-2) == 'A' && S.charAt(i-1) == 'B' && S.charAt(i) == 'C') {
                cnt++;
            }
        }

        System.out.println(cnt);
    }
}


Measured memory_bytes: 21844
object Main {
  def main(args: Array[String]): Unit = {
    val b = io.StdIn.readChar()
    println {
      b match {
        case 'A' => 'T'
        case 'T' => 'A'
        case 'C' => 'G'
        case 'G' => 'C'
      }
    }
  }
}


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

class uint_Trie {
	struct node {
		node *p, *l, *r;
		int cnt;
		node(node *p, node *l = nullptr, node *r = nullptr) : p(p), l(l), r(r), cnt(0) {}
	};
	node *root;
	int siz;
public:
	uint_Trie() : root(new node(nullptr)) {}
	int size() {
		return root->cnt;
	}
	void insert(unsigned val) {
		// if (find(val)) return; // multiset ???????¶????
		node *t = root;
		for (int i = 31; i >= 0; i--) {
			t->cnt++;
			if (val & (1 << i)) {
				if (t->r == nullptr) {
					t->r = new node(t);
				}
				t = t->r;
			}
			else {
				if (t->l == nullptr) {
					t->l = new node(t);
				}
				t = t->l;
			}
		}
		t->cnt++;
	}
	void erase(unsigned val) {
		node *t = root, *ne;
		for (int i = 31; i >= 0; i--) {
			t->cnt--;
			if (val & (1 << i)) {
				if (t->r == nullptr) return;
				t = t->r;
			}
			else {
				if (t->l == nullptr) return;
				t = t->l;
			}
		}
		t->cnt--;
		while (t != root && t->cnt == 0) {
			ne = t->p;
			(t == ne->l ? ne->l : ne->r) = nullptr;
			delete t;
			t = ne;
		}
	}
	bool find(unsigned val) {
		node *t = root;
		for (int i = 31; i >= 0; i--) {
			if (val & (1 << i)) {
				if (t->r == nullptr) return false;
				t = t->r;
			}
			else {
				if (t->l == nullptr) return false;
				t = t->l;
			}
		}
		return true;
	}
	unsigned max() {
		assert(root->cnt >= 1);
		node *t = root;
		unsigned res = 0;
		for (int i = 31; i >= 0; i--) {
			assert(t->l != nullptr || t->r != nullptr);
			if (t->r != nullptr) {
				res |= 1 << i;
				t = t->r;
			}
			else {
				t = t->l;
			}
		}
		return res;
	}
	unsigned min() {
		assert(root->cnt >= 1);
		node *t = root;
		unsigned res = 0;
		for (int i = 31; i >= 0; i--) {
			assert(t->l != nullptr || t->r != nullptr);
			if (t->l != nullptr) {
				t = t->l;
			}
			else {
				res |= 1 << i;
				t = t->r;
			}
		}
		return res;
	}
};

int main()
{
	uint_Trie ut;
	string com;
	int k;
	while (cin >> com, com != "end") {
		if (com == "insert") {
			cin >> k;
			ut.insert(k);
		}
		else {
			int res = ut.max();
			printf("%d\n", res);
			ut.erase(res);
		}
	}
	return 0;
}

Measured memory_bytes: 4268
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<map>
using namespace std;
int main()
{
	long long n;
	cin >> n;
	long long m;
	m = (n - 1) / 999;
	cout << "AB";
	char str = 'C';
	printf("%c\n", str + m);
	return 0;
}

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

int main(void){
	long long int h;
	scanf("%lld",&h);
	long long int ans=1;
	long long int rot=1;
	while(h!=0){
		if(rot!=1){	ans+=rot;}
		h=h/2;
		rot=rot*2;
	}
	printf("%lld",ans);
}

Measured memory_bytes: 128
import sys
stdin = sys.stdin
mod = 10**9 + 7
import numpy as np

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
sa = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)]

n = ni()
a = np.array(na())
c = 0
odd_exist = False
while not odd_exist:
        for ai in a:
                if ai % 2 !=0:
                        odd_exist = True

        if odd_exist:
                print(c)
                break
        else:
                a = a//2
                c += 1
        

Measured memory_bytes: 15712
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string S,T;
    int count=1,a=0;
    
    cin >> S >> T;
    for(int i=0;i<S.size();i++){
        if(S[i]!=T[i]){
            count=0;
        }
        a++;
    }
    if(count==0){
            cout << "No" << endl;
    }else if(count==1 && T[a]!=NULL){
        cout << "Yes" << endl;
    }
    return 0;
}


Measured memory_bytes: 3520
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>
#define ll long long
using namespace std;
void put(int x){
	if(x<0) {
		putchar('-');
		x*=-1;
	}
	if(x==0) {
		putchar('0');
	}
	int num=0;
	char c[15];
	while(x) {
		c[++num]=(x%10)+48;
		x/=10;
	}
	while(num) {
		putchar(c[num--]);
	}
	putchar('\n');
}
inline void in(int &x){
	char ch=getchar();
	int flag=1;
	while(!(ch>='0'&&ch<='9')) {
		if(ch=='-')
			flag*=-1;
		ch=getchar();
	}
	x=ch-'0';
	ch=getchar();
	while(ch>='0'&&ch<='9') {
		x=((x<<3)+(x<<1))+ch-'0';
		ch=getchar();
	}
	x*=flag;
}
int n,a[200005],m;double ans,s[200005],sum[200005];
bool cmp(int a,int b){
	return a>b;
}
int main(){
//	freopen("1.in","r",stdin);
//	freopen("1.out","w",stdout);
	in(n);in(m);for(int i=1;i<=n;i++)in(a[i]);
	for(int i=1;i<=n;i++){
		s[i]+=1.0*(a[i]+1)/2;
		sum[i]=sum[i-1]+s[i];
	}
	for(int i=1;i<=n-m+1;i++)
	ans=max(ans,sum[i+m-1]-sum[i-1]);
	printf("%.10lf\n",ans);
	return 0;
}

Measured memory_bytes: 4096
#include<vector>
#include<map>
#include<algorithm>
#include<set>
#include<iostream>
#include<string>
#include<set>
#include<queue>
#include<random>
//#include<unordered_set>

using namespace std;

/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;

tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> st;*/

#pragma GCC optimize("Ofast")
#pragma GCC optimize("fast-math")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")

#define pb push_back
#define ld long double
#define int long long

mt19937 rnd(51);

int32_t main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int a, b;
	cin >> a >> b;
	cout << a * b;
	return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <unordered_map>
#include <queue>
#define LL long long
using namespace std;
LL read() {
    LL k = 0, f = 1; char c = getchar();
    while(c < '0' || c > '9') {
        if(c == '-') f = -1;
        c = getchar();
    }
    while(c >= '0' && c <= '9')
        k = k * 10 + c - 48, c = getchar();
    return k * f;
}
struct zzz {
    int t, len, nex;
} e[5010];
int head[2510], tot;
inline void add(int x, int y, int z) {
    e[++tot].t = y;
    e[tot].len = z;
    e[tot].nex = head[x];
    head[x] = tot;
}
int dis[2510], inque[2510];
bool vis[2510], can[2510];
bool SPFA(int n) {
    queue <int> q;
    memset(dis, 233, sizeof(dis)); //cout << dis[1];
    memset(vis, 0, sizeof(vis));
    memset(inque, 0, sizeof(inque));
    q.push(1); dis[1] = 0;
    vis[1] = inque[1] = 1;
    while(!q.empty()) {
        int k = q.front(); q.pop(); vis[k] = 0;
        //cout << k << endl;
        for(int i = head[k]; i; i = e[i].nex) {
            if(dis[e[i].t] < dis[k] + e[i].len && !can[e[i].t]) {
                dis[e[i].t] = dis[k] + e[i].len;
                if (!vis[e[i].t]) {
                    q.push(e[i].t); vis[e[i].t] = 1;
                    ++inque[e[i].t];
                    if(inque[k] >= n) return 1;
                }
            }
        }
    }
    return 0;
}
void dfs(int x) {
    vis[x] = 1;
    for(int i = head[x]; i; i = e[i].nex) {
        if(!vis[e[i].t]) dfs(e[i].t);
    }
}
int main() {
    int n = read(), m = read(), p = read();
    for(int i = 1; i <= m; ++i) {
        int x = read(), y = read(), z = read();
        add(x, y, z - p);
    }
    for(int i = 1; i <= n; ++i) {
        memset(vis, 0, sizeof(vis));
        dfs(i);
        if(!vis[n]) can[i] = 1; // cout << i << endl;
    }
    if(SPFA(n)) cout << "-1";
    else cout << max(dis[n], 0);

    return 0;
}

Measured memory_bytes: 512
# -*- coding: utf-8 -*-

n,m = map(int, input().split())
city = [0] * (n + 1)

for i in range(m):
    a, b = map(int, input().split())
    city[a] += 1
    city[b] += 1

for i in range(1,n+1):
    print(str(city[i]))


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

int cmpint(const void *a, const void *b){
	return (*(int*)b - *(int*)a);
}

int main(void){
	int h[10];
	for(int i=0;i<10;++i){
		scanf("%d", h+i);
	}
	qsort(h, 10, sizeof(int), cmpint);
	for(int i=0; i<3;++i){
		printf("%d\n", h[i]);
	}

	return 0;
}

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

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

    std::string s;
    std::cin >> s;

    int max = 0;
    int val = 0;
    for (int i = 0; i < n; i++) {
        if (s[i] == 'I') {
            val++;
        } else {
            val--;
        }

        max = std::max(max, val);
    }

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


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

#include <bits/stdc++.h>
using namespace std;

int main(){
  int n;
  string s;
  cin>>n>>s;
  
  int cnt=0;
  int a,b;
  rep(i,10){
    rep(j,10){
      rep(k,10){
        bool flag=false;
        a=n,b=-1;
        for(int l=n-1;l>=0;l--){
          if(s[l]-'0'==i) a=l;
        }
        for(int r=0;r<n;r++){
          if(s[r]-'0'==k) b=r;
        }
        if(a>=0 && b<n && a+1<b){
          for(int m=a+1;m<b;m++){
            if(s[m]-'0'==j) flag=true;
          }
        }
        if(flag) cnt++;
      }
    }
  }
  
  cout<<cnt<<endl;
  
  return 0;
}

Measured memory_bytes: 3668
n,x,y = [int(i) for i in input().split()]
ans = []
for i in range(1,n):
  for j in range(i+1,n+1):
    chk = min(j-i,1+abs(x-i)+abs(j-y))
    ans.append(chk)   
import collections
c = collections.Counter(ans)
for i in range(1,n):
  print(c[i])

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

int main(){
  
 while(true){
   int total;  
   cin >> total;
  
  vector<int> price(9);
 
  int total2 = 0;
  
  for(int i = 0; i < 9; i++){
    
    cin >> price.at(i);
    
    if(price.at(0) == 0){
      return 0;
    }
    
    else{total2 = total2 + price.at(i);}
  }
  
  cout << total - total2 << endl;
 }
    
}
  


Measured memory_bytes: 3024
#include <bits/stdc++.h>
using namespace std;
long long int gcm(long long int a,long long int b)
{
	if(b == 0)
	{
		return a;
	}
	return gcm(b,a%b);
}
int main(){
	long long int a, b, count = 0;
	cin >> a >> b;
	long long int c = gcm(max(a, b), min(a, b));
	if(c % 2 == 0){
		c /= 2;
		count++;
	}
	while(c % 2 == 0){
		c /= 2;
	}
	for(int i = 3;i <= 1000000;i += 2){
		if(c % i == 0){
			c /= i;
			count++;
		}
		while(c % i == 0){
			c /= i;
		}
		if(c == 1) break;
	}
	if(c != 1) count++;
	cout << count + 1 << endl;
}


Measured memory_bytes: 256
import std.stdio, std.string, std.conv;
import std.array, std.algorithm, std.range;

void main()
{
    foreach(s;stdin.byLine())
    {
        auto nm = s.split().map!(to!int);
        immutable n=nm[0], m=nm[1];
        if(n==0 && m==0) break;
        auto a = iota(1,n+1).array();
        size_t p=n-1;
        while(a.length>1)
        {
            p=(p+m)%a.length;
            a=a[0..p]~a[p+1..$];
            p=p<=0?a.length-1:p-1;
        }
        writeln(a[0]);
    }
}

Measured memory_bytes: 3084
import sys
input = sys.stdin.readline
w,h,n=map(int,input().split())
x1=0
x2=w
y1=0
y2=h
for i in range(n):
    x,y,a=map(int,input().split())
    if a==1:
        x1=max(x1,x)
    if a==2:
        x2=min(x2,x)
    if a==3:
        y1=max(y1,y)
    if a==4:
        y2=min(y2,y)
print(max((x2-x1)*(y2-y1),0) if x2-x1>0 else 0)


Measured memory_bytes: 38256
#include<bits/stdc++.h>
using namespace std;
int main() {
	int n, a[100];
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a, a + n);
	cout << a[n - 1] - a[0] << endl;
}

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

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

    vector<int> C(26);
    vector<vector<int>> S(D, vector<int>(26));

    for (int i = 0; i < 26; i++)
    {
        cin >> C.at(i);
    }

    for (int i = 0; i < D; i++)
    {
        for (int j = 0; j < 26; j++)
        {
            cin >> S.at(i).at(j);
        }
    }

    vector<int> T(D);
    for (int i = 0; i < D; i++)
    {
        cin >> T.at(i);
    }

    int point = 0;
    int t;
    vector<int> last(26);
    for (int d = 0; d < D; d++)
    {
        t = T.at(d);
        last.at(t -1) = d + 1;
        for (int j = 0; j < 26; j++)
        {
            point -= C.at(j) * (d + 1 - last.at(j));
        }

        point += S.at(d).at(t-1);
        cout << point << endl;
    }

    return 0;
}

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

int main() {
	int n; cin >> n;
	vector<int>a(n); for (auto&& x : a)cin >> x;
	sort(a.begin(), a.end());
	int an = a[n - 1], ar = a[0];
	long long dis = abs(an - ar * 2);
	for (int i = 0; i < n - 1; i++) {
		if (abs(an - a[i] * 2) < dis) {
			dis = abs(an - a[i] * 2);
			ar = a[i];
		}
	}
	cout << an << ' ' << ar << endl;
	return 0;
}

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

using namespace std;
using ll=long long;
using vi=vector<int>;
using vl=vector<ll>;
using vs=vector<string>;

#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define rep(i, a, n) for (int i = (n); i < (a); ++i)
#define repr(i, a, n) for (int i = (n); i >= (a); --i)

template<typename T,typename U>
void Inparray(T &f,U n){
  for(int i=0;i<n;i++) cin>>f[i];
}

template<typename T,typename U>
void Printarray(T f,U n){
  for(int i=0;i<n;i++) i!=n ? cout<<f[i]<<" " : cout<<f[i];
}

void flagfunc(bool flag,string A,string B){
  flag ? cout<<A<<endl : cout<<B<<endl;
}

void flag2func(bool flag){
  flag ? cout<<"Yes"<<endl : cout<<"No"<<endl;
}

void flag3func(bool flag){
  flag ? cout<<"YES"<<endl : cout<<"NO"<<endl;
}

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  int a,b,c,d;cin>>a>>b>>c>>d;
  flag2func(abs(c-a)<=d ||(abs(b-a)<=d && abs(c-b)<=d ));
}


Measured memory_bytes: 256
n=int(input())
l=[list(map(int,input().split())) for i in range(n)]
l.sort()
ans=1
c=l[0][0]+l[0][1]
for i in range(1,n):
    if c>=l[i][0]+l[i][1]:
        c=l[i][0]+l[i][1]
    elif c<=l[i][0]-l[i][1]:
        c=l[i][0]+l[i][1]
        ans+=1
print(ans)

Measured memory_bytes: 63576