akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/python3
# -*- coding:utf-8 -*-

from itertools import combinations, permutations

def main():
  n, nc = map(int, input().split())
  md = [list(map(int, input().split())) for _ in range(nc)]
  mc = [list(map(lambda c: int(c)-1, input().split())) for _ in range(n)]
  cnt_c = [[0] * nc for _ in range(3)]
  
  for i in range(n):
    for j in range(n):
      cnt_c[(i + j) % 3][mc[i][j]] += 1
  
  def calc_cost(lx, itarget):
    return sum([cnt*md[i][itarget] for i, cnt in enumerate(lx)])
  
  cost = 10**9
  for inds in combinations(range(nc), 3):
    for itargets in permutations(inds):
      cost = min(cost, sum([calc_cost(cnt_c[i], itarget) for i, itarget in enumerate(itargets)]))
  print(cost)
    
      
  

if __name__=='__main__':
  main()



Measured memory_bytes: 5620
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <typeinfo>

using namespace std;

int main(){
  int N;
  long long x;
  cin >> N >> x;
  vector<long long> a(N);
  for(int i=0;i<N;i++)  cin >> a.at(i);

  long long ans=0;
  if(a.at(0)>x){
    ans+=(a.at(0)-x);
    a.at(0)=x;
  }
  for(int i=1;i<N;i++){
    long long b=a.at(i-1)+a.at(i);
    if(b-x>0){
      ans+=b-x;
      a.at(i)-=(b-x);
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<cassert>
#include<numeric>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
const int INF = 1001001001;
const long long LINF = 1001002003004005006ll;
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 (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int,int> P;

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

vector<int> to[200005];
mint ans;
int n;

int dfs(int v,int p = -1){
  int res = 1;
  vector<int> ast;
  for(int u:to[v]){
    if(u==p)continue;
    int s = dfs(u,v);
    ast.push_back(s);
    res += s;
  }
  if(p!=-1){
    int l = n;
    for(int x:ast)l-=x;
    l--;
    ast.push_back(l);
  }
  ans += mint(2).pow(n-1);
  ans -= 1;
  for(int x:ast){
    ans -= mint(2).pow(x)-1;
  }
  return res;
}

int main(){
  cin >> n;
  rep(i,n-1){
    int a,b;
    cin >> a >> b;
    a--,b--;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  dfs(0);
  ans /= mint(2).pow(n);
  cout << ans << endl;
}

Measured memory_bytes: 32080
s=input()
item=["+","-"]
 
last = ""
for op1 in item:
  for op2 in item:
    for op3 in item:
      ans = s[0] + op1 + s[1] + op2 + s[2] + op3 +s[3]
      if eval(ans)==7:
        last = ans+"=7"
print(last)

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


int main() {
 
  int64_t h,w;
  cin>>h>>w;

  int h1,w1;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      string s;
      cin>>s;
      if(s=="snuke"){
        h1=i;
        w1=j;
        break;
      }
    }
  }
 
  cout<<char(w1+'A')<<h1+1<<endl;

	return 0;
}



Measured memory_bytes: 3592
#include<stdio.h>
#define N 200000

int main(void)
{
	char s[N];
	char t[N];
	int i,cnt=0;

	scanf("%s",s);
	scanf("%s",t);

	for(i=0;i<N;i++){
		if(s[i]=='\0'){
			break;
		}
		if(s[i]!=t[i]){
			cnt++;
		}
	}

	printf("%d\n",cnt);

	return 0;
}


Measured memory_bytes: 2092
'use strict'
const Main = (input) =>{
  let xs = input.trim().split(' ').map(v=>parseInt(v,10));
  let sqrt = Math.ceil(Math.sqrt(xs[0]));
  let num = xs[0];

  for(let n=num; true; n++){
    let prime = true;
      for(let i = 2; i<sqrt; i++){
        if(n%i==0){
          prime = false;
          break;
        }
      }
      if(prime){
        console.log(n);
        return;
      }
  }
}
Main(require('fs').readFileSync('/dev/stdin','utf8'));

Measured memory_bytes: 7372
from collections import defaultdict

n, W = (int(x) for x in input().split())
WV = [tuple(int(x) for x in input().split()) for _ in range(n)]
d = defaultdict(int)  # d[weight_sum] = max_value_sum
d[0] = 0
for i in range(n):
    w, v = WV[i]
    d_tmp = list(d.items())
    for w_sum, v_sum in d_tmp:
        if w_sum + w <= W:
            d[w_sum + w] = max(d[w_sum + w], v_sum + v)

print(max(d.values()))

Measured memory_bytes: 73740
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
constexpr long long INF = 1LL << 62;

struct Edge {
    int src, dst, cost;
    Edge(int s, int d, int c = 1) : src(s), dst(d), cost(c) {}
    bool operator<(const Edge &e){ return cost < e.cost;}
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

// O(|V|+|E|)log|V|)
void dijkstra(int s, Graph &g, vector<long long> &dist) {
    using Info = pair<long long, int>;
    // init
    dist.assign(g.size(), INF);
    dist[s] = 0;
    priority_queue<Info, vector<Info>, greater<Info> > pq;
    pq.emplace(0, s);
    
    // main
    while(!pq.empty()){
        long long d = pq.top().first;
        int v = pq.top().second;
        pq.pop();
        if(dist[v] < d) continue;
        for(Edge e : g[v]){
            if(dist[e.dst] > dist[v] + e.cost){
                dist[e.dst] = dist[v] + e.cost;
                pq.emplace(dist[e.dst], e.dst);
            }
        }
    }

}

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

    // build a graph
    Graph g(k+1);
    for(int i = 1; i < k; ++i) {
        g[i].emplace_back(i, (i+1) %k, 1);
        g[i].emplace_back(i, (i*10)%k, 0);
    }

    // calc
    vector<long long> dist;
    dijkstra(1, g, dist);

    // out
    cout << dist[0] + 1 << '\n';
    return 0;
}

Measured memory_bytes: 7672
using System;
using CompLib.Util;

public class Program
{
    public void Solve()
    {
        var sc = new Scanner();
        int n = sc.NextInt();
        long[] a = new long[n];
        long[] b = new long[n];
        for (int i = 0; i < n; i++)
        {
            a[i] = sc.NextInt();
            b[i] = sc.NextInt();
        }

        long ans = 0;
        for (int i = n - 1; i >= 0; i--)
        {
            long m = (a[i] + ans)%b[i];
            if (m != 0)
            {
                ans += b[i] - m;
            }
        }

        Console.WriteLine(ans);
    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 17292
#include <iostream>
#include <cstring>
#include <algorithm>
#include <functional>
#include <bits/stdc++.h>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
#include <stdlib.h>
#include <deque>
#include <cstdint>
using namespace std;

int main () {
  unsigned long long int n;
  cin >> n ;
  cout << n * (n-1) /2 ;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll                      long long
#define pb                      push_back
#define rep(i,a,b,c)            for(ll i=(a);i<=(b);i+=(c))
#define repb(i,a,b,c)           for(ll i=(a);i>=(b);i-=(c))
#define MOD                     1000000007
#define inf                     3e18
#define ld                      long double
#define mp                      make_pair
#define vpll                    vector<pair<ll,ll> >
#define vll                     vector<ll>
#define vld                     vector<ld>
#define vvll                    vector<vector<ll>>
#define vvld                    vector<vector<ld>>
#define pll                     pair<ll,ll>
#define vvpll                   vector<vector<pair<ll,ll>>>
#define pqll                    priority_queue<ll>
#define mll                     map<ll,ll>
#define mlc                     map<ll,char>
#define um                      unordered_map
#define umll                    um<ll,ll>
#define umlc                    um<ll,char>
#define all(x)                  x.begin(),x.end()
#define fi                      first
#define se                      second
#define ln                      cout<<"\n";
#define endl                    "\n"
#define test                    ll T;cin>>T;while(T--)
#define isvowel(a)              (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')
#define fastIO                  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define show(w,size)            for(ll i=0;i<size;i++) cout<<w[i]<<" ";
#define prll(a)                 cout<<a<<"\n";
#define mset(dp,no)             memset(dp,no,sizeof(dp))
#define input(a,n)              rep(i,0,n-1,1) cin>>a[i];
#define countbit                __builtin_popcount                                           //Number of setbits in decimal notation
#define lb(v,cur)               lower_bound(all(v),cur)-v.begin()
#define ub(v,cur)               upper_bound(all(v),cur)-v.begin()
#define db(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 <<'\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
long long pows(long long a, long long b) {
  long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}
ll powm(ll x,ll y,ll m=MOD){x=x%m;ll res=1;while(y){if(y&1)res=res*x;res%=m;y=y>>1;x=x*x;x%=m;}return res;}
ll modInverse(ll a, ll m=MOD){return powm(a,m-2,m);}
int main()
{
fastIO
ll n,m,i,j,k,x,y,z,t,e,f,p,q,g,l,r,o,w,h,count1=0,prod=1,a,b,c,d,index,x1,x2,y1,y2,diff,ans=0,sum=0,sum1=0,sum2=0,flag=0,flag1=0,flag2=0;
string s,s1,s2;
cin>>s>>s1;
n=s.size();
m=s1.size();
ans=m;
for(i=0;i+m-1<n;i++)
{
  count1=0;
  for(j=0;j<m;j++)
  {
    if(s[i+j]!=s1[j])
    {
      count1++;
    }
  }
  ans=min(ans,count1);
}
cout<<ans;
}


Measured memory_bytes: 3644
// D - Semi Common Multiple
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

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

int main(){
	int N,M; cin>>N>>M;
	int T = -1;
	ll L = 1;
	while(N--){
		int a; cin>>a; a/=2;
		int t; for(t=0; !(a&1); t++) a>>=1;
		if(T < 0) T = t;
		if(t != T){ puts("0"); return 0; }
		if((L=lcm(L, a)) > M){ puts("0"); return 0; }
	}
	cout<< ((M>>T)/L+2-1)/2 <<endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define ll long long



using namespace std;

void file(){
	#ifndef ONLINE_JUDGE
    	freopen("in.txt", "r", stdin);
	#endif
}
int tc;
const int N=5e5+5,M=2e6+5,MOD=1e9+7,OO=1e9;


int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	//file();	
 	
 	int h,a;

 	scanf("%d %d",&h,&a);

 	printf("%d\n",(h+a-1)/a);
}		


Measured memory_bytes: 256
import heapq
from collections import deque
b=[]
heapq.heapify(b)

n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
a = deque(a)

heapq.heappush(b,-1*a.popleft())
ans = 0

while len(a)>0:
  temp = a.popleft()
  point = -1*heapq.heappop(b)
  ans+=point
  heapq.heappush(b, -1*temp)
  heapq.heappush(b, -1*temp)
  
print(ans)

Measured memory_bytes: 32516
using System;
using static System.Console;
using static System.Math;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;


namespace atcoder
{
    class Program
    {
        //メイン関数
        static void Main(string[] args)
        {
            string[] reader = ReadLine().Split(' ');
            int a = int.Parse(reader[0]);
            int b = int.Parse(reader[1]);

            if (a <= 9 && b <= 9) WriteLine(a * b);
            else WriteLine("-1");
        }




        #region 細々としたツール(関数)

        #region 標準入力
        //変数の入力
        static string scan() => ReadLine();
        static int scanInt() => int.Parse(ReadLine());

        //配列の入力
        static string[] MultiScan(char Split)
        {
            string[] N = ReadLine().Split(Split);
            return N;
        }
        static string[] MultiScan()
        {
            string[] N = ReadLine().Split(' ');
            return N;
        }

        static List<int> MultiScanInt(char Split)
        {
            string[] N = ReadLine().Split(Split);
            List<int> output = new List<int>();

            for (int i = 0; i < N.Length; i++)
            {
                output.Add(int.Parse(N[i]));
            }

            return output;
        }
        static List<int> MultiScanInt(char Split, int roop)
        { 
            string[] N = ReadLine().Split(Split);
            List<int> output = new List<int>();

            for (int i = 0; i < roop; i++)
            {
                output.Add(int.Parse(N[i]));
            }

            return output;
        }
        #endregion

        #region 数学関連
        public static int Gcd(int a, int b)
        {
            if (a < b)
                // 引数を入替えて自分を呼び出す
                return Gcd(b, a);
            while (b != 0)
            {
                var remainder = a % b;
                a = b;
                b = remainder;
            }
            return a;
        }//最大公約数
        public static int Lcm(int a, int b)
        {
            return a * b / Gcd(a, b);
        }//最小公倍数
        public static int PlusOneSigma(int x, int loop)
        {
            int output = 0;
            for (int i = 0; i < loop; i++)
            {
                output = output + x + i;
            }
            return output;
        }//１づつ加算のシグマ
        #endregion

        #endregion
    }
}


Measured memory_bytes: 13140
//=========================================\\   
  //          @Author : SajidZakaria           \\
 //     @File Created : 2020-05-31 18:01:04     \\
//===============================================\\

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define endl '\n'

int main(){
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;

	bool z = 0, f = 1;
	__int128 ans = 1, inf = 1000000000000000000ll;
	for(int i=1; i<=n; i++) {
		ll x;
		cin >> x;
		if(!x) z = 1;
		if(f) ans *= x;
		if(ans > inf) f = 0;
	}

	ll a = ans;
	if(z) cout << 0;
	else if(f) cout << a;
	else cout << -1;
	cout << endl;
	
	return 0;
}

Measured memory_bytes: 3644
h,w,d=map(int,input().split())
b=[(0--(h*w-i)//d)*[0]for i in range(d)]
a=[list(map(int,input().split()))for _ in range(h)]
for i in range(h):
  for j in range(w):
    a[i][j]-=1
    b[a[i][j]%d][a[i][j]//d]=(i,j)
bb=[[0]for _ in range(d)]
for i in range(d):
  for j in range(1,len(b[i])):
    bb[i].append(bb[i][-1]+(abs(b[i][j-1][0]-b[i][j][0])+abs(b[i][j-1][1]-b[i][j][1])))
for ll,rr in [list(map(int,input().split()))for _ in range(int(input()))]:
  l=ll-1
  r=rr-1
  print(bb[l%d][r//d]-bb[l%d][l//d])

Measured memory_bytes: 56524
from math import gcd
def readinput():
    n,m=map(int,input().split())
    a=list(map(int,input().split()))
    return n,m,a

def lcm(a,b):
    return a*b//gcd(a,b)

def main(n,m,a):
    #s=set(a)
    #print(s)
    x=a[0]//2
    for i in range(1,n):
        x=lcm(x,a[i]//2)
    #print(x)
    gusubai=False
    kisubai=False
    for i in range(n):
        if x%a[i]!=0:
            gusubai=True
        else:
            kisubai=True
    
    y=m//x
    #print(y,x,m)
    if gusubai and not kisubai:
        ans=y//2+y%2
    elif gusubai and kisubai:
        ans=0
    else:
        ans=y
    return ans

if __name__=='__main__':
    n,m,a=readinput()
    ans=main(n,m,a)
    print(ans)


Measured memory_bytes: 20524
# from math import factorial,sqrt,ceil,gcd
# from itertools import permutations as permus
from collections import deque,Counter
# import re
# from functools import lru_cache # 簡単メモ化 @lru_cache(maxsize=1000)
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

import numpy as np
# import networkx as nx
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix
# from scipy.special import comb

# slist = "abcdefghijklmnopqrstuvwxyz"
N = int(input())
arrA = np.array(input().split(),dtype=np.int64)
arrA = arrA % 2
cnt = Counter(arrA)
oddnums = 2**cnt[0]
all = 3**len(arrA)
ans = all - oddnums

print(ans)
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する
# print("{:.10f}".format(ans))
# print("{:0=10d}".format(ans))


Measured memory_bytes: 21488
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    int a[n],b[n];
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    for(int i=0;i<n;i++){
        cin >> b[i];
    }
    int x=0,y=0,mx=0;
    for(int i=0;i<n;i++){
        if(a[i]>=b[i]){
            x+=a[i]-b[i];
        }
    }
    cout << x << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    int ans = 0;
    int m = 0;
    int h[20] = {};
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> h[i];
        if (h[i] >= h[0] && h[i] >= m)
        {
            if (h[i] > m)
            {
                swap(m, h[i]);
            }

            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
 int N;
  int flag=0;
 scanf("%d",&N);
	for(int i=1;i<=9;i++)
    {
      for(int j=1;j<=9;j++)
      {
        if(i*j==N) 
        {
         flag=1;
         printf("Yes");
         break;
        }
      if(i==9&&j==9) printf("No");
      }
      if(flag==1)break;
    }
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define Nmax 200010
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define RFOR(i,a,b) for(long long i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<P> Graph;
 
int main() {
	int N;
	cin >> N;
	ll A[Nmax]={};
	ll sumA=0;
	REP(i,N){
		cin >> A[i];
		A[i]-=i+1;
		sumA+=A[i];
	}
	ll S[Nmax]={};
  	sort(A,A+N);
  	S[0]=A[0];
  	REP(i,N-1) S[i+1]+=S[i]+A[i+1];
  	//sort(S,S+N);
	ll b=round((double)(sumA/N)); //仮のb
	ll ans1=0,ans2=0;
	ll mina=0;
	REP(i,N) mina+=abs(A[i]-b);
	FOR(j,1,MOD){
		/*REP(i,N){
      	ans1+=abs(A[i]-b+j);//bを上下に1ずつ広げていく
	  	ans2+=abs(A[i]-b-j);
   		}*/
   		int a=upper_bound(A,A+N,b+j)-A;
   		int c=upper_bound(A,A+N,b-j)-A;
   		ans1=abs(S[a-1]-(b+j)*(a))+abs((S[N-1]-S[a-1])-(b+j)*(N-a));
   		ans2=abs(S[c-1]-(b-j)*(c))+abs((S[N-1]-S[c-1])-(b-j)*(N-c));
   		mina=min(mina,min(ans1,ans2));
   		if(mina!=ans1&&mina!=ans2){//単調増加に転じたらbreak
	   		break;
	   	}
   	}
	cout << mina << endl;
	return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(ll i = (ll)a;i < (ll)b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(ll i = (ll)b-1LL;i >= (ll)a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)
#define SIGN(a) (a==0?0:(a>0?1:-1))

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;
typedef long double ld;
typedef pair<ld,ld> pdd;

const ll INF=(1LL<<50);
#if __cplusplus<201700L
ll gcd(ll a, ll b) {
  if(a < b) return gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
#endif
template<class T>
bool chmax(T& a,const T& b){
  if(a<b){
    a=b;
    return true;
  }
  return false;
}
template<class T>
bool chmin(T& a,const T& b){
  if(a>b){
    a=b;
    return true;
  }
  return false;
}
template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}


void solve(long long L){
  long double x=(ld)(L)/3.0;
  cout<<x*x*x<<endl;
}

int main(){
  cout<<setprecision(1000);
    long long L;
    scanf("%lld",&L);
    solve(L);
    return 0;
}


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

namespace AOJ
{
	class Program
	{
		static void Main(string[] args)
		{
			var s = "";
			while ((s = Console.ReadLine()) != null)
			{
				Console.WriteLine(f(s));
			}
		}

		static char f(string s)
		{
			var b = new string[3];
			for (int i = 0; i < 3; i++)
				b[i] = s.Substring(i * 3, 3);

			for (int i = 0; i < 3; i++)
			{
				if (b[i] == "ooo" ||
					new string(b.Select(t => t[i]).ToArray()) == "ooo") return 'o';
				if (b[i] == "xxx" ||
					new string(b.Select(t => t[i]).ToArray()) == "xxx") return 'x';
			}
			if (new string(new char[3] { b[0][0], b[1][1], b[2][2] }) == "ooo" ||
				new string(new char[3] { b[2][0], b[1][1], b[0][2] }) == "ooo") return 'o';
			if (new string(new char[3] { b[0][0], b[1][1], b[2][2] }) == "xxx" ||
				new string(new char[3] { b[2][0], b[1][1], b[0][2] }) == "xxx") return 'x';
			return 'd';
		}
	}
}

Measured memory_bytes: 5616
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
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 debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop//
//bitSearch, bitList, gcdlcm, isPrime, primeFactorize, Npow, divisor, modinv, dfs, bfs, eratos//
//dijkstra, WarshallFloyd, BellmanFord, UnionFind, COM, digitDP ,RMQ//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z, R;
ll MOD = 1000000007; ll INF = 1LL << 62; ll ans = 0; ll z = 0, o = 1;
vl flag, color, D; vll path;
int main() {
	cin >> N >> Z >> W;
	vl A(N);
	for (i = 0; i < N; i++) cin >> A[i];
	if (N == 1) {
		cout << abs(A[0] - W);
	}
	else {
		cout << max(abs(A[N - 1] - W), abs(A[N - 2] - A[N - 1]));
	}
}

Measured memory_bytes: 256
/*In the name of ALLAH, Most Gracious, Most Merciful*/
#include<bits/stdc++.h>

#define ll                      long long int
#define ull                     unsigned long long int
#define PI                      2*acos(0.0)
#define sqr(x)                  (x)*(x)
#define EPS                     10E-10
#define MOD                     1000000007
#define longlimit               92233720368547758
#define infinity                (1<<28)
#define setbits                 __builtin_popcount
#define zerobits                __builtin_ctzll
#define pb(a)                   emplace_back(a)
#define mp                      make_pair
#define ff                      first
#define ss                      second
#define gcd(a, b)               __gcd(a,b)
#define lcm(a, b)               ((a)*(b))/gcd(a,b)
#define watch(x)                cout << (#x) << " is " << (x) << endl
#define FOR(x,n)                for (ll i=x,j=x,k=x;i<n,j<n,k<n;i++,j++,k++)
#define FORR(n,x)               for (ll i=n-1,j=n-1,k=n-1;i>=x,j>=x,k>=x;i--,j--,k--)
#define TEST_CASES()            ll t;cin>>t;while (t--)
#define PRECISION(a,x)          fixed<<setprecision(x)<<a<<endl;
#define all(a)                  (a.begin()),(a.end())
#define UNIQUE(X)               (X).erase(unique(all(X)),(X).end())
#define DELETE(X)               (X).erase (remove (all(X)),(X).end())
#define SORT_UNIQUE(c)          (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define FAST_IO()               ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define FILE_IO()               freopen("output.txt", "w", stdout);freopen("input.txt", "r", stdin)
using namespace std;
ll tc=1;

void solve()
{
   ll n,k,sum=0;
   cin>>n>>k;
   int arr[n];
   FOR(0,n)cin>>arr[i];
   sort(arr,arr+n);
   for(int i=0;i<k;i++)sum+=arr[i];
   cout<<sum<<endl;

}

int32_t main()
{
    FAST_IO();
   // TEST_CASES()
        solve();
}

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

using namespace std;
int main(){
    int N;
    int ans=0;
    cin>>N;
    int p;
    
    for(int a=1;a<N;a++){
        cin>>p;
        if(p==a){

        }else{
            ans++;
        }
    }

    if(ans<=2){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
  int w,h;
  int i,j;

  while(true){
    cin >> h >> w;
    if(h == 0 && w == 0) break;
    
    for(i = 0 ; i < h ; i++){
      for(j = 0 ; j < w ; j++){
	if((i + j) % 2 == 0) cout << "#";
	else cout << ".";
      }
      cout << endl;
    }
    cout << endl;
  }
  return 0;
}

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

int main() {
  string S; cin >> S;
  int L = S.size();
  int MOD = 1000000007;
  vector<vector<long long>> dp(100010, vector<long long>(13, 0));
  dp.at(0).at(0) = 1;
  for (int i = 0; i < L; i++) {
    for (int j = 0; j < 13; j++) {
      if (S.at(i) == '?') {
        for (int d = 0; d <= 9; d++) {
          dp.at(i+1).at((j * 10 + d) % 13) += dp.at(i).at(j);
          dp.at(i+1).at((j * 10 + d) % 13) %= MOD;
        }
      }
      else {
        dp.at(i+1).at((j * 10 + S.at(i) - '0') % 13) += dp.at(i).at(j);
        dp.at(i+1).at((j * 10 + S.at(i) - '0') % 13) %= MOD;
      }
    }
  }
  cout << dp.at(L).at(5) << endl;
}

Measured memory_bytes: 13696
#include<cstdio>
#include<cstring>
#include<queue>
#include<algorithm>
using namespace std;
long long a,b;
int main()
{
	//freopen("light.in","r",stdin);
	//freopen("light.out","w",stdout);
	scanf("%lld %lld",&a,&b);
	long long ans=a;
	a=a-b;
	long long jl=0;
	while(b&&a)
	{
		if(a<b)
			swap(a,b);
		long long t=(a-1)/b;
		ans+=2*t*b;
		long long o=t*b;
		a=a-o;
		if(a==b)
		{
			ans+=a;
			break;
		}
	}
	printf("%lld\n",ans);
	fclose(stdin);
	fclose(stdout);
}

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

using namespace std;

int main(){
	int N;
	cin >> N;
	vector<int> a(N);

	int min = 100, max = -100;

	for (int i = 0; i < N; i++){
		cin >> a[i];
		if (a[i] > max)max = a[i];
		if (a[i] < min)min = a[i];
	}

	int ans = 0;
	int min_cost = 0;

	for (int i = min; i <= max; i++){
		int cost = 0;
		for (int j = 0; j < N; j++){
			cost += (a[j] - i)*(a[j] - i);
		}
		if (i == min){ min_cost = cost; }
		else if (min_cost > cost){ min_cost = cost; }
	}

	cout << min_cost << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)
#define rreps(i,n) for(int i = n; i >= 1; i--)
#define mrep(i,from,n) for(int i = from; i < n; i++)
#define mreps(i,from,n) for(int i = from; i <= n; i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(ALL(x), val), x.end())
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 true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
ll MOD = 1000000007;

template <typename T>
T mod_pow(T a, T p)
{
	if (p == 0)return 1;
	else if (p == 1)return a;
	else if (p % 2 == 0)
	{
		T h = mod_pow(a, p / 2);
		return h * h % MOD;
	}
	else return (mod_pow(a, p - 1) * a) % MOD;
}

template<typename T>
T mod_comb(T n, T m)
{
	if (n < m)return 0;
	if (n / 2 < m)return mod_comb(n, n - m);
	ll resMul = 1;
	ll resDiv = 1;
	for (ll i = 1; i <= m; i++)
	{
		resMul *= (n - i + 1);
		resMul %= MOD;
		resDiv *= i;
		resDiv %= MOD;
	}
	ll res = (resMul * mod_pow(resDiv, MOD - 2)) % MOD;
	return res;
}

void solve()
{	
	ll n,a,b; cin >> n>>a>>b;
	ll ans=mod_pow(2LL,n)-1;
	ll ca=mod_comb(n,a);
	ll cb=mod_comb(n,b);
	ans-=ca;
	ans+=MOD;
	ans-=cb;
	ans+=MOD;
	ans%=MOD;
	cout << ans << endl;
	return;
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <queue>
#include <queue>
#include <stdio.h>
#include <string>

using namespace std;

void solve(string S) {
  int ans;
  int zero = 0;
  for (int i = 0; i < S.length(); i++) {
    if (S[i] == '0') {
      zero += 1;
    }
  }
  int one = S.length() - zero;
  ans = min(one, zero) * 2;
  cout << ans << endl;
}

int main() {
  string S;
  cin >> S;
  solve(S);
  return 0;
}

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

string x,c="abcdefghijklmnopqrstuvwxyz";

int main(){
  cin>>x;
  
  for(int i=0;i<26;i++){
    if(x.at(0)==c.at(i)){
      cout<<c.at(i+1);
    }
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main (void)
{
   
  string s;
  cin>>s;
  int n,i;
  n=s.size();
    for(i=0;i<n/2;i++)
  {
    if(s[i]!=s[n-1-i]){cout<<"No"<<endl;return 0;}
  }
  n=n/2;
  for(i=0;i<n/2;i++)
  {
    if(s[i]!=s[n-1-i]){cout<<"No"<<endl;return 0;}
  }
  cout<<"Yes"<<endl;
  return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;
using msi=map<string,int>;
using mii=map<int,int>;
using psi=pair<string,int>;
using pii=pair<int,int>;
using vlai=valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1e9
#define EPS 1e-9
#define MOD ((ll)1e9+7)
void get(){}template<class H,class...T>void get(H&h,T&...t){cin>>h;get(t...);}
template<class T>void geti(T&a){for(auto&_:a)cin>>_;}
template<class T>void getii(T&a){for(auto&_:a)geti(_);}
void put(string d){}template<class H,class...T>void put(string d,H&h,T&...t){cout<<h;if(sizeof...(t))cout<<d;put(d,t...);}
template<class T>void puti(T&a,string d=" "){bool f=1;for(auto&_:a)cout<<(exchange(f,0)?"":d)<<_;cout<<endl;}
template<class T>void putii(T&a,string d=" "){for(auto&_:a)puti(_,d);}
#define dcl(...) ll __VA_ARGS__;get(__VA_ARGS__)
#define dclt(t,...) t __VA_ARGS__;get(__VA_ARGS__)
template<class F,class S>void add(map<F,S>&mp,F f,S s){if(mp.find(f)==mp.end())mp[f]=F();mp[f]+=s;}
 
int main(){
    int h,v;
    using data=pair<int,string>;
    
    while(cin>>h>>v, h or v){
        int tv[]={-3,-1,1,3};
        int tc[]={v,h,h,v};

        array<int,9> a,b;
        geti(a);
        geti(b);
        string sa,sb;
        for(auto i:a)sa+=to_string(i);
        for(auto i:b)sb+=to_string(i);
    
        unordered_map<string,int> s;

        priority_queue<data> q;
        q.emplace(0,sa);
        
        while(1){
            int cost=q.top().fs;
            string board=q.top().sc;
            q.pop();
            if(board==sb){
                cout<<-cost<<endl;
                break;
            }
            
            int index=board.find('0');
            rep(i,4){
                int fixed=(index+tv[i]+9)%9;
                string next=board;
                next[index]=next[fixed];
                next[fixed]='0';
                if(s.find(next)==s.end() || s[next]<cost-tc[i]){
                     q.emplace(cost-tc[i], next);
                     s[next]=cost-tc[i];
                }
            }
        }
    }
}



Measured memory_bytes: 47156
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <cctype>
#include <iostream>
#include <set>
#include <string>
#include <queue>
#include <map>
#include <utility>
using namespace std;
int size(string x){
	string::size_type size=x.size();
	return size;
}
#define fu(l,k) for(int i=l;i<k;i++)
#define fd(l,k) for(int i=l;i>k;i--)
#define sort(ss) sort(ss.begin(), ss.end())
#define rsort(ss) sort(ss.rbegin(), ss.rend())
typedef  vector<string> vs;
typedef  vector<int> vi;
double pi(){
	return acos(-1.0);
}
typedef set<int> set_i;
typedef set<string> set_s;
int INF=1000000;
int main(){
	string x,p;
	cin>>x;
	cin>>p;
	int a=size(x);
	int ans=0;
	for(int i=0;i<a;i++){
		if(x[i]==p[0]){
			if(i+size(p)<a){
				for(int e=i;e<size(p)+i;e++){
					if(x[e]==p[e-i]) ans++;
					else{
						ans=0;
						break;
					}
					if(ans==size(p)){
						cout<<"Yes"<<endl;
						return 0;
					}
				}
			}
			else{
				for(int e=i;e<size(p)+a;e++){
					if(e<a){
						if(x[e]==p[e-i]) ans++;
						else{
							ans=0;
							break;
						}
					}
					else{
						if(x[e-a]==p[e-i]) ans++;
						else{
							ans=0;
							break;
						}
					}
					if(ans==size(p)){
						cout<<"Yes"<<endl;
						return 0;
					}
				}
			}
		}
	}
	cout<<"No"<<endl;
}

Measured memory_bytes: 1192
#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;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	ll n;cin>>n;
	vector<ll> a(n + 5,0);
		for(ll x = 1; x * x <= n; x++) {
			for(ll y = 1; y * y <= n; y++) {
				for(ll z = 1;z * z<= n;z++){
					ll ans = x * x + y * y + z * z + x * y + y * z + z * x;
					if(ans <= n){
						a[ans] ++;
					}
					}
				}
			}

		for(ll i = 1; i <= n; i++) {
			cout << a[i] << endl;
		}
	return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <string.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <functional>
#include <cassert>
#include <utility>
#include <stack>
#include <queue>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef pair<int,int> Pi;
typedef long long int ll;
const int INF=(ll)(1<<30)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

int a,b,c,d;
int n;

int main() {
	string s; cin >> s;
	vector<int> a(4);
	REP(i, 4) a[i] = s[i] - '0';
	REP(S, 1<<3) {
		int ans = a[0];
		REP(i, 3) if (S>>i & 1) ans += a[i + 1]; else ans -= a[i + 1];
		if (ans == 7) {
			string s = "0-0-0-0=7";
			REP(i, 4) s[i * 2] = '0' + a[i];
			REP(i, 3) if (S>>i & 1) s[i * 2 + 1] = '+';
			cout << s << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
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 (b<a) { a=b; return 1; } return 0; }
const long long INF = 1LL <<60;
typedef long long ll;
using namespace std;

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

ll lcm(ll a, ll b) {
    return a * b / gcd(a, b);
}

ll choose2(ll n){
    return n*(n-1)/2;
}

int main(){
    int k,a,b;
    cin>>k>>a>>b;
    rep(i,a,b){
        if(i%k==0){
            cout<<"OK"<<endl;
            return 0;
        }
    }
    cout<<"NG"<<endl;
    return 0;
}

Measured memory_bytes: 3636
a,b=map(int,input().split())
import math
if (a+b)%3!=0:
  print(0)
  exit()
f=(a+b)//3
g=a-f
f=f-g
if f<0 or g<0:
  print(0)
  exit()
h=min(f,g)
ans=1

def framod(n, mod, a=1):
    for i in range(1,n+1):
        a=a * i % mod
    return a

def power(n, r, mod):
    if r == 0: return 1
    if r%2 == 0:
        return power(n*n % mod, r//2, mod) % mod
    if r%2 == 1:
        return n * power(n, r-1, mod) % mod
def comb(n, k, mod):
    a=framod(n, mod)
    b=framod(k, mod)
    c=framod(n-k, mod)
    return (a * power(b, mod-2, mod) * power(c, mod-2, mod)) % mod
  

print(comb(f+g,min(f,g),10**9+7))

Measured memory_bytes: 38512
import java.util.Scanner;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
 
        int x = sc.nextInt();
        int y = sc.nextInt();
        System.out.println(gcd(Math.max(x, y), Math.min(x, y)));
    }
 
    private static int gcd(int x, int y) {
        int r = x % y;
        if(r == 0) return y;
        return gcd(y, r);
    }
}


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

int main() {
	// your code goes here
		int n, m, yen, yen2, sum;
		
		cin >> n >> m;
		
		cin >> yen >> yen2;
		
		if(n >= m){
			sum = yen * m + yen2 * (n - m);
		}else{
			sum = yen * n;
		}
		
		cout << sum << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define pii pair<int, int>
#define ordered_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
//#define ordered_multiset tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
#define int long long
#define jai_shree_ram  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i, a, b, d) for (int i = a; i <= b; i += d)
#define brep(i, a, b, d) for (int i = a; i >= b; i -= d)
#define pb push_back
#define all(x) x.begin(), x.end()
#define endl '\n'
int MAX = 1e5 + 5;
int MOD = 1e9 + 7;
////////////////////////////////

int n, a[105], dp[100005];

int32_t main(){
    jai_shree_ram 
    int k;
    cin >> n >> k;
    rep(i,1,n,1) cin >> a[i];

    rep(i,1,k,1){
        rep(j,1,n,1)
            if(i >= a[j]) 
                dp[i] += (!dp[i-a[j]]);
    }

    if(dp[k]) cout << "First" <<endl;
    else cout << "Second" << endl;
    return 0; 
}

Measured memory_bytes: 1024
#include<stdio.h>
int main(){
    unsigned short usW_D_num;                /* 情報量の格納用変数 */
    unsigned short usW_D_house[4][3][10];    /* 部屋情報の格納用変数 */
    unsigned short usW_D_bil;                /* 棟番号の格納用変数 */
    unsigned short usW_D_flor;               /* 階数の格納用変数 */
    unsigned short usW_D_room;               /* 部屋番号の格納用変数 */
    signed long  riside;              /* 入居者数の格納用変数 */
    unsigned short i, j, k;            /* ループ変数 */

    /* 配列の初期化 */
    for(i = 0;i < 4;i++){
        for(j = 0;j < 3;j++){
            for(k = 0;k < 10;k++){
                usW_D_house[i][j][k] = 0;
            }
        }
    }

    /* 情報量の入力 */
    scanf("%d", &usW_D_num);
    /* 入居者変更情報の入力 */
    for(i = 0;i < usW_D_num;i++){
        /* 入居者変更情報の入力 */
        scanf("%d %d %d %d", &usW_D_bil, &usW_D_flor, &usW_D_room, &riside);
        /* 入居者変更情報の加算 */
        usW_D_house[usW_D_bil - 1][usW_D_flor - 1][usW_D_room - 1] += riside;
    }

    /* 部屋情報の出力 */
    for(i = 0;i < 4;i++){
        for(j = 0;j < 3;j++){
            for(k = 0;k < 10;k++){
                /* 各部屋の入居者の出力 */
                printf(" %d", usW_D_house[i][j][k]);
            }
            /* 階の区切り */
            printf("\n");
        }
        /* 第四棟でない場合棟を区切る */
        if(i != 3){
           /* 棟の区切り */
           printf("####################\n");
        }
    }
    return 0;
}


Measured memory_bytes: 2044
#include<bits/stdc++.h>
using namespace std;
long long n,k,ans;
int main(){
    cin>>n>>k;
    if(k==0) ans=n*n;
    else
    {
        for(int i=k+1;i<=n;i++)
        {
            ans+=(n/i)*(i-k);
            if(n%i>=k) ans+=n%i-k+1;
        }
    }
    cout<<ans;
    return 0;
}
//68871358
//76140264
//25446011
//200841159

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdio.h>

using namespace std;

int main()
{
    int l;
    cin >> l;
    /*
    int a[n];
    for(int i=0; i<n; i++){
        int id,k;
        cin >> id >> k;
    }
    */
    
    long double a = (long double)(l)/3.0;
    long double ans = a*a*a;

    printf("%.7Lf\n", ans);
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int mod=1000000007;
inline void add(int &x,int y){(x+=y)>=mod?x-=mod:0;}
inline int pl(int x,int y){return (x+=y)>=mod?x-mod:x;}
inline int kpow(int a,int b)
{
	int s=1;
	for(;b;b>>=1,a=1ll*a*a%mod)
		if(b&1)s=1ll*s*a%mod;
	return s;
}
int n,h[110],dp[110][110],d[110],m,ans;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i)scanf("%d",&h[i]),d[i]=h[i];
	sort(d+1,d+1+n);
	m=unique(d+1,d+1+n)-d-1;
	for(int i=1;i<=n;++i)h[i]=lower_bound(d+1,d+1+m,h[i])-d;
	dp[1][0]=kpow(2,d[h[1]]);
	for(int i=1;i<=h[1];++i)dp[1][i]=2*kpow(2,d[h[1]]-d[i])%mod;
	for(int i=0;i<h[1];++i)add(dp[1][i],mod-dp[1][i+1]);
	for(int i=1;i<n;++i)
	{
		if(h[i]>=h[i+1])
		{
			for(int j=0;j<h[i+1];++j)dp[i+1][j]=dp[i][j];
			for(int j=h[i+1];j<=h[i];++j)add(dp[i+1][h[i+1]],dp[i][j]);
			(dp[i+1][h[i+1]]<<=1)%=mod;
		}
		else
		{
			int res=kpow(2,d[h[i+1]]-d[h[i]]);
			for(int j=0;j<h[i];++j)dp[i+1][j]=1ll*dp[i][j]*res%mod;
			for(int j=h[i];j<=h[i+1];++j)dp[i+1][j]=2ll*dp[i][h[i]]*kpow(2,d[h[i+1]]-d[j])%mod;
			for(int j=h[i];j<h[i+1];++j)add(dp[i+1][j],mod-dp[i+1][j+1]);
		}
	}
	for(int j=0;j<=h[n];++j)add(ans,dp[n][j]);
	printf("%d",ans);
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int a,b,c;
    while(scanf("%d%d%d",&a,&b,&c)==3)
    {
        if(a==5&&b==5&&c==7)
            printf("YES\n");
        else if(a==5&&b==7&&c==5)
            printf("YES\n");
        else if(a==7&&b==5&&c==5)
            printf("YES\n");
        else
            printf("NO\n");
    }
    return 0;
}


Measured memory_bytes: 1604
import java.util.*;

class Main {
        public static void main(String args[]) {
                Scanner sc = new Scanner(System.in);
                int H = sc.nextInt(), W = sc.nextInt();
                String[] a = new String[H];
                for (int i = 0; i < H; i++) {
                        a[i] = sc.next();
                }
                StringBuilder SB = new StringBuilder(H * (W + 1) * 2 + 1);
                for (int i = 0; i < H; i++) {
                        for (int j = 0; j < W; j++) {
                                if (j != W - 1 && (i % 2 == 0 || j == 0 || a[i].charAt(j) == '#')) {
                                        SB.append('#');
                                } else {
                                        SB.append('.');
                                }
                        }
                        SB.append('\n');
                }
                SB.append('\n');

                for (int i = 0; i < H; i++) {
                        for (int j = 0; j < W; j++) {
                                if (j != 0 && (i % 2 == 1 || j == W - 1 || a[i].charAt(j) == '#')) {
                                        SB.append('#');
                                } else {
                                        SB.append('.');
                                }
                        }
                        SB.append('\n');
                }

                System.out.print(SB);
        }
}

Measured memory_bytes: 18364
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long long a,c,b;
    cin>>a>>b>>c;
    long long k=b-a,t=c-b;
    if(k<0 || t<0 )
    { k=k*-1;t=t*-1;}
    
    if(t==k)
     cout<<"YES";
    else 
     cout<<"NO";
    return 0;
}
     
   




Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a,b;
  	cin >> a>>b;
  	for(int i = 1;i<=10000;i++){
    	if(floor(i*0.08)==a && floor(i*0.1)==b){
        	cout << i << endl;
          	break;
        }
      	else if(i==10000){
        	cout << -1 << endl;
        }
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
 
int dgr[5];
 
int main()
{
    for(int i=1;i<=3;i++)
    {
      	int a,b;
      	cin>>a>>b;
        dgr[a]++;
        dgr[b]++;
    }
    for(int i=1;i<=4;i++)
    {
        if(dgr[i]>2) return cout<<"NO"<<'\n',0;
    }
    cout<<"YES"<<'\n';
}

Measured memory_bytes: 256
N = int(input())
S = input()

w = S.count('.')
b = N - w
ans = min(w, b)
l, r = 0, w

for si in S:
    if si == '#':
        l += 1  # 現時点iも含め左側に存在する黒の数
    else:
        r -= 1  # 現時点iも含め右側に存在する白の数
    ans = min(ans, l+r)

print(ans)

Measured memory_bytes: 3500