akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {    
    
    public static void main(String[] args){
        
        Scanner sc = new Scanner(System.in);
        
        Map<Character,Integer> map = new HashMap<>();

        String w = sc.next();
        
        for(int i = 0 ;i < w.length();i++){
            if(!map.containsKey(w.charAt(i))){
                map.put(w.charAt(i),1);
            }else{
                int count = map.get(w.charAt(i));               
                count++;
                map.put(w.charAt(i),count);
            }
        }                

        String ans = "Yes";
        
        for(Character key : map.keySet() ){
           int count = map.get(key);
           if(count % 2 != 0){
               ans = "No";
           }            
        }
        
        System.out.println(ans);
        
    }
}        
        
        

Measured memory_bytes: 23892
S=input()
total=0

for i in range(len(S)):
    if  (i%2)==0:
        if  (S[i]=='R')or(S[i]=='U')or(S[i]=='D'):
            pass
        else:
            total+=1
    else:
        if  (S[i]=='L')or(S[i]=='U')or(S[i]=='D'):
            pass
        else:
            total+=1

if  total==0:
    print('Yes')
else:
    print('No')

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

int main() {
 int N,K,A ;
  A=1;
  cin >> N >>K ;
  for (int i; i<N; i++){
    if(A<K){
      A *= 2;
    }
      else{
        A += K;
      }
  }  
    cout << A << endl;
  
}

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

using namespace std;

#define mod 1e9+7

int main()

{

   long long int x;



   cin>>x;

   string s ="";



  while (x > 0){



      int m = x% 26;



      if (m == 0) m = 26;



      s = (char)(m + 96) + s;



      x = (x - m) / 26;

  }

  cout<<s;

    return 0;

}

Measured memory_bytes: 3588
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 50;
constexpr double pi=3.14159265358979;

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

void solve(){
    double x[3],y[3];
    rep(i,3)cin>>x[i]>>y[i];
    double a=sqrt(pow(x[1]-x[0],2)+pow(y[1]-y[0],2));
    double b=sqrt(pow(x[2]-x[0],2)+pow(y[2]-y[0],2));
    double c=sqrt(pow(x[1]-x[2],2)+pow(y[1]-y[2],2));
    x[1]-=x[0];y[1]-=y[0];
    x[2]-=x[0];y[2]-=y[0];
    double S=abs(x[1]*y[2]-y[1]*x[2])/2;
    double r=2*S/(a+b+c);
    double R=max({a,b,c});
    printf("%.15lf\n",R*r/(2*r+R));
}

signed main(){
	std::ios::sync_with_stdio(false);
    std::cin.tie(0);
	solve();
	return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python
from collections import deque, defaultdict
from itertools import combinations, combinations_with_replacement
import bisect
from math import factorial, sqrt, log, ceil, floor

def main():
    #N, M = map(int, input().split())
    N, M = map(int, input().split())

    max_L = None
    min_R = None
    for i in range(M):
        L, R = map(int, input().split())
        if max_L is None or max_L < L:
            max_L = L
        if min_R is None or min_R > R:
            min_R = R

    if max_L <= min_R:
        num = min_R - max_L + 1
    else:
        num = 0
    print(num)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
H, W, K = map(int, input().split())
a = [input() for _ in range(H)]
ans = [[-1 for _ in range(W)] for _ in range(H)]
i_cut_time = 0
j_cut_time = 0
for i in range(H):
    if '#' in a[i]:
        i_cut_time += 1
i_cut = []
start = 0
goal = -1
for i in range(H):
    if len(i_cut) == i_cut_time-1:
        break
    if '#' in a[i]:
        goal = i
        i_cut.append([start, goal, i])
        start = goal+1
for i in range(start, H):
    if '#' in a[i]:
        i_cut.append([start, H-1, i])
# print(i_cut)
cnt = 1
for s, g, p in i_cut:
    j_cut = []
    jstart = 0
    jgoal = -1
    for i in range(W):
        if len(j_cut) == a[p].count('#')-1:
            break
        if a[p][i] == '#':
            jgoal = i
            j_cut.append([jstart, jgoal])
            jstart = jgoal+1
    j_cut.append([jstart, W-1])
    # print(s, g, p, j_cut)
    # for i in range(s, g+1):
    for js, jg in j_cut:
        for j in range(js, jg+1):
            for i in range(s, g+1):
                # print(i, j, cnt)
                ans[i][j] = cnt
        cnt += 1

# print(*ans, sep='\n')
for i in range(H):
    print(*ans[i])

Measured memory_bytes: 12688
#include <bits/stdc++.h>
#define yes { cout << "YES" << endl; exit(0); }
#define no { cout << "NO" << endl; exit(0); }
#define impossible { cout << "Impossible" << endl; exit(0); }

using namespace std;

typedef long long ll;
typedef pair<int,int> Pair;

const int Mod = 998244353;
const int Nmax = 2e5 + 5;

int cnt[Nmax], D[Nmax];

ll power(ll a, int b)
{
    ll ans = 1;

    while(b)
    {
        if(b & 1) ans = ans * a % Mod;
        a = a * a % Mod; b /= 2;
    }
    return ans;
}    

int main()
{
 //   freopen("inputB", "r", stdin);
    // freopen("output", "w", stdout);
    cin.sync_with_stdio(false); cin.tie(0);
    
    int n, i;
    cin >> n;
    for(i=1; i<=n; ++i) 
    {
        cin >> D[i];
        ++cnt[D[i]];
    }
    
    if(D[1] != 0 || cnt[0] > 1)
    {
        cout << 0 << '\n';
        return 0;
    }

    ll ans = 1;
    for(i=1; i<=n; ++i)
        if(cnt[i])
        {
            ll curr = power( cnt[i-1], cnt[i] );
            ans = ans * curr % Mod;
        }

    cout << ans << '\n';

    return 0;
}



Measured memory_bytes: 1024
import java.util.ArrayList;
import java.util.Scanner;

/**
 * Created by guoxiang.li on 2017/02/13.
 */
public class Main {

    private int count=0;
    private ArrayList[] graph;
    boolean[] visited;
    public int undirectedGraphTraversalWays(int[][] nums,int n){

       graph=new ArrayList[n];

        for(int i=0;i<n;i++){
            graph[i]=new ArrayList();
        }

        visited=new boolean[n];

        for(int i=0;i<nums.length;i++){
            graph[nums[i][0]-1].add(nums[i][1]-1);
            graph[nums[i][1]-1].add(nums[i][0]-1);
        }


        visited[0]=true;
        undirectedGraphTraversalWaysHelper(graph[0]);
        return count;

    }


    private boolean undirectedGraphTraversalWaysHelper(ArrayList nodes){


        boolean flag=true;
        for(boolean visitedFlag:visited){
            flag&=visitedFlag;
        }

        if(flag){
            return true;
        }


        for(Object node:nodes){

            int index=((Integer) node).intValue();

            if(visited[index]){
                continue;
            }
            visited[index]=true;

            if(undirectedGraphTraversalWaysHelper(graph[index])){
                count++;
            }

            visited[index]=false;
        }

        return false;



    }

    public static void main(String[] args) {



        Main sol=new Main();
        Scanner sc = new Scanner(System.in);
        // get a integer
        int n = sc.nextInt();
        // get two integers separated with half-width break
        int m = sc.nextInt();

        int[][] edges=new int[m][2];
        for(int i=0;i<m;i++) {
            edges[i][0] = sc.nextInt();
            edges[i][1] = sc.nextInt();
        }

        System.out.println(sol.undirectedGraphTraversalWays(edges,n));


    }


}

Measured memory_bytes: 10972
#include <bits/stdc++.h>
#define rep(i,n) for(long long int i = 0; i < n; i++)
#define _rep(i,m,n) for(long long int i = m; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
const int N = 1000000;
const ll mod = 1000000007;
using Graph = vector<vector<int>>;

int main(){
   char c; cin >> c;
   print(++c);
}

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

int main()
{
    int n, m;
    cin >> n >> m;
    if(n % 2){
        for(int i = 0; i < m; i++){
            cout << i + 1 << " " << n - i << endl;
        }
    }
    else{
        for(int i = 0; i < min(n / 4, m); i++){
            cout << i + 1 << " " << n - i << endl;
        }
        for(int i = n / 4; i < m; i++){
            cout << i + 2 << " " << n - i << endl;
        }
    }
}


Measured memory_bytes: 3556
s = input()
k = int(input())
ans = ""
for i in s:
    c = ord(i)
    if i == "a":
        ans += i
        continue
    need = ord("z") - ord(i) + 1
    if k >= need:
        k -= need
        ans += "a"
    else:
        ans += i
if k:
    ans = ans[:len(s)-1] + chr(ord(ans[-1]) + k % 26)
print(ans)

Measured memory_bytes: 3444
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    int N;
    cin >> N;
    vector<vector<char>> S(2 * N, vector<char>(2 * N));
    rep(i, N) {
        rep(j, N) {
            char c;
            cin >> c;
            S[i][j] = S[i + N][j] = S[i][j + N] = S[i + N][j + N] = c;
        }
    }

    int res = 0;
    for(int sy = 0; sy < N; sy++) {
        int ok = 1;
        for(int i = 0; i < N; i++) {
            for(int j = i + 1; j < N; j++) {
                if(S[sy + i][j] != S[sy + j][i])
                    ok = 0;
            }
        }
        if(ok) {
            res += N - sy;
        }
    }
    for(int sx = 1; sx < N; sx++) {
        int ok = 1;
        for(int i = 0; i < N; i++) {
            for(int j = i + 1; j < N; j++) {
                if(S[i][sx + j] != S[j][sx + i])
                    ok = 0;
            }
        }
        if(ok) {
            res += N - sx;
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 640
N,M,X =map(int,input().split())
CA = [list(map(int,input().split())) for i in range(N)]

ans = float('inf')
for bit in range(1 << N):
    book = [0]*M
    cost = 0
    for i in range(N):
        if(bit >> i) & 1:
            cost += CA[i][0]
            for c in range(M):
                book[c] += (CA[i][c+1])
#    print(book)
    if all(X <= a for a in book):
        ans = min(ans,cost)
if ans == float('inf'):
    print(-1)
else:
    print(ans)

Measured memory_bytes: 9164
n, _ = gets.split(" ").map(&:to_i)
xs = []

n.times { xs << gets.split(" ").map(&:to_i) }

count = 0

xs.slice(0, xs.size - 1).each_with_index do |y, i|
  xs.slice(i + 1, xs.size).each do |z|
    count += 1 if Math.sqrt(y.zip(z).inject(0) do |r, (yy, zz)|
      r + (yy - zz) ** 2
    end).to_s =~ /\A[0-9]+\.0\z/
  end
end

puts count


Measured memory_bytes: 1916
#include <cstdio>
#include <cstring>
#define rng(x, y) (0 <= x && x < W && 0 <= y && y < H)
int H, W, n, gx, gy, x[12][12], d[4] = { 1, 0, -1, 0 };
inline int solve(int sx, int sy, int depth) {
	if (depth == n) {
		if (sx == gx || sy == gy) return 1;
		return 0;
	}
	int ret = 0;
	for (int i = 0; i < 4; i++) {
		int tx = sx + d[i], ty = sy + d[i ^ 1];
		while (rng(tx, ty)) {
			if (x[ty][tx] == 1) {
				x[ty][tx] = 0;
				ret += solve(tx, ty, depth + 1);
				x[ty][tx] = 1;
				break;
			}
			tx += d[i];
			ty += d[i ^ 1];
		}
	}
	return ret;
}
int main() {
	while (scanf("%d%d", &W, &H), W | H) {
		n = 0;
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) scanf("%d", &x[i][j]);
		}
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				if (x[i][j] == 1) n++;
				if (x[i][j] == 2) gx = j, gy = i;
			}
		}
		printf("%d\n", solve(gx, gy, 0));
	}
	return 0;
}

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

int main() {
  int a, b;
  cin >> a >> b;
  int ans = a-1;
  if(b >= a) ans++;
  
  cout << ans << endl;
  
  return 0;
}


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

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

int main() {
        int N;
        cin >> N;
        int a[N];
        int result=0;
        rep(i,N){
                cin >> a[i];
                result = result ^ a[i];
        }

        rep(i,N) cout << (result ^ a[i]) << " ";
        cout << endl;
}

Measured memory_bytes: 4200
#include <cstdio>
#include <climits>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <string>
#include <cstdio>
#include <climits>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <cstring>
#include <set>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
long long MOD = 1000000007;
long long INF = 1000000000000000; //10^15
typedef long long ll;
typedef unsigned long long ull;

int main(void) {
  int n, k;
  ll a[1010], s[1010] = {};

  cin >> n >> k;
  rep(i, n) cin >> a[i];

  rep(i, n) s[i + 1] = s[i] + a[i];

  vector<ll> b; int m = 0;
  for (int i = 0; i <= n; i++) {
    for (int j = i + 1; j <= n; j++) {
      b.push_back(s[j] - s[i]);
      m++;
    }
  }

  ll ma = 0;
  for (int i = 0; i < m; i++) {
    ma = max(ma, b[i]);
  }
  int l = 0;
  while (ma / (1LL << l) > 0) l++;
  /*cout << l << endl;
  rep(i, b.size()) {
    if (b[i] < 10) cout << " ";
    cout << b[i] << " ";
    for (int j = l; j >= 0; j--) {
      cout << ((b[i] >> j) & 1);
    } cout << endl;
  }
  cout << endl;*/

  vector<ll> c;
  for (int i = l; i >= 0; i--) {
    c.clear();
    for (int j = 0; j < b.size(); j++) {
      if ((b[j] >> i) & 1) c.push_back(b[j]);
    }
    if (c.size() >= k) {
      //for (int j = 0; j < c.size(); j++) cout << c[j] << endl;
      //cout << endl;
      b.clear();
      for (int j = 0; j < c.size(); j++) b.push_back(c[j]);
    }
  }

  /*rep(i, b.size()) {
    cout << b[i] << " ";
    for (int j = l; j >= 0; j--) {
      cout << ((b[i] >> j) & 1);
    } cout << endl;
    }*/
  ll ans = b[0];
  for (int i = 0; i < k; i++) ans &= b[i];
  cout << ans << endl;
}


Measured memory_bytes: 6512
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <tuple>
#include <cassert>

using namespace std;

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define mp(a,b) make_pair((a), (b))
#define mt(a,b,c) make_tuple((a),(b),(c))

typedef long long ll;
const int maxV = 211111;
vector<int> G[maxV]; // 頂点情報のみのグラフ

// treeDFS(親, 現在地, 根から現在地までの距離, 根からの最大の距離, 根から最大の距離となる頂点
void treeDFS(int from, int current, int dist, int &maxDist, int &maxVertex) {
    // 距離と終点を更新
    if (dist > maxDist) {
        maxDist = dist;
        maxVertex = current;
    }

    for (auto to : G[current]) {
        // 逆流を防ぐ
        if (to == from) continue;
        treeDFS(current, to, dist + 1, maxDist, maxVertex);
    }
}

void getTreeDiameter() {
    int start = 0, end = 0, maxDist = 0;
    treeDFS(-1, start, 0, maxDist, end);
    start = end, end = 0, maxDist = 0;
    treeDFS(-1, start, 0, maxDist, end);
    //printf("start: %d, end: %d, diameter: %d\n", start, end, maxDist);
    if(maxDist==0) cout << "First" << endl;
    else if(maxDist==1) cout << "Second" << endl;
    else if(maxDist%3 == 1) cout << "Second" << endl;
    else cout << "First" << endl;
}
int main(){
    int n; cin >> n;
    rep(i,n-1){
        int a,b; cin >> a >> b;
        G[a-1].pb(b-1);
        G[b-1].pb(a-1);
    }
    getTreeDiameter();
    return 0;
}

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

const ll MOD = 1000000007;
const int mxN = 200001;

vector<int>adj[mxN];
bool visited[mxN];

void init()
{
	for(int i = 0; i < mxN; i++)
		visited[i] = false;
}

int dfs(int s)
{
	visited[s] = true;

	int size = 1;

	for(int i = 0; i < adj[s].size(); i++)
	{
		if(visited[adj[s][i]] == false)
			size = size + dfs(adj[s][i]);
	}

	return size;
}

void solve()
{
	init();

	int N,M; //nodes and edges
	cin>>N>>M;

	int a,b;

	for(int i = 0; i < M; i++)
	{
		cin>>a>>b;

		adj[a].pb(b);
		adj[b].pb(a);
	}

	//find size of each connected component

	//result is size of the largest component

	int size,res = 0;

	for(int i = 1; i <= N; i++)
	{
		if(visited[i] == false)
		{
			size = dfs(i);
			res = max(res,size);
		}	
	}

	cout<<res<<endl;
}

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

	solve();

	return 0;
}

Measured memory_bytes: 24112
//{{{
#include <bits/stdc++.h>
using namespace std;
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop,~))(__VA_ARGS__)
#define loop(n) rep2(_loop_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define repN(a) repX a
#define repX(a0,a1,a2,x,...) x
#define foreach(x,a) for(auto &x:a)
typedef long long ll;
const int MOD = 1e9+7;
//}}}

int main(){
  int A, B;
  cin >> A >> B;
  int ans = 0;
  ans += min(A, B);
  cin >> A >> B;
  ans += min(A, B);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repbit(bit,n) for (int bit = 0; bit < (1<<n); bit++)
using namespace std;
typedef long long ll;

const int INF = 1001001001;
//const ll INF = 1000000000000000000;

int main() {
	int l, r, d;
	cin >> l >> r >> d;

	int ans = 0;
	for (int i = l; i <= r; i++) {
		if (i % d == 0) ans++;
	}
 	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3584
program aaa
implicit none

integer :: k, i, j
integer, dimension(5) :: a

do i=1, 5
read*, a(i)
end do
read*, k

do i=1, 5
 do j=i+1, 5
 if(abs(a(i)-a(j))>k) then
 write(*,'(a2)') ':('
 return
 end if
 end do
end do

write(*,'(a4)') 'Yay!'

end program

Measured memory_bytes: 256
n = int(input())
s = input()
alpha = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
ans = []
for i in range(len(s)):
    for j in range(len(alpha)):
        if s[i] == alpha[j]:
            ans.append(alpha[(j+n)%26])
print(''.join(map(str,ans)))

Measured memory_bytes: 3188
#pragma region Macros
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

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

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr int MOD = 1e9 + 7;
constexpr long long LINF = 1e18;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;
#pragma endregion

ll rec(int i, int j, vector<vector<ll>> &dp, const vector<ll> &a) {
    if (dp.at(i).at(j) != LINF) return dp.at(i).at(j);

    if (i == j) return dp.at(i).at(j) = a.at(i);
    else return dp.at(i).at(j) = max(a.at(i) - rec(i+1, j, dp, a), a.at(j) - rec(i, j-1, dp, a));
}

void solve() {
    int n;
    cin >> n;
    vector<ll> a(n);
    for (int i=0; i<n; i++) {
        cin >> a.at(i);
    }

    vector<vector<ll>> dp(n, vector<ll>(n, LINF));

    cout << rec(0, n-1, dp, a) << '\n';
}

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

    solve();

    return 0;
}


Measured memory_bytes: 70912
n = gets.to_i

class Point
  attr_accessor :x, :y
  def initialize(x=0, y=0)
    @x = x
    @y = y
  end

  def ans
    "%.8f %.8f" % [@x, @y]
  end
end

def koch(n, a, b)
  if n == 0
    return
  end

  s, t, u = Array.new(3){Point.new}

  th = Math::PI * 60.0/180.0

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

  koch(n-1,a,s)
  puts s.ans
  koch(n-1,s ,u)
  puts u.ans
  koch(n-1, u, t)
  puts t.ans
  koch(n-1,t, b)
end

a, b = Array.new(2){Point.new}
a.x = 0
a.y = 0
b.x = 100
b.y = 0

puts a.ans
koch(n, a, b)
puts b.ans


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

struct node{
  struct node *right; /* ????????? */
  struct node *left;  /* ????????? */
  struct node *parent;/* ??? */
  int key;            /* ??????????????? */
};
typedef struct node * Node;
#define NIL NULL

Node root = NIL;

Node treeMinimum(Node x){
	return(NIL);

}

Node treeSearch(Node u, int k){
	return(NIL);

}

Node treeSuccessor(Node x){
	return(NIL);

}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y



}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  /* ??????????????? */
  z = (Node)malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
  z->parent = NIL;

  /* 2???????卒蔵??即T?????????????????? */
  while(x != NIL){
	  /* z????????\????????????????????? */
	  y = x;
	  if(z->key < x->key){
		  x = x->left;
	  }else{
		  x = x->right;
	  }
  }

  /* p[z] = y? */
  z->parent = y;

  /* 2???????卒蔵??即T??????(????????属???0)??? */
  if(y == NIL){
	  root = z;
  }else if(z->key < y->key){
	  y->left = z;
  }else{
	  y->right = z;
  }

  return;
}

void inorder(Node u){
	if(u == NIL){
		return;
	}
	inorder(u->left);
	printf(" %d", u->key);
	inorder(u->right);
	return;
}
void preorder(Node u){
	if(u == NIL){
		return;
	}
	printf(" %d", u->key);
	preorder(u->left);
	preorder(u->right);
	return;
}

int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}

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

multiset<int> s;
int m,n,x;
int main()
{
    scanf("%d",&n);
    while(n--)
    {
        scanf("%d",&x);
        s.insert(x);
    }
    scanf("%d",&m);
    while(m--)
    {
        scanf("%d",&x);
        if(s.find(x)==s.end()){puts("NO");return 0;}
        s.erase(s.find(x));
    }
    puts("YES");
    return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpl;

#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

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

  ll n;
  cin>>n;
  ll ans=n/2+n%2;
  cout<<ans<<endl;

}


Measured memory_bytes: 256
using System;
class Program
 {
   static void Main(string[] args)
   {
     string s;
     s = Console.ReadLine();
     bool CFlag = false;

     for (int i = 0; i < s.Length; i++)
     {
       if(i==0)
       {
         if(s[i]!='A')
         {
           Console.WriteLine("WA");
           break;
         }
       }else if(i==1)
       {
         if(Char.IsUpper(s[i]))
         {
           Console.WriteLine("WA");
           break;
         }
         
       }else if(i==s.Length-1)
       {
         if(!CFlag||Char.IsUpper(s[i]))
         {
           Console.WriteLine("WA");
           break;
         }
         
         Console.WriteLine("AC");
      
       }else
       {
         if(Char.IsUpper(s[i]))
         {
          if(CFlag)
          {
             Console.WriteLine("WA");
            break;
          }

          if(s[i] == 'C'&&!CFlag)
          {          
            CFlag = true;
          }

         }
         
       }
           
     }
     
   }
 }

Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define clr(a, b) memset(a, b, sizeof(a))
#define Error(x) cout << #x << " = " << x << endl
#define iDEBUG freopen("in.txt", "r", stdin)
#define oDEBUG freopen("output.txt","w",stdout)
#define pb push_back
#define x first
#define y second
#define all(x) x.begin(),x.end()
#define hi cout<<"hi\n"
typedef long long ll;

using namespace std;
int gcd(int m, int n) { if((0 == m) || (0 == n)){return 0;} while(m != n){ if(m > n){m -= n;}else{n -= m;} } return m; }
int lcm(int m, int n) { if((0 == m) || (0 == n)){return 0;} return (m / gcd(m, n)) * n; }

int main()
{
    //iDEBUG; //oDEBUG;
    int a, b, c;
    cin >> a >> b >> c;
    if(a+b >= c)
        cout << "Yes\n";
    else
        cout << "No\n";

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <queue>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
typedef long long ll;
#define rep(i, a, b) for (int i = a; i <= b; ++ i)
#define per(i, a, b) for (int i = a; i >= b; -- i)
const int maxn = 250010;
using namespace std;
int a[maxn], b[maxn], n;
priority_queue <pair<int, int> > p; 
int main() {
	scanf("%d", &n); rep(i, 1, n) {
		scanf("%d", &b[i]), a[b[i]] = i;
		rep(j, 1, i - 1) p.push(make_pair(- (b[i] - 1), i));
	}
	rep(i, 1, n * n) {
		if (a[i]) {
			rep(j, a[i] + 1, n) p.push(make_pair(- (n * n + 1), a[i]));
		} else {
			if (p.empty() || p.top().first > - i) {
				printf("No");
				return 0;
			}
			a[i] = p.top().second;
			p.pop();
		}
	}
	printf("Yes\n");
	rep(i, 1, n * n) printf("%d ", a[i]);
	return 0;
}

Measured memory_bytes: 3696
# include <stdio.h>
# include <bits/stdc++.h>
using namespace std;
# define fi cin
# define fo cout
# define x first
# define y second
# define ll long long
# define IOS ios_base :: sync_with_stdio(0);cin.tie(0)
# define p(v) cerr << #v << " = " << v << '\n'
# define p2(v) cerr << #v << " = " << (complex < int > (v.x,v.y)) << '\n'
# define vi vector < int >
# define vl vector < ll >
# define pii pair < int , int >
# define mp make_pair
# define db long double
# define pb push_back
# define pdd pair < db , db >
# define int ll
int32_t main(void)
{
    #ifdef CF
    freopen("input","r",stdin);
    #endif // CF
    srand(time(0));
    fo << fixed << setprecision(7);
    cerr << fixed << setprecision(7);
    int n;
    fi>>n;
    static int s[1 << 20];
    static char op[1 << 20];
    op[1] = '+';
    for (int i = 1;i <= n;++i)
    {
        fi>>s[i];
        if (i < n)
            fi>>op[i + 1];
    }
    static int ss[1 << 20];
    for (int i = 1;i <= n;++i)
        ss[i] = (op[i] == '-' ? -1 : 1) * s[i] + ss[i - 1];
    static int ab[1 << 20];
    for (int i = n;i;--i)
        ab[i] = ab[i + 1] + s[i];
    static int mn[1 << 20];
    for (int i = n;i;--i)
        mn[i] = op[i] == '+' ? mn[i + 1] : i;
    int ans = ss[n];
    for (int i = 0;i <= n;++i)
        if (op[i] == '-')
            ans = max(ans,ss[i - 1] - (-ab[mn[i + 1]] + ab[i]) + ab[mn[i + 1]]);
    fo << ans << '\n';
    cerr << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
    return 0;
}


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

using namespace std;
using ll = long long;
const int maxn = 1e5+7;

int n, a, b;
ll h[maxn];
bool check(ll x){
	ll sum=0;
	ll sub=a-b;
	for(int i=1; i<=n; ++i){
		if(x*b<h[i]){
			ll tmp=h[i]-x*b;
			sum += tmp/sub;
			if(tmp%sub)sum++;
		}
	}
	return sum<=x;
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> a >> b;
	for(int i=1; i<=n; ++i){
		cin >> h[i];
	}
	sort(h+1, h+1+n);
	ll l=1, r=1e9+7;
	while(l<r){
		ll mid = l+r>>1;
		if(check(mid)){
			r=mid;
		}else{
			l=mid+1;
		}
	}
	cout << r;
}

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

using namespace std;
typedef long long ll;
#define out(ans) cout << ans << endl;
const long long mod = 1e9 + 7;

ll solve753(ll n, ll limit, ll is7, ll is5, ll is3) {
  ll ans = 0;
  if (n > limit) return 0;
  if (is3 && is5 && is7) ans++;
  ans += solve753(10 * n + 3, limit, is7, is5, 1);
  ans += solve753(10 * n + 5, limit, is7, 1, is3);
  ans += solve753(10 * n + 7, limit, 1, is5, is3);

  return ans;
}

int main() {
  ll n;
  cin >> n;
  cout << solve753(0, n, 0, 0, 0);
  return 0;
}


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

struct Node{
  int key;
  Node *right, *left, *parent;
};

Node *root,*NIL;

Node * find(Node *u,int k){
  while(u != NIL && k != u->key){
    if(k < u->key) u = u -> left;
    else u = u->right;
  }
  return u;
}

void insert(int k){
  Node *y = NIL;
  Node *x = root;
  Node *z;

  z=(Node *)malloc(sizeof(Node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y=x;
    if(z->key < x->key){
      x = x->left;
    }
    else{
      x = x->right;
    }
  }
  z->parent = y;
  if(y == NIL){
    root = z;
  }
  else {
    if(z->key < y->key){
      y->left = z;
    }
    else{
      y->right = z;
    }
  }
}

void inorder(Node *u){
  if(u == NIL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}

void preorder(Node *u){
  if(u == NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}

int main(){
  int n,i,x;
  string com;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    cin >> com;
    if(com[0] == 'f'){
      scanf("%d",&x);
      Node *t = find(root,x);
      if(t != NIL)printf("yes\n");
      else printf("no\n");
    }
    else if(com == "insert"){
      scanf("%d",&x);
      insert(x);
    }
    else if(com == "print"){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}





Measured memory_bytes: 21928
n=int(input())

def yakusu_num(x):
    cnt=0
    for i in range(x):
        if x%(i+1)==0:
            cnt+=1
    return(cnt)

ans=0
for i in range(-(-n//2)):
  if yakusu_num(2*i+1)==8:
    ans+=1
  
print(ans)

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

char s[11];
int main()
{
	scanf("%s",s+1);
	if (s[1]=='Y'&&s[2]=='A'&&s[3]=='K'&&s[4]=='I') puts("Yes");
	else puts("No");
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<queue>
#include<cmath>
#include<set>
#include<deque>
#include<iomanip>
#include<tuple>
#include<stack>
using namespace std;
typedef long long ll;

typedef pair<int, int> pii;
typedef tuple<int, int, int> ti3;

//const ll MOD_CONST = 1000000007;
const ll MOD_CONST = 998244353;


const int INF = 1000000000;
const ll BIG_NUM = 1000000000000000000;



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

	vector<int> d(n);
	for (int i = 0; i < n - 1; i++) {
		d[i] = a[i + 1] - a[i];
	}

	d[n - 1] = a[0] + k - a[n - 1];

	sort(d.begin(), d.end());
	cout << k - d[n - 1] << endl;
}



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

using namespace std;

typedef long long int ll;

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

    if(s=="SAT"){
        ans=1;
    }else if(s=="MON"){
        ans=6;
    }else if(s=="TUE"){
        ans=5;
    }else if(s=="WED"){
        ans=4;
    }else if(s=="THU"){
        ans=3;
    }else if(s=="FRI"){
        ans=2;
    }else{
        ans=7;
    }

    cout << ans << endl;

}


Measured memory_bytes: 256
A, B, C = map(int, input().split())
 
li = [A, B, C]
 
def is_odd(x):
  return True if x % 2 == 1 else False
 
def has_odd(l):
  for x in l:
    if is_odd(x):
      return True
  return False
 
ans = 0
 
continue_loop = True
 
while continue_loop:
  if has_odd(li):
    break
  if li[0] == li[1] and li[1] == li[2]:
    ans = -1
    break
  a, b, c = (li[0], li[1], li[2])
  li[0] = (a + b) // 2
  li[1] = (a + c) // 2
  li[2] = (b + c) // 2
  ans += 1
 
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,L,R;
string S,T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;


string s = "z";
vector<char> t(200010),d(200010);
map<char,ll> dir;
bool simu(bool left, ll index){
    ll temp = index;
    bool test = false;
    /*if(index == 6 || index == 7){
        cout<<index<<endl;
        test = true;
    }*/
    rep(i,Q){
        if(t[i] == s[temp]) temp += dir[d[i]];
        if(left && (temp == 0)) return true;
        if(!left && (temp == N+1)) return true;
        if(test) cout<<i<<' '<<temp<<endl;
    }
    return false;
}
int main() {
    cin>>N>>Q>>S;
    s.append(S);
    s.append("z");
    //rep(i,s.size())cout<<s[i];
    //cout<<endl;
    rep(i,Q) cin>>t[i]>>d[i];
    dir['L'] = -1;
    dir['R'] = 1;
    ll left,right;
    ll lb = 0, ub = N+2;
    while(ub - lb > 1){
        ll cen = (ub + lb) / 2;
        (simu(true,cen) ? lb : ub) = cen;
    }
    left = lb;
    lb = N+1; ub = -1;
    while(lb - ub > 1){
        ll cen = (ub + lb) / 2;
        (simu(false,cen) ? lb : ub) = cen;
    }
    right = lb;
    cout<<max(0LL, right - left - 1)<<endl;
    //cout<<left << ' '<<right<<endl;
    //cout<<dir['L']<<' '<<dir['R']<<endl;
}


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

int main(){
	int n;
	cin >> n;
	int ans = 0;
	for(int i = 0; i < n; i++){
		int l, r;
		cin >> l >> r;
		ans += r - l + 1;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ui long long
#define ull unsigned long long
#define db long double
#define pii pair<ll,ll>
#define X first
#define Y second
#define mp make_pair
#define pb push_back
#define vi vector<int>
#define vii vector<vi>
#define lb lower_bound
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,b,a) for(int i=(b);i>=(a);--i)
#define rep0(i,a,b) for(int i=(a);i<(b);++i)
#define fore(i,a) for(int i=0;i<a.size();++i)
#define gc() getchar()
#define ls x<<1,l,m
#define rs x<<1|1,m+1,r
inline int rd()
{
	int x=0;char c=gc();while(!isdigit(c))c=gc();
	while(isdigit(c))x=x*10+c-48,c=gc();return x;
}
const int N=605;
int n,m,d1,d2,c[N][N];
void sol(int d)
{
	int t=0;while(!(d&3))d>>=2,t++;
	if(d&1){rep0(i,0,m)rep0(j,0,m)if(((i>>t)+(j>>t))&1)c[i][j]=1;}
	else{rep0(i,0,m)rep0(j,0,m)if(i>>t&1)c[i][j]=1;}
}
int main()
{
	n=rd();d1=rd();d2=rd();m=n*2;
	sol(d1);sol(d2);int nn=n*n;
	rep0(i,0,m)rep0(j,0,m)if(!c[i][j])
	{
		printf("%d %d\n",i,j);nn--;
		if(!nn)return 0;
	}
	return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

ll N;
string S;
ll nxt[100010][10];

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

  cin>>N>>S;
  memset(nxt,-1,sizeof(nxt));

  for(ll i=N-1;i>=0;i--){
    rep(j,10){
      if(S[i]==(char)('0'+j)) nxt[i][j]=i+1;
      else nxt[i][j]=nxt[i+1][j];
    }
  }

  ll res=0;
  rep(a,10)rep(b,10)rep(c,10){
    ll crt=nxt[0][a];
    if(crt!=-1){
      crt=nxt[crt][b];
    }
    if(crt!=-1){
      crt=nxt[crt][c];
    }
    if(crt!=-1){
      res++;
    }
  }
  cout<<res<<endl;

  return 0;
}


Measured memory_bytes: 8192
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
vector<int> stones;
vector<int> costs;
int hops(int stone)
{
    if (stone < 1)
    {
        return 0;
    }
    if (stone == 1)
    {
        return abs(costs[stone] - costs[stone - 1]);
    }
    if (stones[stone] != -1)
    {
        return stones[stone];
    }
    int cost1 = hops(stone - 1) + abs(costs[stone] - costs[stone - 1]);
    int cost2 = hops(stone - 2) + abs(costs[stone] - costs[stone - 2]);
    int preferable = min(cost1, cost2);
    stones[stone] = preferable;
    return preferable;
}
int main()
{
    int n;
    cin >> n;
    stones.assign(n, -1);
    for (int i = 0; i < n; i++)
    {
        int cost;
        cin >> cost;
        costs.push_back(cost);
    }
    cout << hops(n - 1) << endl;
}

Measured memory_bytes: 5880
# ------------------------------------------------------------
# THIS IS METADATA FOR ATCODER_TOOLS
# BE CAREFULL WHEN YOU CHANGE THE VALUE
# 
# METADATA::START
# test-1
# input: "6\nAC\nTLE\nAC\nAC\nWA\nTLE\n"
# output: "AC x 3\nWA x 1\nTLE x 2\nRE x 0\n"
# test-2
# input: "10\nAC\nAC\nAC\nAC\nAC\nAC\nAC\nAC\nAC\nAC\n"
# output: "AC x 10\nWA x 0\nTLE x 0\nRE x 0\n"
# MODE: TEST
# METADATA::FINISH
# 
# you can add your original test case 
# you can select MODE from NONE, DEBUG, RUN, TEST
# problem_url: https://atcoder.jp/contests/abc173/tasks/abc173_b
# submission_url: https://atcoder.jp/contests/abc173/submissions/me
# -------------------------------------------------------------

# snippets
n = gets.to_i
# arr = gets.split(' ').map(&:to_i)
arr = []
n.times do |i|
  arr[i] = gets.chomp
end

print "AC x "
puts arr.count{|r| r == 'AC'}
print "WA x "
puts arr.count{|r| r == 'WA'}
print "TLE x "
puts arr.count{|r| r == 'TLE'}
print "RE x "
puts arr.count{|r| r == 'RE'}


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

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

  for (int i = 1; i <= 9; i++) {
    for (int j = 1; j <= 9; j++) {
      if (i * j == n) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }

  cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 256
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
from collections import Counter

n = ii()
s = input()

d = Counter(s)
num = d['R']
ans = num
wcnt = 0
rcnt = 0
for i in s:
#    print(i)
    if i == 'W':
        wcnt += 1
    else:
        if num - 1 >= wcnt or wcnt == 0:
            ans -= 1
            num -= wcnt+1
            wcnt = 0
        if num == 0:
            break
print(ans)

Measured memory_bytes: 9776
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
using llong = long long;
using P = pair<int, int>;
const int inf = 1 << 20;
const int mod = 1e9 + 7;

int main() {
   int n, k;
   cin >> n >> k;
   vector<int> p(n);
   rep(i, n) { cin >> p[i]; }
   vector<double> sum(n + 1);
   rep(i, n) { sum[i + 1] = sum[i] + (1 + p[i]) / 2.0; }
   double ans = 0;
   for (int i = k; i < n + 1; i++) {
      ans = max(ans, sum[i] - sum[i - k]);
   }
   printf("%0.10f\n", ans);
   return 0;
}

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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define repp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const lint MOD   = 1e9 + 7;
const double EPS = 1e-10;

int main() {
    int N;
    cin >> N;
    vector<int> A(N, -1);
    rep(i, N) { cin >> A[i]; }

    deque<int> dq{};
    for (auto ai : A) {
        int idx = lower_bound(dq.begin(), dq.end(), ai) - dq.begin();
        if (idx == 0) {
            dq.push_front(ai);
        } else {
            dq[idx - 1] = ai;
        }
    }
    dump(dq);
    cout << dq.size() << endl;
    return 0;
}

Measured memory_bytes: 1024
a = gets.chomp.to_i

def gcd(a, b)
  a = -a if a < 0
  b = -b if b < 0
  while b > 0
    a, b = b, a % b
  end
  a
end

def ngcd(a,b,c)
  gcd(gcd(a,b),c)
end

sum_6 = 0
if a >= 3
  (1..a).each do |i|
    (i+1..a).each do |j|
      (j+1..a).each do |k|
        sum_6 += ngcd(i,j,k)
      end
    end
  end
end

sum_3 = 0
(1..a).each do |i|
  (i+1..a).each do |j|
    sum_3 += gcd(i,j)
  end
end

sum = (1..a).reduce(:+)

puts sum_6 * 6 + sum_3 * 6 + sum


Measured memory_bytes: 14372
// 2020-07-27 07:39:19
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
using P = pair<int, int>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }

int n, p;
string s;
void answer2or5() {
  ll ans = 0;
  rep(i, n) {
    if((s[i]-'0') % p == 0) ans += i+1;
  }
  cout << ans << '\n';
}
void answer() {
  cin >> n >> p >> s;
  if(p == 2 || p == 5) {
    answer2or5();
    return;
  }
  reverse(ALL(s));
  vector<ll> mp(p, 0);
  ll c = 0, d = 1;
  rep(i, n) {
    c = (c + (s[i]-'0') * d) % p;
    mp[c]++;
    d = d * 10 % p;
  }
  ll ans = mp[0];
  for(auto x : mp) {
    ans += x * (x-1) / 2;
  }
  cout << ans << '\n';
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 3740
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main(){
    string S;cin>>S;
    S='0'+S;
    ll ans=0;
    per(i,S.size()){
        if(S[i]<='4' or (S[i]=='5' and S[i-1]<'5')){
            ans+=S[i]-'0';
        }
        else{
            ans+=10-(S[i]-'0');
            S[i-1]++;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 2308
N=int(input())
st=[list(map(str,input().split())) for _ in range(N)]
X=input()

A=[]
answer=0

for i in range(N):
    A.append(st[i][0])

b=A.index(X)

for j in range(b+1,N):
    answer+=int(st[j][1])

print(answer)

Measured memory_bytes: 3064
#!/usr/bin/env python3
import sys

M = 'zzzzzz'

def dfs(s, K, N, r, a, ss):
    m = a[r]
    for i in range(N):
        if s[i] == m:
            t = ''
            for j in range(i, min(i+K, N)):
                t += s[j]
                if t in ss:
                    continue
                if t >= ss[-1]:
                    break
                ss.pop()
                ss.append(t)
                list.sort(ss)
    if ss[-1] == M:
        return dfs(s, K, N, r+1, a, ss)
    return ss[-1]


def solve(s: str, K: int):
    ss = [M] * K
    a = sorted(list(set(s)))
    N = len(s)
    return dfs(s, K, N, 0, a, ss)


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    s = next(tokens)
    K = int(next(tokens))
    print(solve(s, K))

if __name__ == '__main__':
    main()


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

#define rep(i,a,b) for(int i=a;i<b;++i)
#define per(i,a,b) for(int i=b-1;i>=a;--i)
typedef long long ll;
/////////////////////

int const N = 2e3 + 41;
int w[N][N];
int b[N][N], ev[N][N], eh[N][N];

int n, m;
int q;

void build(){
	rep(i, 1, n+1){
		int sum = 0;
		rep(j, 1, m+1){
			sum += w[i][j];
			b[i][j] = b[i-1][j] + sum;
		}
	}

	rep(i, 1, n+1){
		int sum = 0;
		rep(j, 1, m+1){
			sum += (w[i][j] && w[i-1][j]);
			ev[i][j] = ev[i-1][j] + sum; 
		}
	}

	rep(i, 1, n+1){
		int sum = 0;
		rep(j, 1, m+1){
			sum += (w[i][j] && w[i][j-1]);
			eh[i][j] = eh[i-1][j] + sum;
		} 
	}
}

int getRect(int x1, int y1, int x2, int y2, int p[N][N]){
	if(x1 > x2 || y1 > y2) return 0;
	int ret = p[x2][y2] - p[x1-1][y2] - p[x2][y1-1] + p[x1-1][y1-1];
	return ret;
}

int getAns(int x1, int y1, int x2, int y2){
	int ret = getRect(x1, y1, x2, y2, b) - getRect(x1+1, y1, x2, y2, ev) - getRect(x1, y1+1, x2, y2, eh);
	return ret;
}

void solve(){
	cin >> n >> m >> q;
	rep(i, 1, n+1){
		string s;
		cin >> s;
		rep(j, 1, m+1) w[i][j] = (s[j-1] - '0');
	}
	build();
	rep(i, 0, q){
		int x1, y1, x2, y2;
		cin >> x1 >> y1 >> x2 >> y2;
		cout << getAns(x1, y1, x2, y2) << endl;
	}
}

int main(){
#ifdef _DEBUG
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif

	solve();

	return 0;
}

Measured memory_bytes: 66560
#include <bits/stdc++.h>
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define int long long
#define all(c) (c).begin(),(c).end()
#define endl '\n'
using namespace std;

//                                      mdsaqib
signed main(){
    fast;
    int n;
    cin >> n;
    std::vector<int> V ;
    while(n>0){
        n--;
        int k=n%26;
        V.push_back(k);
        n/=26;
    }
    vector <char> A;
    for(int i=V.size()-1;i>=0;i--){
        A.push_back(V[i]+'a');
    }
    for(int i=0;i<A.size();i++){
        cout << A[i];
    }
}


Measured memory_bytes: 3648