akhauriyash/Code-Regression huggingface dataset:
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
 
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
 
// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
 
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define f(i, n) for(int i = 0; i < n; ++i)
#define pb push_back
#define eb emplace_back
#define m_p make_pair
#define T int t = 0; cin >> t; while(t--)
#define pr(a) for(int i = 0; i < (int)a.size(); ++i)cout << a[i] << " ";cout << endl;
#define b_e(a) a.begin(), a.end()
typedef long long ll;
typedef long double lld;
const ll mod = 1e15;
const ll mx = 2e5;
const ll inf = 1e9;
const int sz = 26;
typedef long long ll;


void input(){
    IOS;
    int n;
    cin >> n;
    vector<int>fwd_w(n + 2, 0), bck_r(n + 2, 0);
    string s;
    cin >> s;
    f(i, n){
        fwd_w[i + 1] = fwd_w[i] + ((s[i] == 'W') ? 1 : 0);
    }
    for(int i = n - 1; i >= 0; --i){
        bck_r[i + 1] = bck_r[i + 2] + ((s[i] == 'R') ? 1 : 0);
    }
    //pr(fwd_w);pr(bck_r);
    int ans = inf;
    f(i, n + 1){
        ans = min(ans, max(fwd_w[i], bck_r[i + 1]));
    }
    cout << ans << endl;
}

int main(){
    input();
    return 0;
} 
/*
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
*/

Measured memory_bytes: 5176
/*author - Ashutosh Chitranshi*/
#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;
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define watch2(x,y) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<"\n"
#define watch3(x,y,z) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<" and "<<(#z)<<" is "<<(z)<<"\n"
#define pow2(x) ((x)*(x))
#define ll long long
#define ld long double
#define eb emplace_back
#define pb push_back
#define pf push_front
#define mod 1000000007
#define ordered_set tree<pair<ll,ll>,null_type,less<pair<ll,ll>>,rb_tree_tag,tree_order_statistics_node_update>
#define clock (clock() * 1000.0 / CLOCKS_PER_SEC)
#define mp make_pair
#define ff first
#define ss second
#define null NULL
#define all(c) (c).begin(),(c).end()
#define nl "\n"
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector< vi > vvi;
typedef vector< vl > vvl;
typedef pair< int,int > ii;
typedef pair< ll,ll> pll;
typedef map< ll,ll> mll;
typedef map< int,int> mii;
ll dp[2005];
bool comp(pll a,pll b)
{
    if(a.ff == b.ff)
        return a.ss < b.ss;
    return a.ff < b.ff;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    // ll s;
    // cin >> s;
    // dp[3] = 1ll;
    // for(int i=4;i<=s;i++)
    // {
    //     dp[i] = 1ll;
    //     for(int j=3;j<=i;j++)
    //     {
    //         ll rem = i-j;
    //         dp[i] = (dp[i] + (dp[rem]*dp[j])%mod)%mod;
    //     }
    // }
    // cout << dp[s] << nl;
    ll n;
    cin >> n;
    pll ar[n];
    for(int i=0;i<n;i++)
        cin >> ar[i].ff >> ar[i].ss;
    ll val1 = LLONG_MIN;
    ll val2 = LLONG_MAX;
    ll val3 = val1;
    ll val4 = val2;
    for(int i=0;i<n;i++)
    {
        val1 = max(val1,ar[i].ff+ar[i].ss);
        val2 = min(val2,ar[i].ff+ar[i].ss);
        val3 = max(val3,ar[i].ff-ar[i].ss);
        val4 = min(val4,ar[i].ff-ar[i].ss);
    }
    cout << max(abs(val1-val2),abs(val3-val4)) << nl;
    return 0;
}

Measured memory_bytes: 6772
H,W = map(int,input().split())
S = ["."*(W+2)]
[S.append("."+input()+".") for _ in range(H)]
S.append("."*(W+2))
ans = []

for h in range(1,H+1):
    ans_tmp = ""
    for w in range(1,W+1):
        if S[h][w] == ".":
            tmp = 0
            for i in [-1,0,1]:
                for j in [-1,0,1]:
                    if S[h+i][w+j] == "#":
                        tmp += 1
            ans_tmp += str(tmp)
        else:
            ans_tmp += "#"
    ans.append(ans_tmp)
for s in ans:
    print(s)


Measured memory_bytes: 39792
n = int(input())
p = list(map(int, input().split()))
print(sum(p[i-2]<p[i-1]<=p[i] or p[i]<p[i-1]<=p[i-2] or \
            p[i]==p[i-2]<p[i-1] for i in range(2,n)))

Measured memory_bytes: 9112
<?php
$haveCardNum = trim(fgets(STDIN));
$cardCheckList = createCardCheckList();

for ($i = 0; $i < $haveCardNum; $i++) {
    list($mark, $num) = getSpacesByExplodeTrimInput();
    $cardCheckList[$mark][$num] = 'check';
}

foreach ($cardCheckList as $mark => $value) {
    for ($cardNum = 1; $cardNum <= 13; $cardNum++) {
        if (! isset($cardCheckList[$mark][$cardNum])) {
            echo sprintf('%s %d', $mark, $cardNum), PHP_EOL;
        }
    }
}

function getSpacesByExplodeTrimInput()
{
    return explode(' ', trim(fgets(STDIN)));
}

function createCardCheckList()
{
    return array(
        'S' => array_fill(1, 13, null),
        'H' => array_fill(1, 13, null),
        'C' => array_fill(1, 13, null),
        'D' => array_fill(1, 13, null)
    );
}

Measured memory_bytes: 15460
// OURL: https://atcoder.jp/contests/agc035/tasks/agc035_c
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define RREP(i,a,n) for(int i=(a),i##_len=(n);i<i##_len;++i)
#define MAT1D(V,T,a) vector<T> V (a)
#define MAT2D(V,T,a,b) vector<vector<T>> V (a, vector<T>(b))
#define MAT3D(V,T,a,b,c) vector<vector<vector<T>>> V (a, vector<vector<T>>(b, vector<T>(c)))

// http://beet-aizu.hatenablog.com/entry/2018/04/08/145516
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){ return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}
template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){ for(auto &e:t) fill_v(e,v); }

template <typename A>
string to_string(A v) { bool first = true; string res = "{"; for (const auto &x : v) { if (!first) { res += ", "; } first = false; res += to_string(x); } res += "}"; return res; }

string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string) s); }
string to_string(bool b) { return (b ? "true" : "false"); }
string to_string(vector<bool>::reference b) { return to_string(bool(b)); }
template <typename A, typename B>
string to_string(pair<A, B> p) { return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename A>
string to_string(vector<vector<A>> v) { string res; for(const auto &x : v) {res+="\n ";res += to_string(x);} return res;}

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << " " << to_string(H); debug_out(T...); }

#ifdef LOCAL
#define debug(...) cerr << "[L" << to_string(__LINE__) << ":" <<#__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

void set_edge(stringstream &ss, int i, int j) {
  ss << i << " " << j << endl;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  if (!(N & (N-1))) { // N=2^n
    cout << "No" << endl;
    return 0;
  }
  stringstream ss;
  set_edge(ss, 1,2);
  set_edge(ss, 2,3);
  set_edge(ss, 3,1+N);
  set_edge(ss, 1+N,2+N);
  set_edge(ss, 2+N,3+N);
  int c = (N-3);
  if (N % 2 == 0) {
    c--;
  }
  for (int i = 0; i < c; i+=2) {
    set_edge(ss, i+4+N, 1+N);
    set_edge(ss, i+5+N, i+4+N);
    set_edge(ss, i+5, 1+N);
    set_edge(ss, i+4, i+5);
  }
  if (N%2==0) {
    // N, 2Nを入れる必要がある.
    int p = N ^ (N-1) ^ 1; // p1 < N-1
    set_edge(ss, N, N-1);
    if (p & 1) { // odd
      set_edge(ss, N*2, p);
    } else {
      set_edge(ss, N*2, p+N);
    }
  }
  cout << "Yes" << endl;
  cout << ss.str() << endl;
  return 0;
}


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

using namespace std;

const int INF = 1e9 + 5;

int main()
{
    int n;

    cin >> n;

    vector <int> p(n+1);

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

    // nearest smaller element
    vector <int> nearest(n+1, INF);
    stack <int> s;

    for (int i = 1; i <= n; i++)
    {
        while (!s.empty() && s.top() > p[i])
            s.pop();

        if (!s.empty())
            nearest[i] = s.top();

        s.push(p[i]);
    }

    int ans = -1;

    for (int x: nearest) {
        if (x == INF)
            ans++;
    }

    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 2688
import sys
from collections import deque
sys.setrecursionlimit(10**7)
def input(): return sys.stdin.readline().rstrip()


def bfs(H, W, black_cells, dist):
    d = 0
    while black_cells:
        h, w = black_cells.popleft()
        d = dist[h][w]
        for dy, dx in ((1, 0), (0, 1), (-1, 0), (0, -1)):
            new_h = h + dy
            new_w = w + dx
            if new_h < 0 or H <= new_h or new_w < 0 or W <= new_w:
                continue
            if dist[new_h][new_w] == -1:
                dist[new_h][new_w] = d+1
                black_cells.append((new_h, new_w))
    return d


def main():
    H, W = map(int, input().split())
    grid = [input() for _ in range(H)]
    dist = [[-1]*W for _ in range(H)]

    black_cells = deque()
    for h in range(H):
        for w in range(W):
            if grid[h][w] == '#':
                black_cells.append((h, w))
                dist[h][w] = 0
    print(bfs(H, W, black_cells, dist))


if __name__ == '__main__':
    main()


Measured memory_bytes: 115232
#include <iostream>
using namespace std;
int main(){
	int S, h, m, s;
	cin >> S;
	h = S / 3600;
	S %= 3600;
	m = S / 60;
	s = S % 60;
	cout << h << ":" << m << ":" << s << endl;
	return 0;
}

Measured memory_bytes: 3096
import java.io.*;
  
public class Main {
    public static void main(String[] args) {
        InputStreamReader isr = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(isr);
        try {
            String[] str = br.readLine().split(" ");
            int a = Integer.parseInt(str[0]);
            int b = Integer.parseInt(str[1]);
            if(a < b){
            System.out.println("a < b");
            }else if(a > b){
            System.out.println("a > b");
            }else{
            System.out.println("a == b");
            }
        } catch(IOException e) {
            e.printStackTrace();
        }
    }
}

Measured memory_bytes: 24272
<?php

fscanf(STDIN, "%d", $N);
$i = 0;
while( $N != $i ) {
  fscanf(STDIN, "%d %d %d", $t[$i], $x[$i], $y[$i]);
  if ($i != 0) {
    if (abs($t[$i] - $t[$i - 1]) < abs($x[$i] - $x[$i - 1]) + abs($y[$i] - $y[$i - 1])) {
      echo 'No';
      return;
    } elseif ( ($x[$i] - $x[$i - 1]) == 0 && $y[$i] - $y[$i - 1] == 0 ) {
      echo 'No';
      return;
    }
  } elseif ($i == 0) {
    if ($t[$i] != ($x[$i] + $y[$i])) {
      echo 'No';
      return;
    }
  }
  $i++;
}
echo 'Yes';

?>

Measured memory_bytes: 47092
#include<bits/stdc++.h>
 
#define pb push_back
// #define mp make_pair
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define hell1 1000000007
#define hell2 1000000009
#define pi 3.1415926535
#define ms(s, n) memset(s, n, sizeof(s))
#define prec(n) fixed<<setprecision(n)
#define eps 0.000001
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define ll unsigned long long
#define ld long double 
#define no_of_digits(n) floor(log10(n)) + 1
#define see(x) cerr << (#x) << " is " << (x) << endl
#define INF 1e13
#define LL_MAX 1e18
// memset(array, -1, sizeof(array[0][0]) * row * count)
using namespace std;
 
ll mult(ll a,ll b, ll p=hell1){   return ((a%p)*(b%p))%p; }
ll multbig(ll a,ll b,ll mod=hell1){   if(a==0 or b==0) return 0;if(a==1 or b==1) return (a*b)%mod;ll cur=multbig(a,b/2,mod);cur=(2*cur)%mod;if(b%2) cur=(cur+a)%mod;return cur;}
ll add(ll a, ll b, ll p=hell1){ if(a>=p) a%=p; if(b>=p) b%=p; if(a+b>p) return (a + b)%p; else return a+b;}
ll sub(ll a, ll b, ll p=hell1){return (a%p - b%p + p)%p;}
ll fpow(ll n, ll k, ll p = hell1) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = mult(r,n,p); n = mult(n,n,p);} return r;}
ll inv(ll a, ll p = hell1) {return fpow(a, p - 2, p);}
ll inv_euclid(ll a, ll m = hell1){ll m0 = m;ll y = 0, x = 1;if (m == 1)return 0;while (a > 1){ll q = a / m;ll t = m;m = a % m, a = t;t = y;y = x - q * y;x = t;}if (x < 0)x += m0;return x;}
int isPowerof2(ll x) { return (x && !(x & x-1)); } 
ll log2(ll x) { ll res = 0; while (x >>= 1) res++; return res; } 
bool isPerfectSquare(long double x) {long double sr = sqrt(x); return ((sr - floor(sr)) == 0); }
bool check(ll i,ll j,ll n){return (i>=0 && i<n && j>=0 &&  j<n);} //matrix boundary checking
 
 
ll ceil(const ll &a, const ll &b){return (a - 1)/b + 1;}
 
// max({a, b, c, d})
// cout << fixed for removing e notation
 
bool comp(pair<ll, ll>a, pair<ll, ll>b)
{
    if(a.se*b.fi + b.se > b.se*a.fi + a.se) return true;
    else return false;
}
 
void convert(int arr[], int n) 
{ 
    int temp[n+1];
    for(int i=1;i<=n;i++)
        temp[i] = arr[i]; 
    // memcpy(temp, arr, n*sizeof(int)); 
  
    sort(temp+1, temp+n+1);   
    unordered_map<int, int> umap;
    int val = 1; 
    for (int i = 1; i <= n; i++) 
        umap[temp[i]] = val++;
    for (int i = 1; i <= n; i++) 
        arr[i] = umap[arr[i]]; 
}
 
bool prime[10000005];
void SieveOfEratosthenes(int n) 
{
    memset(prime, true, sizeof(prime)); 
    prime[0] = prime[1] = 0;
    for (int p=2; p*p<=n; p++) 
    {
        if (prime[p] == true) 
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
    }
}

int foo(int a, int b, int c)
{
    return (abs(a-b) + abs(b-c) + abs(a-c));
}


ll getFirstSetBitPos(ll n) 
{ 
    return log2(n & -n) + 1; 
} 

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

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

    ll ans = 0;

    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<n;j++)
            ans += a[i]*a[j];
    }

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


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



int main() {
  int N;
  cin >> N;
  if(N<2) cout << 1;
  else if(N<4) cout << 2;
  else if(N<8) cout << 4;
  else if(N<16) cout << 8;
  else if(N<32) cout << 16;
  else if(N<64) cout << 32;
  else cout << 64;



}

Measured memory_bytes: 3608
#include<stdio.h>
int main()
{
	int n,i,x,t;
	char a[105];
	while(~scanf("%d",&n))
	{
		scanf("%s",a);
		t=0;
		x=0;
		for(i=0;i<n;i++)
		{
			if(a[i]=='R')
			{
				t++;
			}
			else if(a[i]=='B')
			{
				x++;
			}
		}
		if(t>x)
		{
			printf("Yes\n");
		}
		else 
		{
			printf("No\n");
		}
	}
	return 0;
}

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

int main(){
  int x,k;
  cin >> k >> x;
  
  for (int i=x-k+1;i<x;i++){
    cout << i << " ";
  }
  
  for (int i=x;i<x+k;i++){
    cout << i << " ";
  }
  
  return 0;
}

Measured memory_bytes: 256
# 問題文

# 1桁の正整数 a ,b が与えられます。
# 整数 a を b 回繰り返してできる文字列と 整数 b を a回繰り返してできる文字列のうち、
# 辞書順で小さい方を答えてください。

# 制約
# 1 ≤ a ≤ 9
# 1 ≤ b ≤ 9
# a,bは整数

# 入力
# 入力は以下の形式で標準入力から与えられる。
# a b


# 出力
# 2つの文字列のうち辞書順で小さい方を出力せよ。
# (2 つの文字列が等しいときは、そのうちどちらかを出力せよ。)

a, b = map(int, input().split())

if a < b:
    print(str(a) * b)
else:
    print(str(b) * a)

Measured memory_bytes: 2940
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cassert>
#define ll long long
#define MOD 1000000007
using namespace std;
inline int read(){
	int re=0,flag=1;char ch=getchar();
	while(ch>'9'||ch<'0'){
		if(ch=='-') flag=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9') re=(re<<1)+(re<<3)+ch-'0',ch=getchar();
	return re*flag;
}
int dp[3010][3010][2];
int main(){
	int n=read(),m=read(),i,j,k;
	dp[0][0][1]=1;
	for(i=1;i<=n;i++) dp[0][i][0]=1;
	for(i=0;i<m;i++){
		for(j=0;j<=n;j++){
			for(k=0;k<=1;k++){
//				cout<<i<<' '<<j<<' '<<k<<' '<<dp[i][j][k]<<'\n';
				if(j==1){
					dp[i+1][j-1][1]=(dp[i+1][j-1][1]+dp[i][j][k])%MOD;
					dp[i+1][j][1]=(dp[i+1][j][1]+dp[i][j][k])%MOD;
				}
				else if(j){
					dp[i+1][j-1][k]=(dp[i+1][j-1][k]+dp[i][j][k])%MOD;
					dp[i+1][j][k]=(dp[i+1][j][k]+dp[i][j][k])%MOD;
				}
//				if(j>0){
//					dp[i+1][j-1][k|(j==1)]=(dp[i+1][j-1][k|(j==1)]+dp[i][j][k])%MOD;
//					dp[i+1][j][k|(j==1)]=(dp[i+1][j][k|(j==1)]+dp[i][j][k])%MOD;
//				}
				if(j<n){
					dp[i+1][j+1][k]=(dp[i+1][j+1][k]+dp[i][j][k])%MOD;
					dp[i+1][j][k]=(dp[i+1][j][k]+dp[i][j][k])%MOD;
				}
			}
		}
	}
	ll ans=0;
	for(i=0;i<=n;i++) ans=(ans+dp[m][i][1])%MOD;
	printf("%lld\n",ans);
}

Measured memory_bytes: 70784
a[100],l,r,p;main(c){for(;scanf("%d",&r)*r;printf("%d\n",c)){for(c=++r;c;)l=scanf("%d",--c+a);for(;l<r&&!++c|a[p=l+r>>1]-*a;)a[p]<*a?r=p:(l=p+1);}}

Measured memory_bytes: 0
package main

import (
	"fmt"
	"os"
	"bufio"
	"strings"
)

func main(){
	var input string
	alpha_map := make([]int, 26)
	sc := bufio.NewScanner(os.Stdin)
	for{
		sc.Scan()
		input = sc.Text()
		if input == ""{
			break
		}
		s := strings.ToLower(input)
		for _, i := range s{
			index := int(i-'a')
			if index >= 0 && index < 26{
				alpha_map[index]++
			}
		}
	}
	for i:=0; i<26; i++{
		fmt.Printf("%s : %d\n", string('a'+i), alpha_map[i])
	}
}


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

const ll INF = 1LL << 62;
const double PI = acos(-1);
const double eps = 1e-10;

int main() {
  ll n, x, m, len = 0, total = 0;
  cin >> n >> x >> m;
  vector<int> id(m, -1);
  vector<int> a;
  while (id[x] == -1) {
    a.push_back(x);
    id[x] = len;
    len++;
    total += x;
    x = (x * x) % m;
  }

  int c = len - id[x];
  ll s = 0;
  for (int i = id[x]; i < len; i++) s += a[i];

  ll ans = 0;
  if (n <= len) {
    rep(i, n) ans += a[i];
  } else {
    ans += total;
    n -= len;
    ans += s * (n / c);
    n %= c;
    rep(i, n) ans += a[id[x] + i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3956
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <map>
#include <cmath>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;

#define rep(i, o) for (ll i = 0; i < (o);i++)
#define rep_s(i, o) for (int i = 1; i <= (o);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<(int)(b);i++)
#define NUM 1e5

typedef long long ll;
typedef unsigned long long ull;

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll c, ll d) { return c / gcd(c, d) * d; }


template<class T>
bool chmax(T &a, const T &b) { if (a < b) { return b; } return a; }

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

struct UnionFind {
    // 自身が根(=親)なら、その集合に属する頂点の数に -1 をかけたもの
    vector<int> d;
    UnionFind(int n=0): d(n,-1) {}
    int find(int x) {   // root 
        // cout << d[x] << endl;
        if (d[x] < 0) return x;
        return d[x] = find(d[x]);
    }
    bool unite(int x, int y) {
        x = find(x); y = find(y);
        // printf("bef : d[%d] = %d, d[%d] = %d\n", x, d[x], y, d[y]);
        if (x == y) return false; // くっつけられたかの情報が必要な時に(ex. MST)で便利
        if (d[x] > d[y]) swap(x,y); // -d[x] < -d[y] 
        d[x] += d[y];
        d[y] = x;
        // printf("aft : d[%d] = %d, d[%d] = %d\n", x, d[x], y, d[y]);
        return true;
    }
    bool same(int x, int y) { return find(x) == find(y);}
    int size(int x) { return -d[find(x)];}
};

const int MOD = 1000000007;
int main() {
    ll n, m; cin >> n >> m;
    UnionFind uf(n);

    rep(i, m) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        uf.unite(a, b);
    }
    int ans = 0;
    rep(i, n) ans = max(ans, uf.size(i));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4052
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
typedef long long int ll;
ll s[100010];//普通の累積和
ll t[100010];//正の項についての累積和
int main(){
	int n,k; cin >>n>>k;
	vector<ll> a(n);
	for(int i=0;i<n;i++){
		cin >>a[i];
	}
	for(int i=0;i<n;i++){
		s[i+1]=s[i]+a[i];
		t[i+1]=t[i]+max((ll)0,a[i]);
	}
	ll ans=s[n];
	for(int i=0;i<=n-k;i++){
		ll left=t[i];
		ll right=t[n]-t[i+k];
		ans=max(left+right+(s[i+k]-s[i]),ans);//区間を黒に固定する場合
		ans=max(left+right,ans);//区間を白に固定する場合
	}
	cout << ans << endl;
}

Measured memory_bytes: 2560
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <algorithm>

#define rep(i,n) for(int i=0; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()

using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;

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

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

const int INF = 0x3fffffff;


int a[100005], d[100005]={};
int dist(int n){
	if( n == 0 ) return 0;
	if( d[n] ) return d[n];
	return d[n] = dist( a[n] ) + 1;
}

int main(){
	int N, K, ans=0;

	cin >> N >> K;
	rep(i,N){
		cin >> a[i];
		a[i]--;
	}

	rep(i,N) dist(i);
	if( a[0] != 0 ) ans++;
	vector<pii> q;
	rep(i,N) if( d[i] > K ) q.emplace_back( d[i], i );
	sort( all(q) );
	reverse( all(q) );

	//rep(i,N) cout << d[i] << " ";
	//cout << endl;

	for(auto p: q){
		int i = p.second;
		bool f = true;
		for(int k = K; k>0; k--){
			if( !chmin(d[i], k) ){
				f = false;
				break;
			}
			i = a[i];
		}
		ans += f;
		//if( f ) cout << "i=" << i << " to 1" << endl;
	}

	cout << ans << endl;

	return 0;
}


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

int main(){
  int x,y,s;
  x = 1;
  y = 1;
  s = 1;
  while(x>0&&y>0&&s>0){
    cin >> x >> y >> s;
    if(x < 100 && x > 0 && y < 100 && y > 0 && s < 1000 && s > 0){
      int f = 0;
      for(int i=1;i<s;i++){
	int a = 1;
	while(int(a*(100+x)/100) <= i){
	  a += 1;
	}
	a -= 1;
	int b = 1;
	while(int(b*(100+x)/100) <= s-i){
	  b += 1;
	}
	b -= 1;
	if(int(a*(100+x)/100) == i && int(b*(100+x)/100) == s-i ){
	  int k = int((a*(100+y)/100)) + int((b*(100+y)/100));
	  if(k > f){
	    f = k;
	  }
	}
      }
      cout << f <<endl;
    }
  }
}

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

int main() {
  int N, A;
  cin >> N >> A;
  
  if (N % 500 == 0) {
    cout << "Yes" << endl;
  }
  else if (N % 500 <= A) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
//#include <string>
//#include <math.h>
//#include <vector>

using namespace std;

int main() {
  int a, b, c;
  long int a0, b0, c0; 
  long int counter=0;

  cin >> a0 >> b0 >> c0; 

  
  while(a0%2==0 && b0%2==0 && c0%2==0){
    counter++;
    a = b0/2+c0/2;
    b = c0/2+a0/2;
    c = a0/2+b0/2;
    
    if(a==b && b==c){
      counter = -1;
      break;
    }
    a0=a;b0=b;c0=c;
  }

  cout << counter;
  return 0; 
}


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

#ifdef _MSC_VER
#include <Windows.h>
#else
#include <unistd.h>
#endif

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD=(LL)1e9+7;
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

#define INF 1LL << 50



LL R,C,N;
LL dst(LL x,LL y){
    LL res=0;
    if(y==0){
        res=x;
    }else if(x==R){
        res=R+y;
    }else if(y==C){
        res=R+C+(R-x);
    }else{
        res=R+C+R+(C-y);
    }
    return res;
}
int main(){
    
    cin>>R>>C>>N;
    vector<PLL> vec;
    REP(i,N){
        LL x1,x2,y1,y2;
        cin>>x1>>y1>>x2>>y2;
        if(((x1==0||x1==R)||(y1==0||y1==C))&&((x2==0||x2==R)||(y2==0||y2==C))){           
            vec.PB(MP(dst(x1,y1),i));
            vec.PB(MP(dst(x2,y2),i));
        }
    }
    if(SZ(vec)==0){
        cout<<"YES"<<endl;return 0;
    }
    SORT(vec);
    stack<LL>st;
    st.push(vec[0].second);
    FOR(i,1,SZ(vec)){
        int now=vec[i].second;
        int bef=-1;
        if(!st.empty())bef=st.top();
        if(now==bef){
            st.pop();
        }else{
            st.push(vec[i].second);
        }
    }
    vector<LL>res;
    while(!st.empty()){
        LL tmp=st.top();st.pop();
        res.PB(tmp);
    }

    if(SZ(res)==0||SZ(res)==2){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
    return 0;
}

Measured memory_bytes: 6764
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        if(s.length() == 2) {
            System.out.println(s);
        } else if(s.length() == 3) {
            StringBuilder sb = new StringBuilder(s);
            sb.reverse();
            String tmp = sb.toString();
            System.out.println(tmp);
        }
    }
}

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repm(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define inf 2e9
#define MOD 1000000007

using namespace std;
typedef long long ll;

int main(){
  int n; cin >> n;
  vector<int> a(n); rep(i,n) cin >> a[i];

  int ans = 0;
  rep(i,n){
    while(a[i]%2 == 0){
      a[i] /= 2;
      ans++;
    }
  }

  cout << ans << endl;
}


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

using namespace std;

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

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

    long long ans0 = 0;
    for (int i = 0; i < n + 1; ++i) {
        ans0 += abs(a[i + 1] - a[i]);
    }

    for (int i = 1; i < n + 1; ++i) {
        long long ans = ans0;
        ans += -abs(a[i] - a[i - 1]) - abs(a[i + 1] - a[i])
               + abs(a[i + 1] - a[i - 1]);
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 2048
#include<stdio.h>
int main(void){
  int a, b, sum;
  int i = -1, j = -1, k = -1;
  scanf("%d%d", &a, &b);
  for(i = 0; i <= a; i++){
    for(j = 0; j <= a - i; j++){
        sum = 10000 * i + 5000 * j + 1000 * (a - i - j);
        //printf("%d\n", sum);
        if(b == sum ){
          printf("%d %d %d\n", i, j, a - i - j);
          return 0;
        }
    }
  }
  printf("-1 -1 -1");
  return 0;
}

  

Measured memory_bytes: 128
#include <bits/stdc++.h>
#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 SORTR(v,n) sort(v, v+n, greater<int>());
#define SORTPairSecond(v, n) sort(v, v+n, pairCompareSecond);
#define int long long    // %d=>%lld
#define pb push_back
#define INF 1000000007
#define llINF 1e17
#define EPS 1e-9
#define pi acos(-1)

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> piii;
typedef pair<ll, pll> plll;
bool pairCompareSecond(const pii& firstEl, const pii& secondEl) {
    return firstEl.second > secondEl.second;
}


const int MAX_n = 100000;
int n,k;

pii p[MAX_n];


signed main(){
    cin >> n>>k;
    for(int i = 0;i < n;i++){
        cin >> p[i].first;
        cin >> p[i].second;
    }

    priority_queue<pii,vector<pii>,greater<pii> > que;

    for(int i = 0;i < n;i++){
        que.push(p[i]);
    }

    for(int i = 0;i < n;i++){
        if(k>que.top().second){
            k = k-que.top().second;
            que.pop();
        }else{
            break;
        }
    }

    cout<< que.top().first<< endl;

    return 0;
}

Measured memory_bytes: 3956
#include <iostream>
#include <string>
using namespace std;
int main() {
    string s;
    cin >> s;
    bool flag=1;
    if(s[0]!='A') flag=0;
    int cnt=0;
    for(int i=1; i<s.length(); i++) {
        if(i!=1 && i!=s.length()-1 && s[i]=='C') cnt++;
        else if(isupper(s[i])) flag=0;
    }
    if(cnt!=1) flag=0;

    if(flag) cout << "AC" << endl;
    else cout << "WA" << endl;
    return 0;
}


Measured memory_bytes: 256
#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 INF mugen
#define dump(x) cerr<<#x<<"="<<x<<endl
#define all(a) (a).begin(),(a).end()
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
template <class T> void chmin(T & a, T const & b) { if (b < a) a = b; }

using ll = long long;
const ll mod = LLONG_MAX;
int ans;
int main(){
  string s;
  cin>>s;

  for(int i=0;i<s.size();i++){
    if(s[i]!=s[s.size()-i-1]){
      int len=s.size();
      if(s[i]=='x'){
        s=s.substr(0,len-(i))+'x'+s.substr(len-(i),len);
        ans++;
      }else if(s[s.size()-i-1]=='x'){
        s=s.substr(0,i)+'x'+s.substr(i,len);
        ans++;
      }
    }
  }

  //cout<<s<<endl;
  bool flag=false;
  rep(i,s.size()){
    if(s[i]!=s[s.size()-i-1]){
      flag=true;
    }
  }
  if(flag){
    cout<<"-1"<<endl;
  }else{
    cout<<ans<<endl;
  }


}


Measured memory_bytes: 1132
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define VPII vector<pair<int,int> >
#define F first
#define S second
#define RF(x) freopen(x,"r",stdin)
#define WF(x) freopen(x,"w",stdout)
typedef long long LL;
using namespace std;
typedef pair<LL,LL> PLL;
typedef pair<int,int> PII;
const LL MOD = 1e9+7;
const LL INF = 1LL<<30;
const double eps = 1e-13;

int main(){
	LL n,a,b,c,d;
	scanf("%lld%lld%lld%lld%lld",&n,&a,&b,&c,&d);
	n-=1;
	for(LL p=0;p<n;p++){
		LL m=n-p;
		LL maxv=p*d-m*c;
		LL minv=p*c-m*d;
		//printf("%lld %lld",minv,maxv);
		if(b<=a+maxv&&b>=a+minv){
			puts("YES");return 0;
		}
	}puts("NO");
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
	int n;
	cin >> n;
	int a=0, b;
	int cnt = 0;
	while (n/2!=0) n /= 2,cnt++;
	a = n % 2;
	if (a != 0)cnt++;
	int ans = 1;
	for (int i = 1;i < cnt;i++)ans *= 2;
	cout << ans << endl;
	return 0;
}


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

using namespace std;

#define PI 3.14159265358979323846264338327950L

int main(void) {
	long long tmp, ans, N,wa=0;
	long long MOD = 1000000007;

	cin >> N;
	vector<long long> A(N + 5, 0),sum(N+5,0);


    wa=0;
	for (int i = 1; i <= N; i++) {
		cin >> tmp;
        tmp=tmp%MOD;
		A[i]=tmp;

        wa=wa+tmp;
        sum[i]=wa;
	}

    ans=0;
    for(int i=0;i<N;i++){
        tmp=sum[N]-sum[i];
        tmp=tmp%MOD;
        tmp=A[i]*tmp;
        tmp=tmp%MOD;
        ans = ans+tmp;
        ans=ans%MOD;
    }




	cout << ans << endl;


	return 0;
}



Measured memory_bytes: 6400
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int cnt = 0;
    int a,b,k;
    cin >> a >> b >> k;
    for(int i=min(a,b);i>=1;i--){
        if(a%i==0&&b%i==0){
            cnt++;
            if(cnt==k){
                cout << i << endl;
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <climits>
#include <ctime>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <cstring>

// ---------- PBDS -----------------

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>

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

using namespace std;
using namespace __gnu_pbds; 

#define MEM(a, b) memset(a, (b), sizeof(a))
#define ALL(a) a.begin(), a.end()
#define MP(a, b) make_pair(a, b)
#define PB(a) push_back(a)
#define EB(a) emplace_back(a) 
#define boost ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0),cout << fixed << setprecision(10);
// #define ll long long int
#define int long long int

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
// debug & operator << (debug & dd, P p) { dd << "(" << p.x << ", " << p.y << ")"; return dd; }
#define deb(x) debug() << imie(x)

void solve(){
    
    string s, t;
    cin >> s >> t;
    
    int res = INT_MAX;
    for(int i = 0; i <= s.size() - t.size(); ++i){
        int r = i;
            
        int ans = 0;
        for(int j = 0; j < t.size(); ++j, ++r){
            ans += t[j] != s[r];
        }
        
        res = min(res, ans);
        
    }
    
    cout << res;
    
}

int32_t main(){

	boost;

	int T;
	
	//cin >> T;
	 T = 1;
	
	for(int i = 1; i <= T; ++i){
		solve();
		cout << "\n";
	}

	return 0;
}



Measured memory_bytes: 3656
/**
 * Created by hiramekun at 20:53 on 2020-04-26.
 */
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using P = pair<ll, ll>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = ll(n - 1); i >= 0; i--)
#define each(i, mp) for(auto& i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template<class T>
ostream &operator<<(ostream &out, const vector<T> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << ' ';
    return out;
}

template<class T>
istream &operator>>(istream &in, vector<T> &list) {
    ll n = list.size();
    rep(i, n) in >> list[i];
    return in;
}

template<class T>
ostream &operator<<(ostream &out, const vector<vector<T>> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << '\n';
    return out;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

void solve() {
    ll tairyoku_t, kougeki_t, tairyoku_a, kougeki_a;
    cin >> tairyoku_t >> kougeki_t >> tairyoku_a >> kougeki_a;

    bool is_t = true;
    while (tairyoku_t > 0 && tairyoku_a > 0) {
        if (is_t) {
            tairyoku_a -= kougeki_t;
        } else {
            tairyoku_t -= kougeki_a;
        }
        is_t = !is_t;
    }
    cout << (tairyoku_t > 0 ? "Yes" : "No") << '\n';
}

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        solve();
#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstring>
#include <utility>
#include <numeric>

using namespace std;

const int MOD = 1e9 + 7;

class Com{
public:
    int n;
    int mod;

    Com(int n, int mod){
        this->n = n;
        this->mod = mod;

        f.resize(n + 1);
        fInv.resize(n + 1);
        inv.resize(n + 1);

        f[0] = f[1] = 1;
        fInv[0] = fInv[1] = 1;
        inv[1] = 1;

        for(int i = 2; i <= n; i++){
            f[i] = (f[i - 1] * i) % mod;
            inv[i] = mod - (inv[mod % i] * (mod / i)) % mod;
            fInv[i] = (fInv[i - 1] * inv[i]) % mod;
        }
    }

    long long query(int n, int k){
        if(n < k){
            return 0;
        }
        if(n < 0 || k < 0){
            return 0;
        }
        return (((f[n] * fInv[k]) % mod) * fInv[n - k]) % mod;
    }
private:
    vector<long long> f, fInv, inv;
};

int main(){

    int n, k;
    cin >> n >> k;

    Com com(2 * n, MOD);

    if(k >= n - 1){
        cout << com.query(2 * n - 1, n) << endl;
    }
    else{
        long long ans = 0;

        for(int i = 0; i <= k; i++){
            long long temp = (com.query(n, i) * com.query(n - 1, i)) % MOD;
            ans = (ans + temp) % MOD;
        }
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 9600
import math
n = input()
x = list(map(int, input().split()))
y = list(map(int, input().split()))
d1=0
d2=0
d3=0
d_inf=0
for i in range(len(x)):
    d1 += abs(x[i]-y[i])
    d2 += ((x[i]-y[i])**2)
    d3 += abs((x[i]-y[i])**3)
    if abs(x[i]-y[i]) >= d_inf:
        d_inf = abs(x[i]-y[i])
print(d1)
print(math.sqrt(d2))
print(d3**(1/3.0))
print(d_inf)


Measured memory_bytes: 5696
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func getNextLine(scanner *bufio.Reader) string {
	var buffer string
	for {
		line, isPrefix, _ := scanner.ReadLine()
		buffer += string(line)
		if isPrefix == false {
			break
		}
	}
	return buffer
}

func getIntList(scanner *bufio.Reader) []int {
	list := strings.Split(getNextLine(scanner), " ")
	l := len(list)
	result := make([]int, l)
	for i := 0; i < l; i++ {
		result[i], _ = strconv.Atoi(list[i])
	}
	return result
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := bufio.NewReader(fp)
	writer := bufio.NewWriter(os.Stdout)

	var n int

	m := make(map[string]int, 0)
	fmt.Sscan(getNextLine(scanner), &n)
	for i := 0; i < n; i++ {
		line := strings.Split(getNextLine(scanner), " ")
		switch line[0] {
		case "insert":
			m[line[1]] = 1
		case "find":
			_, ok := m[line[1]]
			if ok {
				fmt.Fprintln(writer, "yes")
				continue
			}
			fmt.Fprintln(writer, "no")

		}
	}

	writer.Flush()
}



Measured memory_bytes: 44764
#include<bits/stdc++.h>
#define ll long long int

using namespace std;
int main()
{
    ll a,b,c,d,s=0,i,x=0;
    cin>>a>>b;
    cin>>c>>d;

    while(1)
    {
        c=c-b;
       // cout<<c<<"=c"<<endl;
        if(c<=0||a<=0)
        {
            if(c<=0)
            {
                c=0;
                a=1;
                break;
            }
            else  if(a<=0)
            {
                c=1;
                a=0;
                break;
            }
        }
        a=a-d;
              if(c<=0||a<=0)
        {
            if(c<=0)
            {
                c=0;
                a=1;
                break;
            }
            else  if(a<=0)
            {
                c=1;
                a=0;
                break;
            }
        }
       // cout<<a<<"=a"<<endl;
    }

    if(a==1)
    {
        cout<<"Yes"<<endl;

    }
    else if(a==0)
    {
        cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3632
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<queue>
#include<vector>
using namespace std;

#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL

int main() {
	for (int H; cin >> H&&H;) {
		int A[10][6] = {};
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < 5; j++) {
				cin >> A[i][j];
			}
		}

		int ans = 0;

		for (bool flag = true; flag;) {//??????????????£???????????????
			flag = false;
			for (int i = 0; i < H; i++) {
				int F = 0, E = 1;
				for (int j = 1; j < 5 + 1; j++) {
					if (A[i][j] != A[i][j - 1]) {
						if (E - F >= 3) {
							flag = true;
							ans += A[i][j - 1] * (E - F);
							for (int f = F; f < E; f++) {
								A[i][f] = 0;
							}
							break;
						}
						F = j;
						E = j + 1;
					}
					else if (A[i][j - 1] != 0) {
						E++;
					}
				}
			}

			//cout << "before" << endl;
			//for (int i = 0; i < H; i++) {
			//	for (int j = 0; j < 5; j++) {
			//		cout << A[i][j] << " ";
			//	}
			//	cout << endl;
			//}

			for (bool flag2 = true; flag2;) {
				flag2 = false;
				for (int i = H - 1; i > 0; i--) { //i!=0
					for (int j = 0; j < 5; j++) {
						//?¶???????????????????
						if (A[i][j] == 0) {
							if (A[i - 1][j] |= 0)flag2 = true;
							swap(A[i][j], A[i - 1][j]);
						}
					}
				}
			}

			//cout << "after" << endl;
			//for (int i = 0; i < H; i++) {
			//	for (int j = 0; j < 5; j++) {
			//		cout << A[i][j] << " ";
			//	}
			//	cout << endl;
			//}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#include <random>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <functional>
#include <random>
#include <time.h>
#include <chrono>
#include <sstream>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define MOD 1000000007
#define SORT(s) sort(s.begin(), s.end());
#define reverse(s) reverse(s.begin(), s.end());
#define P pair<int,int>
#define mp make_pair
#define valid(x,y,h,w) (0<=x&&x<h&&0<=y&&y<w)
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
int ndx[8] = { 0,1,0,-1, 1,1,-1,-1 };
int ndy[8] = { 1,0,-1,0, 1,-1,-1,1 };
using namespace std;
int POW(int x, int y) { return int(pow(double(x), double(y))); }
double log(double a, double b) { return log(b) / log(a); }



int main() {
	ll n0, m0;
	cin >> n0 >> m0;
	vector<ll> x0(n0), y0(m0);
	rep(i, n0) {
		cin >> x0[i];
	}
	rep(i, m0) {
		cin >> y0[i];
	}
	ll n = n0 - 1, m = m0 - 1;
	vector<ll> x(n), y(m);
	rep(i, n) {
		x[i] = x0[i + 1] - x0[i];
	}
	rep(i, m) {
		y[i] = y0[i + 1] - y0[i];
	}

	ll ans0 = 0;
	rep(i, n) {
		ans0 += ((((i + 1) * (n - i)) % MOD) * x[i]) % MOD;
		ans0 = ans0 % MOD;
	}
	ll ans = 0;
	rep(i, m) {
		ans += ((((((i + 1) * (m - i)) % MOD) * ans0) % MOD) * y[i]) % MOD;;
		ans = ans % MOD;
	}
	cout << ans << endl;
}

Measured memory_bytes: 3328
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val a = readLine()!!.split(" ").map(String::toInt)
    var sum = mutableMapOf<Int, Int>()
    a.forEach { a ->
            sum[a] = sum.getOrPut(a) { 0 } + 1
            sum[a+1] = sum.getOrPut(a+1) { 0 } + 1
            sum[a+2] = sum.getOrPut(a+2) { 0 } + 1
    }
    println(sum.maxBy { it.value }!!.value)

}

Measured memory_bytes: 56436
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.jar.Attributes.Name;
import java.util.stream.Stream;


public class Main{
    public static void main(String[] args)throws IOException{
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(input.readLine());
        String[] an = input.readLine().split(" ");
        double ave = 0.0;
        double[] na = Stream.of(an).mapToDouble(Double::parseDouble).toArray();
        for(double a : na){
            ave = ave + a;
        }
        int b = na.length;
        ave = ave / (double) b;
        ave = Math.round(ave);
        double sum = 0;
        for(double c : na){
        double v = Math.abs(c - ave);
        sum = sum + ( v * v );
        }

        System.out.println((long)sum);


    }
}



Measured memory_bytes: 27988