akhauriyash/Code-Regression huggingface dataset:
INPUT_SENTENCES = 1                                                                                                                                                                                                 
ss = [input() for i in range(INPUT_SENTENCES)][0].split(" ")                                                                                                                                                        
N = int(ss[0])                                                                                                                                                                                                      
D = int(ss[1])                                                                                                                                                                                                      
result = []                                                                                                                                                                                                         
s = 0                                                                                                                                                                                                               
cnt = 0                                                                                                                                                                                                             
for i in range(N):                                                                                                                                                                                                  
    s += 2*D+1                                                                                                                                                                                                      
    cnt += 1                                                                                                                                                                                                        
    if s >= N:                                                                                                                                                                                                      
        break                                                                                                                                                                                                       
print(cnt)

Measured memory_bytes: 3316
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int H = sc.nextInt();
			if (H == 0) {
				sc.close();
				break;
			}
			int W = sc.nextInt();
			long L = sc.nextLong();
			int[][] dir = { { -1, 0 }, { 0, 1 }, { 1, 0 }, { 0, -1 } };// 北、東、南、西
			char[][] maze = new char[H][];
			for (int i = 0; i < maze.length; i++) {
				maze[i] = sc.next().toCharArray();
			}

			HashMap<Integer, ArrayList<Integer>> hashMap = new HashMap<Integer, ArrayList<Integer>>();
			// <前のマス, 次のマス>
			int now = 0;
			int d = 0;// 向き N:0, E:1, S:2, W:3
			for (int i = 0; i < maze.length; i++) {
				for (int j = 0; j < maze[i].length; j++) {
					if (maze[i][j] != '#' && maze[i][j] != '.') {
						now = i * 100 + j;
						if (maze[i][j] == 'N') {
							d = 0;
						} else if (maze[i][j] == 'E') {
							d = 1;
						} else if (maze[i][j] == 'S') {
							d = 2;
						} else if (maze[i][j] == 'W') {
							d = 3;
						}
					}
				}
			}

			boolean rec = false;
			while (L > 0) {
				int x = now / 100;
				int y = now - x * 100;
				x += dir[d][0];
				y += dir[d][1];
				if (x < 0 || x >= H || y < 0 || y >= W || maze[x][y] == '#') {
					d = (d + 1) % 4;
					continue;
				}

				int next = x * 100 + y;
				L--;
				if (hashMap.get(now) == null) {
					hashMap.put(now, new ArrayList<Integer>());
					hashMap.get(now).add(next);
				} else if (hashMap.get(now).contains(next) && rec) {
					int size = 0;
					for (Map.Entry<Integer, ArrayList<Integer>> e : hashMap.entrySet()) {
						size += e.getValue().size();
					}
					L = L % size;
					hashMap.clear();
				} else if (hashMap.get(now).contains(next)) {
					hashMap.clear();
					hashMap.put(now, new ArrayList<Integer>());
					hashMap.get(now).add(next);
					rec = true;
				} else {
					hashMap.get(now).add(next);
				}
				now = next;
			}

			int x = now / 100;
			int y = now - x * 100;
			char face = '.';
			if (d == 0) {
				face = 'N';
			} else if (d == 1) {
				face = 'E';
			} else if (d == 2) {
				face = 'S';
			} else if (d == 3) {
				face = 'W';
			}

			System.out.println((x + 1) + " " + (y + 1) + " " + face);
			System.gc();
		}

	}
}

Measured memory_bytes: 58920
# Xは正の整数, pは非負整数, A[k]は偶数
# X == A[k] * (p + 0.5)
# X == A[k]//2 * (2*p + 1)
# X / (A[k]//2) == 2*p + 1
# X % (A[k]//2) == 0 and count_div_two(X) == count_div_two(A[k]//2)

# 全てのcount_div_twoが同じ
# M//最小公倍数 / 2 (切り上げ)

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

# c = 0
# for i in range(1, M+1):
#     print(i, [i/a for a in A])
#     if all(i/a-i//a == 0.5 for a in A):
#         c += 1

# print(c)

def gcd(a, b):
    if a > b:
        a, b = b, a
    if a == 0:
        return b
    return gcd(b%a, a)
def lcm(a, b):
    return (a*b) // gcd(a, b)
def count_div_two(x):
    c = 0
    while x%2 == 0:
        x //= 2
        c += 1
    return c

b = [a//2 for a in A]

if len(set(count_div_two(b_i) for b_i in b)) > 1:
    print(0)
    exit()

b_lcm = 1
for b_i in b:
    b_lcm = lcm(b_lcm, b_i)

c = M//b_lcm
print(-(-c//2))

Measured memory_bytes: 14244
from collections import deque

n,limit = map(int,input().split())
total_time = 0
queue = deque()
for _ in range(n):
    p,t = input().split()
    queue.append([p,int(t)])

while len(queue) > 0:
    head = queue.popleft()
    if head[1] <= limit:
        total_time += head[1]
        print('{} {}'.format(head[0],total_time))
    else:
        head[1] -= limit
        total_time += limit
        queue.append(head)


Measured memory_bytes: 13272
#include<cstdio>
#include<bits/stdc++.h>
#define fi first
#define sc second
#define pb push_back

#define mp make_pair

using namespace std;
 
typedef pair<int, int> pi;
 
int R, C, dr[4] = {-1, 0, 1, 0}, dc[4] = {0, 1, 0, -1};
int dist[55][55];
int parr[55][55], parc[55][55];
char grid[55][55];
bool path[55][55];
int bfs() {
	memset(dist, -1, sizeof(dist));
	dist[0][0] = 0;
	queue<pi> q;
	q.push(mp(0, 0));
	while (!q.empty() && dist[R-  1][C - 1] == -1) {
		pi curr = q.front(); q.pop();
		for (int i = 0; i < 4; i++) {
			if (curr.fi + dr[i] < 0 || curr.fi + dr[i] >= R) continue;
			if (curr.sc + dc[i] < 0 || curr.sc + dc[i] >= C) continue;
			if (grid[curr.fi + dr[i]][curr.sc + dc[i]] == '#') continue;
			if (dist[curr.fi + dr[i]][curr.sc + dc[i]] != -1) continue; 
			dist[curr.fi + dr[i]][curr.sc + dc[i]] = dist[curr.fi][curr.sc] + 1;
			q.push(mp(curr.fi + dr[i], curr.sc + dc[i]));
			parr[curr.fi + dr[i]][curr.sc + dc[i]] = curr.fi;
			parc[curr.fi + dr[i]][curr.sc + dc[i]] = curr.sc;
		}
	}
	if (dist[R-  1][C - 1] != -1) {
		int r = R - 1, c = C - 1;
		path[r][c] = true;
		while (r != 0 || c != 0) {
			path[r][c] = true;
			int nxr = parr[r][c];
			int nxc = parc[r][c];  
			r = nxr; c = nxc; 
		} 
		path[0][0] = true;
	}
	return dist[R - 1][C - 1];
}
int main() {  
	scanf("%d %d", &R, &C);
	for (int i = 0; i < R; i++) {
		scanf(" %s", grid[i]);
	}
	int ans = bfs();
	if (ans == -1) cout << -1 << endl;
	else {
		int score = 0;
		for (int i = 0; i < R; i++) {
			for (int j = 0; j < C; j++) {
				if (i == 0 && j == 0) continue;
				if (i == R - 1 && j == C  - 1) continue;
				if (path[i][j]) continue;
				if (grid[i][j] == '#') continue; 
				score++;
			}
		}
		cout << score << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#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()
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

int main() 
{
  int n; cin >> n;
  cout << "ABC" << n << endl;
  system("pause");
}

Measured memory_bytes: 504
#include<bits/stdc++.h>
#define p 1000000007
using namespace std;
long long n,ans;
map<long long,long long> dp;// dp内 表示n值的方案数 进行记忆化压缩路径 
/*
对于任意一组a b 可以递推出另三组a b 

u*2 v*2
u*2 v*2+2
u*2+1 v*2+1

即在a b 后面加上 0 0,1 0,1 1三组数字
 
如  当一组解  a=10  b=01   u=11 v=11
可以递推出 
a1=10 0
b1=01 0
u1=110 u1=u*2 
v1=110 v1=v*2 

a2=10 1
b2=01 0
u2=111 u2=u*2+1 
v2=111 v2=v*2+1

a3=10 1
b3=01 1
u3=110 u3=u*2
v3=1000 v3=v*2+2 

据此可以递归出其他答案 
*/ 
long long solve(long long x){
	if(dp[x])return dp[x];//记忆化 
	return dp[x]=(solve((x>>1))+solve((x-2)>>1)+solve((x-1)>>1))%p;//压缩路径 
}
int main(){
	cin>>n;
	dp[1]=2;
	dp[0]=1;
	ans=solve(n);
	printf("%lld",ans);
	return 0;
}

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

template <class T> using V = vector<T>;
template <class S, class T> using P = pair<S, T>;
template <class... T> using TP = tuple<T...>;

using ll = long long;
using db = double;
using ldb = long db;
using str = string;
using vll = V<ll>;
using vvll = V<V<ll>>;
using pll = P<ll,ll>;
using tpll = TP<ll,ll,ll>;
using vpll =V<pll>;
using vtpll = V<tpll>;
using vst = V<str>;
using vch = V<char>;

#define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++)
#define rFOR(i,a,b) for(ll i=(b);i>(ll)(a);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) __lcm(a,b)
#define co(a) cout<<a<<endl
#define ci(a) cin>>a
#define pb(a) push_back(a)
#define pob pop_back()
#define mp make_pair
#define mt make_tuple
#define pbmp(a,b) push_back(mp(a,b))
#define subs(a,b) substr(a,b)
#define cfs(a) cout<<fixed<<setprecision(a)
#define INF 1e16
#define mod 1e9+7
//vvll v(n,vll(m)) n行m列
//A.erase(A.begin()+i) 配列Aのi番目を消せる
//std::binary_search(v.bgn,v.en,a);
//abs(a,b)   pow(a,n)  to_string  stoll
//auto Iter=lower_bound(v.bgn,v.en,a);
//lower//upper  co(*Iter)co(Iter-v.bgn);

const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
void Comuse() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
#define comuse Comuse()
ll combi(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
  str s;
  cin>>s;
  ll n=s.sz;
  vll c(3);
  FOR(i,0,n-1){
    if(s[i]!=s[i+1]&&i+1!=n-1){
      c[0]++;
    }
    else if(s[i]==s[i+1]&&i+1!=n-1&&i+1!=n-3){
      i+=2;
      c[0]+=2;
    }
    else if(s[i]!=s[i+1]&&i+1==n-1){
      c[0]+=2;
    }
    else if(s[i]==s[i+1]&&i+1==n-1){
      c[0]++;
    }
    else if(s[i]==s[i+1]&&i+1==n-3){
      c[0]+=3;
      i+=2;
    }
    //co(i<<" "<<c[0]);
  }
  co(c[0]);
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final long a = scanner.nextInt();
        final long b = scanner.nextInt();
        final long c = scanner.nextInt();

        if (c - (a + b) <= 0) {
            System.out.println("No");
            return;
        }

        if (4 * a * b < c * c - 2 * a * c - 2 * b * c + 2 * a * b + a * a + b * b) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


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

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

Measured memory_bytes: 3628
#include<iostream>
#include <string.h>
#include<stdio.h>
#include <vector>
#include <math.h>


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


int main() {
	ll a, ans,b2,ans2;
	long double b, c;
	cin >> a >> b;
	b2 = 100*b + 0.5;

	
	ans = a * b2;
	ans /= 100;

	

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3148
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define FOR(i,a,n) for(ll i=a;i<(ll)(n);i++)

int main(){
    int N;
    cin>>N;
    int h[N];
    rep(i, N) cin>>h[i];

    int max = h[0];
    int min = h[0];
    int count = 0;
    FOR(i, 1, N){
        max = std::max(max, h[i]);
        min = std::min(min, h[i]);

        if(h[i-1] == h[i]) h[i-1] = max; 

        if(i < N-1 && h[i-1] > h[i] && h[i] < h[i+1]){
            count += max - h[i];
            max = h[i];
            min = h[i];
        }

        if(i == N-1){
            count += max;
        }
    }

    if(N == 1) count = h[0];

    cout << count << endl;
}


Measured memory_bytes: 256
// eddy1021
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef double D;
typedef long double LD;
typedef long long LL;
typedef pair<int,int> PII;
typedef pair<LL,LL> PLL;
#define mod9 1000000009LL
#define mod7 1000000007LL
#define INF  1023456789LL
#define INF16 10000000000000000LL
#define eps 1e-9
#define SZ(x) (int)(x).size()
#define ALL(x) (x).begin(), (x).end()
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#ifndef ONLINE_JUDGE
#define debug(...) printf(__VA_ARGS__)
#else 
#define debug(...)
#endif
inline LL getint(){
  LL _x=0,_tmp=1; char _tc=getchar();    
  while( (_tc<'0'||_tc>'9')&&_tc!='-' ) _tc=getchar();
  if( _tc == '-' ) _tc=getchar() , _tmp = -1;
  while(_tc>='0'&&_tc<='9') _x*=10,_x+=(_tc-'0'),_tc=getchar();
  return _x*_tmp;
}
inline LL add( LL _x , LL _y , LL _mod = mod7 ){
  _x += _y;
  return _x >= _mod ? _x - _mod : _x;
}
inline LL sub( LL _x , LL _y , LL _mod = mod7 ){
  _x -= _y;
  return _x < 0 ? _x + _mod : _x;
}
inline LL mul( LL _x , LL _y , LL _mod = mod7 ){
  _x *= _y;
  return _x >= _mod ? _x % _mod : _x;
}
LL mypow( LL _a , LL _x , LL _mod ){
  if( _x == 0 ) return 1LL;
  LL _ret = mypow( mul( _a , _a , _mod ) , _x >> 1 , _mod );
  if( _x & 1 ) _ret = mul( _ret , _a , _mod );
  return _ret;
}
LL mymul( LL _a , LL _x , LL _mod ){
  if( _x == 0 ) return 0LL;
  LL _ret = mymul( add( _a , _a , _mod ) , _x >> 1 , _mod );
  if( _x & 1 ) _ret = add( _ret , _a , _mod );
  return _ret;
}
inline bool equal( D _x ,  D _y ){
  return _x > _y - eps && _x < _y + eps;
}
#define Bye exit(0)
int __ = 1 , _cs;
/*********default*********/
#define N 101010
int fac[ N ] , inv[ N ];
void build(){
  fac[ 0 ] = inv[ 0 ] = 1;
  for( int i = 1 ; i < N ; i ++ ){
    fac[ i ] = mul( fac[ i - 1 ] , i );
    inv[ i ] = mypow( fac[ i ] , mod7 - 2 , mod7 );
  }
}
int C( int a , int b ){
  return mul( fac[ a ] , mul( inv[ b ] , inv[ a - b ] ) );
}
int n , a[ N ] , cc[ N ];
int fst , snd;
void init(){
  n = getint();
  for( int i = 1 ; i <= n + 1 ; i ++ ){
    a[ i ] = getint();
    cc[ a[ i ] ] ++;
  }
  int who = 0;
  for( int i = 1 ; i <= n ; i ++ )
    if( cc[ i ] > 1 )
      who = i;
  for( int i = 1 ; i <= n + 1 ; i ++ )
    if( a[ i ] == who ){
      if( fst == 0 ) fst = i;
      else snd = i;
    }
}
void solve(){
  for( int i = 1 ; i <= n + 1 ; i ++ ){
    int ans = C( n + 1 , i );
    int lft = fst - 1;
    int rgt = n + 1 - snd;
    if( lft + rgt + 1 >= i )
      ans = sub( ans , C( lft + rgt , i - 1 ) );
    if( i == 1 ) ans = n;
    printf( "%d\n" , ans );
  }
}
int main(){
  build();
  //__ = getint();
  while( __ -- ){
    init();
    solve();
  }
}


Measured memory_bytes: 2816
import re

S = 'S' + input()
new_s = list(S.replace('BC', 'D'))


cnt = 0
A = 0
for i in range(len(new_s)):
    if new_s[i] == 'A':
        A += 1
    elif new_s[i] == 'D':
        cnt += A
    else:
        A = 0
print(cnt)

Measured memory_bytes: 4900
from heapq import heappop, heappush, heapify
K = int(input())
M = K

que = list(range(1, 10))
V = set()
heapify(que)

while M + 100 >= 0:
    top = heappop(que)
    if top in V:
        continue
    V.add(top)
    M -= 1

    top = str(top)
    L = int(top[0])
    R = int(top[-1])

    for i in (L - 1, L, L + 1):
        if 1 <= i <= 9:
            heappush(que, int(str(i) + top))
    for i in (R - 1, R, R + 1):
        if 0 <= i <= 9:
            heappush(que, int(top + str(i)))

V = [int(d) for d in V]
V.sort()
print(V[K - 1])


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

int main(void){
    int n;
    cin >> n;
    vector<vector<string>> s(8);
    s[3] = {
        "aa.",
        "..b",
        "..b"
    };
    s[4] = {
        "aabd",
        "ffbd",
        "hgcc",
        "hgee"
    };
    s[5] = {
        "aabba",
        "bcc.a",
        "b..cb",
        "a..cb",
        "abbaa"
    };
    s[6] = {
        "aabc..",
        "ddbc..",
        "..aabc",
        "..ddbc",
        "bc..aa",
        "bc..dd"
    };
    s[7] = {
        "aabbcc.",
        "dd.dd.a",
        "..d..da",
        "..d..db",
        "dd.dd.b",
        "..d..dc",
        "..d..dc"
    };
    if (n == 2) {
        cout << -1 << endl;
    } else if (n <= 7) {
        rep(y,n) cout << s[n][y] << endl;
    } else {
        vector<string> t(n, string(n, '.'));
        int a = n/4-1;
        int b = n-a*4;
        rep(i,a)rep(y,4)rep(x,4) {
            t[i*4+y][i*4+x] = s[4][y%4][x%4];
        }
        rep(y,b)rep(x,b){
            t[a*4+y][a*4+x] = s[b][y][x];
        }
        rep(y,n) cout << t[y] << endl;
    }
    return 0;
}


Measured memory_bytes: 2304
/*
AOJ - ITP1_10_b
Date: 20181012
Author: Mikoron * ♡mikoiwate_351♡
*/

#include<stdio.h>
#include<math.h>
#include<stdlib.h>

int main(void) {

        double a, b, c, angle;

        scanf("%lf %lf %lf", &a, &b, &angle);
        angle = angle*M_PI/180;
        c = sqrt((a*a)+(b*b)-(2*a*b*cos(angle)));

        printf("%.7lf\n", (a*b*sin(angle)/2));
        printf("%.7lf\n", a+b+c);
        printf("%.7lf\n", b*sin(angle));

        return 0;
}



Measured memory_bytes: 2140
from math import ceil
S = input()
ans = [0]*len(S)
cnt = 1
tmp = S[0]
pos = 0
for n,i in enumerate(S[1:],1):
    if i == tmp:
        cnt += 1
    if i == 'R' and i != tmp:
        ans[pos] = cnt
        cnt = 1
        tmp = i
    if i == 'L' and i != tmp:
        ans[n] = cnt
        pos = n-1
        cnt = 1
        tmp = i
if i == 'L':
    ans[pos] = cnt
else:
    ans[-1] = cnt
i = 0
while i < len(S):
    if ans[i]:
        ans[i],ans[i+1] = ceil(ans[i+1]/2)+ans[i]//2,ceil(ans[i]/2)+ans[i+1]//2
        i += 2
    else:
        i += 1
print(' '.join(list(map(str,ans))))

Measured memory_bytes: 17064
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

void main() {
    int n = readint;
    writeln((n * (n + 1)) / 2);
}



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

int main()
{
  int X, Y;
  cin >> X >> Y;

  for (int i = 0; i <= X; i++)
  {
    if (i * 2 + (X - i) * 4 == Y)
    {
      cout << "Yes";
      return 0;
    }
  }

  cout << "No";
}

Measured memory_bytes: 3636
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <iomanip>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007
const double PI = acos(0);


//ここから編集する


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

    int N;
    cin >> N;

    vector<pair<double, double> > vp;
    rep(i, 0, N) {
        double x, y;
        cin >> x >> y;
        vp.emplace_back(x, y);
    }

    const int freq = (int) 1e6;
    const double r = 1e11;

    vector<int> cnt(N);

    for (int i = 0; i < freq; ++i) {
        double theta = 4 * PI / freq * i;
        double x = r * cos(theta);
        double y = r * sin(theta);

        int id = -1;

        for (int j = 0; j < vp.size(); ++j) {
            if (id == -1) {
                id = j;
            } else {
                if ((x - vp[j].first) * (x - vp[j].first) + (y - vp[j].second) * (y - vp[j].second) <
                    (x - vp[id].first) * (x - vp[id].first) + (y - vp[id].second) * (y - vp[id].second)) {
                    id = j;
                }
            }
        }

        cnt[id]++;
    }


    cout << fixed << setprecision(9);
    for (int i = 0; i < N; ++i) {
        cout << 1.0 * cnt[i] / freq << endl;
    }


    return 0;
}


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

#define FOR(i, s, e)   for(int i = (s); i < (e); i++)
#define FOR64(i, s, e) for(ll  i = (s); i < (e); i++)
#define ALL(x)         (x).begin(), (x).end()
#define SORT(b, e)     sort((b), (e))
#define REV(b, e)      reverse((b), (e))
#define VSORT(v)       sort((v).begin(), (v).end())
#define VREV(v)        reverse((v).begin(), (v).end())
#define pb(a)          push_back(a)
#define INF            999999999

typedef long long ll;

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

	if(N == 1){
		cout << "Hello World" << endl;
	}
	else{
		int A, B;
		cin >> A >> B;
		cout << A + B << endl;
	}

	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
// #include <atcoder/all> // NOTE: AtCoderライブラリ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
// using namespace atcoder; // NOTE: AtCoderライブラリ
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef pair<int, int> pii;
// #define INF __INT32_MAX__
#define INF 1e9
#define LINF __LONG_LONG_MAX__

int main() {
    int N; cin >> N;
    vector<int> X(N), L(N); rep(i, N) cin >> X[i] >> L[i];
    
    vector<pii> y(N);
    rep(i, N) {
        y[i] = make_pair(X[i] - L[i], X[i] + L[i]);
    }

    sort(y.begin(), y.end(), [](const pii &a, const pii &b) {
        return a.second < b.second;
    });

    int prev = -INF;
    int cnt = 0;
    for (auto a : y) {
        int a1 = a.first;
        int a2 = a.second;

        if (prev <= a1) {
            prev = a2;
            cnt++;
        }
    }

    cout << cnt << endl;
}


Measured memory_bytes: 4772
import sys
from functools import reduce
import copy
import math
from pprint import pprint
import collections
import bisect


sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def int_inputs(num_of_input):
    ins = [int(input()) for i in range(num_of_input)]
    return ins


def solve(inputs):
    [N, T] = string_to_int(inputs[0])
    P = string_to_int(inputs[1])

    count = 0
    prev = 0
    for p in P:
        if p == 0:
            continue
        else:
            if p - prev < T:
                count += p - prev
            else:
                count += T
        prev = p
    count += T
    return count


def string_to_int(string):
    return list(map(int, string.split()))


if __name__ == "__main__":
    ret = solve(inputs(2))
    print(ret)


Measured memory_bytes: 87160
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
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;}

int main() {
    string s,t;
    cin >> s >> t;
    int n = s.size();
    int m = t.size();
    string ans = "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz";
    for(int i = 0;i+m<=n;i++) {
        bool ok = true;
        // tを部分文字列として含むか判定
        rep(j,m) {
            if(s[i+j] == '?') continue;
            if(s[i+j] != t[j]) ok = false;
        }
        if(!ok) continue;
        //t以外の?はaにしてその辞書順最小をとる
        string u = s;
        
        rep(j,m) {
            u[i+j] = t[j];
        }
        rep(j,n) {
            if(u[j] == '?') u[j] = 'a';
        }
        // cout << u << endl;
        ans = min(ans,u);
    }
    if(ans == "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz") {
        cout << "UNRESTORABLE" << endl;
        return 0;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3628
#[macro_use]
mod input {

use std;
use std::io;

const SPLIT_DELIMITER: char = ' ';

#[macro_export]
#[allow(unused_macros)]
macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

#[allow(dead_code)]
pub fn input_line_str() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
pub fn p<T>(t: T)
where
    T: std::fmt::Display,
{
    println!("{}", t);
}

#[allow(dead_code)]
pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
where
    T: std::str::FromStr,
{
    let mut v: Vec<Vec<T>> = Vec::new();

    for _ in 0..line {
        let vec_line = input_vector();
        v.push(vec_line);
    }
    v
}

#[allow(dead_code)]
pub fn input_vector<T>() -> Vec<T>
where
    T: std::str::FromStr,
{
    let mut v: Vec<T> = Vec::new();

    let s = input_line_str();
    let split_result = s.split(SPLIT_DELIMITER);
    for z in split_result {
        let buf = match z.parse() {
            Ok(r) => r,
            Err(_) => panic!("Parse Error"),
        };
        v.push(buf);
    }
    v
}

#[allow(dead_code)]
pub fn str2vec(s: &str) -> Vec<char> {
    let mut v: Vec<char> = Vec::new();
    for c in s.chars() {
        v.push(c);
    }
    v
}
}

use input::*;
use std::collections::HashSet;

fn main() {
    let (a, b, c): (usize, usize, usize);
    input!(a, b, c);
    let mut map = HashSet::new();
    map.insert(a);
    map.insert(b);
    map.insert(c);
    p(map.len());
}

Measured memory_bytes: 4352
package main

import (
	"bufio"
	"fmt"
	"io"
	"log"
	"os"
	"sort"
	"strconv"
)

func main() {
	n, m := readInt(), readFloat64()
	a := make([]float64, n)

	tot := 0.0
	for i := range a {
		a[i] = readFloat64()
		tot += a[i]
	}
	sort.Float64s(a)

	if a[n-int(m)] >= tot/(4*m) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

// sort ------------------------------------------------------------

type xxx struct {
	x int
}

type sortArray []xxx

func (s sortArray) Len() int           { return len(s) }
func (s sortArray) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s sortArray) Less(i, j int) bool { return s[i].x < s[j].x }

// -----------------------------------------------------------------

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	log.SetFlags(log.Lshortfile)
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func gcd(m, n int) int {
	for m%n != 0 {
		m, n = n, m%n
	}
	return n
}

func lcm(m, n int) int {
	return m / gcd(m, n) * n
}


Measured memory_bytes: 1732
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>
#include <numeric>
#include <cctype>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <utility>
#include <fstream>

using namespace std;
typedef long long ll;
using ull = unsigned long long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { a = abs(a), b = abs(b); while (b > 0) { tie(a, b) = make_pair(b, a % b); } return a; }
//mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

constexpr long long INF = 1LL << 60;
constexpr int inf = 1000000007;
//constexpr long long mod = 1000000007LL;
constexpr long long mod = 998244353;
constexpr int MAX = 5000000;

class UnionFind {
public:
	vector<int> Parent;
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}
	int root(int A) {
		if (Parent[A] < 0) {
			return A;
		}
		return Parent[A] = root(Parent[A]);
	}

	long long size(int A) {
		return -(long long)Parent[root(A)];
	}

	bool connect(int A, int B) {
		A = root(A);
		B = root(B);
		if (A == B) {
			return false;
		}
		if (size(A) < size(B)) {
			swap(A, B);
		}

		Parent[A] += Parent[B];
		Parent[B] = A;

		return true;
	}

};
int main()
{

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int n, m; cin >> n >> m;
	UnionFind uni(n);
	int res = 0;
	for (int i = 0; i < m; i++) {
		int u, v; cin >> u >> v;
		u--; v--;
		uni.connect(u, v);
	}
	for (int i = 0; i < n; i++) if (uni.root(i) == i) res++;
	res--;
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 3740
#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>

using namespace std;

typedef long long ll;

int main(){

	double x1,y1,x2,y2,xq,yq;
	while(~scanf("%lf,%lf,%lf,%lf,%lf,%lf",&x1,&y1,&x2,&y2,&xq,&yq)){
		double vx = x2-x1;
		double vy = y2-y1;

		double lb=-10000000.0;
		double ub=10000000.0;
		double cx,cy,vqx,vqy,md;
		for(int i=0;i < 100; i++){
			md = (lb+ub)/2.0;
			cx = x1 + vx*md;
			cy = y1 + vy*md;

			vqx = cx - xq;
			vqy = cy - yq;

			double slope = vx * vqx + vy* vqy;

			if(slope < 0){
				lb = md;
			}
			else if(slope>0){
				ub = md;
			}

			if(abs(slope) < 10e-9){
				printf("%f %f\n",2.0*cx-xq,2.0*cy-yq);
				break;
			}
		}
	}
}

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

using namespace std;

#define ll long long


const int mod = 998244353,MOD=1e9+7;

const int N=3e3;

ll dp[N][N][2];

int n,a[N];


ll solve(int l,int r,int p){
	if (l>r)
		return 0;
	ll &ret = dp[l][r][p];
	if (ret!=-1)
		return ret;
	if (!p)
		return ret=max(a[l]+solve(l+1,r,!p),a[r]+solve(l,r-1,!p));
	else
		return ret=min(solve(l+1,r,!p)-a[l],solve(l,r-1,!p)-a[r]);
}

int main() {
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	scanf("%d",&n);
	memset(dp,-1,sizeof(dp));
	for(int i=0;i<n;i++)
		scanf("%d",&a[i]);
	printf("%lld\n",solve(0,n-1,0));
}


Measured memory_bytes: 141056
#include <iostream>
#include <string>
using namespace std;
int main(void){
    // Your code here!
    int x=0,o=0,n;
    int a[26]={};
    string mozi,s;
    //cin.ignore();
    
    while(cin >> s){
        mozi+=s;
        //getline(cin,mozi);
        //cin.ignore();
    }
    x=mozi.size();
    while(1){
        
        if(o>=x){
            break;
        }
        if((int) mozi[o] >= 97 && (int) mozi[o] <= 122){
            a[(int) mozi[o]-97]+=1;
            
        }else if((int)mozi[o]>=65&&(int)mozi[o]<=90){
            a[(int)mozi[o]-65]+=1;
        }else{
            //cout<<"F";
        }
        
       
        
        
        o+=1;
    }
    for(int i=0;i<26;i++){
        cout<<char((char)97 + i)<<" : "<<a[i]<<endl;
    }
    return 0;
}



Measured memory_bytes: 3204
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
#include<map>
#include<unordered_map>
#include <queue>
 
using namespace std;
using ll=long long;
#define rep(i,n)  for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

int main(){
    int m, d;
    cin >> m >> d;

    int ans = 0;
    for(int i=1; i<=d; ++i){
        if(i/10<2||i%10<2)continue;
        int seki = (i/10)*(i%10);
        if(seki<=m&&seki>=1)ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin >> a >> b;
  cout << a-b+1;
  /*
  if(strlen(a)==3)cout << a[2] << a[1] << a[0];
  else cout << a;
  /*
  int n;
  cin >> n;
  int a[n],r[n],b[n],p=0,q=0;
  char s[n];
  for(int i=0;i<n;i++){
    r[i]=99999999;
    b[i]=99999999;
  }
  for(int i=0;i<n;i++){
    cin >> a[i] >> s[i];
    if(s[i]=='R'){
      r[p]=a[i];
      p++;
    }
    else{
      b[q]=a[i];
      q++;
    }
  }
  sort(r,r+n);
  sort(b,b+n);
  for(int i=0;i<n;i++){
    if(r[i]==99999999)break;
    cout << r[i] << endl;
  }
  for(int i=0;i<n;i++){
    if(b[i]==99999999)break;
    cout << b[i] << endl;
  }
  */
}


Measured memory_bytes: 256
A=[tuple(map(int, input().split())) for _ in range(3)]
N=int(input())
B=[int(input())for _ in range(N)]
C=[[False]*3 for _ in range(3)]
for b in B:
    for i in range(3):
        for j in range(3):
            if A[i][j]==b:
                C[i][j]=True
ans=False
for i in range(3):
    ans|=all(C[i][j] for j in range(3))
    ans|=all(C[j][i] for j in range(3))
ans|=all(C[j][j] for j in range(3))
ans|=all(C[2-j][j] for j in range(3))
print("YNeos"[not ans::2])

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mod 1000000007
#define wi while
#define vl vector<ll>
#define vi vector<int>
#define map map<char,ll>
#define endl "\n"
const int mxN = 200001;
int main()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    
    int n,k;
    cin>>n>>k;
    int a[n];
    for(int i=0;i<n;++i)
    {
        cin>>a[i];
    }
    int dp[n+1];
    dp[0] = 0;
    for(int i=1;i<n;++i)
    {
        int mn = INT_MAX;
        for(int j=1;j<=k;++j)
        {
            if((i-j)>=0)
            {
                mn = min(mn,dp[i-j]+abs(a[i]-a[i-j]));
            }
            else
            {
                break;
            }
        }
        dp[i] = mn;

    }
    
    // for(int i=0;i<n;++i)
    // {
    //     cout<<dp[i][0]<<" "<<dp[i][1]<<endl;
    // }
    cout<<dp[n-1]<<endl;

    
    return 0;

}


Measured memory_bytes: 4368
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define is(a, b) a == b
#define len(v) ll(v.size())

const ll INF = 1LL << 58;

//xより以下の要素へのindex
template <class T> int former(const vector<T> &v, T x) {
  return upper_bound(v.begin(), v.end(), x) - v.begin() - 1;
}
//x以上の要素へのindex
template <class T> int latter(const vector<T> &v, T x) {
  return lower_bound(v.begin(), v.end(), x) - v.begin();
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a,b,c,x,y;
    cin>>a>>b>>c>>x>>y;
    ll ans=pow(10,10);
    for(ll i=0;i<max(x,y)*2+1;i=i+2){
        if(c*i+a*max(ll(0),x-i/2)+b*max(ll(0),y-i/2)<ans){
            ans=c*i+a*max(ll(0),x-i/2)+b*max(ll(0),y-i/2);
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REP1(i,n) for(int i = 1; i < n+1 ;i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
#define SZ(x) ((int)(x).size())
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
using namespace std;
typedef long long ll;
using p = pair<int, int>;
using P = pair<ll, ll>;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
using Graph = VV;


int main(){
    ios::sync_with_stdio(false); cin.tie(0);
    int n,m;
    V a(m);ll sum =0;
    cin >> n >> m;
    REP(i,m){ cin >> a[i];
    sum+=a[i];
    }
    if(sum>n) cout << -1 << endl;
    else cout << n-sum << endl;
    


}
 

Measured memory_bytes: 3788
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <utility>
#include <set>
#include <map>
#include <tuple> 
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <list>
using namespace  std;
typedef pair<long long , long long> P;
typedef long long ll;
typedef long long lint;
#define REP(i, n) for(long long (i)=0; (i)<(n); ++i)
#define FOR(i, a, b) for(long long (i)=(a); (i)<(b); ++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
const long long MOD = static_cast<long long>(1e9) + 7LL;
const long long INF = 1234567891234567890LL;

template<typename T>
long long pow(T n, T x, T MOD=(T)(1e9)+7){
    long long res = 1LL;
    while(x){
        if(x%2==1) res = (res*n) % MOD;
        x = x>>1;
        n= (n*n) % MOD;
    }
    return res%MOD;
}

template<typename T>
long long factorial(T n, T MOD=(T)(1e9)+7) {
    if(n<=1) return 1LL;
    else return (n * factorial(n-1)) % MOD;
}

template<typename T>
long long cmb(T n, T r, T MOD=(T)(1e9)+7){
    long long res = 1LL;
    r = (r<n-r? r: n-r);
    if(r==0) return 1LL;
    for(lint i=n-r+1; i<=n; i++) res = (res*i)%MOD;
    res *= pow(factorial(r), MOD-2, MOD);
    return res % MOD;
}
signed main(){
    ll N, K;
    cin>>N>>K;
    ll M=N-K;
    for(ll i=1; i<=K; i++){
        ll res = 0;
        
        res = (res + cmb(K-1, K-i))%MOD;
        if(M>=i-1) res = (res * cmb(M+1, M-i+1))%MOD;
        else res = 0;
        cout << res%MOD << endl;
    }
    return 0;
}

Measured memory_bytes: 256
/*  "Sahand Alitanloo"  */
#include <bits/stdc++.h>
#define F first
#define S second
#define fast() ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define per(i) cout<<fixed<<setprecision(i)
#define pb push_back
#define all(v) begin(v),end(v)
#define endl '\n'
using namespace std;
typedef pair<int,int> pii;
typedef long double ld;
typedef long long ll;
const int MAX_N = 1e5+10;
const ll mod = 1e9+7;
const ll INF = 1e9;
inline ll bpow(ll t,ll n){ll ans=1;while(n>0){if(n&1)ans=(ans*t)%mod;t=(t*t)%mod,n>>=1;}return ans;}
/*
ll fact[MAX_N],ifact[MAX_N];
inline ll c(ll n,ll k){if(k>n||k<0)return 0;return (fact[n]*ifact[k]%mod*ifact[n-k])%mod;}
inline void get_fact(){fact[0]=1;ifact[0]=1;for(ll i=1;i<MAX_N;i++)fact[i]=(fact[i-1]*i)%mod,ifact[i]=bpow(fact[i],mod-2);}
*/

#define int ll
int c[1000][1000];
int p[1000][1000];
int cc[1000];
main(){
    fast();per(0);
    //get_fact();
	int n;cin>>n;
	for(int i=1;i<=n;i++)
		for(int j=0;j<10;j++)
			cin>>c[i][j];
	for(int i=1;i<=n;i++)
		for(int j=0;j<=10;j++)
			cin>>p[i][j];
	int ans=-1;
	for(int i=1;i<(1<<10);i++){
		memset(cc,0,sizeof cc);
		for(int j=0;j<10;j++)
			if(i>>j&1){
				for(int k=1;k<=n;k++)
					if(c[k][j]==1)
						cc[k]++;
			}
		int sum=0;
		for(int k=1;k<=n;k++)
			sum+=p[k][cc[k]];
		if(ans==-1)
			ans=sum;
		ans=max(ans,sum);

	}
	cout<<ans;
}

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

using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
#define all(x) x.begin(), x.end()

template <typename T1, typename T2> inline void chkmin(T1 &x, const T2 & y) {if (x > y) x = y;}
template <typename T1, typename T2> inline void chkmax(T1 &x, const T2 & y) {if (x < y) x = y;}

#define int ll
int n;
vector<int> a;
const int MAXN = 2e5 + 10;
void read() {
	cin >> n;
	a.resize(n);
	for (auto &i : a)
		cin >> i;
}

int ans;
const int INF = 1e18;
const int MAXLAST = 5;
const int ADD = MAXLAST;
int dp[MAXN][MAXLAST * 2][2];

void run() {
	for (int i = 0; i < MAXN; i++)
		for (int j = 0; j < MAXLAST * 2; j++)
			for (int k = 0; k < 2; k++)
				dp[i][j][k] = -INF; 
	dp[0][ADD][0] = 0;
	for (int i = 1; i <= n; i++) {
		int now = i / 2;
		int pre = (i - 1) / 2;
		if (now == pre) {
			for (int last = -MAXLAST; last < MAXLAST; last++) {
				int fans = max(dp[i - 1][last + ADD][0], dp[i - 1][last + ADD][1]);
				if (fans == -INF) continue;
				chkmax(dp[i][last + ADD][0], fans);
			}
			for (int last = -MAXLAST; last + 1 < MAXLAST; last++) {
				int fans = dp[i - 1][last + ADD][0];
				if (fans == -INF) continue;
				fans += a[i - 1];
				chkmax(dp[i][last + 1 + ADD][1], fans);
			}
		} else {
			for (int last = -MAXLAST + 1; last < MAXLAST; last++) {
				int fans =  max(dp[i - 1][last + ADD][0], dp[i - 1][last + ADD][1]);
				if (fans == -INF) continue;
				chkmax(dp[i][last - 1 + ADD][0], fans);
			}
			for (int last = -MAXLAST; last < MAXLAST; last++) {
				int fans =  dp[i - 1][last + ADD][0];
				if (fans == -INF) continue;
				fans += a[i - 1];
				chkmax(dp[i][last + ADD][1], fans);
			}
		}
	}
	/*cout << "need = " << endl;
	for (int i = 0; i <= n; i++) {
		cout << i / 2 << " ";
	}
	cout << endl;

	cout << "dp = " << endl;
	for (int k = 0; k < 2; k++) {
		for (int i = 0; i <= n; i++) {
			for (int j = -MAXLAST; j < MAXLAST; j++) {
				cout << dp[i][j + ADD][k] << " ";
			}
			cout << endl;
		}
		cout << endl;
	}*/
	ans = max(dp[n][ADD][0], dp[n][ADD][1]);
}

void write() {
	cout << ans << endl;
}

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	read();
	run();
	write();
	return 0;
}

Measured memory_bytes: 35932
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll f(ll b, ll n){
    if (n < b)return n;
    return f(b, n/b)+n%b;
}
int main(){
    ll n, s;cin >> n >> s;
    if (n < s){
        cout << -1 << endl;
    }
    else if (n == s){
        cout << n+1 << endl;
    }
    else{
        ll ans = 1e12;
        for (ll b = 2; b*b <= n; b++)
        {
            if (f(b, n) == s){
                ans = min(ans, b);
            }
        }
        for (ll p = 1; p*p < n; p++)
        {
            ll b = (n-s)/p+1;
            if (b < 2)continue;
            if (f(b, n) == s){
                ans = min(ans, b);
            }
        }
        if (ans == ll(1e12)){
            cout << -1 << endl;
            return 0;
        }
        cout << ans << endl;
    }
    
    
}

Measured memory_bytes: 256
import java.util.Scanner;


public class Main {

	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);
		int second = sc.nextInt();
		sc.close();

		int h = 0,m = 0,s = 0;

		if(second != 0){
			h = (int)(Math.floor(second / 3600));
			m = (int)(Math.floor(second / 60)) % 60;
			s = second % 60;
		}
		System.out.println(h+":"+m+":"+s);
	}

}

Measured memory_bytes: 17284
/*
 * atcoder/abc092/c.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }

const int MAX = 100100;
int N;
vector<int> A;
ll acc_l[MAX] = {0};
void solve() {
  cin >> N;
  int a;
  A.push_back(0);
  loop(n,0,N) {
    cin >> a;
    A.push_back(a);
  }
  A.push_back(0);
  N += 2;

  loop(n,1,N) acc_l[n] = acc_l[n-1] + abs(A[n] - A[n-1]);
  // loop(n,0,N) cout << acc_l[n] << " "; cout << endl;

  loop(k,1,N-1) {
    cout << acc_l[k-1] + abs(A[k+1]-A[k-1]) + (acc_l[N-1] - acc_l[k+1]) << endl;
  }
}
int main() {
  // cout.precision(15); cout << fixed;

  solve();

  return 0;
}


Measured memory_bytes: 2552
N , M = (int(a) for a in input().split())
stair = [1]*(N+1)
for i in range(1 , M+1) :
    a = int(input())
    stair[a]=0

for i in range(2, N+1) :
    stair[i] *= ((stair[i-1] + stair[i-2]) % (10**9+7))
         
print(stair[N])

Measured memory_bytes: 6964
mod = 998244353
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

    N, S = map(int, input().split())
    A = list(map(int, input().split()))

    half = pow(2, mod-2, mod)
    dp = [[0] * (S+1) for _ in range(N+1)]
    dp[0][0] = 1
    for i, a in enumerate(A):
        for j in range(S+1):
            dp[i+1][j] = (dp[i+1][j] + dp[i][j])%mod
            if j+a <= S:
                dp[i+1][j+a] = (dp[i+1][j+a] + (dp[i][j] * half)%mod)%mod
    print((dp[-1][S] * pow(2, N, mod))%mod)


if __name__ == '__main__':
    main()


Measured memory_bytes: 132948
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <set>
#include <map>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>

using namespace std;


int main()
{
	int k, s; cin >> k >> s;

	int count = 0;
	for (int i = 0; i <= k; i++) {
		for (int j = 0; j <= k; j++) {
			int v = s - i - j;
			if (0 <= v && v <= k) count++;
		}
	}

	cout << count << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define int ll
#define all(x) x.begin(), x.end()
#define x first
#define y second
#define mp make_pair
#define mt make_tuple

const int N = 1e6 + 10;

int n;
int a[N];
map<int, int> s;

bool check(int k) {
	s.clear();
	for (int i = 1; i < n; ++i) {
		if (a[i - 1] < a[i]) {
			continue;
		} else {
			int j = a[i];
			while (s.size() && s.rbegin()->x > j) {
				s.erase(s.rbegin()->x);
			}
			if (s[j] == 0) {
				if (k == 1) {
					return false;
				}
				s[j] = 1;
				continue;
			}
			while (j > 0) {
				if (s[j] + 1 < k) {
					++s[j];
					break;
				} else {
					s[j] = 0;
					--j;
				}
			}
			if (!j) {
				return false;
			}
		}
	}
	return true;
}

signed main() {
#ifdef LC
	assert(freopen("input.txt", "r", stdin));
#endif
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	int lef = 0, rig = n;
	while (rig - lef > 1) {
		int mid = (lef + rig) / 2;
		if (check(mid)) {
			rig = mid;
		} else {
			lef = mid;
		}
	}
	cout << rig << "\n";
	return 0;
}


Measured memory_bytes: 1792