akhauriyash/Code-Regression huggingface dataset:
// Rakib (CSE'19)
         
        #include<bits/stdc++.h>
         
         
        #define               ll               long long
        #define               boost_           ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
        #define               pb               push_back
        #define               ull              unsigned long long
        #define               read(i,n,a)      for(i=0;i<n;++i) cin>>a[i];
        #define               show(i,a)        for(auto i:a) cout<<i<<" "; cout<<endl;
        #define               dpoint(n)        cout<<showpoint<<fixed<<setprecision(n);
         
        using namespace std;
         
        int gcd(int x,int y){
            if(!y) return x;
            return gcd(y,x%y);
        }
        bool sortbysec(const pair<int,int>&a, const pair<int,int>&b){ return (a.second<b.second); }
        bool sortbysecinrev(const pair<int,int>&a, const pair<int,int>&b){ return (a.second>b.second); }
        bool sortbysize(string &s1,string &s2){ return s1.size() < s2.size(); }
        bool sortinrev(const pair<int,int> &a, const pair<int,int> &b){ return (a.first > b.first); }
        bool sortcol( const vector<int>& v1, const vector<int>& v2 ) { return v1[0] < v2[0]; }

        ll proceed(){
           
           ll n;
           cin >> n;
           
           ll i,ans=0;
           for(i=1;i<n;++i){
               
               if(i*i<n) ans+=2*i-1;
               else   ans+=((n-1)/i)*2;
               
           }
           
           cout << ans << endl;

           return 0;
       }
            //** Main **//
         
        int main(){
         
                boost_;
                int t=1,i=0;
               // cin >> t;
                while(t--){
         
                    proceed();
         
                }
         
                return 0;
        }

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#include <typeinfo>
#include <cxxabi.h>
#ifdef LOCAL
  #include "dbgtoki.hpp"
  #define DUMP(i) dump((string)TOSTRING(i), demangle(typeid(i).name()), __LINE__ , i) 
DbgTimer D_t;
  #define TSTART() D_t.start()
  #define TSTOP() D_t.stop()
#else
  #define DUMP(i) 
  #define TSTART()
  #define TSTOP()  
#endif
 
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(s) (s).begin(), (s).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()) , v.end());
using namespace std;
typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;

const int EPS = 1e-9;

int main (){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b;
  while(cin >> a >> b){
    TSTART();
    int ans = a+b;
    if(ans >= 10) cout << "error" << endl;
    else cout << ans << endl;
    TSTOP();
  }
    return 0;
}



Measured memory_bytes: 256
N, A, B = map(int, input().split())
N_i = []
k = 0
total = 0

for i in range(N + 1):
    k = i
    for j in range(5):
        N_i.append(k % 10)
        k = k // 10

    if A <= sum(N_i) and sum(N_i) <= B:
        total += i

    N_i = []

print(total)

Measured memory_bytes: 3060
//36
#include<iostream>

using namespace std;

int main(){
  static bool cmp[10000001]={};
  for(int i=2;i<=10000000;i++){
    if(!cmp[i]){
      for(int j=2;i*j<=10000000;j++){
	cmp[i*j]=true;
      }
    }
  }
  for(int n;cin>>n,n;){
    for(;;n--){
      if(!cmp[n]&&!cmp[n-2]&&!cmp[n-6]&&!cmp[n-8])break;
    }
    cout<<n<<endl;
  }
  return 0;
}

Measured memory_bytes: 10000
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
int way[51];
int main(){
	ull i,n,m,ans=0;
	cin>>n>>m;
	memset(way,0,sizeof(0));
	for(i=1;i<=m;i++){
		int a,b;
		cin>>a>>b;
		way[a]++;
		way[b]++;
	} 
	for(i=1;i<=n;i++)
		cout<<way[i]<<endl;
	return 0;
}

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

int main(void) {
  char a, b;
  cin >> a >> b;
  if (a == 'H' && b == 'H' || a == 'D' && b == 'D')
    cout << 'H' << endl;
  else
    cout << 'D' << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <complex>

using namespace std;

#define loop(i,a,b) for(int i=(a); i<(int)(b); i++)
#define rep(i,b) loop(i,0,b)
#define all(c) (c).begin(), (c).end()

typedef complex<int> P;

auto compfn = [](const P& p, const P &q)->bool{
    return p.real()!=q.real() ?
    p.real()<q.real() : p.imag()<q.imag();
};

int main(){
    int n;
    while(cin>>n,n){
        vector<P> v(n);
        rep(i,n){
            int x,y; cin>>x>>y;
            v[i]=P(x,y);
        }
        int ans=0;
        sort(all(v),compfn);
        rep(i,n)rep(j,i){
            P &p=v[i], &q=v[j];
            P ii=P(0,1);
            P a=p+(q-p)*ii, b=q+(q-p)*ii;
            if((binary_search(all(v),a,compfn)&&
                binary_search(all(v),b,compfn))){
                ans=max(norm(a-b),ans);
            }
        }
        cout<<ans<<endl;
    }
}

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

int main(){
    string s;
    cin >> s;
    for(int i=0;i<4;++i){
        int cnt = 0;
        for(int j=0;j<4;++j){
            if(s[i] == s[j]) ++cnt;
        }
        if(cnt != 2){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    
    return 0;
}

Measured memory_bytes: 256
N,K = map(int,input().split())

H = []
for i in range(N):
  h = int(input())
  H.append(h)
H.sort()

hmax_hmin = []
for i in range(N-K+1):
  hmax_hmin.append(H[i+K-1] - H[i]) 
print(min(hmax_hmin))

Measured memory_bytes: 11288
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <functional>

using namespace std;

using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define Rep(i, n) for (long long i = 0; i< (long long)(n); i++)
#define RRep(i,n) for (long long i = ((long long)(n)-1); i>=0; i--)

struct Edge{
    int to;
    int weight;
    Edge(int t, int w) : to(t), weight(w){ }
};

using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;

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

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

template <class T>
T gcd(T a, T b){
    if( b==0 ) return a;
    return gcd(b, a%b);
}

template <class T>
T lcm(T a, T b){
    return (a*b)/gcd(a,b);
}

int INF = 1e9+7;

vector<int> dx = {-1,0,1,0};
vector<int> dy = {0,-1,0,1};

int main(){
    int n;
    cin >> n;
    int ans = n*(n+1)/2;
    cout << ans << endl;
}

Measured memory_bytes: 256
# C - Attack Survival
from collections import Counter

N, K, Q = map(int, input().split())
a = [int(input()) for i in range(Q)]
A = Counter(a)
B = 1 - (K-Q)

for i in range(N):
    if A[i+1] >= B:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 11900
N,K = map(int,input().split())
XYC = [tuple(map(int,input().split())) for i in range(N)]

from math import hypot,acos,atan2,cos,sin
def circles_cross_points(x1,y1,r1,x2,y2,r2):
    d = hypot(x1-x2, y1-y2)
    if r1 + r2 < d or abs(r1 - r2) >= d: return []
    x = (r1**2 + d**2 - r2**2) / (2*r1*d)
    if not -1 <= x <= 1: return []
    a = acos(x)
    t = atan2(y2-y1, x2-x1)
    return [
        (x1+cos(t+a)*r1, y1+sin(t+a)*r1),
        (x1+cos(t-a)*r1, y1+sin(t-a)*r1)
    ]

eps = 10e-10
def is_ok(t):
    cands = []
    for x,y,_ in XYC:
        cands.append((x,y))
    for i,(x1,y1,c1) in enumerate(XYC[:-1]):
        for x2,y2,c2 in XYC[i+1:]:
            ps = circles_cross_points(x1,y1,t/c1,x2,y2,t/c2)
            cands += ps
    for cx,cy in cands:
        k = 0
        for x,y,c in XYC:
            d = hypot(cx-x,cy-y)
            if c*d <= t + eps:
                k += 1
                if k >= K:
                    return True
    return False

ok = 10**10
ng = 0
for _ in range(100):
    m = (ok+ng)/2
    if is_ok(m):
        ok = m
    else:
        ng = m
    if ok-ng < 10e-7: break
print(ok)

Measured memory_bytes: 3316
import sys
import itertools

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


def resolve():
    n, m, q = map(int, input().split())
    ABCD = [list(map(int, input().split())) for _ in range(q)]

    res = 0
    for pattern in itertools.combinations_with_replacement(range(1, m + 1), n):
        score = 0
        for a, b, c, d in ABCD:
            if pattern[b - 1] - pattern[a - 1] == c:
                score += d
        res = max(res, score)

    print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 73448
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }

        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var NK = Sarray();
            var N = NK[0];
            var K = NK[1];
            var RSP = Sarray();
            var dct = new Dictionary<char, long>();
            dct['s'] = RSP[0];
            dct['p'] = RSP[1];
            dct['r'] = RSP[2];
            var T = ReadLine().ToCharArray();
            var ans = 0L;
            for (var i = 0; i < K; ++i)
                ans += dct[T[i]];
            for (var i = K; i < N; ++i)
            {
                if (T[(int)(i - K)] == T[(int)i])
                {
                    T[(int)i] = 'u';
                    continue;
                }
                ans += dct[T[(int)i]];
            }
            WriteLine(ans);
            //Out.Flush();
        }
    }
}

Measured memory_bytes: 13920
N, M = map(int, input().split())

ks_lists = [list(map(int, input().split())) for _ in range(M)]
p_list = list(map(int, input().split()))


n_combi = 0
for combi in range(1 << N):
    Flag = True
    for i in range(M):
        k = ks_lists[i][0]
        s_list = ks_lists[i][1:]
        p = p_list[i]

        tmp_sum = 0
        for s in s_list:
            tmp_sum += (combi >> (s-1)) & 1
        if tmp_sum % 2 != p:
            Flag = False
            break
    if Flag:
        n_combi += 1

print(n_combi)


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

int main()
{
  int N; cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; ++i)
  {
    cin >> A[i];
  }
  
  long long cnt = 0;
  for (auto& a : A)
  {
    while (a % 2 == 0)
    {
      a /= 2;
      cnt++;
    }
  }
  
  cout << cnt << "\n";
  
  return 0;
}


Measured memory_bytes: 892
#include<stdio.h>

#define MAX 1000000

int main(){
  char prime[MAX];
  int num,i,j,ans;

  for(i = 0; i < MAX; i++){
    prime[i] = 1;
  }

  prime[0] = prime[1] = 0;

  for(i = 2; i < (MAX /2); i++){
    if(prime[i]){
      for(j=2*i;j<MAX;j+=i){
	prime[j] = 0;
      }
    }
  }

  while(scanf("%d",&num) != EOF){
    ans = 0;
    for(i=2;i<=num;i++){
      ans += prime[i];
    }
    printf("%d\n",ans);
  }

  return 0;
}

Measured memory_bytes: 1572
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch LimitedInsertion | diff LimitedInsertion.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address LimitedInsertion.cpp && ./a.out

/*
 
 3/23/2019
 
 22:00-22:57 give up
 
 3/26/2019
 
 12:25- read editorials
 
 https://img.atcoder.jp/agc032/editorial.pdf
 
 Research all the cases in small data set.
 It's possible to figure out that B[i]>=i is the condition to build B.
 Let's move backward. If we can build `B`, there should exist `i` s.t. B[i]==i.
 We can remove max { i s.t. B[i]==i} because it doesn't break j<i s.t. B[j]==j.
 Thus maximum such `i` is optimal. We can greedily keep removing until getting empty.
 
 */

const int MAX_N=1e2+1;
int B[MAX_N];
int N;

VI res;
void f(VI &X) {
  int N=SZ(X);
  for(int i=N-1; i>=0; --i) if(i+1==X[i]) {
    res.push_back(X[i]);
    VI Y;
    REP(j,N) if(i!=j) Y.push_back(X[j]);
    f(Y);
    return;
  }
}
void solve() {
  VI X(B,B+N);
  f(X);
  if(SZ(res)!=N) {
    println("-1");    
  } else {
    reverse(ALL(res));
    FORR(x,res) println("%d",x);
  }
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>N;
  REP(i,N) cin>>B[i];
  solve();
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int s1,s2,s3,a;
  cin >> a;
  s1 = a/100;
  s2 = a/ 10 % 2;
  s3 = a % 2;
  cout << s1 + s2 + s3 << endl;
}

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


#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()

#define int long long

#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second

#define mod 1000000007

template <typename T>
void print(T x)
{
	std::cout << x <<" " ;
}


template <typename T>
void println(T x)
{
	std::cout << x << "\n";
}

signed main(void) {
	int n,k;
	cin >> n>>k;

	vector<double>p(n);
	vector<double>s(n+1,0);

	double tmp = 0;
	rep(i, n) {
		cin >> tmp;
		p[i] = (tmp + 1) / 2;
	}
	
	rep(i, n) {
		s[i+1] = s[i+1]=s[i]+p[i];
	}
	double ans= 0;

	rep(i, n-k+1) {
		ans = max(s[i + k] - s[i],ans);
	}

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

Measured memory_bytes: 3456
import * as fs from "fs";
const input = fs.readFileSync("/dev/stdin", "utf-8");

const main = (input: string): void => {
  const N = parseInt(input, 10);
  let pow = 1;

  for (let i = 1; i <= N; i++) {
    pow = (pow * i) % 1000000007;
  }
  console.log(pow);
};

main(input);


Measured memory_bytes: 33108
//@author :  |< U $ |-|
#include<cmath>
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<deque>
#include<queue>
#include<algorithm>
#include<list>
#include<cstring>
#include<unordered_map>
#define ll long long
// #define pb push_back
// #define pop pop_back
#define pi pair<long long ,long long>
#define mp make_pair
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define jaldi ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define inm1(b)  memset(b,-1,sizeof(b))
#define in0(b) memset(b,0,sizeof(b))
#define ininf(b) memset(b,1000000001,sizeof(b))
#define MOD 1e9+7
#define inf 10000000001
#define d1(a) cout<<a<<" "<<endl
#define d2(a,b) cout<<a<<" "<<b<<endl
#define d3(a,b,c) cout<<a<<" "<<b<<" "<<c<<endl
#define TakeInput freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
using namespace std;

ll gcd(ll a, ll b) {if(a == 0)return b;return gcd(b % a, a);}



int main(){
    
    jaldi
    #ifndef ONLINE_JUDGE
    TakeInput
    #endif
    
    ll h,w,sx,sy,ex,ey;
    ll i,j,k;

    cin>>h>>w>>sx>>sy>>ex>>ey;
    string a[h];
    sx--;sy--;ex--;ey--;
    for(i=0;i<h;i++)cin>>a[i];

    deque<pi> q;
    q.push_back(mp(sx,sy));
    vector<vector<ll> > dis(h+1,vector<ll> (w+1,inf));

    dis[sx][sy] = 0;
    while(!q.empty()){

        ll cx = q.front().F;
        ll cy = q.front().S;

        ll r[] = {1,-1,0,0};
        ll c[] = {0,0,1,-1};

        q.pop_front();

        // d2(cx,cy);
        for(i=0;i<4;i++){
            ll nx = cx + r[i];
            ll ny = cy + c[i];
            if(nx<h && ny<w && ny>=0 && nx>=0 && a[nx][ny] != '#'){
                if(dis[nx][ny] > dis[cx][cy]){
                    dis[nx][ny] = dis[cx][cy];
                    q.push_front(mp(nx,ny));
                }
            }
        }

        for(i=cx-2 ; i<=cx+2 ; i++){
            for(j=cy-2 ; j<=cy+2 ; j++){
            
                if(i<h && j<w && j>=0 && i>=0 && a[i][j] != '#'){
                    if(dis[i][j] > dis[cx][cy] + 1){
                        dis[i][j] = dis[cx][cy] + 1;
                        q.push_back(mp(i,j));
                    }
                }
            }
        }

    }

    cout<< (dis[ex][ey]==inf ? -1 :  dis[ex][ey]);



}


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

int main() {
  string strx;
  int size;
  
  cin >> strx;
  
  size = strx.size();
  
  if (strx.at(0) == strx.at(1) && strx.at(1) == strx.at(2)){
    cout << "Yes" << endl;
  } else if (strx.at(1) == strx.at(2) && strx.at(2) == strx.at(3)){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#pragma GCC optimize("Ofast")

// Begin {{{
using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

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

template <class T>
inline vector<T> make_v(const T &initvalue, intmax_t sz) {
    return vector<T>(sz, initvalue);
}

template <class T, class... Args>
inline auto make_v(const T &initvalue, intmax_t sz, Args... args) {
    return vector<decltype(make_v<T>(initvalue, args...))>(sz, make_v<T>(initvalue, args...));
}

constexpr int INF = 0x3f3f3f3f;
constexpr int64_t LINF = 0x3f3f3f3f3f3f3f3fLL;
// }}} End

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

    size_t N; cin >> N;

    vector<size_t> vec;
    unordered_map<size_t, size_t> cnt;
    for (size_t i = 0; i < N; ++i) {
        size_t a; cin >> a;
        cnt[a]++;
        if (cnt[a] >= 2) {
            vec.emplace_back(a);
            cnt[a] = 0;
        }
    }

    sort(vec.rbegin(), vec.rend());

    cout << (vec.size() >= 2 ? vec[0] * vec[1] : 0) << "\n";

    return 0;
}


Measured memory_bytes: 4388
#include "bits/stdc++.h"
using namespace std;

#define fi first
#define se second
#define pb push_back
#define int long long
#define all(x) (x).begin(), (x).end()

using LL = long long;
using LD = long double;
using pii = pair<int, int>;
using vii = vector<pii>;

const int INF = 1e18;
const int MOD = 1e9 + 7;
const int N = 1e5 + 5;

int n;
int a[N], b[N];

int32_t main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);

	cin >> n;

	for (int i = 1; i <= n + 1; i++) {
		cin >> a[i];
	}

	for (int i = 1; i <= n; i++) {
		cin >> b[i];
	}

	int ans = 0;
	for (int i = 1; i <= n; i++) {
		if (b[i] >= a[i]) {
			ans += a[i];
			b[i] -= a[i];
			a[i] = 0;
			if (b[i] >= a[i + 1]) {
				ans += a[i + 1];
				b[i] -= a[i + 1];
				a[i + 1] = 0;
			} else {
				ans += b[i];
				a[i + 1] -= b[i];
				b[i] = 0;
			}
		} else {
			ans += b[i];
			a[i] -= b[i];
			b[i] = 0;
		}
	}

	cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef std::function<bool (int64_t x)> FT;
int64_t f(int64_t i, int64_t e, const FT &g)
  {int64_t m = 0, t = e;
  while (llabs(i - e) > 1) {m = (i + e) / 2; if (g(m)) i = m; else e = m;}
  return g(i) ? i : t;}
int main()
  {string s, t; cin >> s >> t;
  map<char, vector<int>> m;
  for (int i = 0; i < s.size(); ++i) m[s[i]].push_back(i);
  auto i = 0LL, ans = 0LL;
  for (auto c: t)
    {auto is = m[c];
    if (is.empty()) {puts("-1"); return 0;}
    auto g = [&](int64_t x) {return i <= is[x];};
    auto j = f(is.size() - 1, -1, g);
    if (j == -1)
      {ans += s.size();
      i = 0; i = is[f(is.size() - 1, -1, g)] + 1;}
    else i = is[j] + 1;}
  ans += i; cout << ans << endl;}

Measured memory_bytes: 4440
/*input
1 5 2 0
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<long long, null_type, less<long long>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
typedef long long int ll;
#define ld long double
#define pii pair<ll,ll>
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
const ll maxn=60005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const ld PI=acos(-1);
const ld eps=1e-9;

ll mypow(ll a,ll b){
    if(b<=0) return 1;
    ll res=1LL;
    while(b){
        if(b&1) res=res*a%MOD;
        a=a*a%MOD;
        b>>=1;
    }
    return res;
}
int main(){
    int h,w,a,b;
    cin>>h>>w>>a>>b;
    swap(a,b);
    REP(i,a){
        REP(j,b){
            cout<<0;
        }
        REP(j,w-b) cout<<1;
        cout<<'\n';
    }
    REP(i,h-a){
        REP(j,b) cout<<1;
        REP(j,w-b) cout<<0;
        cout<<'\n';
    }
}

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

int selectionSort(int a[], int N){
	int idx = 0;
	for ( int i = 0; i < N-1; i ++){
		int minj = i;
		for ( int j = i + 1; j < N; j++){
			if ( a[j] < a[minj] ) minj = j;
		}
		if ( minj != i ){
			int tmp = a[i];
			a[i] = a[minj];
			a[minj] = tmp;
			idx++;
		}
	}
	return idx;
}

int main(){
	int N;
	int a[100];
	cin >> N;
	for ( int i = 0; i < N; i++) cin >> a[i];

	int idx = selectionSort( a, N);

	for ( int i = 0; i < N; i++){
		if (i) cout << " ";
		cout << a[i];
	}
	cout << endl;
	cout << idx << endl;
	return 0;
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a) for(int i=0;i<(a);i++)
const ll MOD=1000000007;
// const ll MOD=998244353;

int A[101010],L[101010],R[101010];

int main(){
  int N; cin>>N;
  for(int i=1;i<=N;i++) cin>>A[i];
  L[1]=A[1];
  for(int i=2;i<=N;i++) L[i]=__gcd(L[i-1],A[i]);
  R[N]=A[N];
  for(int i=N-1;i>=1;i--) R[i]=__gcd(R[i+1],A[i]);
  L[0]=R[2], R[N+1]=L[N-1];
  int ans=1;
  for(int i=1;i<=N;i++){
    ans=max(ans,__gcd(L[i-1],R[i+1]));
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1536
object Main {

  def main(args: Array[String]): Unit = {
    import scala.io.StdIn._

    val c = (0 until 3).map { _ =>
      readLine().split(" ").map(_.toInt)
    }. toArray

    val forI = (0 until 2) forall { i =>
      (0 until 2) forall { j =>
        (c(i)(j) - c(i+1)(j)) == (c(i)(j+1) - c(i+1)(j+1))
      }
    }
    val forJ = (0 until 2) forall { j =>
      (0 until 2) forall { i =>
        (c(i)(j) - c(i)(j+1)) == (c(i+1)(j) - c(i+1)(j+1))
      }
    }

    if (forI && forJ)
      println("Yes")
    else
      println("No")
  }

}

Measured memory_bytes: 27212
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,no-stack-protector,fast-math")
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
const int N = 4e5 + 5, M = 2 * N + 5;


int main(){
    string s;
    cin >> s;
    if(s == "ABC")cout << "ARC" << endl;
    if(s == "ARC")cout << "ABC" << endl;
}


Measured memory_bytes: 3536
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>

using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;

int main() {
  int N; ll x; cin>>N>>x;
  vector<ll> a(N);
  REP(i,N) cin>>a[i];
  sort(a.begin(), a.end());
  int ans = 0;
  REP(i,N) {
    x -= a[i];
    if(x < 0LL) {
      break;
    }
    ans++;
  }
  if(x > 0LL) ans --;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstring>  // memset()
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#define ll long long
#define For(i, a, b) for (int i = (int)(a), sz = (int)(b); i < sz; i++)
#define rFor(i, a, b) for (int i = (int)(a); i >= (int)(b); i--)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define fill(a, b) memset(a, b, sizeof(a))
#define IO ios_base::sync_with_stdio(0), cin.tie(0)

const int MAX = 2e5 + 5;

int main() {
    IO;
    ll n, a, have = 0, c = 1000, prev;
    cin >> n >> prev;
    For(i, 1, n) {
        cin >> a;
        if (a > prev) {
            have = c / prev, c %= prev;
            c += have * a;
        }
        prev = a;
    }
    printf("%lld\n", c);
    return 0;
}

Measured memory_bytes: 3776
open Batteries
let () =
  let a,b,c = Scanf.scanf "%d %d %d " (fun a b c -> a,b,c) in
  let lst = List.sort compare [a;b;c] in
  Printf.printf "%s\n" @@
  if List.nth lst 2 = ((List.nth lst 0) + (List.nth lst 1)) then "Yes" else "No"


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

int main() {
  string S;
  cin >> S;
  int n = S.length();
  bool c;
  for (int i=n-2; i>0; i-=2) {
    c = true;
    int h = i/2;
    for (int j=0; j<h; j++)
      if (S[j] != S[j+h])
        c = false;
    if (c) {
      cout << i << endl;
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<complex>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;

using namespace std;
#define N 200010
ll n,a[N];
int main(){
    cin>>n;
    lol(i,n){
	cin>>a[i];
	a[i]-=i;
    }
    sort(a,a+n);
    ll t=a[n/2];
    ll ans=0;
    lol(i,n){
	ans+=abs(t-a[i]);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<ll,ll>;
#define rep(i,n) for(ll i=0;i<(ll)n;++i)
const ll INF = 999999999999999;
ll n,m,x;
ll ans = INF;
vector<vector<ll>> book;
vector<ll> und;

void dfs( ll num ,ll cst ,vector<ll> now ){
  if( num == n ){
    sort(now.begin(),now.end());
    //cout << cst << " " << now.at(0) << endl;
    if( now.at(0) >= x ){
      ans = min(ans,cst);
    }
    return;    
  }
  dfs(num+1,cst,now);
  rep(i,m) now.at(i) += book.at(num).at(i+1);
  cst += book.at(num).at(0);
  dfs(num+1,cst,now);
}
  

int main(){
  cin >> n >> m >> x;
  book.resize(n);
  for(ll i=0;i<n;++i) book.at(i).resize(m+1);
  rep(i,n) rep(j,m+1) cin >> book.at(i).at(j);
  vector<ll> now(m);
  dfs(0,0,now);
  if( ans == INF ){
    cout << -1 << endl;
    return 0;
  }
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3640
#include <iostream>
using namespace std;
long long m5[2001];

int main(void) {
  long long X;
  cin >> X;
  for (long long i = 0; i <= 1000; i++) {
    m5[1000+i] = i*i*i*i*i;
    m5[1000-i] = -m5[1000+i];
  }

  for (int A = -1000; A <= 1000; A++) {
    for (int B = -1000; B <= 1000; B++) {
      if ((m5[A+1000] - m5[B+1000]) == X) {
        cout << A << " " << B << endl;
        return 0;
      }
    }
  }
  cout << 0 << endl; // err
  return 0;
}


Measured memory_bytes: 3580
#include<iostream>
#include<bits/stdc++.h>
#define int long long
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int32_t main()
{ fast;
  int a,b,c;
  cin>>a>>b>>c;
 // int k=max(a,b);
  if(c<=(a+b))
  {
    cout<<"No";
  }
  else
  {
    if(4*a*b<(c-a-b)*(c-a-b))
    {
    	cout<<"Yes";
	}
	else
	{
		cout<<"No";
	}
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
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){return b?gcd(b,a%b):a;}
const LL mod=1000000007;
const LL LINF=1LL<<62;
const int INF=1<<30;
int dx[]={1,0,-1,0,1,-1,1,-1};
int dy[]={0,1,0,-1,1,-1,-1,1};

int n,m,q;
vector<int> a(50),b(50),c(50),d(50);
int v[10];

int dfs(int k,int s){
    if(k == n){
        int r = 0;
        for (int i = 0; i < q; i++) {
            if(v[b[i]] - v[a[i]] == c[i]) r += d[i];
        }
        return r;
    }
    int ret = 0;
    for (int i = s; i <= m; i++) {
        v[k] = i;
        chmax(ret, dfs(k+1, max(i,s)));
    }
    return ret;
}

int main(){
    cin >> n >> m >> q;
    for (int i = 0; i < q; i++) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        a[i]--,b[i]--;
    }
    cout << dfs(0, 1) << endl;
    return 0;
}


Measured memory_bytes: 3644
import Control.Monad
f i = do
  aopb_in <- (return . words) =<< getLine
  let a = (read::String->Int) (aopb_in !! 0)
  let b = (read::String->Int) (aopb_in !! 2)
  let op = aopb_in !! 1
  if op == "?"
    then return () else do
      when (op == "+") (putStrLn (show (a + b)))
      when (op == "-") (putStrLn (show (a - b)))
      when (op == "*") (putStrLn (show (a * b)))
      when (op == "/") (putStrLn (show (a `div` b)))
      f $ i+1

main = f 1



Measured memory_bytes: 4100
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
#define MOD 1000000007
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define all(v) (v).begin() , (v).end()
#define sumof(v) accumulate(all(v), 0LL, plus<ll>())
#define maxof(v) max_element(all(v))
#define minof(v) min_element(all(v))
#define inf INT_MAX

void dfs(vector<int>* graph, int start, vector<int>& dp, vector<bool>& visited){
    visited[start] = true;
    for(int i=0; i<graph[start].size(); ++i){
        if(visited[graph[start][i]]==false){
            dfs(graph, graph[start][i], dp, visited);
        }
        dp[start] = max(dp[start], 1 + dp[graph[start][i]]);
    }
    return;
}

int main(){
    FASTIO
    ll N, M; cin>>N>>M;
    vector<int> graph[N+1];
    for(int i=0; i<M; ++i){
        int x, y; cin>>x>>y;
        graph[x].push_back(y);
    }
    vector<int> dp(N+1, 0);
    vector<bool> visited(N+1, false);
    for(int i=1; i<=N; ++i){
        if(visited[i]==false){
            dfs(graph, i, dp, visited);
        }
    }
    int ans = 0;
    for(int i=1; i<=N; ++i){
        ans = max(ans, dp[i]);
    }
    cout<<ans<<endl;
}

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

public class Main{

    public static void main(String[] args) throws IOException {
        // write your code here

        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

        int n = Integer.parseInt(reader.readLine());
        System.out.println(Math.PI*2*n);
        //System.out.println(2*3.14*n);

    }
}


Measured memory_bytes: 33076
#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0
#define ll long long

int n, k;
vector <int> a;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> k;
    a.resize(n);
    for(auto &i : a) cin >> i;
    ll cur = 0;
    for(int i = k ; i < n ; i++){
        cur += max(0, a[i]);
    }
    ll sum = 0;
    for(int i = 0 ; i < k ; i++){
        sum += a[i];
    }
    ll ans = cur + max(0LL, sum);
    for(int i = k ; i < n ; i++){
        cur -= max(0, a[i]);
        cur += max(0, a[i - k]);
        sum += a[i];
        sum -= a[i - k];
        ans = max(ans, cur + max(0LL, sum));
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
N, M = [int(i) for i in input().split()]
p_ls = [int(i) - 1 for i in input().split()]

par = [i for i in range(N)]
rank = [1 for i in range(N)]

def find(x):
    if par[x] == x:
        return x
    else:
        return find(par[x])

def unite(x, y):
    x = find(x)
    y = find(y)
    if x == y:
        pass
    else:
        if rank[x] > rank[y]:
            par[y] = x
            rank[x] += rank[y]
        else:
            par[x] = par[y]
            rank[y] += rank[x]

def is_same(x, y):
    if find(x) == find(y):
        return True
    else:
        return False

data_ls = list()
for i in range(M):
    x, y = [int(i)-1 for i in input().split()]
    if is_same(x, y):
        pass
    else:
        unite(x, y)
cnt = 0
for i in range(N):
    if is_same(i, p_ls[i]):
        cnt += 1
print(cnt)

Measured memory_bytes: 13880
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <deque>

int main(){
  int K, T;
  scanf("%d", &K);
  scanf("%d", &T);
  std::vector<int > a(T);
  int maxval = 0;
  for (int i=0; i<T; i++){
    scanf("%d", &a[i]);
    maxval = std::max(maxval, a[i]);
  }
  int half = (K+1)/2;
  if (K%2==0){
    printf("%d\n", std::max(0, 2*(maxval-half)-1));
  } else {
    printf("%d\n", std::max(0, 2*(maxval-half)));
  }
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#define rep(i,n) for(int i = 0; i < n;i++)
#define ll long long
#include <bits/stdc++.h>
using namespace std;
int main() {
  ll n,a,b,c,d,e;cin>>n>>a>>b>>c>>d>>e;
  ll ans=0;
  ll x;
  x=min(min(a,b),c);
  x=min(min(x,d),e);
  ans=(n+x-1)/x;
  
  cout<<ans+4;
}
    
    

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

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var ss = Console.ReadLine().Split();
            var N = int.Parse(ss[0]);
            var A = int.Parse(ss[1]);
            var B = int.Parse(ss[2]);

            Console.WriteLine(Math.Min(N * A, B));
        }
    }
}

Measured memory_bytes: 13140
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <tuple>
#include <algorithm>
#include <array>
using namespace std;
using ll = long long;
#define rep(i,n) for(decltype(n) i=0; i<n; ++i)
inline constexpr ll Inf = (1ULL << 62) -1;

template <class T>
void updatemax(T& a, T b) { if (b > a) a = b; }

int main() {
    ll k;
    cin >> k;

    ll n=7;
    vector<bool> r(k);
    for (ll i=1; i<=k; ++i) {
        ll m = n % k;
        if (m == 0) {
            cout << i << endl;
            return 0;
        }
        if (r.at(m))
            break;
        r.at(m) = true;
        n = n*10+7;
        n %= k;
    }
    
    cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 3272
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 1; i < (n); i++) 
#define out(n) cout << n << endl;

int main() {
    long long n,k,now=1,range,loop;
    bool flg = false;
    cin >> n >> k;

    int dp[n+1][2],a[n+1];

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

    for (int i = 1; i < n+1; i++)
    {
        cin >> a[i];
    }

    for (int i = 1; i < k+1; i++)
    {
        if(dp[a[now]][0] > 0){
            range = i-dp[a[now]][1];
            flg = true;
            break;
        }
        dp[a[now]][1] = i;
        dp[a[now]][0] = 1;
        now = a[now];
    }

    if(flg == true){
        loop = (k - dp[a[now]][1])/range;
        int ans_count = k - dp[a[now]][1]+1 - loop*range;

        for (int i = 0; i < ans_count; i++)
        {
            now = a[now];
        }

        out(now);
    }else{
        out(now);
    }
    

}

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

#define REP(i, n, N) for(ll i=(n); i<(N); i++)
#define RREP(i, n, N) for(ll i=(N-1); i>=(n); i--)
#define LREP(lst,itr) for(auto itr = lst.begin(); itr != lst.end(); ++itr)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define P(s) cout<<(s)<<endl
#define P2(a, b) cout<<(a)<<" "<<(b)<<endl
#define P3(a, b, c) cout<<(a)<<" "<<(b)<<" "<<(c)<<endl
#define V2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

//A,Bの最大公約数(ユークリッドの互除法)
ll gcd(ll A,ll B){
    if(A<B) swap(A,B);
    return (B==0 ? A : gcd(B,A%B));
}

//A,Bの最小公倍数
ll lcm(ll A,ll B){
    return (A/gcd(A,B))*B;
}

int main(){
    int N;
    cin >> N;
    ll ans;
    vector<ll> a(N);
    REP(i,0,N) cin >> a[i];
    ans = a[0];
    REP(i,1,N){
        ans = lcm(ans, a[i]);
    }
    P(ans);
}

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

int main() {
  int N;
  double T, A;
  cin >> N >> T >> A;

  double H[N];
  for (int i = 0; i < N; i++) {
    cin >> H[i];
  }

  vector<pair<double,int>> distances;

  for (int i = 0; i < N; i++) {
    double avg = T - H[i] * 0.006;
    distances.push_back({abs(A-avg),i+1});
  }

  sort(distances.begin(),distances.end());

  cout << distances[0].second << endl;
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;

namespace AtCoder {
    class Practice {
        static void Main() => CustomMain();

        static void Solve() {
            var n = ReadInt();
            var a = ReadIntArray();

            var oddCnt = 0;
            foreach (var aa in a) {
                if (IsOdd(aa)) oddCnt++;
            }

            WriteAnswer(!IsOdd(oddCnt) ? "YES" : "NO");
        }


        static void CustomMain() {
#if DEBUG
            // ファイルからテストケースを読み込む
            global::Common.ChangeStdIn();
            // 時間計測
            var stopwatch = new Stopwatch();
            stopwatch.Start();
#endif
            // 出力高速化
            var streamWriter = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
            Console.SetOut(streamWriter);
            // 回答
            Solve();
#if DEBUG
            stopwatch.Stop();
            Console.WriteLine(stopwatch.Elapsed);
#endif
            Console.Out.Flush();
        }

        static string ReadString() => Console.ReadLine().Trim();
        static int ReadInt() => int.Parse(ReadString());
        static long ReadLong() => long.Parse(ReadString());
        static float ReadFloat() => float.Parse(ReadString());
        static double ReadDouble => double.Parse(ReadString());

        static string[] ReadStringArray() => ReadString().Split(' ');
        static int[] ReadIntArray() => Array.ConvertAll(ReadString().Split(' '), int.Parse);
        static long[] ReadLongArray() => Array.ConvertAll(ReadString().Split(' '), long.Parse);
        static float[] ReadFloatArray() => Array.ConvertAll(ReadString().Split(' '), float.Parse);
        static double[] ReadDoubleArray() => Array.ConvertAll(ReadString().Split(' '), double.Parse);

        static T TypeConversion<T>(string s) {
            if (typeof(T) == typeof(int)) {
                return (T) Convert.ChangeType(int.Parse(s), typeof(T));
            } else if (typeof(T) == typeof(long)) {
                return (T) Convert.ChangeType(long.Parse(s), typeof(T));
            } else if (typeof(T) == typeof(double)) {
                return (T) Convert.ChangeType(double.Parse(s), typeof(T));
            } else {
                return (T) Convert.ChangeType(s, typeof(T));
            }
        }

        static void ReadMulti<T, U>(out T a, out U b) {
            var str = ReadStringArray();
            a = TypeConversion<T>(str[0]);
            b = TypeConversion<U>(str[1]);
        }

        static void ReadMulti<T, U, V>(out T a, out U b, out V c) {
            var str = ReadStringArray();
            a = TypeConversion<T>(str[0]);
            b = TypeConversion<U>(str[1]);
            c = TypeConversion<V>(str[2]);
        }

        static void WriteAnswer(object ans) => Console.WriteLine(ans);

        static bool IsOdd(long num) {
            return (num & 1) == 1;
        }

        static bool IsEven(long num) {
            return (num & 1) == 0;
        }

        static long GCD(long a, long b) {
            return b != 0 ? GCD(b, a % b) : a;
        }
    }
}

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

int main(){
  int n;
  cin >> n;
  vector<int> a(n), b(n);
  for (int i = 0; i < n; i++) cin >> a.at(i);
  b = a;
  sort(b.rbegin(), b.rend());
  int mx1 = b.at(0);
  int mx2 = b.at(1);
  for(int i = 0; i < n; i++){
    if(a.at(i) == mx1) cout << mx2 << endl;
    else cout << mx1 << endl;
  }
  return 0;
}

Measured memory_bytes: 3200
#include<stdio.h>
int main (void){
	int mai,kin,i,n,m,en[6]={500,100,50,10,5,1};
	while(1){
		scanf("%d",&kin);
		if(kin==0) break;
		kin=1000-kin;
		mai=0;
		for(i=0;i<6;i++){
			mai+=kin/en[i];
			kin=kin%en[i];
		}
		printf("%d\n",mai);
	}
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define dbg puts("It's Just Begining.Wait For The End!!!!!\n")
#define CHECK(x) cout << (#x) << " is " << (x) <<"\n";
#define endl printf("\n")
typedef pair<ll,ll> pii;
#define pb push_back
#define ms(a,b) memset(a, b, sizeof(a))
#define in(x) scanf("%lld",&x)
#define out(x) printf("%lld",x)
#define X first
#define Y second
#define sps printf(" ")
#define dou(x) cout<<fixed<<setprecision(6)<<x
#define all(v) v.begin(),v.end()
int main()
{
    ll i,j,k,l,n,m,gc=0,a,b,c;
    in(k);
    for(a=1;a<=k;a++)
        for(b=1;b<=k;b++)
            for(c=1;c<=k;c++)gc+=__gcd(a,__gcd(b,c));
    out(gc);endl;
}


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

int main(){
    int n,m;
    string s, c;
    cin >> n >> s;
    m = 0;
    for(int i = 0; i < n; i++){
        if(i + 1 > n) break;
        if(s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C' ){
            m++;
        }
    }

    cout << m << endl;

}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (int i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,v) for (int i = 0; i < v.size(); i++)
#define RREPALL(i,v) for (int i = v.size()-1; i >= 0; i--)
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(v.begin(), v.end())
#define MIN_ELEMENT(v) min_element(v.begin(), v.end())
#define MAX_ELEMENT(v) max_element(v.begin(), v.end())
#define COUNT(v,n) count(v.begin(), v.end(), n)
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
typedef long long ll;
typedef unsigned long long ull;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

int main()
{
    ll n;
    cin>>n;
    cout<<(n - 1) * n / 2<<endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main
{
	public static void main(String[] args){
		
	int[] men = new int[7];
	int[] kari = new int[7];
	int[] ue = new int[30];
	int[] yoko = new int[30];
		
	Scanner scan = new Scanner(System.in);
	
	for(int i=1; i<=6; i++){
		men[i] = scan.nextInt();}
		
	int kai = scan.nextInt();
	
	for(int p=0; p<kai; p++){
		ue[p] = scan.nextInt();
		yoko[p] = scan.nextInt();}
		
	for(int p=0; p<kai; p++){
		for(int i=1; i<=6; i++){
			if(men[i]==ue[p]){
				if(i==2){
					kari[1] = men[1];		kari[2] = men[2];
					kari[5] = men[5];		kari[6] = men[6];
			
					men[1] = kari[2];		men[2] = kari[6];
					men[6] = kari[5];		men[5] = kari[1];
				}
				else if(i==3){
					kari[1] = men[1];		kari[3] = men[3];
					kari[4] = men[4];		kari[6] = men[6];
			
					men[1] = kari[3];		men[3] = kari[6];
					men[4] = kari[1];		men[6] = kari[4];
				}
				else if(i==4){
					kari[1] = men[1];		kari[3] = men[3];
					kari[4] = men[4];		kari[6] = men[6];
			
					men[1] = kari[4];		men[3] = kari[1];
					men[4] = kari[6];		men[6] = kari[3];
				}
				else if(i==5){
					kari[1] = men[1];		kari[2] = men[2];
					kari[5] = men[5];		kari[6] = men[6];
			
					men[1] = kari[5];		men[2] = kari[1];
					men[6] = kari[2];		men[5] = kari[6];
				}
				else if(i==6){
					kari[1] = men[1];		kari[2] = men[2];
					kari[5] = men[5];		kari[6] = men[6];
			
					men[1] = kari[2];		men[2] = kari[6];
					men[6] = kari[5];		men[5] = kari[1];
					
					kari[1] = men[1];		kari[2] = men[2];
					kari[5] = men[5];		kari[6] = men[6];
			
					men[1] = kari[2];		men[2] = kari[6];
					men[6] = kari[5];		men[5] = kari[1];
				}
			}
		}
		
		for(int q=0; q<4; q++){
			if(men[2]==yoko[p]){
				break;
			}
			
			kari[1] = men[1];		kari[2] = men[2];
			kari[5] = men[5];		kari[6] = men[6];
			
			men[1] = kari[2];		men[2] = kari[6];
			men[6] = kari[5];		men[5] = kari[1];
			
			kari[1] = men[1];		kari[3] = men[3];
			kari[4] = men[4];		kari[6] = men[6];
			
			men[1] = kari[4];		men[3] = kari[1];
			men[4] = kari[6];		men[6] = kari[3];
			
			kari[1] = men[1];		kari[2] = men[2];
			kari[5] = men[5];		kari[6] = men[6];
			
			men[1] = kari[5];		men[2] = kari[1];
			men[6] = kari[2];		men[5] = kari[6];
		}
		
		System.out.println(men[3]);
	}
	}
}


Measured memory_bytes: 26072
n,k,q,*a=map(int,open(0).read().split())
s=sorted
m=1e9
for b in a:
    i=[i for i,t in enumerate(a)if t<b]
    l=s(sum([s(a[i+1:j])[::-1][k-1:]for i,j in zip([-1]+i,i+[n])],[]))
    if len(l)>=q:m=min(m,l[q-1]-b)
print(m)

Measured memory_bytes: 115164
(let ((x (read)))
  (format t "~A~%"
          (cond ((<= 400 x 599) 8)
                ((<= 600 x 799) 7)
                ((<= 800 x 999) 6)
                ((<= 1000 x 1199) 5)
                ((<= 1200 x 1399) 4)
                ((<= 1400 x 1599) 3)
                ((<= 1600 x 1799) 2)
                (t 1))))

Measured memory_bytes: 24392