akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

struct p{char c;int a;};
int costb[3000][3000],costw[3000][3000],dp[3000][3000];

template<typename T>
struct BIT{
  int n;
  vector<T> bit;
  //1-indexed
  BIT():n(-1){}
  BIT(int n_,T d):n(n_),bit(n_+1,d){}

  //bit[i]は長さはiの最後のbit分で、スタートはそれ以外のbit 合計でちょうどiまでの情報
  //最後のbitが表す物をk,それ以外のbitが表す物をlとするとbit[i]=(l,l+k]でl+k=i

  T sum(int i){
    T s=bit[0];
    for(int x=i;x>0;x-=(x&-x))//x&-x:(xの最後のbit) 上の言葉でxをl+kからlにしてる
      s+=bit[x];
    return s;
  }

  void add(int i,T a){
    if(i==0) return;
    for(int x=i;x<=n;x+=(x&-x))//k,l+kは自明に増える lは増えない(lとkの間に0が出来ない)
      bit[x]+=a;
  }

  void check(){
    for(int i=0;i<=10;i++)cout<<bit[i]<<" ";cout<<endl;
  }

  int lower_bound(int w){//w以上となる最小の場所を返す 単調性を仮定してる(bit[i]>=0)
    if(w<=0) return 0;
    int x=0,r=1;
    while(r<n) r<<=1;
    for(int k=r;k>0;k>>=1){//xに2のべき乗を大きい方から足せるなら足すだけ
      if(x+k<=n&&bit[x+k]<w){
        w-=bit[x+k];
        x+=k;
      }
    }
    return x+1;//xはw未満を満たす最大の場所なので1大きい値を返す
  }

  T sum0(int i){
    return sum(i+1);
  }

  void add0(int i,T a){
    add(i+1,a);
  }

  T query(int l,int r){
    return sum(r-1)-sum(l-1);
  }

  T query0(int l,int r){
    return sum(r)-sum(l);
  }
};

signed main(){
  int N;cin>>N;
  vector<p> v(2*N);
  for(int i=0;i<2*N;i++){
    char c;int a;cin>>c>>a;
    v[i]={c,a};
  }
  BIT<int> b(3000,0),w(3000,0);
  for(int i=2*N-1;i>=0;i--){
    if(v[i].c=='B'){
      int res=b.sum(v[i].a);
      for(int j=0;j<=N;j++){
        int tmp=w.sum(j);
        costb[j][v[i].a]=res+tmp;
      }
      b.add(v[i].a,1);
    }
    else{
      int res=w.sum(v[i].a);
      for(int j=0;j<=N;j++){
        int tmp=b.sum(j);
        costw[v[i].a][j]=res+tmp;
      }
      w.add(v[i].a,1);
    }
  }
  for(int i=0;i<=N;i++){
    for(int j=0;j<=N;j++){
      if(!i&&!j)continue;
      if(!i)dp[i][j]=dp[i][j-1]+costb[i][j];
      if(!j)dp[i][j]=dp[i-1][j]+costw[i][j];
      if(i&&j)dp[i][j]=min(dp[i][j-1]+costb[i][j],dp[i-1][j]+costw[i][j]);
    }
  }
  cout<<dp[N][N]<<endl;
}


Measured memory_bytes: 73984
import java.io.*;
import java.util.*;

public class Main {
    public static final long mod = (long)1e9+7;
    public static final long INF = Long.MAX_VALUE/2;
    public static final int inf = Integer.MAX_VALUE/2;

    static void solve(InputReader in, PrintWriter out){
        int a = in.ni(), b = in.ni(), c = in.ni(), d = in.ni();
        int ans;
        if(a<=c){
            if(c<=b){
                if(b>=d) ans = d-c;
                else ans = b-c;
            } else ans = 0;
        }else{
            if(a<=d){
                if(d>=b) ans = b-a;
                else ans = d-a;
            } else ans = 0;
        }
        out.println(ans);
    }

    public static void main(String[] args){
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        solve(in, out);
        out.close();
    }
    public static class InputReader{
        private BufferedReader br;
        private StringTokenizer st;
        public InputReader(InputStream is){
            br = new BufferedReader(new InputStreamReader(is));
            st = null;
        }
        public String ns(){
            if(st == null || !st.hasMoreTokens()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (Exception e){
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }
        public int ni(){
            return Integer.parseInt(ns());
        }
        public long nl(){
            return Long.parseLong(ns());
        }
        public double nd(){
            return Double.parseDouble(ns());
        }
        public char nc(){
            return ns().toCharArray()[0];
        }
        public int[] ni(int n){
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = ni();
            }
            return a;
        }
        public long[] nl(int n){
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nl();
            }
            return a;
        }
        public double[] nd(int n){
            double[] a = new double[n];
            for (int i = 0; i < n; i++) {
                a[i] = nd();
            }
            return a;
        }
    }
}

Measured memory_bytes: 23124
import math

V = list(map(int, input().split()))
A = V[0]
B = V[1]
H = V[2]
M = V[3]

pi = math.pi
rad_per_min_A = 2*pi/12/60
rad_per_min_B = 2*pi/60

m = H*60+M

rad_A = m*rad_per_min_A
rad_B = M*rad_per_min_B

Ax = A*math.cos(rad_A)
Ay = A*math.sin(rad_A)
Bx = B*math.cos(rad_B)
By = B*math.sin(rad_B)

L = ((Ax-Bx)**2+(Ay-By)**2)**0.5
print(L)

Measured memory_bytes: 9336
import Control.Monad
import qualified Data.Vector.Unboxed as UV
import Data.List
import qualified Data.ByteString.Char8 as B

r3 [a,b,c]=(a,b,c)
main = do
    n<-readLn::IO Int
    xs<-UV.replicateM n $ r3.unfoldr (B.readInt.B.dropWhile(==' '))<$>B.getLine
    print $ f n xs
f n xs = (\(a,b,c)->maximum [a,b,c]) $ UV.foldl' p (0,0,0) xs where
    p (u,v,w) (a,b,c) = (a+max v w, b+max u w, c+max u v)


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


#include <bits/stdc++.h>
using namespace std;

int main(){
    int n,t;
    scanf("%d %d",&n,&t);
    int i,ans=0,t1,t2;
    scanf("%d",&t1);
    for(i=1;i<n;i++){
        scanf("%d",&t2);
        ans += min(t,(t2-t1));
        t1 = t2;
    }
    printf("%d\n",ans+t);

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long a[1000];; 
int main()
{
	long long n,ba=1;
	cin>>n;
	for(int t=2;t<=n;t++)
	{
		int x=t;
		for(int i=2;i*i<=t;i++)
		{
	        while(x%i==0)
	        {
	        	a[i]++;
		        x/=i;
		        //cout<<i<<" ";
		    }
	    } 
	    if(x!=1)
	    {
	    	//cout<<x;
	    	a[x]++;
		}
		//cout<<endl;
	}
	//cout<<endl;
	for(int t=2;t<=n;t++)
	{
		ba%=1000000007;
		ba*=((a[t]+1)%1000000007);
		//cout<<t<<" "<<a[t]<<" "<<ba<<endl;
	}
	//cout<<ba;
	cout<<ba%1000000007;
	return 0;
}
//1000

Measured memory_bytes: 256
/** MIT License Copyright (c) 2018 Vasilyev Daniil **/
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
template<typename T> using v=vector<T>;
#define int long long
typedef string str;
typedef vector<int> vint;
#define rep(a,l,r) for(int a=(l);a<(r);a++)
#define pb push_back
#define sz(a) ((int)(a).size())
const long long inf=4611686018427387903;//2^62-1
#if 0 //FileIO
ifstream fin ("input.txt" );
ofstream fout("output.txt");
#define get fin>>
#define put fout<<
#else
#define get cin>>
#define put cout<<
#endif
#define eol put endl
void read(){}             template<typename Arg,typename... Args> void read (Arg& arg,Args&... args){get   (arg)     ;read(args...) ;}
void print(){}            template<typename Arg,typename... Args> void print(Arg  arg,Args...  args){put   (arg)<<" ";print(args...);}
void debug(){cerr<<endl;} template<typename Arg,typename... Args> void debug(Arg  arg,Args...  args){cerr<<(arg)<<" ";debug(args...);}
int getInt(){int a; get a; return a;}
//code goes here
void run(){
    str s;get s;
    int k;get k;
    set<str>pos;
    rep(i,0,sz(s)){
        str cur="";
        rep(j,i,min(i+k+1,sz(s))){
            cur+=s[j];pos.insert(cur);
            if(sz(pos)>k){
                str ter=(*pos.rbegin());
                pos.erase(ter);
            }
        }
    }
    put (*pos.rbegin());
}
int32_t main() {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);run();return 0;}


Measured memory_bytes: 768
def fibonacci(F, n):
    if n == 0 or n == 1:
        F[n] = 1
        return F[n]
    if F[n]:
        return F[n]
    else:
        F[n] = fibonacci(F, n-1) + fibonacci(F, n-2)
        return F[n]

if __name__ == "__main__":
    n = int(input())
    F = []
    for _ in range(n+1):
        F.append(None)
    fibonacci(F, n)
    print(F[n])


Measured memory_bytes: 5596
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T
import Data.List (unfoldr)

main :: IO ()
main = do
  (n : _) <- map unsafeTextToInt . T.words <$> T.getLine :: IO [Int]
  let
    next :: Maybe Digits -> Maybe ([Int], Maybe Digits)
    next = fmap next'
      where
        next' :: Digits -> ([Int], Maybe Digits)
        next' = (,) <$> map snd <*> succDs
  mapM_ putStrLn . map (('a' :) . map toLEL . reverse) . unfoldr next . Just . zeroes $ n

type Digits = [(Int, Int)]

extend :: Digits -> Digits
extend [] = (1, 0) : []
extend ds@((m, k) : _) = (max m (succ k), 0) : ds

zeroes :: Int -> Digits
zeroes 1 = []
zeroes l  = extend . zeroes . pred $ l

succDs :: Digits -> Maybe Digits
succDs [] = Nothing
succDs ((m, k) : ds) | k < m = Just ((m, succ k) : ds)
succDs (_ : ds) = extend <$> succDs ds

showDs :: Digits -> String
showDs = ('a' :) . map (toLEL . snd) . reverse

toLEL :: Int -> Char
toLEL = toEnum . (fromEnum 'a' +)

unsafeTextToInt :: T.Text -> Int
unsafeTextToInt s = case T.signed T.decimal s of
  Right (n, _) -> n


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

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

  int t;
  int ans = 0;
  int ma = 0;
  for(int i = 0;i < n;i++){
    cin >> t;
    ans += t;
    ma = max(t, ma);
  }

  cout << ans-ma/2 << endl;

  return 0;
}


Measured memory_bytes: 256
h, w = map(int, input().split())

area = []
area.append(['.' for i in range(w+2)])

for i in range(h):
    l = list(input())
    tmp = ['.']
    tmp.extend(l)
    tmp.extend(['.'])
    area.append(tmp)
area.append(['.' for i in range(w+2)])


for i in range(1,h+1):
    s = ''
    
    for j in range(1,w+1):
        if area[i][j] == '#':
            s += '#'
        else:
            cnt = 0
            if area[i-1][j-1] == '#': cnt += 1
            if area[i-1][j] == '#': cnt += 1
            if area[i-1][j+1] == '#': cnt += 1
            
            if area[i][j-1] == '#': cnt += 1
            if area[i][j] == '#': cnt += 1
            if area[i][j+1] == '#': cnt += 1
            
            if area[i+1][j-1] == '#': cnt += 1
            if area[i+1][j] == '#': cnt += 1
            if area[i+1][j+1] == '#': cnt += 1
            
            s += str(cnt)
    print(s)


Measured memory_bytes: 3064
private fun readInts() = readLine()!!.split(" ").map { it.toInt() }

fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val H = readInts()

    var count = 0
    var max = H[0]
    for (h in H) {
        if (max > h) {
            continue
        }

        count++

        if (max < h) {
            max = h
        }
    }

    println(count)
}

Measured memory_bytes: 36108
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
using namespace std;

int main() {
  int n;
  cin >> n;
  cout << 3 * pow(n, 2);
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
  
  public static void main (String[] args){
  
  	Scanner scanner = new Scanner(System.in);
    
  	int blueCards = scanner.nextInt();
    String[] blueList = new String[blueCards];
  
    scanner.nextLine();
    
  	for(int index=0; index<blueCards; index++){
  		String temp = scanner.nextLine();
      	blueList[index]=temp;
  	}
    
    int redCards = scanner.nextInt();
    String[] redList = new String[redCards];
    
    scanner.nextLine();
    
    for(int index=0; index<redCards; index++){
      String temp = scanner.next();
      redList[index] = temp;
    }
    
    HashMap <String,Integer> cardMap = new HashMap <String,Integer>();
    
    for (int index=0; index<blueCards; index++) {
    	if (cardMap.containsKey(blueList[index])) {
    	} else {
    		cardMap.put(blueList[index], index);
    	}
    }
    
    for (int index=0; index<redCards; index++) {
    	if (cardMap.containsKey(redList[index])){
    	} else {
    		cardMap.put(redList[index], index+blueCards);
    	}
    }
    
    int[] scoreList = new int[blueCards+redCards];
    for (int index=0; index<scoreList.length; index++) {
    	int defaultValue = 0;
    	defaultValue = scoreList[index];
    }
    
    for (int index=0; index<blueCards; index++) {
    	String temp = blueList[index];
    	int indexNum = cardMap.get(temp);
    	int score =scoreList[indexNum];
    	score++;
    	scoreList[indexNum]=score;
    }
    
    for (int index=0; index<redCards; index++) {
    	String temp = redList[index];
    	int indexNum = cardMap.get(temp);
    	int score = scoreList[indexNum];
    	score--;
    	scoreList[indexNum]=score;
    }
    
    int maximunScore =0;
    
    for (int index=0; index<blueCards+redCards; index++) {
    	int temp=scoreList[index];
    	if (temp>maximunScore) {
    		maximunScore=temp;
    	}
    }
    
    System.out.println(maximunScore);
    
  }
}

Measured memory_bytes: 21716
#include <iostream>

#define Nmax int(1e5 + 1)
using namespace std;

char s[Nmax];
int nr,p;

int main()
{
    cin >> s;
    p = '1' - s[0];
    for(int i = 1; s[i]; ++i)
    {
        if((s[i] - '0') != p)
            nr++,s[i] = p + 48;
        p = '1' - s[i];
    }
    cout << nr;
    return 0;
}


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

int main()
{
	ll ans = 0;
	ll x; cin >> x;

	ans = (x / 500LL) * 1000LL;
	x %= 500LL;
	ans += (x / 5LL) * 5LL;

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define faster  ios :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define ull unsigned long long
#define pb push_back
const double PI = acos(-1.0);
using namespace std;

int main()
{
    faster
    
    int x;
    cin>>x;
    
    if(x>=400 && x<=599)
        cout<<8<<endl;
    else if(x>=600 && x<=799)
        cout<<7<<endl;
    else if(x>=800 && x<=999)
        cout<<6<<endl;
    else if(x>=1000 && x<=1199)
        cout<<5<<endl;
    else if(x>=1200 && x<=1399)
        cout<<4<<endl;
    else if(x>=1400 && x<=1599)
        cout<<3<<endl;
    else if(x>=1600 && x<=1799)
        cout<<2<<endl;
    else if(x>=1800 && x<=1999)
        cout<<1<<endl;




    return 0;
}


Measured memory_bytes: 3648
N, A, B = map(int, input().split())
S = input()
ps = 0
os_r = 0
for s in S:
    if s == 'c':
        print("No")
    elif s == 'a':
        if ps < A + B:
            print("Yes")
            ps += 1
        else:
            print("No")
    else:
        if ps < A + B and os_r < B:
            print("Yes")
            ps += 1
            os_r += 1
        else:
            print("No")

Measured memory_bytes: 70572
/*************
 *
 *ALDS1_7_B
 *Binary Trees
 *
 *2020/07/16
 *************/


#include<cstdio>

typedef struct{
  int l;//left 
  int r;//right
} Node;

const int max_node = 25;

void search_depth(Node *node,int *node_depth,int id,int depth){
  
  node_depth[id] = depth;
  
  if(node[id].l != -1) search_depth(node,node_depth,node[id].l,(depth+1));
  if(node[id].r != -1) search_depth(node,node_depth,node[id].r,(depth+1));

}

void search_height(Node *node,int *node_height,int id){
  
  if(node[id].l != -1 && node[id].r != -1) {
    search_height(node,node_height,node[id].l);
    search_height(node,node_height,node[id].r);
    int bigger_depth =(node_height[node[id].l] > node_height[node[id].r])?node_height[node[id].l]:node_height[node[id].r];
    node_height[id] = bigger_depth+1;
    return;
  }
  if(node[id].l != -1){
    search_height(node,node_height,node[id].l);
    node_height[id] = node_height[node[id].l]+1;
    return;
  }

  if(node[id].r != -1){
    search_height(node,node_height,node[id].r);
    node_height[id] = node_height[node[id].r]+1;
    return;
  }
  
  node_height[id] = 0;
  return;
}

int main(void){
  
  Node node[max_node] = {0};
  int parent[max_node];
  int sibling[max_node];
  int degree[max_node] = {0};
  int node_depth[max_node] = {0};
  int node_height[max_node];
  int n=0;

  int parent_id = -1;
  
  /*入力*/
  scanf("%d",&n);

  for(int i=0;i<n;i++){
    int id,left,right;
    scanf("%d %d %d",&id,&left,&right);
    node[id].l =left;
    node[id].r = right;
    parent[id] = -1;
    sibling[id] = -1;
  }

  /*処理*/

  //各ノードの親、兄弟、子の数を調べる
  for(int i=0;i<n;i++){
    if(node[i].l != -1){
      parent[node[i].l] = i;
      sibling[node[i].l] = node[i].r;
      degree[i]++;
    }
    if(node[i].r != -1){
      parent[node[i].r] = i;
      sibling[node[i].r] = node[i].l;
      degree[i]++;
    }
  }

  //親を基準に各ノードの深さを求める

  for(int i=0;i<n;i++){
    if(parent[i] == -1){
      parent_id = i;
      break;
    }
  }

  search_depth(node,node_depth,parent_id,0);
  search_height(node,node_height,parent_id);
  
  /*出力*/
  for(int i=0;i<n;i++){
    printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ",i,parent[i],sibling[i],degree[i],node_depth[i],node_height[i]);

    if(parent[i] == -1) printf("root\n");
    else{
      if(node[i].l == -1 && node[i].r == -1) printf("leaf\n");
      else printf("internal node\n");
    }
    
  }
  
  
  return 0;
}



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

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

int main() {
  ll a, b;
  cin >> a >> b;
  ll g = gcd(a, b);
  ll res = 1;
  for(ll p=2; p*p<=g; p++){
    if(g%p!=0) continue;
    while(g%p==0) g /= p;
    res++;
  }
  if(g!=1) res++;
  cout << res << endl;
  return 0;
  
}

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

int main() {
  int S; cin >> S;
  int f = S / 100;
  int s = S % 100;
  
  
  
  if (1<=s && s<=12 && 1<=f && f<=12) {
    cout << "AMBIGUOUS" << endl;
  }else if (1<=f && f<=12 && 0<=s && s<=99) {
    cout << "MMYY" << endl;
  }else if (0<= f && f<=99 && 1<=s && s<=12) {
    cout << "YYMM"<< endl;
  }else {
    cout << "NA" << endl;
  }
}
  
 

  

Measured memory_bytes: 256
N = int(input())
Xs = list(map(lambda x: int(x), input().split(" ")))

result = float("inf")

min_num = min(Xs)
max_num = max(Xs)

for i in range(min_num, max_num+1):
    temp_result = 0
    for x in Xs:
        temp_result += pow(x-i, 2)
    result = min(result, temp_result)


print(result)


Measured memory_bytes: 3060
#include <iostream>
#include <vector>

int main(void) {
    u_int a, b, n;
    const int NOT_ASSIGNED = -1;

    std::cin >> a >> b;
    for (; a != 0 && b != 0; std::cin >> a >> b) {
        /*
         * 初期化
         */
        std::vector<std::vector<int>> matrix(a);
        for (int x = 0; x < a; ++x) {
            if (x == 0) {
                // x = 0 上はそれぞれ1通り
                matrix[x].resize(b, 1);
            } else {
                matrix[x].resize(b, NOT_ASSIGNED);
            }
            matrix[x][0] = 1;  // y = 0 上はそれぞれ1通り
        }

        /*
         * 行き止まりを反映する
         */
        std::cin >> n;
        for (u_int i = 0, x, y; i < n; ++i) {
            std::cin >> x >> y;
            matrix[--x][--y] = 0;  // 行き止まり

            // x = 0 上に行き止まりがあるとき、y 以降は通ることができない
            if (x == 0) {
                auto it = matrix[0].begin();
                for (std::advance(it, y + 1); it != matrix[0].end(); ++it) {
                    *it = 0;
                }
            }
            // y = 0 上に行き止まりがあるとき、x 以降は通ることができない
            if (y == 0) {
                for (int j = x + 1; j < a; ++j) {
                    matrix[j][0] = 0;
                }
            }
        }

        /*
         * 経路の計算
         */
        matrix[0][0] = 0;
        for (int x = 1; x < a; ++x) {
            for (int y = 1; y < b; ++y) {
                if (matrix[x][y] == NOT_ASSIGNED) {
                    matrix[x][y] = matrix[x][y-1] + matrix[x-1][y];
                }
            }
        }

        std::cout << matrix[a-1][b-1] << std::endl;
    }

    return 0;
}

Measured memory_bytes: 1196
#include<bits/stdc++.h>
#define faster  ios :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define ull unsigned long long
#define pb push_back
const double PI = acos(-1.0);
using namespace std;

int main()
{
    faster

    int n;
    cin>>n;

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

    ll s=0;

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

    cout<<s<<endl;




    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
                                        #include<iostream>
                                        #include<cstdio>
                                        #include<vector>
                                        #include<queue>
                                        #include<map>
                                        #include<cstring>
                                        #include<string>
                                        #include <math.h>
                                        #include<algorithm>
                                    //    #include <boost/multiprecision/cpp_int.hpp>
                                        #include<functional>
                           //     #define int long long
                                        #define inf  1000000007
                                        #define pa pair<int,int>
                                        #define ll long long
                                        #define pal pair<double,pa>
                                        #define ppa pair<int,int>
                                        #define ppap pair<pa,pa>
                                        #define ssa pair<string,int>
                                        #define  mp make_pair
                                        #define  pb push_back
                                        #define EPS (1e-10)
                                        #define equals(a,b) (fabs((a)-(b))<EPS)
                                  #define VI vector<int>
                                        using namespace std;
                                        
                                  class pas{
                                    	public:
                                    	int x,y;
                                    	pas(int x=0,int y=0):x(x),y(y) {}
                                    	pas operator + (pas p) {return pas(x+p.x,y+p.y);}
                                    	pas operator - (pas p) {return pas(x-p.x,y-p.y);}
                                    	pas operator * (int a) {return pas(x*a,y*a);}
                                    	pas operator / (int a) {return pas(x/a,y/a);}
                                    //	double absv() {return sqrt(norm());}
                                    	int norm() {return x*x+y*y;}
                                    	bool operator < (const pas &p) const{
                                    		return x != p.x ? x<p.x: y<p.y;
                                    	}
                                    	bool operator == (const pas &p) const{
                                    		return x==p.x && y==p.y;
                                    	}
                                    };
int a[60]={0};
           signed main(){
   int n,k;
           	int ans=0;
           	cin>>n>>k;
           	for(int i=0;i<n;i++){
           		int r;
           		cin>>r;
           		ans+=min(r,k-r);
           	}
           	cout<<2*ans<<endl;
           }
             

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

using namespace std;

int main(){
int N;int K; cin >> N >> K; vector<int> S(N); 
  for(int i = 0; i < N; i++){ cin >> S[i];}
  sort(S.begin(),S.end());
  reverse(S.begin(),S.end()); int sum = 0;
  for(int i = 0; i < K; i++){
    sum += S[i];}
  
  cout << sum << endl;
  
  return 0;}
  
    


Measured memory_bytes: 256
#define DBG 0 //submit 0
#define ll long long
#if DBG
    #include <algorithm>
    #include <array>
    #include <ctime>
    #include <cstdlib>
    #include <string>
    #include <vector>
    #include <unordered_map>
    #include <iostream>
    #include <cmath>
    #include <queue>
    #include <numeric>
#else
    #include <bits/stdc++.h>
#endif
 
using namespace std;
 
 
int main(){
    int m,n,ans=0;
    bool flag=false;
    string s;
   
    cin >> n;
    cin >> s;
    //for(int i=0;i<n;i++) cin >> s[i];
    if(n%2==1){
        flag=true;
    }else{
        for(int i=0;i<n/2;i++){
            if(s[i]!=s[i+n/2]){
                flag=true;
            }
        }
    }
    
    
    cout << (!flag ? "Yes" : "No");
    //cout << ans;
    //printf("%.10f",ans_d);

    cout << endl;
}


Measured memory_bytes: 256
N = int(input())
S = sorted(int(input()) for T in range(0,N))
MAX = sum(S)
if MAX%10==0:
    R10 = [T for T in S if T%10!=0]
    if len(R10)==0:
        print(0)
    else:
        print(MAX-R10[0])
else:
    print(MAX)

Measured memory_bytes: 9048
#include<stdio.h>
#include<stdlib.h>

void Array_Print(int N, int A[]){
	for(int i=0; i<N; i++){
		if(i == N-1) printf("%d", A[i]);
		else printf("%d ", A[i]);
	}
	printf("\n");
}

void Insertion_Sort(int N, int A[]){
	int k,i,j;
	for(i=1; i<N; i++){
		k = A[i];
		if(A[i-1] > A[i]){
			A[i] = A[i-1];
			A[i-1] = k;
		}
		for(j=i-1; j>=0; j--){
			if(A[j-1] > A[j]){
				A[j] = A[j-1];
				A[j-1] = k;
			}
			else break;
		}
		Array_Print(N,A);
	}
}

int main(int argc, char const *argv[]){
	// Input the number of elements in array A
	int N;
	scanf("%d", &N);
	// Input elements in array A
	int A[N+1];
	for(int i=0; i<N; i++){
		scanf("%d", &A[i]);
	} 
	// printf("\n");
	Array_Print(N,A);
	// Insertion Sort
	Insertion_Sort(N,A);
	return 0;
}


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

typedef long long ll;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define ANS(n) cout << (n) << endl

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(a);i>=(b);i--)

#define ALL(obj) (obj).begin(),(obj).end()

#define pii pair<int,int>

#define pb(a) push_back(a)
#define mp make_pair

int main()
{
	vector<tuple<int,int,int>> t(4);	//2Lあたりの価格, サイズ, 価格
	int q,h,s,d;
	ll n;
	cin >> q >> h >> s >> d >> n;
	n *= 4;
	t[0] = make_tuple(q * 8, 1, q);
	t[1] = make_tuple(h * 4, 2, h);
	t[2] = make_tuple(s * 2, 4, s);
	t[3] = make_tuple(d * 1, 8, d);
	sort(ALL(t));
	ll ans = 0;
	FOR(i,0,4){
		ll buy = n / get<1>(t[i]);
		n -= buy * get<1>(t[i]);
		ans += buy * get<2>(t[i]);
	}
	ANS(ans);
	return 0;
}


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

const ll MOD = 1000000007;

// nのcnt乗
ll pow2( ll n, ll cnt ){
  if( cnt == 0 ) return 1;
  if( cnt == 1 ) return n;
  ll tmp = pow2(n,cnt/2);
  if( cnt%2 == 0 )
    return tmp%MOD*tmp%MOD;
  else
    return tmp%MOD*n%MOD*tmp%MOD;
}

// nから(n-cnt+1)までの積 
ll fac( ll n, ll cnt ){
  if( cnt == 0 ) return 1;
  if( cnt == 1 ) return n ;
  return fac(n-1,cnt-1)%MOD*n%MOD;
}

int main(){
  ll x,y;cin >> x >> y;

  if( (2*x-y) < 0 || (2*x - y)%3 != 0 ){
    cout << 0 << endl;
    return 0;
  }
  ll t = (2*x-y)/3;
  ll s = x - 2*t;

  ll n = s+t;

  // nCs mod MOD を求める
  ll m = min(s,t);
  if( m < 0 ){
    cout << 0 << endl;
    return 0;
  }
  ll denominator = fac(m,m)%MOD;


  ll ans = fac(n,m) * pow2(denominator,MOD-2);
  ans %= MOD;

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 8784
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
typedef long long int lli;
int main() {
  int d,t,s;
  scanf("%d %d %d", &d, &t, &s);
  double l = (double)d/s;
  if(l<=t){
      printf("Yes\n");
      //printf("%f",l);
  }
  else{
      printf("No\n");
      //printf("%f", l);
  }
}



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

static const int MAX = 100000;

int A[MAX + 1];
int pressed[MAX + 1];

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

    bool can = false;
    int i = 1;
    int cnt = 0;
    while (true) {
        if (pressed[i]) break;
        pressed[i] = 1;
        i = A[i];
        cnt++;
        if (i == 2) {
            can = true;
            break;
        }
    }

    if (can) cout << cnt << endl;
    else cout << -1 << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#define MAX_WEIGHT 512
#define QUANTITY 10

int main(void) {
    int x, i;
    
    while(scanf("%d", &x) != EOF) {
        int idx = 0;
        int ary[11] = {0};
        int weight = MAX_WEIGHT;
        for(i = 1; i <= QUANTITY; i++) {
            if((x - weight) >= 0) {
                ary[11 - i] = weight;
                if((11 - i) > idx)
                    idx = 11 - i;
                x -= weight;
            }
            if(weight == 1) break;
                weight /= 2;
        }
        
        for(i = 1; i < 11; i++) {
            if(ary[i]) {
                printf("%d", ary[i]);
                if(i != idx)
                    putchar(' ');
            }
            if(i == idx)
                putchar('\n');
        }
    }
    return(0);
}

Measured memory_bytes: 600
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int M = sc.nextInt();
    int D = sc.nextInt();
    int count = 0;
    int first, second;
    for (int i = 4; i <= M; i++)
      for (int j = 22; j <= D; j++) {
    	second = j / 10;
        first = j - second * 10;
        if (first >= 2 && second >= 2 && first * second == i)
          count++;
      }
    System.out.println(count);
  }
}

Measured memory_bytes: 21844
#include<stdio.h>
int main()
{
          int a,b,c,x,i=0;
          scanf("%d%d%d",&a,&b,&c);

          for(x=1;x<=c;x++)
          {
                    if(c%x==0)
                    {
                              if(x>=a&&x<=b)
                              {
                                        i++;
                              }


                    }
          }
          printf("%d\n",i);

          return 0;

}



Measured memory_bytes: 2100
#include<bits/stdc++.h>
#define ll long long
#define db long double
#define fi first
#define se second
#define  pb push_back
#define  pob pop_back
#define W while
#define fn(i,x) for(int i=0;i<x;i++)
#define fs(i,s,x) for(int i=s;i<x;i++)
#define fr(i,x) for(int i=x;i>=0;i--)
#define fit(it,s) for(auto it=s.begin();it!=s.end();it++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define mod 1000000007
#define MAX 1005
using namespace std;
int main()
{
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);

    // freopen("in.txt","r",stdin);
    // freopen("out.txt","w",stdout);
    
    db n,k;
    cin >> n >> k;
    db ans=0;
    for(int i=1;i<=n;i++){
      ll x = ceil((db)k/i);
      x = ceil((db)log2(x));
      
      ans += (db)((db)(1/(n*pow(2,x))));
    }
    cout << fixed << setprecision(13) << ans;
    return 0;

}

Measured memory_bytes: 512
import java.util.*;

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

    int ans = 1;
    for(int i=0; i<N; i++){
        if(ans<K){
            ans *= 2;
        }else{
            ans += K;
        }
    }
    System.out.println(ans);
    }
}


Measured memory_bytes: 35616
#include<iostream>
#include<cstdio>
using namespace std;
long long s;
int main()
{
	scanf("%lld",&s);
	if(s==1e18)
	printf("1000000000 0 0 0 0 1000000000");
	else
	{
		printf("1000000000 0 0 1 ");
		printf("%d %d\n",s%1000000000,s/1000000000+1);
	}
	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 rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using pii = pair<int, int>;

void Main(){
	int n;
	cin >> n;
	vi a(n);
	rep(i, n) cin >> a[i];

    for(int i = n-1; i >= 0; i--){
        int part_rem = 0;
        for(int j = i; j < n; j += i+1){
            part_rem += a[j];
        }
        part_rem %= 2;
        if(a[i] != part_rem){
            a[i] = 1 - a[i];
        }
        
    }

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

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

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

using ll = long long;
using P = pair<int,int>;

int main(){
    int x;
    cin >> x;
    if (x >= 30){
        cout << "Yes" << endl;
    } else{
        cout << "No" << endl;
    }

    return 0;
}

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

using namespace std;

int main() {
  string str;
  string cmp = "zyxwvutsrqponmlkjihgfedcba";
  string ans;
  int use[30] = {};
  
  cin >> str;

  if ( cmp == str ) {
    cout << "-1" << endl;
  } else {
    for ( int i = 0; i < str.size(); i++) {
      use[str[i] - 'a']  = 1;
    }

    if ( str.size() < 26 ) {
      int i = 0;
      while ( use[i] == 1 ) {
	i++;
      }
      str += i + 'a';

      cout << str << endl;
    } else {
      ans = str;

      int j = ans.size() - 1, k;
      
      while ( ans <= str ) {
	for ( k = str[j] - 'a'; k < 26; k++) {
	  if ( use[k] == 0 ) {
	    ans[j] = k + 'a';
	    if( ans > str ) {
	      break;
	    }
	  }
	}

	if( ans > str ) {
	  break;
	}
	
	use[ans[j] - 'a'] = 0;
	ans.erase(j, 1);

	j--;
      }

      cout << ans << endl;
    }
      
  }



  return (0);
}



Measured memory_bytes: 256
n, x = gets.split(/ /).map(&:to_i)
l_list = gets.split(/ /).map(&:to_i)

# puts "n: #{n}"
# puts "x: #{x}"
# puts "l_list: #{l_list.inspect} (#{l_list.length})"

class Jump
  def initialize(d, index)
    @d = d
    @index = index
  end

  attr_reader :d, :index
end

d = [Jump.new(0, 1)]
l_list.each.with_index(1) do |l, i|
  d_next = d.last.d + l
  if d_next <= x
    d.push(Jump.new(d_next, i + 1))
  else
    break
  end
end

puts d.last.index


Measured memory_bytes: 1788
#include<iostream>
#include<vector>
#include<tuple>
#include<cmath>
#include<algorithm>
#include<iomanip>
using namespace std;

int main(){
  int n;  cin >> n;
  vector<int>jun(n);
  vector<vector<double> >dis(n,vector<double>(n));
  vector<pair<int,int> >z;
  for(int i=0;i<n;i++){
    jun.at(i) = i;
    int x,y;  cin >> x >> y;
    z.push_back(make_pair(x,y));
  }
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      dis.at(i).at(j) = sqrt((z.at(i).first - z.at(j).first)*(z.at(i).first - z.at(j).first) + (z.at(i).second - z.at(j).second)*(z.at(i).second - z.at(j).second));
      dis.at(j).at(i) = dis.at(i).at(j);
    }
  }

  long double sum = 0;
  int count = 0;
  do{
    for(int i=0;i<n-1;i++){
      sum += dis.at(jun.at(i)).at(jun.at(i+1));
    }
    count++;
  }while(next_permutation(jun.begin(),jun.end()));

  cout << fixed << setprecision(10) << sum/count << endl;
}


Measured memory_bytes: 3856
a,b,x = gets.split.map &:to_i

d = x * 1.0 / (a * a)

if d * a * 2.0 / b >= a then
	b2 = d * a * 2 / a - b
	puts Math.atan((b - b2) / a) / ( 2 * Math::PI) * 360
else
	a2 = d * a * 2 / b
	puts Math.atan(b / a2) / ( 2 * Math::PI) * 360
end


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin>>N;
  int i;
  int s;
  s=0;
  for(i=100000000; i>0; i/=10){
    int n;
    n=N/(100000000/i);
    if(n>0){
      s+= n%10;
    }
    else{
      break;
    }
  }
  if(N%s==0){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}


Measured memory_bytes: 256
H,W = list(map(int,input().split()))
s = []
for _ in range(H):
    s.append(input())

d = [[1,0],[-1,0],[0,1],[0,-1]]
def check(i,j):
    flag = 0
    if s[i][j] == '#':
        for d_ in d:
            i_ = i+d_[0]
            j_ = j+d_[1]
            if H > i_ >= 0 and W > j_ >= 0:
                if s[i_][j_] == '#':
                    flag = 1
    else:
        flag = 1
    return flag

ans = 1
for i in range(H):
    for j in range(W):
        if check(i,j) == 0:
            ans = 0
if ans:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// #define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
//adds two more functions to set
//(1)*(set.find_by_order(k))[kth element in the sorted set]
//(2)set.order_of_key(k)[count of elements strictly less than k]
#define ll long long
#define ld long double
#define vv vector
#define pp pair
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
typedef pair<ll, ll> pll;
typedef vv<bool> vbool;
typedef vv<ll> vll;
typedef vv<ld> vld;
typedef vv<pll> vpll;
#ifdef LOCAL
#include "prettyprint.hpp"
#define LG(args...)                           \
{                                             \
	string _s = #args;                        \
	replace(_s.begin(), _s.end(), ',', ' ');  \
	stringstream _ss(_s);                     \
	err(istream_iterator<string>(_ss), args); \
	cerr << endl;                             \
}
void err(istream_iterator<string> it) {}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << "(" << *it << ":" << a << ") ";
	err(++it, args...);
}
#define fastio
#else
#define LG(...)
#define fastio                    \
	ios_base::sync_with_stdio(0); \
	cin.tie(0);
#define endl "\n"
#endif
//:::::::::::::::::::::::::::::::::::::::::::::
const ll INF = 9e18;
const ll MOD = 1e9 + 7;

int main(){
	fastio;
	ll n;
	cin>>n;
	string s;
	if(n >=30)
		s ="Yes";
	else
		s ="No";
	cout<<s<<endl;
}

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


int main()
{
	ll n,W;
	cin>>n>>W;
	ll w[n+1],v[n+1];
	ll h[n+1];
	for (int i = 1; i <= n; ++i)
	{
		cin>>w[i]>>v[i];
	}
	ll dp[n+1][W+1];
	for (int i = 0; i <= n; ++i)
	{
		dp[i][0]=0;
	}
	for (int i = 0; i <= W; ++i)
	{
		dp[0][i]=0;
	}
	for (int i = 1; i <= n; ++i)
	{
		for(int j=1;j<=W;j++)
		{
			if(j-w[i]>=0)
				dp[i][j]=max(dp[i-1][j],dp[i-1][max(j-w[i],0LL)]+v[i]);
			else
				dp[i][j]=dp[i-1][j];
		}	
	}
	// for (int i = 1; i <= n; ++i)
	// {
	// 	for(int j = 1;j <= W; j++)
	// 	{
	// 		cout<<dp[i][j]<<" ";
	// 	}	
	// 	cout<<endl;
	// }
	cout<<dp[n][W]<<endl;
}

Measured memory_bytes: 79104
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef ::std::int_fast64_t i64;
typedef ::std::uint_fast64_t u64;
typedef ::std::int_fast32_t i32;
typedef ::std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(::std::istream& is, ::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    vector.reserve(size);
    ::std::copy_n(::std::istream_iterator<T>(is), size, ::std::back_inserter(vector));
  }
  template <typename T>
  void read(::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    ::tools::read(::std::cin, vector, size);
  }

  template <typename T, ::std::size_t N>
  void read(::std::istream& is, ::std::array<T, N>& array) {
    ::std::copy_n(std::istream_iterator<T>(is), N, array.begin());
  }
  template <typename T, ::std::size_t N>
  void read(::std::array<T, N>& array) {
    ::tools::read(::std::cin, array);
  }
}

#endif

// main.cpp

int main() {
  i64 N;
  std::cin >> N;
  std::vector<i64> A(N), B(N);
  for (i64 i = 0; i < N; ++i) {
    std::cin >> A[i] >> B[i];
  }

  if (N % 2 == 0) {
    auto A_it1 = A.begin() + (N / 2 - 1);
    auto A_it2 = A.begin() + N / 2;
    auto B_it1 = B.begin() + (N / 2 - 1);
    auto B_it2 = B.begin() + N / 2;
    std::nth_element(A.begin(), A_it1, A.end());
    std::nth_element(A_it2, A_it2, A.end());
    std::nth_element(B.begin(), B_it1, B.end());
    std::nth_element(B_it2, B_it2, B.end());
    std::cout << (*B_it1 + *B_it2) - (*A_it1 + *A_it2) + 1 << std::endl;
  } else {
    auto A_it = A.begin() + N / 2;
    auto B_it = B.begin() + N / 2;
    std::nth_element(A.begin(), A_it, A.end());
    std::nth_element(B.begin(), B_it, B.end());
    std::cout << *B_it - *A_it + 1 << std::endl;
  }

  return 0;
}

Measured memory_bytes: 6432
import java.util.Arrays;
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		new Main().start();
	}
	void start(){
		Scanner in = new Scanner(System.in);
		int[] a = new int[3];
		for(int i = 0; i < 3; i++){
			a[i] = in.nextInt();
		}
		Arrays.sort(a);
		System.out.println(a[0] + a[1]);
		in.close();
	}

}


Measured memory_bytes: 22612
def a(v1,v2):
	if v1[0] != v2[0]:
		return (v2[1]-v1[1])/(v2[0]-v1[0])
	else:
		return (v2[1]-v1[1])*(10**10)
def dlt(p,v,sign):
	while len(p) > 2:
		if sign*(a(v[p[-3]],v[p[-2]]) - a(v[p[-2]],v[p[-1]])) < 0:
			del p[-2]
		else:
			break
	return p
def convex(v,n):
	d,u = [],[]
	for i in range(n):
		d = dlt(d+[i],v,1)
		u = dlt(u+[i],v,-1)
	return n - len(set(d+u))
while 1:
	n = input()
	if n == 0: break
	v = [map(float,raw_input().split(",")) for i in range(n)]
	v = sorted(sorted(v, key = lambda x:x[1]))
	print convex(v,n)

Measured memory_bytes: 4300
"use strict";

const fs = require("fs");

const lines = fs.readFileSync("/dev/stdin", "utf-8").split("\n");
lines.pop();

let amount = Number(lines[0]);
let result = 0;

result += Math.floor(amount / 500) * 1000;
amount %= 500;

result += Math.floor(amount / 5) * 5;

console.log(result);


Measured memory_bytes: 21064
#include <stdio.h>
using namespace std;
const int MAXN = 2e5 + 1;
int n, m, i, j, k, z;
long a[MAXN], b[MAXN];
signed main()
{
    scanf("%d %d %d", &n, &m, &k);
	for (i = 1; i <= n; ++i)
		scanf("%d", &a[i]), a[i] += a[i - 1];
	for (i = 1; i <= m; ++i)
		scanf("%d", &b[i]), b[i] += b[i - 1];
	z = 0, i = 0, j = m;
	while (a[i] <= k && i <= n)
	{
		while (b[j] > k - a[i])
			--j;
		if (i + j > z)
			z = i + j;
		++i;
	}
	printf("%d", z);
}

Measured memory_bytes: 4828
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    [a, b, c] <- getIntList
    putStrLn . solve $ a + b + c

solve n | n >= 22 = "bust"
        | otherwise = "win"

Measured memory_bytes: 380
import java.util.*;

public class Main {

	public static void main(String args[])
	{
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int x=sc.nextInt();
		int t=sc.nextInt();
		int ans=(int)Math.ceil((double)n/x);
		//System.out.println(ans);
		System.out.println(ans*t);
	}
}


Measured memory_bytes: 35636
# -*- coding: utf-8 -*-
import sys

n = int(input())
s = [int(c) for c in input().split(' ')]

count = 0

for i in range(n-2):
    if s[i] < s[i+1] < s[i+2] or s[i] > s[i+1] > s[i+2]:
        count += 1

print(count)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<(ll)n;++i)
int main(){
  string s;
  cin >> s;
  
  ll n = s.size()-7;
  for(ll i=0;i<8;++i){
    string j = s.substr(0,i) + s.substr(i+n);
    //cout << j << "\n";
    if( j == "keyence" ){
	  puts("YES");
      return 0;
    }
  }
  puts("NO");
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define IOS cin.tie(0),ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
template<class Type>struct is_vector : std::false_type {};
template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T> inline ostream& operator << (ostream& out, const vector<T>& v) {
    if (v.empty())return out;
    constexpr bool is_vector_v = is_vector<T>::value;
    if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
    else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
    return out;
}
inline void put() {}
template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
inline void putn() {}
template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }

vector<int> topologicalSort(vector<vector<int>>& path){
    int n = (int)path.size();
    vector<int> res;
    vector<int> entry(n,0);
    queue<int> q;
    for(int i=0;i<n;++i){
        for(int j=0;j<path[i].size();++j){
            entry[path[i][j]]++;
        }
    }
    for(int i=0;i<n;++i){
        if(!entry[i]){
            q.push(i);
        }
    }
    while(!q.empty()){
        int p = q.front();
        q.pop();
        res.push_back(p);
        for(int i=0;i<path[p].size();++i){
            if(--entry[path[p][i]]==0){
                q.push(path[p][i]);
            }
        }
    }
    return res;
}

int main(){
    IOS;
    string s;
    cin >> s;
    int n = (int)s.size();
    vector<int> a(n+1,0);
    vector<vector<int>> path(n+1);
    REP(i,n){
        if(s[i]=='<'){
            path[i].push_back(i+1);
        }else{
            path[i+1].push_back(i);
        }
    }
    auto ts =topologicalSort(path);
    REP(i,ts.size()){
        REP(j,path[ts[i]].size()){
            chmax(a[path[ts[i]][j]],a[ts[i]]+1);
        }
    }
    ll res = 0;
    REP(i,n+1){
        res+=a[i];
    }
    put(res);
    return 0;
}


Measured memory_bytes: 34584
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define L_T_S_K ;
const int mod = 1e9 + 7;
int binpow(int a, int b) {
    a %= mod;
    int res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return res;
}

int32_t main(){
 L_T_S_K;
 int m , d;
    cin >> m >> d;
    int k = 10; 
    int cnt = 0;
    for(int i = 1 ; i <= m ;i++){
    int k = 10;
    while(k <= d){
        int a , b;
        int t = k;
        a = t%10;
        t/=10;
        b = t%10;
        t/=10;
            if(t == 0)
            if(a >= 2 && b >= 2){
                if(a*b == i) cnt++;
            }
        
        k++;
     }
  }  
    cout << cnt;

 return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
 
int main()
{   
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin>>s;
    ll n =s.length();
    ll ans = 0;
    for(ll i=0;i<n;i++)
    {
        if(s[i] == '2')
            ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256