akhauriyash/Code-Regression huggingface dataset:
def main():
    n = int(input())
    a = list(map(int,input().split()))
    ary = [0] * 8
    tmp = 0
    for i, aa in enumerate(a):
        if 0 < aa <= 399 and ary[0] == 0:
            ary[0] = 1
        elif 399 < aa <= 799 and ary[1] == 0:
            ary[1] = 1
        elif 799 < aa <= 1199 and ary[2] == 0:
            ary[2] = 1
        elif 1199 < aa <= 1599 and ary[3] == 0:
            ary[3] = 1
        elif 1599 < aa <= 1999 and ary[4] == 0:
            ary[4] = 1
        elif 1999 < aa <= 2399 and ary[5] == 0:
            ary[5] = 1
        elif 2399 < aa <= 2799 and ary[6] == 0:
            ary[6] = 1
        elif 2799 < aa <= 3199 and ary[7] == 0:
            ary[7] = 1
        elif 3199 < aa:
            tmp += 1
            # print(a[i])
    if sum(ary) == 0:
        print(1,tmp)
    else:
        print(sum(ary), sum(ary) + tmp)

if __name__ =='__main__':
    main()


Measured memory_bytes: 3064
[n, yen] = list(map(int, input().split()))
ans = [-1, -1, -1]
for x in range(0, yen // 10000 + 1):
    for y in range(0, (yen - 10000*x)//5000 + 1):
        z = (yen - 10000*x - 5000*y) // 1000
        if x + y + z == n:
            ans = [x, y, z]
print("{} {} {}".format(ans[0], ans[1], ans[2]))


Measured memory_bytes: 3060
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<limits.h>

#define rep(i,begin,end) for(int i=begin; i<end; i++)
#define revrep(i,begin,end) for(int i=begin; i>end; i--)
#define lld long long int

int main(){
    int n, z, w;
    scanf("%d %d %d", &n, &z, &w);
    int a[n];
    rep(i, 0, n){
        scanf("%d", &a[i]);
    }
    int ans;
    if(n == 1){
        ans = abs(a[0] - w);
    }else{
        int p, q;
        p = abs(a[n-1] - w);
        q = abs(a[n-2] - a[n-1]);
        ans = p > q ? p : q;
    }
    printf("%d", ans);

    return 0;
}

Measured memory_bytes: 128
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e16;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}


int main(){
    ll N, x; cin >> N >> x;
    if(x==1 || x==2*N-1){
        cout << "No" << endl; return 0;
    }
    cout << "Yes" << endl;
    vl ans(2*N-1); REP(i, 2*N-1) ans[i] = i+1;
    swap(ans[x-1], ans[N-1]);
    swap(ans[0], ans[N-2]);
    swap(ans[2*N-2], ans[N]);
    REP(i, 2*N-1) cout << ans[i] << endl;
    return 0;
}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
 
using namespace std;
 
#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; scanf("%lld", &x);
 
//int dxy[5] = {0, 1, 0, -1, 0};
// assign


signed main()
{
    string data;
    while (cin >> data) {
        vvi board;
        if (data[0] == '#') break;
        vi tmp;
        rep(i, data.size()) {
            if (data[i] == '/') {
                board.pb(tmp);
                tmp.assign(0,0);
            } else if (data[i] == 'b') {
                tmp.pb(1);
            } else {
                rep(j, data[i] - '0') {
                    tmp.pb(0);
                }
            }
        }
        board.pb(tmp);
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        a--; b--; c--; d--;
        int temp = board[a][b];
        board[a][b] = board[c][d];
        board[c][d] = temp;

        rep(i, board.size()) {
            int a = 0;
            rep(j, board[i].size()) {
                if (board[i][j]) {
                    if (a) {
                        cout << a;
                        a = 0;
                    }
                    cout << "b";
                } else {
                    a++;
                }
                //cout << board[i][j];
            }
            if (a) {
                cout << a;
            }
            if (i+1 != board.size()) {
                cout << "/";
            }
        }
        cout << endl;
    }


    return 0;
}

Measured memory_bytes: 3056
import Control.Monad

transmigration h str = drop h str ++ take h str

shuffle str [] = str
shuffle str (h:hs) = shuffle str1 hs
  where
    str1 = transmigration h str

main = do
  str <- getLine
  when (str /= "-") $ do
    m <- readLn
    h <- replicateM m readLn
    putStrLn $ shuffle str h
    main

Measured memory_bytes: 4200
import math
from collections import defaultdict
ml=lambda:map(int,input().split())
ll=lambda:list(map(int,input().split()))
ii=lambda:int(input())
ip=lambda:list(input())
ips=lambda:input().split()

"""========main code==============="""

a,b,c=ml()
cost=[]
for i in range(a):
    cost.append(ll())
ans=1e18    
flag=1
for i in range(1<<a):
    val=[0]*(b+1)
    for j in range(a):
        if(i&(1<<j)):
            for k in range(b+1):
                val[k]+=cost[j][k]    
    f=0
    for j in val[1:]:            
        if(j<c):
            f=1
            break
    if f==0:
        flag=0
        ans=min(val[0],ans)
if(flag):
    print(-1)
else:    
    print(ans)        

Measured memory_bytes: 74400
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<queue>

#define REP(i, n) for(int i = 0;i < n;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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef long long int ll;
ll dx[4] = {1,0,0,-1};
ll dy[4] = {0,1,-1,0};

#define ARRAY_MAX 1005

int main(){

    int h,w,k;
    cin >> h >> w >> k;
    //縦をi行変更した後横をj行反転
    int tmp;
    bool ans = false;

    for(int i = 0;i <= w;i++){
        tmp = h*i;
        for(int j = 0;j <= h;j++){
            if((tmp - i*j)+j*(w-i) == k){
                ans = true;
            }
            //cout << i << " " << j << " " <<(tmp - i*j)+j*(w-i)<< endl;
        }
    }

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

    return 0;
}

Measured memory_bytes: 256
mod = 10**9 + 7
N = int(input())
A = list(map(int, input().split()))
ans = 0

for i in range(61):
    tmp_1 = 0
    tmp_0 = 0
    for k in range(N):
        if (A[k] >> i) & 1:
            tmp_1 += 1
        else:
            tmp_0 += 1
    ##print(i, tmp_1, tmp_0)
    ans += (tmp_1 * tmp_0) * (2 ** i)
print(ans%mod)

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

#define NDEBUG
#ifdef DEBUG
#include "../cout11.h"
#undef NDEBUG
#endif
#include <cassert>

typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
#define cons make_pair



int solve(string& s) {
    int best = INT_MAX;
    int L = s.size();
    for (int i=0; i<L-2; ++i) {
        int x = 100*(s[i]-'0') + 10*(s[i+1]-'0') + 1*(s[i+2]-'0');
        int y = abs(x - 753);
        best = min(best, y);
    }
    return best;
}

int main() {
    string s; cin >> s;
    cout << solve(s) << endl;
    return 0;
}


Measured memory_bytes: 256
program agc034_b
    use,intrinsic :: iso_fortran_env
    implicit none
    character(200000):: s
    integer(int64):: i,l,ca,ans

    read*, s
    l = len_trim(s)

    i = 1
    ca = 0
    ans=0
    do while(i <= l)
        if (s(i:i+1) == 'BC') then
            ans=ans+ca
            i=i+2
        else if (s(i:i) == 'A') then
            ca=ca+1
            i=i+1
        else
            ca=0
            i=i+1
        end if
    end do
    print'(i0)', ans
end program agc034_b    

Measured memory_bytes: 1084
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
ll ans[500010],cnt[500010],a[500010],n;
priority_queue<ll,vector<ll>,greater<ll> > q;
priority_queue<ll,vector<ll>,greater<ll> > p;
int main(){
	cin>>n;
	for(int i=0;i<3*n;i++)cin>>a[i];
	ll sum=0;
	for(int i=0;i<n;i++){
		sum+=a[i];
		q.push(a[i]);
	}
	ans[n-1]=sum;
	for(int i=n;i<2*n;i++){
		sum+=a[i];
		q.push(a[i]);
		sum-=q.top();
		q.pop();
		ans[i]=sum;
	}
	sum=0;
	for(int i=3*n-1;i>=2*n;i--){
		sum+=a[i];
		p.push(-a[i]);
	}
	cnt[2*n]=sum;
	for(int i=2*n-1;i>=n;i--){
		sum+=a[i];
		p.push(-a[i]);
		sum-=-p.top();
		p.pop();
		cnt[i]=sum;
	}
	ll mx=-1e17;
	for(int i=n-1;i<2*n;i++)
		mx=max(mx,ans[i]-cnt[i+1]);
	cout<<mx<<endl;
	return 0;
}

Measured memory_bytes: 10100
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N=2e5+1;
int A[N],n;
LL best=1e18,Par[N];
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d",&A[i]);
        Par[i]=(LL)Par[i-1]+A[i];
    }
    for(int i=1;i<n;i++){
        if(best>abs(Par[n]-Par[i]-Par[i])){
            best=abs(Par[n]-Par[i]-Par[i]);
          //  printf("%d\n",i);
        }
    }
    printf("%I64d",best);
    return 0;
}


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

#define int long long

using namespace std;

signed main(void)
{
	int n,i,k,now = 7,ans=1;
	
	cin >> n;
	
	if(n%2==0||n%5==0)
	{
		cout << -1 << "\n";
	}
	else
	{
		while(1)
		{
			if(now % n == 0)
			{
				cout << ans << "\n";
				
				break;
			}
			else
			{
				ans++;
				
				now = (now * 10 + 7 )% n;
				
			}
			
		}
	}
	
	return 0;
} 

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

int main() {
    ll s;
    cin >> s;
    int x, y;
    int v = 1000000000;
    x = (v - s % v) % v;
    y = (s + x) / v;

    cout << "0 0 1000000000 1 " << x << " " << y  << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>

using namespace std;

//#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ; //何もしない文
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size()) //unsignedのサイズをint型に変換

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL; 

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const int MAX_N = 105;
const int MAX_W = 1e5+10;
LL dp[MAX_N][MAX_W];
int v[MAX_N];
int w[MAX_N];

int N,W;

// i番目以降で重量j以下の制約での最大価値
LL rec(int i, int j)
{
    LL res;
    if(dp[i][j] != -1) return dp[i][j];

    if(i == N) res = 0;
    else if(j < w[i]) res = rec(i+1, j);
    else res = max(rec(i+1,j), rec(i+1, j- w[i]) + v[i]);

    dp[i][j] = res;
    dump(i)
    dump(j)
    dump(res)

    return res;
}


//ここから書き始める
int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);	
    cin >> N >> W;
    REP(i,N)
    {
        cin >> w[i] >> v[i];
    }

    memset(dp,-1,sizeof(dp));

    cout << rec(0,W) << endl;

}


Measured memory_bytes: 82304
#include <bits/stdc++.h>
#define dcout cout << fixed << setprecision(15)
#define rep(i, a) for(int i = 0; i < a; i++)
#define arep(i, x) for(auto i : x)
#define all(v) v.begin(), v.end()
#define int long long
#define F first
#define S second
#define VE vector<int>
#define pb(x) push_back(x)
using namespace std;
signed main() {
    int a, b;
    cin >> a >> b;
    if(a < b) {
        rep(i, b) {
            cout << a;
        }
    } else {
        rep(i, a) {
            cout << b;
        }
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main{

    int h, w;
    int[] dx = {0, 0, 1, -1, 1, 1, -1, -1};
    int[] dy = {1, -1, 0, 0, 1, -1, 1, -1};
    char[][] donut;

    void solve(){
        Scanner sc = new Scanner(System.in);

        while(true){
            h = sc.nextInt();
            w = sc.nextInt();
            if(h==0 && w==0) break;

            donut = new char[h][w];
            for(int i=0; i<h; i++){
                String line = sc.next();
                donut[i] = line.toCharArray();
            }

            int max = 0;
            StringBuilder minString = new StringBuilder();

            for(int l=h*w; l>=2; l--){
                HashSet<String> set = new HashSet<String>();
                for(int i=0; i<h; i++){
                    for(int j=0; j<w; j++){
                        for(int k=0; k<8; k++){                        
                            StringBuilder s = new StringBuilder();
                            s.append(donut[i][j]);
                            int ny = (i + dy[k]) % h == -1 ? h-1 : (i + dy[k]) % h;
                            int nx = (j + dx[k]) % w == -1 ? w-1 : (j + dx[k]) % w;
                            while(!(ny==i && nx==j)){
                                if(s.length()==l) break;
                                s.append(donut[ny][nx]);
                                ny = (ny + dy[k]) % h == -1 ? h-1 : (ny + dy[k]) % h;
                                nx = (nx + dx[k]) % w == -1 ? w-1 : (nx + dx[k]) % w;
                            }
                            if(s.length()!=l) continue;

                            if(!set.add(s.toString())){
                                if(minString.length()==0) minString = s;
                                else minString = min(s, minString);
                                max = l;
                            }
                        }
                    }
                }
                if(max!=0) break;
            }

            if(minString.length()==0) System.out.println(0);
            else System.out.println(minString.toString());
        }
    }

    StringBuilder min(StringBuilder s1, StringBuilder s2){
        int l1 = s1.length(), l2 = s2.length();
        for(int i=0; i<Math.min(l1, l2); i++){
            if(s1.charAt(i)<s2.charAt(i)) return s1;
            else if(s1.charAt(i)>s2.charAt(i)) return s2;
        }
        if(l1<l2) return s1;
        return s2;
    }

    public static void main(String[] args){
        new Main().solve();
    }
}

Measured memory_bytes: 205128
#include<iostream>
#include<algorithm>
using namespace std;
int n,a,b,c,mini,mini_no,m;
int t[10][10],u[10];
int main(){
  while(cin>>n&&n){

    for(int i=0;i<10;i++)
      for(int j=0;j<10;j++)
	t[i][j]=(i==j?0:999999);
    m=-1;
    for(int i=0;i<n;i++){
      cin>>a>>b>>c;
      t[a][b]=t[b][a]=c;
      m=max(m,max(a,b));
    }
    m++;
    for(int k=0;k<m;k++){
      for(int i=0;i<m;i++){
	for(int j=0;j<m;j++){
	  t[i][j]=min(t[i][j],t[i][k]+t[k][j]);
	}
      }
    }







    mini=999999;
    for(int i=0;i<m;i++){
      u[i]=0;
      for(int j=0;j<m;j++){
	u[i]+=t[i][j];
      }
    }
    for(int i=0;i<m;i++){
      if(mini>u[i]){
	mini=u[i];
	mini_no=i;
      }
    }
    cout<<mini_no<<' '<<mini<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

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


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


#define f(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define char_f(i,a) for(int i=(int)(a);(char)s[i]!='\0';i++)
#define rf(i,a,b) for(int i=(int)(a);i>=(int)(b);i--)
#define llf(i,a,b) for(long long int i=(long long int)(a);i<=(long long int)(b);i++)
#define llrf(i,a,b) for(long long int i=(long long int)(a);i>=(long long int)(b);i--)



#define ll long long
#define fi first
#define se second
#define pb push_back
#define pop pop_back
#define mem(ara) memset((ara),0,sizeof(ara))
#define memn(ara) memset((ara),-1,sizeof(ara))
#define bb begin()
#define ee end()
#define em emplace
#define eb emplace_back





#define si set<int>
#define sd set<double>
#define sll set<long long int>
#define ss set<string>
#define sc set<char>

#define pii pair<int,int>
#define pli pair<long long int,int>
#define pil pair<int,long long int>
#define pll pair<long long int,long long int>
#define pci pair<char,int>
#define pic pair<int,char>
#define pcl pair<char,long long int>
#define plc pair<long long int,char>

#define pss pair<string,string>
#define pcc pair<char,char>

#define pis pair<int,string>
#define psi pair<string,int>
#define pls pair<long long int,string>
#define psl pair<string,long long int>
#define pdd pair<double,double>
#define pcs pair<char,string>
#define psc pair<string,char>



#define vi  vector<int>
#define vll vector<long long int>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vii vector<pii>



#define mod 1000000007
#define mx (1<<30)-1
#define llmx (1ll<<62)
#define n_size 100005
#define g_size 10000005
double PI=acos(-1);



///unsigned int uMAX=4294967295;
///unsigned ll int ullMAX=18446744073709551615;





int arr[g_size];



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

	int n,m,T,res;

	int maxi=-mx,mini=mx,count=0,x=0;

	int i,j,k;

	bool flag;

	string s1,s2;

	char s[100000];

	int ara[n_size],ara2[n_size];

	cin>>n;

	f(i,0,n-1)
    {
        cin>>m;

        if(m>=1 && m<=399) arr[0]++;
        else if(m>=400 && m<=799) arr[1]++;
        else if(m>=800 && m<=1199) arr[2]++;
        else if(m>=1200 && m<=1599) arr[3]++;
        else if(m>=1600 && m<=1999) arr[4]++;
        else if(m>=2000 && m<=2399) arr[5]++;
        else if(m>=2400 && m<=2799) arr[6]++;
        else if(m>=2800 && m<=3199) arr[7]++;
        else if(m>=3200) x++;
    }


	f(i,0,7)
	{
	    count+=(arr[i]!=0);
	}
    if(count)cout<<count<<" "<<count+x<<endl;
    else{
        cout<<1<<" "<<x<<endl;
    }
}


Measured memory_bytes: 256
#include <stdio.h>


int linearSearch(int A[],int n,int key){
  int i=0;
  A[n]=key;
  while(A[i]!=key){
    i++;
  }
  return i!=n;
}

int main(void){
  int n,q,i,sum=0;
  scanf("%d",&n);
  int s[n];
  for(i=0;i<n;i++){
    scanf("%d",&s[i]);
  }

  scanf("%d",&q);
  int t[q];
  for(i=0;i<q;i++){
    scanf("%d",&t[i]);
  }

  for(i=0;i<q;i++){
    if(linearSearch(s,n,t[i])){
      sum++;
    }
  }

  printf("%d\n",sum);
  return 0;
}

Measured memory_bytes: 636
(let ((n (read))
      (now (read))
      (fro 0)
      (ans 0)
      (flg nil))
  (if (not (= now 0)) (setf flg T) (setf fro now))
  (loop for x from 2 upto n
        do (setf now (read))
           (cond ((< (1+ fro) now) (setf flg T))
                 ((= (1+ fro) now) (incf ans))
                 (T (incf ans now)))
           (setf fro now))
  (format t "~A~%" (if flg -1 ans)))

Measured memory_bytes: 66148
#include <stdio.h>
#include <string.h>
#define alphabet 26
int main()
{
    int i,j,n,Eng[50][alphabet]={},D[alphabet]={};
    char S[51];
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%s",S);
        for(j=0;j<strlen(S);j++) Eng[i][S[j]-'a']++;
    }
    for(i=0;i<alphabet;i++) D[i]=Eng[0][i];
    for(i=1;i<n;i++) for(j=0;j<alphabet;j++) if(D[j]>Eng[i][j]) D[j]=Eng[i][j];
    for(i=0;i<alphabet;i++) for(j=0;j<D[i];j++) printf("%c",'a'+i);
    puts("");
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<set>
#include<string>
typedef long long ll;
using namespace std;
#define INF (1 << 30)
#define INFLL (1LL << 60)
#define rep(i, n) for(int i=0; i<(n); ++i)

int main()
{
	int N, M; cin >> N >> M;
	vector<int> P(M), Y(M);
	for (int i = 0; i < M; ++i) cin >> P[i] >> Y[i], --P[i];

	//同じ県の市をまとめる
	vector<vector<int> > vals(N);
	for (int i = 0; i < M; ++i) vals[P[i]].push_back(Y[i]);

	//各県の市の順番を並べ替える
	for (int p = 0; p < N; ++p) {
		sort(vals[p].begin(), vals[p].end());
		//vals[p].erase(unique(vals[p].begin(), vals[p].end()), vals[p].end());	//重複する値は削除する
	}

	for (int i = 0; i < M; ++i) {
		int p = P[i];
		printf("%06d", p + 1);

		//Y[i]年が何番目かを求める
		int id = lower_bound(vals[p].begin(), vals[p].end(), Y[i]) - vals[p].begin();

		printf("%06d\n", id + 1);
	}
	//rep(i, M) {
	//	cout << setw(6) << setfill('0');
	//	cout << setw(6) << setfill('0');
	//	cout << endl;
	//}
	return 0;
}


Measured memory_bytes: 9016
#include <iostream>
#include<algorithm>
#include<string>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#include <iomanip>
#pragma region Macros
#define int long long
#define double long double
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define LAST(x) x[x.size()-1]
#define ALL(x) (x).begin(),(x).end()
#define swap(a,b) (a += b,b = a - b,a -= b)
#define CEIL(a,b) ((a+b-1)/b)
int FACT(int a) {
	if (a == 0)
		return 1;
	else
		return a * FACT(a - 1);
}
int nPr(int n, int r) {
	r = n - r;
	int sum = 1;
	int i;
	for (i = n; i >= r + 1; i--)sum *= i;
	return sum;
}
//int nCr1(int n, int r)
//int nCr2(int n, int r) 
int GCD(int a, int b) // assuming a,b >= 1
{
	if (a < b)
		swap(a, b);
	if (b == 0)
		return a;
	if (a % b == 0)
		return b;
	return GCD(b, a % b);
}
int LCM(int a, int b) // assuming a,b >= 1
{
	return  a * b / GCD(a, b);
}
double LOG(int a, int b) {
	return log(b) / log(a);
}
inline bool BETWEEN(int x, int min, int max) {
	if (min <= x && x <= max)
		return true;
	else
		return false;
}

using namespace std;
#pragma endregion
signed main() {
	int n;
	cin >> n;
	cout << (n-2)*180 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int 
#define endl '\n'
#define INF 1000000000
#define MOD 1000000007
#define MAX 100000000 
#define mp make_pair
#define pb push_back
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    double a[n+1];
    for(int i=1;i<=n;i++)
    {
    	cin>>a[i];
    }
    double dp[n+1][n+1],ans=0;
    memset(dp,0,sizeof(dp));
    dp[0][0]=1;
    for(int i=1;i<=n;i++)
    {
    	for(int j=0;j<=i;j++)
    	{
    		if(j==0)
    		{
    			dp[i][j]=dp[i-1][j]*(1-a[i]);
    		}
    		else
    		{
    			dp[i][j]=dp[i-1][j]*(1-a[i])+dp[i-1][j-1]*a[i];
    		}
    	}
    }
    for(int i=(n+1)/2;i<=n;i++)
    {
    	ans+=dp[n][i];
    }
    cout<<fixed<<setprecision(12)<<ans<<endl;
}

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

int main() {

    int a,b,c;

    cin >> a >> b >> c;

    string ans = "No";

    if(a >= b && a >= c){
        if(a == b+c){
            ans = "Yes";
        }
    }
    else if(b >= a && b >= c){
        if(b == a+c){
            ans = "Yes";
        }
    }
    else if(c >= a && c >= b){
        if(c == a+b){
            ans = "Yes";
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b  =sc.nextInt();
        int c = sc.nextInt();
        if (b - a == c - b ) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }

}

Measured memory_bytes: 21716
S = input()
N = len(S)

s = 0
for i in range(1 << (N - 1)):
    bs = format(i, f'0{N - 1}b')[::-1]
    t = S[0]
    for j in range(N - 1):
        if bs[j] == '1':
            s += int(t)
            t = S[j + 1]
        else:
            t += S[j + 1]
    s += int(t)
print(s)


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

int main(void){
  int n; cin >> n;
  string s[n];
  rep(i,n){
    cin >> s[i];
  }
  map<string, int> x;
  rep(i,n){
    if(x.count(s[i])){
      x[s[i]]++;
    }
    else x[s[i]] = 1;
  }
  int mx = 0;
  for(auto p : x){
    int value = p.second;
    mx = max(mx,value);    
  }
  for(auto p : x){
    if(p.second == mx){
      cout << p.first << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 26752
#include <bits/stdc++.h>
#include <string>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <numeric>
using namespace std;

int abs(int num){
   if (num > 0)
      return num;
   else
      return -num;
}

int main(){
  char A,B;
  cin >> A >> B;
  if(A < B){
    cout << "<" << endl;
  }
  else if(A == B){
    cout << "=" << endl;
  }
  else{
    cout << ">" << endl;
  }
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define lor(a,b,c) for(register int a=b;a<=c;++a)

const int MAX=2e5+5;

int n,m,a[MAX];
int line[MAX];

inline int read();
bool judge(int);

int main(){

	n=read(); m=(n<<1)-1; lor(i,1,m) a[i]=read();

	int l=1,r=m;
	while(l<=r){
		int mid=(l+r)>>1;
		if(judge(mid)) l=mid+1;
		else r=mid-1;
	}	
	printf("%d\n",r);
	
	return 0;
}

inline int read(){
	char tmp=getchar(); int sum=0; bool flag=false;
	while(tmp<'0'||tmp>'9'){
		if(tmp=='-') flag=true;
		tmp=getchar();
	}
	while(tmp>='0'&&tmp<='9'){
		sum=(sum<<1)+(sum<<3)+tmp-'0';
		tmp=getchar();
	}
	return flag?-sum:sum;
}

bool judge(int mid){
	lor(i,1,m) line[i]=(a[i]>=mid);
	int l,r; l=r=n;
	while(l>1&&r<m){
		if(line[l-1]==line[l]||line[r]==line[r+1]) return line[l];
		l--; r++;
	}
	return line[1];
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+5; 

#define endl "\n"

ll gcd(ll x,ll y){
	if(y) return gcd(y,x%y);
	return x;
} 

ll lcm(ll x,ll y){
	return x/gcd(x,y)*y;
}

int a[N];

int main(){
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	ll n,m,tmp,X;
	cin>>n>>m;
	X=1;
	for(int i=0;i<n;i++){
		cin>>a[i];
		a[i]>>=1;
		X=lcm(X,a[i]);
		if(X>m) {
			cout<<0<<endl;
			return 0;
		}
	}
	for(int i=0;i<n;i++){
		tmp=X/a[i];
		if(!(tmp&1)){
			cout<<0<<endl;
			return 0;
		}
	}
	ll ans=m/X;
	cout<<((ans+1)>>1)<<endl;
	return 0;
}
/*
化式子。
X=ak*(p+0.5)
X=bk*(2p+1)
X=bk*dk，dk为奇数
X显然是lcm(bi)的正整数倍，
如果存在dk=X/bk为偶数，那么无解，
否则在正整数范围内有解，且X为lcm的奇数倍， 
那么在[1,m]中符合条件的X有((m/X)+1)/2个 
*/

Measured memory_bytes: 640
#include <iostream>
#include <map>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;
using ll = long long;
using ld = long double;

int main() {

    ll N;
    vector<ll> A;
    cin >> N;
    for (int i = 0; i < N; ++i) {
        ll a;
        cin >> a;
        A.push_back(a);
    }

//    for (int i = 0; i < N; ++i) {
//       ll b = A[i];
//        cout << A[i];
//    }
//    cout << " " << endl;
    sort(A.begin(),A.end());

    //tekito 2つめを最大にして、後最大差分をえらんで、残った数字を先頭にいれて数えればいい？

    vector<ll> B;
    int j =0;
    for (int i = 0; i < N; ++i) {
        j++;
        ll a  = A[N-1-i];
        if(j == N){
            B.insert(B.begin(),a);
            break;
        }
        B.push_back(a);
        j++;
        ll a2 = A[i];
        if(j == N){
            B.insert(B.begin(),a2);
            break;
        }
        B.push_back(a2);
    }

//    for (int i = 0; i < N; ++i) {
//        ll b = B[i];
//        cout << B[i];
//    }
//    cout << " " << endl;
    ll r = 0;
    ll bf = B[0];
    for (int i = 1; i < N; ++i) {
        ll b = B[i];
        r += abs(b - bf);
        bf = b;
    }

    vector<ll> C;
    j =0;
    for (int i = 0; i < N; ++i) {
        j++;
        ll a2 = A[i];
        if(j == N){
            C.insert(C.begin(),a2);
            break;
        }
        C.push_back(a2);
        j++;
        ll a  = A[N-1-i];
        if(j == N){
            C.insert(C.begin(),a);
            break;
        }
        C.push_back(a);
    }

//    for (int i = 0; i < N; ++i) {
//        ll b = B[i];
//        cout << B[i];
//    }
//    cout << " " << endl;
    ll r2 = 0;
    ll bf2 = C[0];
    for (int i = 1; i < N; ++i) {
        ll b = C[i];
        r2 += abs(b - bf2);
        bf2 = b;
    }
    ll r3 = (r > r2)? r : r2;
    cout << r3 << endl;

    return 0;
}

Measured memory_bytes: 3316
/*
 * WelcomeToAtCoder.cpp
 *
 *  Created on: 2020/02/19
 *      Author: black
 */
#include <iostream>
#include <algorithm>
using namespace std;


int main(){
	int c[9];
	for (int i = 0; i < 9; ++i){
		cin >> c[i];
	}
	int a[3];
	int b[3];

	for (int i = 0; i <= 100; ++i){
		a[0] = i;
		b[0] = c[0] - a[0];
		b[1] = c[1] - a[0];
		b[2] = c[2] - a[0];
		for (int j = 0; j <= 100; ++j){
			if ((j+b[0] == c[3]) && (j+b[1] == c[4]) && (j+b[2] == c[5])){
				for (int k = 0; k <= 100; ++k){
					if ((k+b[0] == c[6]) && (k+b[1] == c[7]) && (k+b[2] == c[8])){
						cout << "Yes" << endl;
						return 0;
					}
				}
			}
		}
	}

	cout << "No" << endl;
	return 0;
}


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

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

	// #ifndef ONLINE_JUDGE
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	// #endif

	int n;
	cin >> n;
	long long int a[n+1],dp[n+1][n+1],pre[n+1];
	pre[0]=0;
	for(int i=1;i<=n;i++){
		cin >> a[i];
		pre[i]=a[i]+pre[i-1];
	}
	for(int i=0;i<=n;i++) for(int j=0;j<=n;j++) dp[i][j]=LONG_MAX;
	
	for(int l=1;l<=n;l++){
		if(l==1){
			for(int i=1;i<=n;i++) dp[i][i]=0;
		}
		else{
			for(int i=1;i+l-1<=n;i++){
				int j = i+l-1;
				for(int k=i;k<j;k++){
					dp[i][j]=min(dp[i][j],pre[j]-pre[i-1]+dp[i][k]+dp[k+1][j]);
				}
			}
		}
	}
	cout << dp[1][n];

	
	




	
	




	

}


Measured memory_bytes: 1536
from collections import Counter
n = int(input())
a = list(map(int, input().split()))

c = Counter(a)

ans = c[0]
x = 0
for i in range(max(a)):
    if ans < c[i] + c[i+1] + c[i+2]:
        ans = c[i] + c[i+1] + c[i+2]
        x = c[i+1]

print(ans)


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

using namespace std;
const int maxn = 1e3 + 5;
int a[maxn];

int main()
{
    int a, b, x;
    while (cin >> a >> b) {
        x = 2 * b - a;
        cout << x << endl;
    }
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

namespace CSharp
{
    static class Program
    {
        static void Main(string[] args)
        {
            int n, m;
            ReadInt(out n, out m);
            var A = ReadIntArray();
            var selected = A.OrderByDescending(x => x).Take(m).ToArray();
            bool ans = selected.Min() * 4 * m >= A.Sum();
            Console.WriteLine(YesNo(ans));
        }

        #region Helpers

        static int[] ReadIntArray() => Console.ReadLine().Split().Select(s => int.Parse(s)).ToArray();
        static long[] ReadLongArray() => Console.ReadLine().Split().Select(s => long.Parse(s)).ToArray();

        static int[] ReadLineIntArray(int count) => Enumerable.Repeat(0, count).Select(_ => int.Parse(Console.ReadLine())).ToArray();
        static long[] ReadLineLongArray(int count) => Enumerable.Repeat(0, count).Select(_ => long.Parse(Console.ReadLine())).ToArray();

        static string ReadString() => Console.ReadLine();
        static int ReadInt() => int.Parse(Console.ReadLine());
        static long ReadLong() => long.Parse(Console.ReadLine());

        static void ReadInt(out int first)
        {
            var array = ReadIntArray();
            first = array[0];
        }

        static void ReadInt(out int first, out int second)
        {
            var array = ReadIntArray();
            first = array[0];
            second = array[1];
        }

        static void ReadInt(out int first, out int second, out int third)
        {
            var array = ReadIntArray();
            first = array[0];
            second = array[1];
            third = array[2];
        }

        static void ReadInt(out int first, out int second, out int third, out int fourth)
        {
            var array = ReadIntArray();
            first = array[0];
            second = array[1];
            third = array[2];
            fourth = array[3];
        }

        static void ReadLong(out long first)
        {
            var array = ReadLongArray();
            first = array[0];
        }

        static void ReadLong(out long first, out long second)
        {
            var array = ReadLongArray();
            first = array[0];
            second = array[1];
        }

        static void ReadLong(out long first, out long second, out long third)
        {
            var array = ReadLongArray();
            first = array[0];
            second = array[1];
            third = array[2];
        }

        static void ReadLong(out long first, out long second, out long third, out long fourth)
        {
            var array = ReadLongArray();
            first = array[0];
            second = array[1];
            third = array[2];
            fourth = array[3];
        }

        static string YesNo(bool condition) => condition ? "Yes" : "No";
        static string YESNO(bool condition) => condition ? "YES" : "NO";

        #endregion
    }
}

Measured memory_bytes: 13524
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
char p[201000];
int n, C[2], v[201000], S[201000];
long long s=0;
int main(){
    int i;
    scanf("%s",p);
    for(i=0;p[i];i++){
        C[p[i]-'0']++;
    }
    n=i;
    for(i=1;i<=C[1];i++){
        s += (i+1)/2;
    }
    int c=0, t=0;
    for(i=0;p[i];i++){
        if(p[i]=='1')c++;
        if(p[i]=='0' && c%2==1){
            c++;
            t++;
            s+=(C[1]+t+1)/2;
            v[i]=1;
        }
        S[i] = (c+1)/2;
    }
    int c0=0,c1=0;
    for(i=n-1;i>=0;i--){
        swap(c0,c1);
        if(p[i]=='0'){
            if(!v[i]){
                s+=c1+S[i];
            }
        }
        if(p[i]=='1')c1++;
        
    }
    printf("%lld\n",s);
}


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

using namespace std;

#define long long long
#define INF (long) 1e18
#define MOD 1'000'000'007
#define mll map<long, long>
#define pll pair<long, long>
#define umap unordered_map
#define umll umap<long, long>
#define uset unordered_set
#define pb push_back
#define FOR(i, a, b) \
  for (long i = (a); i < (long) (b); i++)
#define PRINTV(v) \
  FOR (_i, 0, v.size()) \
    cout << v[_i] << " "; \
  cout << "\n";

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

  long n, k;
  cin >> n >> k;

  if (k == 0) {
    printf("%lld\n", n*n);
    return 0;
  }
  long total = 0;
  FOR (b, k+1, n+1) {
    long l = b;
    long x = ceil(double(n) / b);
    long r = l + b * (x-1);
    long y = x * (b - k);
    if (r > n+1) y -= r - max(n+1, r - (b-k));
    //printf("%lld: %lld\n", b, y);
    total += y;
  }
  printf("%lld\n", total);
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] arr = {sc.nextInt(), sc.nextInt(), sc.nextInt(), sc.nextInt(), sc.nextInt()};

        int sum = 0;
        int slot = arr[0];

        for (int i = 1; i < arr.length; i++) {
            int rem = arr[i] % 10;
            if (rem != 0) {
                if (rem < slot % 10) {
                    sum += (int) Math.ceil(slot / 10.0) * 10;
                    slot = arr[i];
                } else sum += (int) Math.ceil(arr[i] / 10.0) * 10;;
            } else {
                sum += arr[i];
            }
        }
        System.out.println(sum + slot);
    }
}

Measured memory_bytes: 21716
n=int(input())
arr=[]
for i in range(n):
    ansnum=int(input())
    for j in range(ansnum):
        a,b = map(int,input().split())
        arr.append((i,a,b))
#print(arr)
if len(arr)==0:
    print(n)
else:
    #スキップするユーザの選定
    maxcount=0
    for k in range(2**n):
        A=list(bin(k))[2:]
        #print(A[2:])
        while len(A)<n:
            A.insert(0,0)
        A=[int(i) for i in A]

        #d={}
        #print(A)
        for num,j in enumerate(arr):
            if A[j[0]]==0:
                pass
            #print(j)
            #print(j[2])
            #print(A[j[1]-1])
            elif A[j[1]-1]!=j[2]:
                break
            """
            if j[1] not in d:
                d[j[1]]=j[2]
            elif d[j[1]]!=j[2]:
                break
            """
            #print(num)
            if num==len(arr)-1: 
                maxcount=max(maxcount,sum(A))
    print(maxcount)



Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define inf 1000000000000000001
#define mod 1000000007
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define pb push_back
#define f first
#define s second
#define fast_cin ios_base::sync_with_stdio(false);cin.tie(NULL);
#define precise fixed(cout);cout<<setprecision(16);
#define Set(N,p) N=((N)|((1LL)<<(p)))
#define Reset(N,p) N=((N)&(~((1LL)<<(p))))
#define Check(N,p) (!(((N)&((1LL)<<(p)))==(0)))
#define POPCOUNT __builtin_popcountll
#define RIGHTMOST __builtin_ctzll
#define LEFTMOST(x) (63-__builtin_clzll((x)))
#define NUMDIGIT(x,y) (((vlong)(log10((x))/log10((y))))+1)
#define OUT(x) for(auto a:x) cout << a << " "; cout << endl;
#define OK cout << "@===================ok===================@" <<endl;
#define WTF cout <<"< "<<lo<<" | "<< hi <<" >" << endl;

using namespace std;

int main()
{
    fast_cin;
    precise;
    int n,k;
    cin >> n>>k;
    vi v(n);
    vector<double> dp(n);
    for(int i=0;i<n;i++) {
        cin >> v[i];
        dp[i]=1.0*(v[i]+1)/2;
    }

    double mx=0;
    double s=0;
    for(int i=0;i<min(n,k);i++){
        s+=dp[i];
    }
    mx=max(mx,s);
    for(int i=min(n,k);i<n;i++){
        s+=dp[i];
        s-=dp[i-min(n,k)];
        mx=max(mx,s);
    }
    cout << mx <<"\n";

}


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

int main()
{
    long long n, m;

    scanf("%lld%lld", &n, &m);
    if (n >= m / 2) {
        printf("%lld\n", m / 2);
    } else {
        m -= n * 2;
        n += m / 4;
        printf("%lld\n", n);
    }
}


Measured memory_bytes: 256
def main():
  n, a = map(int, input().split())
  xlst = list(map(int, input().split()))
  xlst.insert(0, 0)
  """
  dp[i][j][k] ... iまででj個使ってkを作る
  dp[i][j][k] += dp[i - 1][j - 1][k - x]
  """
  
  dp =  [[[0] * (50 * n + 1) for _ in range(n + 1)] for _ in range(n + 1)]
  for i in range(n + 1):
    dp[i][0][0] = 1
  
  
  for i in range(1, n + 1):
    x = xlst[i]
    dpi = dp[i]
    dpi_1 = dp[i - 1]
    for j in range(1, n + 1):
      dpij = dpi[j]
      dpi_1j = dpi_1[j]
      dpi_1j_1 = dpi_1[j - 1]
      for k in range(1, n * 50 + 1):
        if k >= x:
          #dp[i][j][k] += dp[i - 1][j - 1][k - x] + dp[i - 1][j][k]
          dpij[k] += dpi_1j_1[k - x] + dpi_1j[k]
        else:
          #dp[i][j][k] += dp[i - 1][j][k]
          dpij[k] += dpi_1j[k]
  
  ans = 0
  for j in range(1, n + 1):
    ans += dp[n][j][j * a]
  
  print(ans)

main()

Measured memory_bytes: 62972
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    int N = scanner.nextInt();
    int T = scanner.nextInt();
    int A = scanner.nextInt();
    int[] H = new int[N];
    for (int i = 0; i < N; i++) {
      H[i] = scanner.nextInt();
    }
    int ans = -1;
    double closest = 1_000_000;
    for (int i = 0; i < N; i++) {
      if (ans < 0 || Math.abs(T - H[i] * 0.006 - A) < closest) {
        ans = i + 1;
        closest = Math.abs(T - H[i] * 0.006 - A);
      }
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 23636
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
#define DBG(X) cout << #X << "=" << (X) << '\n';
#define SAY(X) cout << (X) << '\n';
#else
#define DBG(X)
#define SAY(X)
#endif

#define M_PI       3.14159265358979323846

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

std::string pad(int num)
{
    char buffer[4];
    std::snprintf(buffer, sizeof(buffer), "%03d", num);
    return buffer;
}

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

#ifdef _MSC_VER
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#endif

bool solve()
{
    int n;
    cin >> n;

    vector<int> v = fetch_vec<int>(n);
    int counter = 0;

    for (int i = 1; i < n - 1; ++i)
    {
        if ((v[i] <= v[i+1] && v[i] >= v[i-1]) || (v[i] >= v[i + 1] && v[i] <= v[i - 1]))
            ++counter;
    }

    cout << counter << endl;

    return true;
}

int main()
{
    solve();

    return 0;
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    s = input()

    n = len(s) // 2
    p = s.count("p")
    print(n - p)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 3188
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))

def gcd(a, b):
    if b == 0: return a
    if (a, b) in memo: return memo[(a, b)]
    res = memo[(a, b)] = gcd(b, a % b)
    return res
memo = {}

def main():
    md = 10 ** 9 + 7
    h, w, t = MI()
    # t=1のパターンに置き換える
    h1 = h // gcd(h, t)
    w1 = w // gcd(w, t)
    ans = (pow(2, h1, md) + pow(2, w1, md) + pow(2, gcd(h1, w1), md) - 3) % md
    # print(ans)
    # t=1のパターンの個数分累乗
    ans = pow(ans, gcd(h, t) * gcd(w, t), md)
    print(ans)

main()


Measured memory_bytes: 3188