akhauriyash/Code-Regression huggingface dataset:
// created by mtnshh
 
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;

#define ll long long
#define ld long double
 
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
 
#define err() cout<<"=================================="<<endl;
#define errA(A) for(auto i:A)   cout<<i<<" ";cout<<endl;
#define err1(a) cout<<#a<<" "<<a<<endl
#define err2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define err3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl
#define err4(a,b,c,d) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<" "<<#d<<" "<<d<<endl

#define pb push_back
#define all(A)  A.begin(),A.end()
#define allr(A)    A.rbegin(),A.rend()
#define ft first
#define sd second
 
#define pll pair<ll,ll>
#define V vector<ll>
#define S set<ll>
#define VV vector<V>
#define Vpll vector<pll>
 
#define endl "\n"
 
const ll logN = 20;
const ll M = 1000000007;
const ll INF = 1e12;
#define PI 3.14159265
 
const ll N = 100005;

void solve(){
	ld r;
	cin>>r;
	cout << fixed << setprecision(6) << 2*PI*r << endl;	
	return;
}

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	ll no;
	// cin>>no;
	no = 1;
	while(no--){
		solve();
	}
    return 0;
}

Measured memory_bytes: 3732
using System;

namespace atcoderA
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            int[] input = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            int A = input[0];
            int B = input[1];
            int C = input[2];
            int ans = B / A;
            Console.WriteLine(ans < C ? ans : C);
        }
    }
}

Measured memory_bytes: 13140
import sys

# import re
# import math
import collections
# import decimal
# import bisect
# import itertools
# import fractions
# import functools
import copy
# import heapq
# import decimal
# import statistics
import queue

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7
MOD2 = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===


def main():
    n = input()
    a = [2, 4, 5, 7, 9]
    b = [0, 1, 6, 8]
    c = [3]

    sl = int(n[-1])
    if sl in a:
        print("hon")
    elif sl in b:
        print("pon")
    elif sl in c:
        print("bon")

if __name__ == '__main__':
    main()


Measured memory_bytes: 9808
#include <stdio.h>
#include <string.h>
int main() {
	char a[100010];
	int ans = 0, len;
	int l = 0, r = 1;
	scanf("%s", a);
	len = strlen(a);
	for (; l <= len - r; l++,r++)
	{

		if (a[l] != a[len - r]) {
			if (a[l] == 'x') {
				r--;
				ans++;
			}
			else if (a[len - r] == 'x') {
				l--;
				ans++;
			}
			else {
				printf("-1");
				return 0;
			}
		}
	}
	printf("%d", ans);
	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 rep_range(i, s, e) for (int i = (s); i < (int)(e); i++)
#define rep_rev(i, s, e) for (int i = (s)-1; i >= (int)(e); i--)
#define sort_vec(v) sort((v).begin(),(v).end())
typedef int64_t lint;
// lint mod = 998244353;
// lint mod = 1000000007;
template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

void app() {
  int d;
  cin>>d;

  int n=26;
  vector<int> c(n);
  rep(j,n){
    cin>>c[j];
  }
  vector<vector<int>> s(d,vector<int>(n));
  rep(i,d) rep(j,n) cin>>s[i][j];

  vector<int> lastd(n,-1);
  rep(i,d){
    int bj=0,bdscore=-1e9;
    rep(j,n){
      int dscore=s[i][j]+c[j]*(i-lastd[j]);
      if(chmax(bdscore,dscore)){
        bj=j;
      }
    }
    cout<<bj+1<<endl;
    lastd[bj]=i;
  }

}

int main(){app();return 0;}


Measured memory_bytes: 3684
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

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

    cout << ((s[0] != s[1] && s[1] != s[2] && s[2] != s[0]) ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <cstdio>
#include <queue>
#include <iostream>


class UFT{
public:
	UFT():parent(this){};
	UFT *&find(){
		if (parent == this){
			return parent;
		}else{
			return (parent = parent->find());
		}
	}
	void set_union(UFT &new_parent){
		find()->set_parent(new_parent.find());
	}
	bool operator==(UFT &other){
		return (find() == other.find());
	}
private:
	UFT *parent;
	void set_parent(UFT *new_parent){parent = new_parent;}
};
class Edge{
public:
	int s, t, w;
	Edge(int start = 0, int to = 0, int weight = 0):s(start), t(to), w(weight){};
	bool operator<=(const Edge &e) const {return w >= e.w;}
	bool operator<(const Edge &e) const {return w > e.w;}
	bool operator>=(const Edge &e) const {return w <= e.w;}
	bool operator>(const Edge &e) const {return w < e.w;}
	bool operator==(const Edge &e) const {return w == e.w;}
};
int main(){
	int v, e;
	std::scanf("%d %d", &v, &e);
	std::priority_queue<Edge> queue;
	std::vector<UFT> node(v);
	for (auto i = 0; i < e; ++i){
		int s, t, w;
		std::scanf("%d %d %d", &s, &t, &w);
		queue.push(Edge(s, t, w));
	}
	int sum = 0;
	while (queue.size() > 0){
		if (node.at(queue.top().s) == node.at(queue.top().t)){
			queue.pop();
		}else{
			sum += queue.top().w;
			node.at(queue.top().s).set_union(node.at(queue.top().t));
			queue.pop();
		}
	}
	std::printf("%d\n", sum);
}

Measured memory_bytes: 2772
num=int(input())
b1=[int(x) for x in input().split(' ')]
b2=[int(x) for x in input().split(' ')]



def c_minchov(x,y,p):
	b1,b2=x,y
	fsum=0
	for i in range(len(b1)):
		fsum+=abs(b1[i]-b2[i])**p
	res=fsum**(1/p)
	return res

def c_chebichev(x,y):
	b1,b2=x,y
	dis=[abs(b1[i]- b2[i]) for i in range(len(b1))]

	res= max(dis)
	return res


p1=c_minchov(b1,b2,1)
p2=c_minchov(b1,b2,2)
p3=c_minchov(b1,b2,3)
p4=c_chebichev(b1,b2)
print("{:.6f}".format(p1))
print("{:.6f}".format(p2))
print("{:.6f}".format(p3))
print("{:.6f}".format(p4))



Measured memory_bytes: 5660
import math


def split3(a, b):
    s = (a[0] * (2 / 3) + b[0] * (1 / 3), a[1] * (2 / 3) + b[1] * (1 / 3))
    t = (a[0] * (1 / 3) + b[0] * (2 / 3), a[1] * (1 / 3) + b[1] * (2 / 3))
    return s, t


def rotate60(s, t):
    th = math.pi / 3
    u0 = s[0] + math.cos(th) * (t[0] - s[0]) - math.sin(th) * (t[1] - s[1])
    u1 = s[1] + math.sin(th) * (t[0] - s[0]) + math.cos(th) * (t[1] - s[1])
    return (u0, u1)


lst = [(0, 0), (100, 0)]
n = int(input())

for i in range(n):
    L = len(lst)
    new_lst = []
    for l in range(L - 1):
        left = lst[l]
        right = lst[l + 1]
        new_lst.append(left)
        s, t = split3(left, right)
        u = rotate60(s, t)
        new_lst.append(s)
        new_lst.append(u)
        new_lst.append(t)
    new_lst.append(right)
    lst = new_lst
for p in lst:
    print(*p)



Measured memory_bytes: 6280
import itertools
import bisect

N = int(input())
S = input()
R_set = set()
G_set = set()
B_set = set()
R = []
G = []
B = []
R_ids = [0] * N
G_ids = [0] * N
B_ids = [0] * N

for i, s in enumerate(S):
    if s == 'R':
        R_set.add(i)
        R.append(i)
        R_ids[i] = 1
    elif s == 'G':
        G_set.add(i)
        G.append(i)
        G_ids[i] = 1
    else:
        B_set.add(i)
        B.append(i)
        B_ids[i] = 1


R_ids = list(itertools.accumulate(reversed(R_ids)))[::-1]
G_ids = list(itertools.accumulate(reversed(G_ids)))[::-1]
B_ids = list(itertools.accumulate(reversed(B_ids)))[::-1]

r = (R_set, R, R_ids)
g = (G_set, G, G_ids)
b = (B_set, B, B_ids)

def count_rgb(r, g, b):
    res = 0
    r_set, _r, r_ids = r
    g_set, _g, g_ids = g
    b_set, _b, b_ids = b
    for r_idx in _r:
        start = bisect.bisect_left(_g, r_idx)
        for g_idx in _g[start:]:
            diff = g_idx - r_idx
            num = b_ids[g_idx]
            if g_idx+diff in b_set:
                num -= 1
            res += num
    return res
            

ans = 0
for rgb in itertools.permutations((r, g, b), 3):
    ans += count_rgb(rgb[0], rgb[1], rgb[2])

print(ans)

Measured memory_bytes: 9848
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;


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

    while (true) {
        int n; cin >> n;
        if (!n) break;
        int w, h; cin >> w >> h;
        vector<vector<int>> mat(h, vector<int>(w, 0));
        rep(i, n) {
            int x, y; cin >> x >> y;
            x--; y--;
            mat[y][x] = 1;
        }

        int s, t; cin >> s >> t;
        int ans = 0;
        rep(i, h-t+1) rep(j, w-s+1) {
            int tmp = 0;
            FOR(k, i, i+t) FOR(l, j, j+s) {
                // cout << k << " " << l << endl;
                if (mat[k][l]) tmp++;
            }
            ans = max(ans, tmp);
            // cout << "----" << endl;
        }

        // cout << mat.size() << ":h , w:" << mat[0].size() << endl;

        cout << ans << endl;
    }
}


Measured memory_bytes: 3164
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] cards = new int[n];
        for (int i = 0; i < n; i++) {
            cards[i] = sc.nextInt();
        }
        Arrays.sort(cards);
        
        int[][] ab = new int[m][2];
        for (int i = 0; i < m; i++) {
            int k = sc.nextInt();
            int v = sc.nextInt();
            ab[i][0] = v;
            ab[i][1] = k;
        }
        
        Arrays.sort(ab, (x, y) -> Integer.compare(x[0], y[0]));
        
        int idx = 0;
        for (int i = m - 1; i >= 0; i--) {
            boolean end = false;
            int k = ab[i][1];
            int v = ab[i][0];
            
            for (int j = 0; j < k; j++) {
                if (cards[idx] >= v) {
                    end = true;
                    break;
                }
                cards[idx] = v;
                idx++;
                if (idx == n) {
                    end = true;
                    break;
                }
            }
            if (end) break;
        }
        
        long answer = 0;
        for (int val : cards) {
            answer += (long)val;
        }
        
        System.out.println(answer);
    }
}

Measured memory_bytes: 95496
#include<stdio.h>
#include<string.h>
int main(){
    int l;
    char s[32],r[32];
    scanf("%s",s);
    l=strlen(s);
    for(int i=0;i<l;i++){
        r[l-i-1]=s[i];
    }
    for(int i=0;i<l;i++){
        printf("%c",r[i]);
    }
    printf("\n");
    return 0;
}

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

using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr ll mod = static_cast<ll>(1e9 + 7);

int n;
ll a[100005];
std::vector<ll> plus, minus;
int main() {
	std::cin >> n;

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

	std::sort(a, a + n);
	ll m = a[n - 1] - a[0];
	minus.push_back(a[0]);

	for (int i = 1, end = n - 1; i < end; ++i)
		if (a[i] > 0) {
			m += a[i];
			plus.push_back(a[i]);
		}
		else {
			m -= a[i];
			minus.push_back(a[i]);
		}

	std::cout << m << std::endl;
	plus.push_back(a[n - 1]);

	int plusnum = plus.size(), minusnum = minus.size();

	for (int i = 1; i < plusnum; ++i) {
		std::cout << minus[0] << " " << plus[i] << std::endl;
		minus[0] -= plus[i];
	}

	for (int i = 0; i < minusnum; ++i) {
		std::cout << plus[0] << " " << minus[i] << std::endl;
		plus[0] -= minus[i];
	}

	return 0;
}


Measured memory_bytes: 3572
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 1000000000;
const long long int llINF = 1000000000000000000;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll N;
  cin >> N;
  vl A(5);
  REP(i, 5) cin >> A[i];
  ll ans = 0;
  REP(i, 5) {
    if (A[i] < N) {
      ans = max(ans, (ll)ceil((long double)N / (long double)A[i]));
    }
  }
  if (ans == 0)
    cout << 5 << endl;
  else
    cout << ans + 4 << endl;
  return 0;
}


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

using namespace std;
using Int = long long;

signed main(){
    Int l, r;
    cin >> l >> r;

    if(r - l >= 2019) {
        cout << 0 << endl;
    } else {
        Int min = 2019;
        for(Int i = l; i < r; i++){
            for(Int j = i + 1; j <= r; j++){
                Int tmp = (i * j) % 2019;
                if (min > tmp) min = tmp;
            }
        }
        cout << min << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<deque>
#include<tuple>
#include<algorithm>
#include<numeric>
#include<limits>
#include<boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
using namespace std;
#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define rep(I,N) for(auto I=0;I<(N);++I)
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define dw(I,A,B) for(auto I=(A);I>=(B);--I)
#define all(C) (C).begin(),(C).end()
#define rall(C) (C).rbegin(),(C).rend()
#define ft first
#define sd second
#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define rs resize
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
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>inline void                                      in(T &p){cin>>p;}
template<class T1,class T2>inline void                            in(T1 &p1,T2 &p2){cin>>p1>>p2;}
template<class T1,class T2,class T3>inline void                   in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T1,class T2,class T3,class T4>inline void          in(T1 &p1,T2 &p2,T3 &p3,T4 &p4){cin>>p1>>p2>>p3>>p4;}
template<class T1,class T2,class T3,class T4,class T5>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4,T5 &p5){cin>>p1>>p2>>p3>>p4>>p5;}
template<class T>inline void                                      ins(T &p){for_each(all(p),in<decltype(p[0])>);}
template<class T>inline void                             out(T p){cout<<p<<endl;}
template<class T1,class T2>inline void                   out(T1 p1,T2 p2){cout<<p1<<" "<<p2<<endl;}
template<class T1,class T2,class T3>inline void          out(T1 p1,T2 p2,T3 p3){cout<<p1<<" "<<p2<<" "<<p3<<endl;}
template<class T1,class T2,class T3,class T4>inline void out(T1 p1,T2 p2,T3 p3,T4 p4){cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<endl;}
inline                                              void out(double p){printf("%.10f\n",p);}
template<class T>inline                             void outs(T p){for_each(all(p),out<decltype(p[0])>);}
template<class T>inline void outs(vector<T> V){int n=V.size();rep(i,n)cout<<V[i]<<" \n"[i==n-1];}
inline void solve(void){
  string s;in(s);
  int n=s.size();
  string t(s);
  reverse(all(t));
  string s2=s.substr(0,(n-1)/2);
  string t2(s2);
  reverse(all(t2));
  string s3=s.substr((n+3)/2-1,n-(n+3)/2+1);
  string t3(s3);
  reverse(all(t3));
  if(s==t&&s2==t2&&s3==t3)out("Yes");
  else out("No");
}
int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


Measured memory_bytes: 256
import sys
S = str(input())
while S != '':
    if (S[:5] == 'dream' and S[5:11] == 'eraser') or (S[:5] == 'dream' and S[5: 10] == 'erase') or (S[:5] == 'dream' and S[5:] == '') or (S[:5] == 'dream' and S[5:10] == 'dream'):
        S = S[5:]
    elif (S[:5] == 'erase' and S[5:] != '' and S[5] != 'r') or (S[:5] == 'erase' and S[5:] == ''):
        S = S[5:]
    elif S[:6] == 'eraser':
        S = S[6:]
    elif S[:7] == 'dreamer':
        S = S[7:]
    else:
        print('NO')
        sys.exit()
        break
        
print('YES')


Measured memory_bytes: 3188
from heapq import *
N,M=map(int,input().split())
INF=float("inf")
G=[[] for i in range(N)]
Gm=[[] for i in range(N)]
for i in range(M):
    a,b,c=map(int,input().split())
    a,b=a-1,b-1
    G[a].append((b,c))
    Gm[b].append((a,c))
O=[[0]*N for i in range(N)]
stack=[g for g in Gm[N-1]]
reached=[0]*N
reached[N-1]=1
while(stack):
    a,c=stack.pop()
    reached[a]=1
    for i,j in Gm[a]:
        if reached[i]==0:
            stack.append((i,j))
R=[False]*N
R[0]=0
stack=[(-i[1],0,i[0]) for i in G[0] if reached[i[0]]==1]
heapify(stack)
while(stack):
    c,a,b=heappop(stack)
    c=-c
    if R[b]==False:
        O[a][b]=1
        R[b]=c
        for i in G[b]:
            if reached[i[0]]==1:
                heappush(stack,(-i[1]-c,b,i[0]))
    if R[b]!=False and R[b]<c:
        if O[a][b]==1:
            print("inf")
            quit()
        else:
            R[b]=c
            O[a][b]=1
            for i in G[b]:
                if reached[i[0]]==1:
                    heappush(stack,(-i[1]-c,b,i[0]))

print(R[N-1])


Measured memory_bytes: 59224
#include <iostream>
#include <vector>

using namespace std;

int main()
{
	int n, m;
	cin >> n >> m;
	vector<int> h(n);
	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}
	vector<vector<int>> a(n);
	int b, c;
	for (int i = 0; i < m; i++) {
		cin >> b >> c;
		b--;
		c--;
		a[b].emplace_back(c);
		a[c].emplace_back(b);
	}

	int ans = 0;
	bool f;
	for (int i = 0; i < n; i++) {
		f = true;
		for (auto & j : a[i]) {
			if (h[i] <= h[j]) {
				f = false;
				break;
			}
		}
		if (f) {
			ans++;
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 8804
// https://atcoder.jp/contests/abc128/tasks/abc128_d
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef priority_queue<int, vector<int>, greater<int>> PQ;
#define INF (1e9)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOREACH(x, a) for (auto &(x) : (a))
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
// int gcd(long a, long b) { return b ? gcd(b, a % b) : a; }
// int lcm(long a, long b) { return a * b / gcd(a, b); }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    vector<int> v(n), ans(100, -INF);
    REP(i, n) cin >> v[i];
    // 左側から取り出す処理
    int suml = 0;
    PQ que1;
    for (int i = 0; i <= min(k, n); i++) {
        if (i > 0) {
            que1.push(v[i - 1]);
            suml += v[i - 1];
        }
        int sumr = 0;
        PQ que2 = que1;
        // 右側から取り出す処理
        for (int j = 0; i + j <= min(k, n); j++) {
            if (j > 0) {
                que2.push(v[n - j]);
                sumr += v[n - j];
            }
            ans[i + j] = max(ans[i + j], suml + sumr);
            int cnt = 0, mi = 0;
            PQ que3 = que2;
            while (!que3.empty()) {
                cnt++;
                if (i + j + cnt > k)
                    break;
                mi += que3.top();
                que3.pop();
                ans[i + j + cnt] = max(ans[i + j + cnt], suml + sumr - mi);
            }
        }
    }
    cout << *max_element(ALL(ans)) << endl;

    return 0;
}


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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)

int32 n,a,b,c;
vector<char> ans;
vector<string> s;
bool dfs(int32 a,int32 b,int32 c,int32 i){
  if(a < 0 || b < 0 || c < 0)return false;
  if(i==n)return true;
  if(s[i] == "AB"){
    if(dfs(a+1,b-1,c,i+1)){
      ans.pb('A');
      return true;
    }else if(dfs(a-1,b+1,c,i+1)){
      ans.pb('B');
      return true;
    }else{
      return false;
    }
  }else if(s[i] == "BC"){
    if(dfs(a,b+1,c-1,i+1)){
      ans.pb('B');
      return true;
    }else if(dfs(a,b-1,c+1,i+1)){
      ans.pb('C');
      return true;
    }else{
      return false;
    }
  }else{
    if(dfs(a+1,b,c-1,i+1)){
      ans.pb('A');
      return true;
    }else if(dfs(a-1,b,c+1,i+1)){
      ans.pb('C');
      return true;
    }else{
      return false;
    }
  }
  return false;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> a >> b >> c;
  s.resize(n);
  REP(i,n)cin >> s[i];
  if(a+b+c==0){
    Yes(false);
    return 0;
  }
  // if(a+b+c==1){
  //   // vector<string> s(n);
  //   // REP(i,n)cin >> s[i];
  //   // vector<char> ans;
  //   // vector<vector<int32>> cand = {{1,0,0},{0,1,0},{0,0,1}};
  //   // for(auto [x,y,z] : cand){
  //   //   ans.clear();
  //   //   bool flg = true;
  //   //   FORR(i,n-1,0){
  //   //     if(s[i] == 'AB'){
  //   //       if()
  //   //     }else if(s[i] == "BC"){

  //   //     }
  //   //   }
  //   //   if(flg){
  //   //     Yes(true);
  //   //     reverse(ALL(ans));
  //   //     for(auto t : ans)ANS(t);
  //   //     return 0;
  //   //   }
  //   // }
  //   // Yes(false);
  //   return 0;
  // }
  // if(a+b+c==2){
  //   return 0;
  // }
  if(a+b+c == 1 || a+b+c == 2){
    if(dfs(a,b,c,0)){
      reverse(ALL(ans));
      Yes(true);
      for(auto t : ans)ANS(t);
    }else{
      Yes(false);
    }
    return 0;
  }
  REP(i,n){
    if(s[i] == "AB"){
      if(a+b==0){
        Yes(false);
        return 0;
      }
      if(a > b){
        a--;b++;
        ans.pb('B');
      }else{
        a++;b--;
        ans.pb('A');
      }
    }else if(s[i] == "BC"){
      if(b+c==0){
        Yes(false);
        return 0;
      }
      if(b > c){
        b--;c++;
        ans.pb('C');
      }else{
        b++;c--;
        ans.pb('B');
      }
    }else{
      if(a+c==0){
        Yes(false);
        return 0;
      }
      if(a > c){
        a--;c++;
        ans.pb('C');
      }else{
        a++;c--;
        ans.pb('A');
      }
    }
  }
  Yes(true);
  for(auto x : ans)ANS(x);
  return 0;
}

Measured memory_bytes: 12960
#include <stdio.h>
#include <limits.h>
#define large 300001
// #define large 100

int main()
{
    int n;
    scanf("%d",&n);
    char s[large];
    scanf("%s",&s);

    int sumw[large]={};
    int sume[large]={};
    if(s[0]=='E') sume[0]++;
    else sumw[0]++;
    for(int i=1;i<n;i++)
    {
        if(s[i]=='E')
        {
            sume[i]=sume[i-1]+1;
            sumw[i]=sumw[i-1];
        }
        else
        {
            sume[i]=sume[i-1];
            sumw[i]=sumw[i-1]+1;
        }
    }
    int min=INT_MAX;
    for(int i=0;i<n;i++)
    {
        int sum;
        if(i==0) sum=sume[n-1]-sume[i];
        else if(i==n-1) sum=sumw[i-1]; 
        else sum=sumw[i-1]+sume[n-1]-sume[i];
        // sum=sumw[i-1]+sume[n-1]-sume[i];

        if(sum<min) min=sum;
    }
    printf("%d\n",min);
}

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

using namespace std;

int main()
{
	int X, N;
	cin >> X >> N;
	vector<int> num(105, 0);
	for (int i = 0; i < N; i++)
	{
		int a;
		cin >> a;
		num[a] = 1;
	}

	int mini = 1000;
	int ans = 0;
	for (int i = 0; i < 105 ; i++)
	{
		if (!num[i]) {
			if(mini > abs(i-X)){
				mini = abs(i-X);
				ans = i;
				
			}
		}
	}
	cout << ans << endl;





	return 0;
}

Measured memory_bytes: 3572
n , m = map(int , input().split())
A = list(map(int , input().split()))
B_C = []
for i in range(m):
    b , c = map(int , input().split())
    B_C.append([b , c])
A.sort()
B_C.sort(key = lambda x : -x[1])
k = 0
for b , c in B_C:
    for i in range(k ,min( k + b, n)):
        A[i] = max(A[i] , c)
    k += b
print(sum(A))

Measured memory_bytes: 28744
//Link : https://atcoder.jp/contests/arc101/tasks/arc101_c

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 5010
#define mod 1000000007

int add(int x,int y) {
  int ret = ((x+y)%mod + mod)%mod;
  return ret;
}
int mul(int x,int y) {
  return (ll)x*y%mod;
}

vector<int> adj[N];

int dp[N][2][N];
int sz[N];

int tmp[2][N];

int m[N];
int getMatching(int n) {
  return m[n];
}
void solveDp(int node,int par) {
  sz[node] = 1;
  dp[node][0][1] = 1;
  for(int i=0;i<adj[node].size();++i) {
    int ch = adj[node][i];
    if( ch== par) {
      continue;
    }

    solveDp(ch,node);

    for(int st=0;st<2;++st) {
      for(int j=0;j<=sz[node]+sz[ch];++j) {
        tmp[st][j] = 0;
      }
    }

    for(int sz1=sz[node];sz1>=0;--sz1) {
      for(int sz2=sz[ch];sz2>=0;--sz2) {
        for(int st1=0;st1<2;++st1) {
          for(int st2=0;st2<2;++st2) {
            tmp[st1^st2][sz1+sz2] = add(tmp[st1^st2][sz1+sz2],
            mul(dp[node][st1][sz1],dp[ch][st2][sz2]));
          }
        }
      }
    }

    for(int st=0;st<2;++st) {
      for(int j=0;j<=sz[node]+sz[ch];++j) {
        dp[node][st][j] = tmp[st][j];
      }
    }
    sz[node] += sz[ch];
  }
  if(sz[node]%2==0) {
    int tmp[2] = {0};
    for(int st = 0;st<2;++st) {
      for(int i=1;i<=sz[node];++i) {
        tmp[st^1] = add(tmp[st^1], -mul(getMatching(i),dp[node][st][i]));
      }
    }
    dp[node][0][0] = add(dp[node][0][0],tmp[0]);
    dp[node][1][0] = add(dp[node][1][0],tmp[1]);
  }
}

void solve() {
  int n;scanf("%d ", &n);
  for(int i=0;i<n-1;++i) {
    int a,b;
    scanf("%d %d ", &a,&b);
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  m[0] = 1;
  for(int i=2;i<N;i+=2) {
    m[i] = mul(m[i-2],i-1);
  }
  solveDp(1,0);
  int ret = 0;
  for(int st=0;st<2;++st) {
    for(int i=1;i<=n;++i) {
      ret = add(ret, mul(getMatching(i), dp[1][st][i]));
    }
  }
  cout<<ret<<endl;
}

int main() {
    //freopen("input.txt","r",stdin);
    solve();
    return 0;
}


Measured memory_bytes: 195712
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader input =new BufferedReader(new InputStreamReader(System.in));
        String[] inputs = input.readLine().split(" ");
        int a = Integer.parseInt(inputs[0]);
        int b = Integer.parseInt(inputs[1]);
        int c = Integer.parseInt(inputs[2]);
        if ((b-a) == (c-b)) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
}


Measured memory_bytes: 23508
import Control.Monad
import Data.List
import Data.Maybe

main = do
    n<-readLn::IO Int
    (xyhs, xyzs)<-partition (\(_:_:h:_)->h>0) <$> replicateM n (map read.words<$>getLine) ::IO ([[Int]],[[Int]])
    let Just (Just h,(x,y)) = find (chkz xyzs) $ map (f xyhs) [(cx,cy)|cx<-[0..100],cy<-[0..100]]
    putStrLn $ unwords $ map show [x,y,h]
--
f xyhs (cx,cy) = (chk $ map (g cx cy) xyhs, (cx,cy))
g cx cy (x:y:h:_) = h+ abs(x-cx)+ abs(y-cy)

chk [h] = Just h
chk (a:b:hs)
    | a==b = chk (b:hs)
    | otherwise = Nothing
--
chkz _ (Nothing, _) = False
chkz xyzs (Just h,(x,y)) = all (\(u:v:_) -> (h-abs(u-x)-abs(v-y)) <=0) xyzs

Measured memory_bytes: 1020
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        while (scan.hasNextInt()) {
            int a = scan.nextInt();
            int b = scan.nextInt();
            int sum = a+b;
            int length = (int) (Math.log10(sum) + 1);
            System.out.println(length);
        }
    }
}

Measured memory_bytes: 26268
n=int(input())
XL=[]
for _ in range(n):
    XL.append(list(map(int,input().split())))
XL.sort()
ans=n
right=XL[0][0]+XL[0][1]
for i in range(n-1):
    if right<=XL[i+1][0]-XL[i+1][1]:
        right=XL[i+1][0]+XL[i+1][1]
    else:
        if right<=XL[i+1][0]+XL[i+1][1]:
            ans-=1
        else:
            ans-=1
            right=XL[i+1][0]+XL[i+1][1]
print(ans)

Measured memory_bytes: 27896
// --https://kenkoooo.com/atcoder/#/table/soma62jp
#include <iostream>
#include <string>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cstring>

using namespace std;

int main(int argc, char* argv[]) {

	int A, B, ans = 1;
	string S;

	cin >> A >> B;
	cin >> S;

	if (S[A] != '-') {
		ans = 0;
	}

	for (int i = 0; i < S.length(); i++) {
		if (i == A)
			continue;
		if (!(S[i] >= '0' && S[i] <= '9')) {
			ans = 0;
		}
	}

	if (ans) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}



Measured memory_bytes: 256
N = int(input())
stage = list(map(int, input().split(" ")))

INF = float('inf')
DP = [INF for i in range(N)]

for i in range(N):
    if i == 1:
        DP[i] = abs(stage[i] - stage[i-1])
    elif i == 2:
        DP[i] = min(abs(stage[i] - stage[i-2]), DP[i-1] + abs(stage[i] - stage[i-2]))
    else:
        DP[i] = min(DP[i-1] + abs(stage[i] - stage[i-1]), DP[i-2] + abs(stage[i] - stage[i-2]))

print(DP[N-1])

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

constexpr long long MOD = 1'000'000'007;

class binomial_coefficients {
	long long MAX_VAL;
	vector<long long> fac, mmi;

public:

	binomial_coefficients(){
	}
	
	binomial_coefficients(long long num){
		init(num);
	}
	
	~binomial_coefficients(){
		
	}
	
	void init(long long num){
		MAX_VAL = num+1; 
		fac.resize(MAX_VAL);
		mmi.resize(MAX_VAL);
		
		factorial_mod();
		modular_multiplicatibe_inverse();
	}
	
	void factorial_mod(){
		 fac[0] = 1;
		for(long long i = 1; i < MAX_VAL; fac[i] %= MOD, i++)
			fac[i] = fac[i - 1] * (i % MOD);
	}
	
	long long power(long long x, long long n){
		long long ans = 1;
		for(;n;n >>= 1, x *= x, ans %= MOD, x %= MOD)
			if(n&1)ans*=x;
		return ans % MOD;
	}
	
	void exgcd(long long a, long long b, long long &x, long long &y){
		if(b == 0){
			x = 1;
			y = 0;
			return ;
		}
		exgcd(b, a % b, y, x);
		y -= a / b * x;
	}
	
	void modular_multiplicatibe_inverse(){
		long long x, y;  
		exgcd(fac[MAX_VAL - 1], MOD, x, y);
		mmi[MAX_VAL-1] = (x % MOD + MOD) % MOD;
		// mmi[MAX_VAL-1] = power(fac[MAX_VAL-1], MOD-2);
		for(long long i = MAX_VAL - 2; i >= 0; mmi[i]%=MOD, i--)
			mmi[i] = mmi[i + 1] * ((i + 1) % MOD);
	}
	
	long long combination(long long n, long long r){
		return r < 0 ? 0 :n < r ? 0 :fac[n] * (mmi[r] * mmi[n-r] % MOD) % MOD;
	}
};


int main(){
	
	long long n, k;
	long long ans = 0;
	binomial_coefficients bc;
	vector<vector<long long>> dp;
	
	cin>>n>>k;
	
	bc.init(n+k);
	dp.resize(k+1, vector<long long>(n+2));
	
	
	dp[0][0] = 1;
	
	for(int i = 1; i <= k; i++){
		for(int j = 0; j <= n; j++){
			dp[i][j] = dp[i-1][j];
			if(j >= i) dp[i][j] += dp[i][j-i];
			dp[i][j] %= MOD;
		}
	}
	
	ans = dp[k][n];
	
	cout<<ans<<endl;
}


Measured memory_bytes: 10748
gray, brown, green, sky_blue, blue, yellow, orange, red = [0] * 8
N = int(input())
alist = list(map(int, input().split()))
free = 0
for a in alist:
    if 1 <= a <= 399:
        gray += 1
    elif 400 <= a <= 799:
        brown += 1
    elif 800 <= a <= 1199:
        green += 1
    elif 1200 <= a <= 1599:
        sky_blue += 1
    elif 1600 <= a <= 1999:
        blue += 1
    elif 2000 <= a <= 2399:
        yellow += 1
    elif 2400 <= a <= 2799:
        orange += 1
    elif 2800 <= a <= 3199:
        red += 1
    else:
        free += 1
colors = [color for color in [gray, brown, green, sky_blue, blue, yellow, orange, red] if color > 0]
print(max(1, len(colors)), len(colors) + free)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int main()
{
    ll n{};
    cin>>n;
    n++;
    ll A[n]{};
    ll B[n]{};
    ll C[n-1]{};
    for(ll i=1;i<n;i++){
        cin>>A[i];
    }
    for(ll i=1;i<n;i++){
        cin>>B[i];
    }
    for(ll i=1;i<n-1;i++){
        cin>>C[i];
    }
    ll sum = B[A[1]];
    for(ll i=2;i<n;i++){
        sum+=B[A[i]];
        if(A[i]==A[i-1]+1){
            sum+=C[A[i-1]];
        }
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 764
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <numeric>
typedef long long Int;
#define rep(i,a,b) for(Int i=a;i<b;++i)
#define rrep(i,a,b) for(Int i=a;i>=b;--i)
using namespace std;

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

  	string S; cin >> S;
    int res = 0;
    rep(i, 0, S.size()) {
        if (S[i] == '+') ++res;
        else --res;
    }
    
    cout << res << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
template <class T> int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define popcount __builtin_popcount

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

template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

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


const int MAX = 1000000;
bool is_prime[MAX + 10];
//int key(int n)
//{
//	vector<int> p;
//	for (int i = 2; i <= n; ++i)
//		if (is_prime[i] && n % i == 0)
//			p.push_back(i);
//	return 2 * p.back() - accumulate(all(p), 0);
//}
int key(int n)
{
	int sum = 0, last;
	for (int i = 2; i <= n; ++i)
		if (is_prime[i] && n % i == 0)
			sum += i, last = i;
	return 2*last - sum;
}
int main()
{
	fill_n(is_prime, MAX, true);
	for (int i = 2; i*i <= MAX; ++i)
		if (is_prime[i])
			for (int j = 2*i; j <= MAX; j += i)
				is_prime[j] = false;

	int a, b;
	while (scanf("%d%d", &a, &b), a | b)
		puts(key(a) > key(b) ? "a" : "b");
}

Measured memory_bytes: 1816
def fact(n, mod)
  f = 1
  n.downto(1){|i|
    f = (f * i) % mod
  }
  f
end

N, M = gets.chomp.split(" ").map(&:to_i)
MOD = 10 ** 9 + 7

if (N-M).abs > 1 then
  puts 0
elsif N == M then
  wk = fact(N, MOD)
  puts (2 * wk * wk) % MOD
else
  w = [N, M].min
  wk = fact(w, MOD)
  puts ((w+1) * wk * wk) % MOD
end


Measured memory_bytes: 1788
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
input:
5
0 3 2 3 3 1 1 2
1 2 0 2 3 4
2 3 0 3 3 1 4 1
3 4 2 1 0 1 1 4 4 3
4 2 2 1 3 3

output:
0 0
1 2
2 2
3 1
4 3
"""

import sys
import heapq as hp

WHITE, GRAY, BLACK = 0, 1, 2
D_MAX = int(1e7 + 1)


def generate_adj_matrix(v_info):
    for v_detail in v_info:
        v_index = int(v_detail[0])
        v_adj_length = int(v_detail[1])
        v_adj_list = v_detail[2:]
        # assert len(v_adj_list) == v_adj_length * 2
        for j in range(0, v_adj_length * 2, 2):
            init_adj_matrix[v_index][int(v_adj_list[j])] = int(v_adj_list[j + 1])

    return init_adj_matrix


def dijkstra_path():
    # path search init
    start_vertex_index = 0
    path_list[start_vertex_index] = 0
    path_heap = []
    # heapq: compare by tuple[0]
    hp.heappush(path_heap, (path_list[start_vertex_index], start_vertex_index))
    while len(path_heap) >= 1:
        current_vertex_index = hp.heappop(path_heap)[1]

        color[current_vertex_index] = BLACK

        for adj_vertex_index in range(vertices_num):
            current_adj_weight = adj_matrix[current_vertex_index].get(adj_vertex_index, -1)
            if current_adj_weight < 0:
                continue
            elif color[adj_vertex_index] is not BLACK:
                # d[u] + w[u,v]
                alt_path = path_list[current_vertex_index] + current_adj_weight
                if alt_path < path_list[adj_vertex_index]:
                    # update path_list
                    path_list[adj_vertex_index] = alt_path
                    # update heap
                    hp.heappush(path_heap, (alt_path, adj_vertex_index))
                    parent_list[adj_vertex_index] = current_vertex_index
                    color[adj_vertex_index] = GRAY

    return path_list


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    vertices_num = int(_input[0])
    init_vertices_table = list(map(lambda x: x.split(), _input[1:]))
    # assert len(init_vertices_table) == vertices_num

    parent_list, path_list = [-1] * vertices_num, [D_MAX] * vertices_num
    color = [WHITE] * vertices_num
    init_adj_matrix = tuple(dict() for _ in range(vertices_num))
    adj_matrix = generate_adj_matrix(init_vertices_table)
    ans = dijkstra_path()
    for i, v in enumerate(ans):
        print(i, v)

Measured memory_bytes: 8908
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while(true){
			int[] arr = parceIntArray(br.readLine().split(" "));
			Score score = new Score(arr[0], arr[1], arr[2]);
			if(score.equals(new Score(-1, -1, -1))){
				break;
			}else{
				System.out.println(score.getGrade());
			}
		}
	}
	
	private static int[] parceIntArray(String[] strArr){
		int[] arr = new int[strArr.length];
		for(int i = 0;i < arr.length;i++){
			arr[i] = Integer.parseInt(strArr[i]);
		}
		return arr;
	}
}

class Score {
	int midterm;
	int term;
	int makeUp;

	Score(int midterm, int term, int makeUp) {
		this.midterm = midterm;
		this.term = term;
		this.makeUp = makeUp;
	}

	String getGrade() {
		int finalScore = midterm + term;
		String result;
		if (midterm == -1 || term == -1 || finalScore < 30) {
			result = "F";
		} else if (finalScore < 50) {
			if (makeUp >= 50) {
				result = "C";
			} else {
				result = "D";
			}
		}else if(finalScore < 65){
			result = "C";
		}else if(finalScore < 80){
			result = "B";
		}else{
			result = "A";
		}
		return result;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + makeUp;
		result = prime * result + midterm;
		result = prime * result + term;
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Score other = (Score) obj;
		if (makeUp != other.makeUp)
			return false;
		if (midterm != other.midterm)
			return false;
		if (term != other.term)
			return false;
		return true;
	}
	
}

Measured memory_bytes: 16972
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <limits>
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define int_INF 2147483647
#define pint_INF 2000000000
#define ll_INF 	9223372036854775807
#define MOD 1000000007
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvll vector<vector<long long>>
#define vvc vector<vector<char>>
#define vll vector<long long>
#define pii pair<int,int>
#define vpii vector<pair<int,int>>
#define sysp system("PAUSE")
#define pno cout << "no" << endl
#define pyes cout << "yes" << endl
#define pYes cout << "Yes" << endl
#define pNo cout << "No" << endl
#define pNO cout << "NO" << endl
#define pYES cout << "YES" << endl
#define endl "\n"
#define pi 3.14159265358979
using namespace std;
using ll = long long;

int main() {
	ll K; cin >> K;
	ll temp = 1;
	ll res = -1;
	for (ll n = 1; n <= K; n++) {
		ll num = 7 * temp;
		if (num % K == 0) {
			res = n; break;
		}
		temp = 10 * temp + 1;
		temp %= K;
	}

	if (res < 0) {
		cout << -1 << endl;
	}
	else {
		cout << res << endl;
	}

}

Measured memory_bytes: 3576
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<ctime>
#include<map>
#include<bitset>
#include<set>
#include<assert.h>
#define LL long long
#define mp(x,y) make_pair(x,y)
#define pll pair<long long,long long>
#define pii pair<int,int>
#define SZ(x) ((int)x.size())
using namespace std;
inline LL read()
{
	LL f=1,x=0;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int stack[20];
template<typename T>inline void write(T x)
{
	if(x<0){putchar('-');x=-x;}
    if(!x){putchar('0');return;}
    int top=0;
    while(x)stack[++top]=x%10,x/=10;
    while(top)putchar(stack[top--]+'0');
}
template<typename T>inline void pr1(T x){write(x);putchar(' ');}
template<typename T>inline void pr2(T x){write(x);putchar('\n');}
template<typename T>inline void chkmin(T &x,T y){x=x<y?x:y;}
template<typename T>inline void chkmax(T &x,T y){x=x>y?x:y;}
const int MAXN=8005;
const int MAXM=205;
const int mod=998244353;
int pow_mod(int a,int b)
{
	int ret=1;
	for(;b;b>>=1,a=1LL*a*a%mod)if(b&1)ret=1LL*ret*a%mod;
	return ret;
}
vector<int> wn[2][25];
void init()
{
	for(int i=1,t=0;i<MAXN*4;i<<=1,++t)
	{
		int w1=pow_mod(3,(mod-1)/(i<<1)),w2=pow_mod(w1,mod-2);
		for(int j=0,u=1,v=1;j<i;j++,u=1LL*u*w1%mod,v=1LL*v*w2%mod)
			wn[0][t].emplace_back(u),wn[1][t].emplace_back(v);
	}
}
int R[MAXN*4],L;
void NTT(int *y,int len,int on)
{
	for(int i=0;i<len;i++)if(i<R[i])swap(y[i],y[R[i]]);int g=(on==-1?1:0);
	for(int i=1,t=0;i<len;i<<=1,++t)for(int j=0;j<len;j+=(i<<1))for(int k=0;k<i;k++)
	{
		int u=y[j+k],v=1LL*y[j+k+i]*wn[g][t][k]%mod;
		y[j+k]=(u+v)%mod;y[j+k+i]=(u-v+mod)%mod;
	}if(on==-1)for(int i=0,temp=pow_mod(len,mod-2);i<len;i++)y[i]=1LL*y[i]*temp%mod;
}
int pre[MAXN],inv[MAXN];
int C(int n,int m){return n<m?0:1LL*pre[n]*inv[m]%mod*inv[n-m]%mod;}
int n,m,f[MAXM][MAXN*4],A[MAXN*4],B[MAXN*4];
void ad(int &x,int y){x+=y;if(x>=mod)x-=mod;}
void dl(int &x,int y){x-=y;if(x<0)x+=mod;}
int main()
{
	pre[0]=1;for(int i=1;i<MAXN;i++)pre[i]=1LL*pre[i-1]*i%mod;
	inv[MAXN-1]=pow_mod(pre[MAXN-1],mod-2);
	for(int i=MAXN-2;i>=0;i--)inv[i]=1LL*inv[i+1]*(i+1)%mod;
	init();n=read();m=read();
	for(int i=0;i<=n;i++)f[m][i]=C(n,i);
	for(int i=m-1;i>=0;i--)
	{
		for(int j=0;j<=n;j++)
		{
			ad(f[i][j],1LL*f[i+1][j]*C(j+1,2)%mod);ad(f[i][j],f[i+1][j]);
//			for(int k=j+1;k<=n;k++)ad(f[i][j],1LL*f[i+1][k]*C(k+2,k+2-j)%mod);
		}
		memset(A,0,sizeof(A));memset(B,0,sizeof(B));
		for(int j=0;j<=n;j++)B[j+2]=1LL*f[i+1][j]*pre[j+2]%mod;
		for(int j=3;j<=n+2;j++)A[j]=inv[j];reverse(A,A+1+(n+2));int ln;L=0;
		for(ln=1;ln<=2*(n+2);ln<<=1)++L;
		for(int j=0;j<ln;j++)R[j]=(R[j>>1]>>1)|(j&1)<<(L-1);
		NTT(B,ln,1);NTT(A,ln,1);
		for(int j=0;j<ln;j++)A[j]=1LL*A[j]*B[j]%mod;NTT(A,ln,-1);
		for(int j=0;j<=n;j++)ad(f[i][j],1LL*A[j+n+2]*inv[j]%mod);
	}
	pr2(f[0][0]);
	return 0;
}


Measured memory_bytes: 24320
open Str

let binary_search ar n x =
  let rec search l r =
    if l >= r then false else
      let m = (l + r) / 2 in
      if ar.(m) = x then true
      else if ar.(m) < x then search (m+1) r
      else search l m
  in search 0 n
           
let read_array f =
  split (regexp " +") (read_line ()) |> List.map f |> Array.of_list

let read_list f =
  split (regexp " +") (read_line ()) |> List.map f
                                                 
let () =
  let n = read_int () in
  let s = read_array int_of_string in
  let _ = read_line () in
  let t = read_list int_of_string in
  List.fold_left (fun c x -> if binary_search s n x then c+1 else c) 0 t |> string_of_int |> print_endline

Measured memory_bytes: 16120
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(v) v.begin(), v.end()

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

    double ans=0;

    for(int i=1; i<=n; i++){
        int tmp=i;
        double counti = 1.0/n;

        while(tmp < k){
            tmp *= 2;
            counti /= 2;
        }

        ans += counti;

    }

    cout << fixed << setprecision(15);
    cout << ans << endl;
}


Measured memory_bytes: 3736