akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <random>
#include <chrono>

using namespace std;
using namespace __gnu_pbds;

#define endl '\n'

typedef long long ll;
typedef pair<int, int> pii;
//typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

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

	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	
	ll a, b;
	cin >> a >> b;
	
	if(a >= 13)
		cout << b << endl;
	else if(a < 6)
		cout << 0 << endl;
	else
		cout << b / 2 << endl;

	return 0;
}


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

int main()
{
    int N, Q;
    std::cin >> N >> Q;
    std::string S;
    std::cin >> S;

    std::vector<int> vec((N + 1), 0);

    for (int i = 1; i < vec.size() - 1; i++)
    {
        if (S[i] == 'C' && S[i - 1] == 'A')
        {
            vec[i + 1] = vec[i] + 1;
        }
        else vec[i + 1] = vec[i];
    }

    std::vector<int> lefts(Q), rights(Q);
    for (int i = 0; i < Q; i++)
    {
        std::cin >> lefts[i] >> rights[i];
    }

    for (int i = 0; i < Q; i++)
    {
        int ir = rights[i];
        int il = lefts[i];
        int r = vec[ir];
        int l = vec[il];
        std::cout << r - l << std::endl;
    }


    return 0;
}

Measured memory_bytes: 2176
def main():
    N = int(input())
    c = [pow(6, i) for i in range(7)] + [pow(9, i) for i in range(1, 6)]
    c.sort()
    dp = [[0] * (N+1) for _ in range(len(c))]
    for j in range(1, N+1):
        dp[0][j] = j
    for i in range(1, len(c)):
        for j in range(1, N+1):
            dp[i][j] = dp[i-1][j]
            if j - c[i] >= 0:
                dp[i][j] = min(dp[i][j], dp[i][j-c[i]] + 1)
    r = 10**6
    for i in range(len(c)):
        r = min(r, dp[i][-1])
    print(r)
main()


Measured memory_bytes: 48752
#require 'prime'
#require 'openssl'
MOD=10**9+7;  cnt=0; sum=0; prev=nil; can=true; h=Hash.new(0)
def gs() gets.chomp end
def gi() gets.chomp.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end

def ar2(s1,s2,de=nil) Array.new(s1){Array.new(s2,de)} end
def ar3(s1,s2,s3,de=nil) Array.new(s1){Array.new(s2){Array.new(s3,de)}} end

def desc(ar) ar.sort!{|x,y| y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+).to_i end
def ceil(a,b) (a.to_f/b).ceil end

def C(a,b) b==0||a==b ? 1 : (b=a-b if a/2<b;(a-b+1..a).inject(:*)/(1..b).inject(:*)) end
def rui(ar) s=[0]; ar.size.times{|i| s<<s[-1]+ar[i]}; s end
def rev_rui(ar) s=[0]; ar.size.times.reverse_each{|i| s<<s[-1]+ar[i]}; s end

def puts_yesno(b) puts(b ? 'Yes' : 'No') end
def putsend(s) puts s; exit end
def pu(h) begin; require './../nemi_lib/debug.rb'; puts_val(h); rescue LoadError; end; end
########### ( ˘ω˘ )ｽﾔｧ… ###########
n,m,q=gsmi
abcd=q.times.map{gsmi}

num_range=(0..(m-1)).to_a

#pats=[]
prev=[[]]
n.times do |nn|
  current = []
  prev.each do |i|
    num_range.each do |j|
      if i==[]
        pat1 = [j]
      elsif i[-1]<=j
        pat1 = i+[j]
      else
        next
      end
      current<<pat1
    end
  end
  prev=current
end
#puts prev.to_s

max=0
prev.each do |pat|
  sum=0
  abcd.each do |a,b,c,d|
     sum+=d if pat[b-1]-pat[a-1]==c
  end
  max=sum if max<sum
end

puts max

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

using namespace std;
 
int main() {
	int n;
	cin >> n;
	int a, b, c, d;
	a = n / 1000;
	b = (n % 1000) / 100;
	c = (n % 100) / 10;
	d = n % 10;
	if ((a == b&&b == c) || (b == c&&c == d)) printf("Yes\n");
	else printf("No\n");
}

Measured memory_bytes: 256
// g++ .cpp && ./a.out
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;

typedef pair<int, int> p;
typedef long long ll;

const int mod = 1000000007;
const int inf = 1000000007;

int main() {
  int n;
  string s;
  cin >> n >> s;
  ll cnt = 0;
  vector<ll> cntR(n);
  vector<ll> cntB(n);
  vector<ll> cntG(n);
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      if (s[j] == 'R') cntR[i]++;
      if (s[j] == 'B') cntB[i]++;
      if (s[j] == 'G') cntG[i]++;
    }
  }
  for (int i = 0; i < n - 1; i++) {
    for (int j = i + 1; j < n; j++) {
      {
        if (s[i] == 'R' && s[j] == 'B') {
          cnt += cntG[j];
          if (s[2 * (j - i) + i] == 'G' && 2 * (j - i) + i < n) cnt--;
        }
        if (s[i] == 'R' && s[j] == 'G') {
          cnt += cntB[j];
          if (s[2 * (j - i) + i] == 'B' && 2 * (j - i) + i < n) cnt--;
        }
        if (s[i] == 'B' && s[j] == 'R') {
          cnt += cntG[j];
          if (s[2 * (j - i) + i] == 'G' && 2 * (j - i) + i < n) cnt--;
        }
        if (s[i] == 'B' && s[j] == 'G') {
          cnt += cntR[j];
          if (s[2 * (j - i) + i] == 'R' && 2 * (j - i) + i < n) cnt--;
        }
        if (s[i] == 'G' && s[j] == 'B') {
          cnt += cntR[j];
          if (s[2 * (j - i) + i] == 'R' && 2 * (j - i) + i < n) cnt--;
        }
        if (s[i] == 'G' && s[j] == 'R') {
          cnt += cntB[j];
          if (s[2 * (j - i) + i] == 'B' && 2 * (j - i) + i < n) cnt--;
        }
      }
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 3664
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
//ll mod = 998244353;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    int n, k;
    ll s;
    cin >> n >> k >> s;
    rep(i, n) {
        if (i != 0) cout << " ";
        if (k == 0) cout << 1000000001 - s;
        else {
            cout << s;
            --k;
        }
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3636
from collections import Counter
n = int(input())
nums = list(map(int, input().split()))
q = int(input())
vals = [tuple(map(int, input().split())) for _ in range(q)]

c = Counter(nums)
total = sum([x*y for x, y in c.items()])
for b, k in vals:
    o = c[b]
    del c[b]
    c[k] += o
    total += k * o - b * o
    print(total)


Measured memory_bytes: 104100
#include <bits/stdc++.h>
using namespace std;
int main () {
  int N;
  cin >> N;
  vector<int> data(N);
  for(int i = 0; i < N; i++){
    cin >> data.at(i);
  }
  int ans = 0;
  for(int i = 1; i < N - 1; i++){
    if(data.at(i - 1) > data.at(i) && data.at(i) > data.at(i + 1))ans++;
    if(data.at(i - 1) < data.at(i) && data.at(i) < data.at(i + 1))ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#2020-03-21
import math
while True:
    n = int(input())
    if n == 0:
        break
    s = list(map(int, input().split()))
    
    ave = sum(s) / n
    dev = math.sqrt(sum((ave - si) ** 2 for si in s) / n)

    print("{:.8f}".format(dev))


Measured memory_bytes: 5712
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <utility>
typedef long long ll;
const int INF = 1e9+1;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
using namespace std;

int main() {
	long long int n,a,b;
	long long int ans = 0;
	cin >> n>>a>>b;
	vector<long long int> d(n);
	for (int i = 0; i < n; i++)cin >> d.at(i);

	for (int i = 0; i < n - 1; i++) {
		if (a * (d.at(i + 1) - d.at(i)) > b)ans += b;
		else ans += a * (d.at(i + 1) - d.at(i));
	}
	cout << ans << endl;
	return 0;
}

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

num = len(set(S))

result = 0
for i in range(N-1):
  A = S[:i+1]
  B = S[i+1:]
  
  tmp = len(set(A) & set(B))
  if tmp > result:
    result = tmp
  
print(result)

Measured memory_bytes: 3060
class KMP:
    def __init__(self, P):
        self.P = P
        self.N = len(P)
        self.T = [0] * (self.N + 1)
        self._compile()

    def _compile(self):
        j = 0
        self.T[0] = -1
        for i in range(1, self.N):
            self.T[i] = j
            j += 1 if self.P[i] == self.P[j] else -j
        self.T[self.N] = j

    def search(self, S):
        NS = len(S)
        i = m = 0
        A = []
        while m + i < NS:
            if self.P[i] == S[m + i]:
                i += 1
                if i != self.N:
                    continue
                A.append(m)
            m += i - self.T[i]
            i = max(0, self.T[i])
        return A

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = [A[i]^A[(i+1)%N] for i in range(N)]
D = [B[i]^B[(i+1)%N] for i in range(N)]
C = C + C[:-1]
K = KMP(D).search(C)
#C string D pattern
for k in K:
    print(k, A[k]^B[0])


Measured memory_bytes: 128080
def two(n):
  count=0
  while n%2==0:
    count+=1
    n//=2
  return count

n=int(input())

ans=0
t=0
for i in range(1, n+1):
    ttt=two(i)
    if ttt>=t:
        ans=i
        t=ttt
        

print(ans)

Measured memory_bytes: 3060
from heapq import *
N, K, Q = map(int, input().split())
a = list(map(int, input().split()))
b = [None]*(N+2)
x = []

def merge(q1, q2):
    if q1 < q2:
        q1, q2 = q2, q1
    s = q1[0] + q2[0]
    while q2[1]:
        add(q1, heappop(q2[1]))
    q1[0] = s
    return q1

def add(q, v):
    q[0] += 1
    w = push(q[1], K-1, v)
    if w:
        push(x, Q, -w)

def push(q, m, v):
    if len(q) < m:
        heappush(q, v)
        return
    return heappushpop(q, v)

r = 10**9
for i in sorted(range(1, N+1), key=lambda x: -a[x-1]):
    if b[i-1] and b[i+1]:
        s, t = b[i-1][0], b[i+1][0]
        b[i-s] = b[i+t] = merge(b[i-1], b[i+1])
        add(b[i-s], a[i-1])
        b[i] = 1
    elif b[i-1]:
        add(b[i-1], a[i-1])
        b[i] = b[i-1]
    elif b[i+1]:
        add(b[i+1], a[i-1])
        b[i] = b[i+1]
    else:
        b[i] = [0,[]]
        add(b[i], a[i-1])
    if len(x) == Q:
        r = min(r, -x[0]-a[i-1])
print(r)

Measured memory_bytes: 3444
import java.io.IOException;
import java.util.Arrays;
import java.util.Scanner;

import sun.security.krb5.Asn1Exception;

public class Main {

	public static void main(String[] args) throws IOException {

		Scanner scan = new Scanner(System.in);

		int N = scan.nextInt();

		System.out.println(N / 3);
	}

	//***********************以下共通関数************************************************
	/**
	 * 文字列を反転して返す
	 * @param pStr 文字列
	 * @return 反転した文字列
	 */
	public static String myReverse(String pStr) {
		if (pStr.length() < 1) {
			return "";
		}

		StringBuffer sb = new StringBuffer(pStr);
		return sb.reverse().toString();
	}

	/**
	 * 余りを求める。
	 * @param a
	 * @param b
	 * @return 余り。余りがマイナスの時はプラスで返す。
	 */
	public static long myMod(long a, long b) {
		long ret = 0;

		ret = a % b;

		if (ret < 0) {
			ret += b;
		}

		return ret;
	}

	/**
	 * 乗数を求める ※mod対応
	 * @param kisu 基数
	 * @param josu 乗数
	 * @param primeNumMod_0 法 mod値 使わない場合は「0」
	 * @return
	 */
	public static long myPowWithMod(long kisu, long josu, long primeNumMod_0) {

		long ans = 1;

		//乗数が0の場合→1
		if (josu == 0)
			return 1;

		if (primeNumMod_0 == 0) {
			//modを使わないとき

			while (josu > 0) {

				if (josu % 2 == 0) {
					//累乗が偶数の時

					kisu *= kisu;
					josu = josu / 2;
				} else {
					//累乗が奇数の時
					ans *= kisu;
					josu--;
				}
			}

			return ans;

		} else {
			//modを使うとき

			//初めに桁を落とす
			kisu = myMod(kisu, primeNumMod_0);

			while (josu > 0) {

				if (josu % 2 == 0) {
					//累乗が偶数の時

					kisu *= myMod(kisu, primeNumMod_0);
					josu = josu / 2;

				} else {
					//累乗が奇数の時
					ans *= myMod(kisu, primeNumMod_0);
					josu--;

				}
			}

			return myMod(ans, primeNumMod_0);

		}

	}

}


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

int main(){
	string S;
	cin>>S;
	int A=0,C=0,s=0;
	rep(i,S.size()){
		if(i==0){
			if(S.at(i)=='A'){
				A++;				
			}
		}else if(i==1||i==S.size()-1){
			if('a'<=int(S.at(i))&&int(S.at(i))<='z'){
				s++;
			}
		}else{
			if(S.at(i)=='C'){
				C++;				
			}
			if('a'<=int(S.at(i))&&int(S.at(i))<='z'){
				s++;
			}
		}
	}
	//cout<<A<<C<<s;
	if(A==1&&C==1&&s==S.size()-2){
		cout<<"AC"<<endl;
	}else{
		cout<<"WA"<<endl;
	}
	
return 0;}

/*compile
g++ code.cpp
./a.out
run*/

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <vector>
#include <queue>
#include <string>
#include <cmath>
#include <map>
#include <string.h>
#define ll long long

using namespace std;

int a, b;

int main(){
	
	cin >> a >> b;
	int ans = a * b - (a + b - 1);
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

n, max_w = [int(i) for i in input().split()]#print(n, max_w)

v = []
w = []
for j in range(n):
    value,weight=[int(i) for i in input().split()]
    v.append(value)
    w.append(weight)

dp = [[0 for i in range(max_w+1)] for j in range(n+1)]

for i in range(n):
    for cw in range(max_w+1):
        if cw >= w[i]:
            dp[i+1][cw] = max(dp[i][cw-w[i]]+v[i], dp[i][cw])
        else:
            dp[i+1][cw] = dp[i][cw]
print(dp[n][max_w])


Measured memory_bytes: 42268
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace D
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var XY = Console.ReadLine().Trim().Split(' ').Select(long.Parse).ToArray();
            var (X, Y) = (XY[0], XY[1]);
            Console.WriteLine(Math.Abs(X - Y) > 1 ? "Alice" : "Brown");
        }
    }
}


Measured memory_bytes: 28188
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n;

	cin>>n;

	int a[n],b[n],c[n],i;

	for(i=0;i<n;i++)
		cin>>a[i]>>b[i]>>c[i];

	int dpa[n]={0},dpb[n]={0},dpc[n]={0};

	dpa[0] = a[0];
	dpb[0] = b[0];
	dpc[0] = c[0];

	for(i=1;i<n;i++)
	{
		dpa[i] = a[i] + max(dpb[i-1],dpc[i-1]);
		dpb[i] = b[i] + max(dpa[i-1],dpc[i-1]);
		dpc[i] = c[i] + max(dpb[i-1],dpa[i-1]);

	}

	cout<<max(dpa[n-1],max(dpb[n-1],dpc[n-1]));

	
}

Measured memory_bytes: 5916
import java.util.*;
public class Main{
  public static void main(String[]args){
      Scanner sc = new Scanner(System.in);

      int a = sc.nextInt();
      int b = sc.nextInt();

      if(a+b<10){
        System.out.println(a+b);
      }else{
        System.out.println("error");
  }
}
}


Measured memory_bytes: 21460
#include <iostream>
using namespace std;
int main(void){
   int N,M;
   cin>>N>>M;
   char A[N][N],B[M][M];
   for(int i=0;i<N;i++){
       for(int j=0;j<N;j++){
           cin>>A[i][j];
       }
   }
   for(int i=0;i<M;i++){
       for(int j=0;j<M;j++){
           cin>>B[i][j];
       }
   }
   bool check=false;
   for(int i=0;i<=N-M;i++){
       for(int j=0;j<=N-M;j++){
           int count=0;
           for(int k=0;k<M;k++){
               for(int l=0;l<M;l++){
                   if(B[k][l]==A[i+k][j+l]) count++;
               }
           }
           if(count==M*M) check=true;
       }
   }
   if(check==true) {cout<<"Yes";}
   else cout<<"No";
   return 0;
   
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

#define pb push_back
#define pp pop_back
#define f first
#define s second
#define sz(a) (int)((a).size())
#define NoType ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL)
#define mp make_pair

typedef tree<int, null_type, less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
//find_by_order(x) -> returns an iterator to the element at a given position
//order_of_key(x) -> returns the position of a given element

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair < int, int > pi;

const int mod = (int)1e9 + 7;
const int MAXN = 1e5+12;
//indexed_set s;

int x;

int main() {

cin >> x;
if (x >= 30) cout << "Yes";
else cout << "No";

return 0;
}


Measured memory_bytes: 3632
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int X, Y;

  std::cin >> X >> Y;

  std::cout << X + Y / 2 << std::endl;

  return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
x = [-1]*n
ans = 0
count = 0
for i in range(m):
    s, c = map(int, input().split())
    if (s==1) and (c==0) and(n!=1):
        count = 1
    if x[s-1]!=-1 and x[s-1]!=c:
        count = 1
    if x[s-1] != c:
        ans += c*(10**(n-s))
    x[s-1] = c

if count==1:
    print(-1)
elif n==1 and ans==0:
    print(0)
elif ans>=10**(n-1):
    print(ans)
else:
    print(ans+10**(n-1))

Measured memory_bytes: 3064
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list
#from itertools import combinations # (string,3) 3回
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    n,m = readInts()
    AB = []
    for i in range(n):
        a,b = readInts()
        AB.append((a,b))
    AB = sorted(AB,key = lambda x:x[0]) # Aに着目して安いやつ Aが値段でBが在庫や！！
    ans = 0
    cnt = 0
    ok = False
    #print(AB)
    for i in range(n):
        a,b = AB[i]
        if ok:
            break
        #print(m,cnt,m-cnt,b,ans)
        if cnt <= m and b <= m - cnt:
            ans += a * b
            cnt += b
        elif cnt <= m:
            ans += a * (m - cnt)
            cnt = m
            ok = True
    print(ans)


if __name__ == '__main__':
  main()


Measured memory_bytes: 18896
n=int(input())
a=list(map(int,input().split()))
a.append(0)
a.insert(0,0)
total=0
ans=[]
for i in range(n+1):
    total+=abs(a[i]-a[i+1])
for i in range(n):
    ans.append(total-(abs(a[i]-a[i+1])+abs(a[i+1]-a[i+2]))+abs(a[i]-a[i+2]))
for j in ans:
    print(j)


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

using namespace std;

#define all(v)				((v).begin()), ((v).end())
#define allr(v)				((v).rbegin()), ((v).rend())
#define sz(v)				((int)((v).size()))
#define rep(i, v)		for(int i=0;i<sz(v);++i)
#define lp(i, n)		for(int i=0;i<(int)(n);++i)
#define lpi(i, j, n)	for(int i=(j);i<(int)(n);++i)
#define lpd(i, j, n)	for(int i=(j);i>=(int)(n);--i)
#define ll long long
#define pb					push_back
#define fIO ios_base::sync_with_stdio(0);cin.tie(0);

const ll oo = 1e7;
const double pi = 3.1415926535897;


const double EPS = (1e-7);
int dcmp(double x, double y) {	return fabs(x-y) <= EPS ? 0 : x < y ? -1 : 1;	}


typedef vector<int>                vi;
typedef vector<pair<int,int>>      vii;
typedef vector<ll>                 vll;
typedef vector<double>             vd;
typedef vector< vi >               vvi;
typedef vector< vd >               vvd;
typedef vector<string>             vs;

/**
    * PLEASEEE READDD PROBLEEEM CARFULLY ****
    * Always check for OVERFLOW ll vs int
    * Always check for array bounds
    * Check for function return
    * READ OUTPUT SECTION AGAIN!!!
**/
vector<int> arr[1009];
map<pair<int,int>,int> m;
struct edge{
    int from,to,w;
    edge(int uu,int vv,int ww):from(uu),to(vv),w(ww){}

    bool operator < (const edge &rhs) const{
        return w > rhs.w;
    }
};

const int N = 205;

int main(){
    int n,v;

    cin >> n;

    priority_queue<double,vector<double>,greater<double>> pq;
    for(int i = 0;i < n;i++){
        cin >> v;
        pq.push(v);
    }

    while(pq.size() > 1){
        double u = pq.top();
        pq.pop();

        double v = pq.top();pq.pop();

        pq.push((u + v) / 2);
    }

    cout << pq.top();

}















Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <bitset>
using namespace std;
int main() {
  int h, w, k;
  int ans = 0, ch;
  string s;
  cin >> h >> w >> k;
  vector<vector<int> > c(h, vector<int>(w));

  for (int i=0; i<h; i++) {
    cin >> s;
    for (int j=0; j<w; j++) {
      if (s[j]=='.') {
        c[i][j] = 0;
      } else {
        c[i][j] = 1;
      }
    }
  }
  for (int i=0; i<(1<<h); i++) {
    bitset<6> hh(i);
    for (int j=0; j<(1<<w); j++) {
      bitset<6> ww(j);
      int val = 0;
      for (int m=0; m<h; m++) {
        for (int l=0; l<w; l++) {
          if (hh.test(m)==1 && ww.test(l)==1 && c[m][l]==1) {
            val++;
          }
        }
      }
      if (val==k) {
        ans++;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3224
import java.util.*;

class Main{
    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);
        int intInput = sc.nextInt();

        int count = 1;
        while (count * count <= intInput){
            count ++;
        }
        count --;

        System.out.println(count * count);
    }
}

Measured memory_bytes: 21844
/*
lakshaygpt28
Lakshay Gupta
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

using ll = long long;
using db = double;
using pii = pair < int, int >;
using pll = pair < ll, ll >;
using vll = vector < ll >;

template < typename T > using OrderedSet = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
template < typename T > using MinPriorityQueue = priority_queue < T, vector < T >, greater < T > >;


#ifndef ONLINE_JUDGE
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1) {
    cerr << name << " : " << arg1 << std :: endl;
}
template < typename Arg1, typename... Args >
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | ";
    __f(comma + 1, args...);
}
#else
#define debug(...)
#endif

#define fast_io() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define eb emplace_back
#define mp make_pair
#define pb push_back
#define mt make_tuple
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

const db PI = acos(-1);
const ll LINF = LLONG_MAX;
const int INF = INT_MAX, MOD = 1e9 + 7, N = 1e5 + 10;

vll g[N];
bool vis[N];

ll n, k;
ll ans = 1;

void dfs(ll node, ll color);

int main() {
    fast_io();
    cin >> n >> k;
    ll u, v;
    for (ll i = 0; i < n - 1; i++) {
        cin >> u >> v;
        g[u].eb(v);
        g[v].eb(u);
    }
    dfs(1, k);
    cout << ans << "\n";
    return 0;
}

void dfs(ll node, ll color) {
    // debug(node, color);
    ans = (ans * color) % MOD;
    vis[node] = true;
    ll i = 1;
    for (auto x : g[node]) {
        if (!vis[x]) {
            // debug(x, color, i);
            if (color < k) {
                dfs(x, k - 1 - i);
            } else {
                dfs(x, color - i);
            }
            i++;
        }
    }
}


Measured memory_bytes: 9344
//  @ /\/\ BESH //

#include <bits/stdc++.h>
#define inp_out_work ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define testCase    int T; cin>>T; while(T--)
#define fr(i,n) for(int i=0;i<n;i++)
#define fro(i,s,e) for(int i=s;i<=e;i++)
#define endl '\n'
#define debug(P) cout<<#P<<" = "<<P<<endl;
#define pb push_back


using namespace std;

typedef long long ll;
typedef long double ld;

const int MAXN = 1000001;
const int mod = 1000000007;

int main(){
    string s;
    cin>>s;
    string day[] = {"SUN", "MON", "TUE", "WED", "THU", "FRI",  "SAT"};

    int d;

    for(int i = 0; i < 7; i++)if(day[i] == s)d = i;

    cout<< (7-d) << endl;

}


Measured memory_bytes: 764
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define inf 1e+9
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }

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

    int n,k,ans=0;
	string s;
	cin >> n;
	cin >> s;

	
	if(n>=3200){
		cout << s << endl;
	}
	else{
		cout << "red" << endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define N 1000005
#define ll long long
#define debug(a) cout<<#a<<": ";for(auto i:a)cout<<i<<" ";cout<<endl;
#define trace(a) cout<<#a<<": "<<a<< endl;

int a[N];
vector<int> adj[N];
int sub[N];
bool vis[N],mark[N];
int dfs(int node) {
	vis[node] = true;
	sub[node] = 1;
	for(int it : adj[node]) {
		if(!vis[it]) {
			sub[node] += dfs(it);
		}
	}
	return sub[node];
}
int main() {
	ios_base::sync_with_stdio(false);cout.tie(0);cin.tie(0);
	int i,j,k,l,m,n,t;
	string str;
	cin >> str;
	n = str.length();
	if(str[0] == '0' || str[n-1] == '1') {
		cout << "-1" << endl;
		return 0;
	}
	int currRoot = 2;
	adj[2].push_back(1);
	adj[1].push_back(2);
	vector<pair<int,int>> ed;
	ed.push_back({2,1});
	for(i = 1;i < n-1;i++) {
		int id = i+2;
		if(str[i] == '1') {
			adj[id].push_back(currRoot);
			adj[currRoot].push_back(id);
			ed.push_back({currRoot,id});
			currRoot = id;
		}
		else {
			adj[currRoot].push_back(id);
			adj[id].push_back(currRoot);
			ed.push_back({currRoot,id});
		}
	}
	dfs(currRoot);
	for(i = 1;i <= n;i++) {
		if(sub[i] == n) continue;
		mark[sub[i]] = true;
		mark[n-sub[i]] = true;
	}
	for(i = 0;i < n;i++) {
		if(mark[i] == true && str[i-1] == '0') {
			cout << "-1" << endl;
			return 0;
		}
		else if(mark[i] == false && str[i-1] == '1'){
			cout << "-1" << endl;
			return 0;
		}
	}
	// cout << n-1 << endl;
	for(auto it : ed) {
		cout << it.first << " " << it.second << endl;
	}
}

Measured memory_bytes: 37444
import java.util.*;

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

        int n = sc.nextInt();
        int[] arr = new int[n];

        for (int i = n-1; i >= 0; i--) {
            arr[i] = sc.nextInt();
        }

        String answer = "Yes";
        for (int i = 1; i < n; i++) {
            int diff = arr[i] - arr[i-1];
            if (diff > 1) {
                answer = "No";
                break;
            } else if (diff == 1) {
                arr[i]--;
            }
        }
        System.out.println(answer);
    }
}

Measured memory_bytes: 50584
#include <iostream>
using namespace std;
int main()
{
	int a, b;
	cin >> a >> b;
	if (b == 1) {
		b += 20;
	}
	if (a == 1) {
		a += 20;
	}
	if (a > b) {
		cout << "Alice" << endl;
	}
	else if (b > a) {
		cout << "Bob" << endl;
	}
	else {
		cout << "Draw" << endl;
	}
	return 0;
}

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

namespace AGC027_A{
    class Program{
        static void Main(string[] args){
            var input = Console.ReadLine().Split(' ');
            int n = int.Parse(input[0]);
            int x = int.Parse(input[1]);
            var count = 0;
            var candies = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
            candies.Sort();
            for(var i = 0;i < n - 1;i++){
                if(x >= candies[i]){
                    x -= candies[i];
                    count++;
                }else{
                    Console.WriteLine(count);
                    return;
                }
            }
            if(x == candies.Last()){
                count++;
            }
            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 11348
open Str

let read_list f =
  split (regexp " +") (read_line ()) |> List.map f
                                                 
let () =
  let n = read_int () in
  let al = Array.make (n+1) [] in
  let vt = Array.make (n+1) true in
  let rec read x =
    if x = 0 then ()
    else begin
        (match read_list int_of_string with
           u :: _ :: vs -> al.(u) <- vs
         | _ -> failwith "read");
        read (x-1)
      end
  in
  let rec dfs (t, ls) i =
    if vt.(i) then begin
      vt.(i) <- false;
      let (t', ls') = List.fold_left dfs (t+1, ls) al.(i) in
      (t'+1 , (i, t, t') :: ls')
      end
    else
      (t, ls)
  in
  let rec loop (t, ls) i =
    if i > n then ls
    else
      if vt.(i) then
        let (t', ls') = dfs (t, ls) i in loop (t', ls') (i+1)
      else
        loop (t, ls) (i+1)
  in
  read n;
  loop (1,[]) 1 |> List.sort compare |>
    List.iter (fun (x, y, z) -> (string_of_int x) ^ " " ^ (string_of_int y) ^ " " ^ (string_of_int z) |> print_endline)

Measured memory_bytes: 2504
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	
	string s; cin >> s;
	int a = atoi(s.substr(0, 2).c_str()), b = atoi(s.substr(2, 2).c_str());
	bool m1 = 0 < a && a <= 12;
	bool m2 = 0 < b && b <= 12;
	
	if(m1 && m2) cout << "AMBIGUOUS" << endl;
	else if(!m1 && !m2) cout << "NA" << endl;
	else cout << (m1 ? "MMYY" : "YYMM") << endl;
	return 0;
}

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

ll solve() {
    ll N;
    string S;
    cin >> N >> S;
    vector<vector<int>> pos(10);
    int k = 0;
    for ( char c : S ) {
        pos[c-'0'].push_back(k);
        k++;
    }

    vector<int> pow{100,10,1};
    ll ans = 0;
    for ( int i = 0; i < 1000; i++ ) {
        int p = 0;
        bool ng = false;
        for ( int d = 0; d < 3; d++ ) {
            int n = i / pow[d] % 10;
            auto it = lower_bound(pos[n].begin(), pos[n].end(), p);
            if ( it == pos[n].end() ) {
                ng = true;
                break;
            }
            p = *it + 1;
        }
        if ( !ng ) ans++;
    }
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 512
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#include <algorithm>
#include <bitset>
#include <complex>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#include <cassert>
#include <functional>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(...) ;
#else
#define debug(...) cerr << __LINE__ << " : " << #__VA_ARGS__ << " = " << _tostr(__VA_ARGS__) << endl;

template<typename T>
ostream &operator<<(ostream &out, const vector<T> &v);

template<typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template<typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}

void _tostr_rec(ostringstream &oss) {
  oss << "\b\b \b";
}

template<typename Head, typename... Tail>
void _tostr_rec(ostringstream &oss, Head &&head, Tail &&... tail) {
  oss << head << ", ";
  _tostr_rec(oss, forward<Tail>(tail)...);
}

template<typename... T>
string _tostr(T &&... args) {
  ostringstream oss;
  int size = sizeof...(args);
  if (size > 1) oss << "{";
  _tostr_rec(oss, forward<T>(args)...);
  if (size > 1) oss << "}";
  return oss.str();
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010

ll power(ll k, ll n, int M) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * k % M;
    k = k * k % M;
    n /= 2;
  }
  return res;
}

int calc(int X) {
  int res = 0;
  while (X) {
    X = X % __builtin_popcount(X);
    res++;
  }
  return res;
}

int main() {
  int N, pop = 0;
  char S[SIZE];

  scanf("%d%s", &N, S);

  ll sum = 0;
  for (int i = 0; i < N; i++) {
    pop += S[i] == '1';
    // sum = sum * 2 + (S[i] == '1');
  }

  ll sum1 = 0, sum2 = 0;

  for (int i = 0; i < N; i++) {
    if (pop - 1 > 0) {
      sum1 = (sum1 * 2 + (S[i] - '0')) % (pop - 1);
    }
    if (pop + 1 > 0) {
      sum2 = (sum2 * 2 + (S[i] - '0')) % (pop + 1);
    }
  }

  int ans;

  for (int i = 0; i < N; i++) {
    if (S[i] == '0') {
      int M = pop + 1;
      ans = calc((sum2 + power(2, N - i - 1, M)) % M) + 1;
    } else if (S[i] == '1' && pop > 1) {
      int M = pop - 1;
      ans = calc((sum1 + M - power(2, N - i - 1, M)) % M) + 1;
    } else {
      ans = 0;
    }

    debug(ans, pop, calc(sum ^ (1 << (N - i - 1))));
    printf("%d\n", ans);
  }

  return 0;
}

Measured memory_bytes: 3932
import java.io.*;

public class Main{
  public static void main(String[] args) throws IOException{
    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    String   input   = reader.readLine();
    String[] numbers = input.split(" ");
    System.out.println(numbers[2] +" "+ numbers[0] +" "+ numbers[1]);
  }
}

Measured memory_bytes: 21204
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, a, b) for(int i = a; i < b; i++)
#define all(x) x.begin(), x.end()
#define fi first
#define se second
#define pb push_back
#define debug(x) cerr <<__LINE__<< ": " <<#x<< " = " << x << endl
#define debug_vec(v) cerr<<__LINE__<<": "<<#v<<" = ";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
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; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

void solve() {
    string s;
    cin >> s;
    if (s[2] == s[3] && s[4] == s[5]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}


Measured memory_bytes: 3652
#include <stdio.h>

int main(void)
{
	int a[4] = {0}, b[4] = {0}, hit = 0, blow = 0;
	int i, j;
	
	while(scanf("%d", &a[0]) != EOF){
		
		scanf("%d %d %d", &a[1], &a[2], &a[3]);
		scanf("%d %d %d %d", &b[0], &b[1], &b[2], &b[3]);
		
		for(i = 0; i < 4; i++){
			if(a[i] == b[i])
				hit++;
		}
		
		for(i = 0; i < 4; i++){
			if(a[i] != b[i]){
				for(j = 0; j < 4; j++){
					if(a[i] == b[j])
						blow++;
				}
			}
		}
		
		printf("%d %d\n", hit, blow);
		
		hit = 0;
		blow = 0;
	}
	
	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define pb push_back
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 5*(int)1e5 + 10;

int n, a[N];
#define int long long

int dp[N][2][2];

int solve(int idx, int pos, int neg){
   if(idx >= n)
      return (pos and neg) ? 0 : -inf;
   int &ans = dp[idx][pos][neg];
   if(~ans)
      return ans;
   ans = 0;
   ans = max(a[idx] + solve(idx+1, 1, neg), -a[idx] + solve(idx+1, pos, 1));
   return ans;
}



vector<int> neg, pos;

int32_t main(){_
   cin>>n;

   for (int i = 0; i < n; ++i)
   {
      cin>>a[i];
      if (a[i] < 0){
         neg.pb(a[i]);
      }
      else{
         pos.pb(a[i]);
      }
   }

   memset(dp, -1, sizeof dp);
   cout<<solve(0, 0, 0)<<endl;

   vector<P> v;

   sort(neg.begin(), neg.end());
   sort(pos.begin(), pos.end());

   if (sz(neg) > 0 and sz(pos) > 0){
      
      int negative = neg.back();
      neg.pop_back();
      int positive = pos.back();
      pos.pop_back();
      for(auto it: pos){
         v.pb({negative, it});
         negative -= it;
      }

      v.pb({positive, negative});
      positive -= negative;

      for(auto it: neg){
         v.pb({positive, it});
         positive -= it;
      }

      for(auto it: v){
         cout<<it.F<<' '<<it.S<<endl;
      }
      exit(0);
   }

   if (sz(neg) == 0){
      
      int last = pos.back();
      pos.pop_back();
         
      int curr = 0;

      int first = pos[0];
      for (int i = 1; i < sz(pos); ++i)
      {
         v.pb({first, pos[i]});
         first -= pos[i];
      }

      v.pb({last, first});

      for(auto it: v)
         cout<<it.F<<' '<<it.S<<endl;

      exit(0);
   }

   int last = neg.back();
   neg.pop_back();
   
   for (int i = sz(neg)-1; i >= 0; --i)
   {
      v.pb({last, neg[i]});
      last -= neg[i];
   }

   for(auto it: v){
      cout<<it.F<<' '<<it.S<<endl;
   }


   return 0;
}

Measured memory_bytes: 28272
n = int(input())

if n == 0:
  print(0)
else:
  i = 1
  ans = ''
  while n != 0:
    pi = pow(-1, i-1) * pow(2, i)
    if n % pi == pi // 2:
      ans += '1'
      n -= pi // 2
    else:
      ans += '0'
    i += 1
  print(ans[::-1])


Measured memory_bytes: 3060
#include <stdio.h>
#define int64 long long

int main(void)
{
  int64 nn;
  scanf("%lld", &nn);
  int64 hh[nn];
  for(int64 ii = 0;ii < nn;ii++)
  {
    scanf("%lld", &hh[ii]);
  }
  
  int64 cnt = 0, ans = 0;
  for(int64 ii = 0;ii < nn - 1;ii++)
  {
    if(hh[ii] >= hh[ii + 1])
    {
      cnt++;
    }
    else
    {
      if(ans < cnt)
      {
        ans = cnt;
      }
      cnt = 0;
    }
  }
  if(ans < cnt)
  {
    ans = cnt;
  }
  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 2444
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i=0; i<(ll)n; i++)
#define REPR(i, n) for(ll i=(ll)n-1; i>=0; i--)
#define FOR(i, m, n) for(ll i=(ll)m; i<(ll)n; i++)
#define FORR(i, m, n) for(ll i=(ll)m-1; i>=(ll)n; i--)
#define ALL(x) (x).begin(), (x).end()
#define ASC(v) sort(ALL(v));
#define DESC(v) sort(ALL(v), greater<int>());
#define UNIQ(a) sort(ALL(a));(a).resize(unique(ALL(a)) - a.begin());
#define PRINTD(x, d) cout << fixed << setprecision(d) << x << "\n";
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
const double PI = acos(-1);
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
bool isprime(int x){ int i; if(x<2)return 0; else if(x==2) return 1; if(x%2==0) return 0; for(i=3; i*i<=x; i+=2) if(x%i==0) return 0; return 1; }
int digsum(int n) { int r=0; while(n>0) { r+=n%10; n/=10; } return r; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
struct nya{ nya(){ cin.tie(0); ios::sync_with_stdio(false); } }nyan;


int main(){
    ll R;
    cin >> R;
    double res = R * 2 * PI;
    PRINTD(res, 20);
}


Measured memory_bytes: 3828
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
using namespace std;

int main() {
	bool b = true;
	int time, N, T, X, Y;
	vector<int> t, x, y;
	t.emplace_back(0);
	x.emplace_back(0);
	y.emplace_back(0);
	cin >> N;
	for (int i = 1; i <= N; i++) {
		cin >> T >> X >> Y;
		t.emplace_back(T);
		x.emplace_back(X);
		y.emplace_back(Y);
		if (b) {
			time = (t[i] - t[i - 1]) - (abs(x[i] - x[i - 1]) + abs(y[i] - y[i - 1]));
			if (time % 2 != 0 || time < 0) {
				b = false;
			}
		}
	}
	if (b) {
		cout << "Yes";
		return 0;
	}
	cout << "No";
	return 0;
}

Measured memory_bytes: 1644
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
#include<functional>
//#include<bits/stdc++.h>
using ll = long long;
using namespace std;
const ll INF = 1000000000000000000;//10^18
const ll mod = 1000000007;
//printf("%.10f\n", n);
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (a % b == 0)return b;
	return gcd(b, a % b);
}
ll modpow(ll x, ll y, ll m = mod) {
	ll res = 1;
	while (y) {
		if (y % 2) { res *= x; res %= m; }
		x = x * x % mod; y /= 2;
	}
	return res;
}
ll res[1234567];
void prime_factor(ll n) {
	for (int i = 2; i * i <= n; i++) {
		ll a = 0;
		while (n % i == 0) {
			a++; n /= i;
		}
		res[i] = max(res[i], a);
	}
	if (n != 1) { res[n] = max((ll)1, res[n]); }
}
ll ok[123456];
signed main() {
    ll n, m, a, b, lcm = 1, g = 0, ans = 0; cin >> n;
	vector<ll> v(n);
	for (int h = 0; h < n; h++) {
		cin >> v[h]; prime_factor(v[h]);
	}
	for (int h = 2; h < 1234567; h++) {
		for (int i = 0; i < res[h]; i++) {
			lcm *= h; lcm %= mod;
		}
	}
	for (int h = 0; h < n; h++) {
		ans += lcm * modpow(v[h], mod - 2); ans %= mod;
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
    int n;cin>>n;
    set<string> s;
    for(int i=0;i<n;i++) {
        string is;cin>>is;
        s.insert(is);
    }
    cout<<s.size()<<endl;
    return 0;
}

Measured memory_bytes: 19224
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	int n, m; cin >> n >> m;
	string s; cin >> s;
	
	vi next(n + 1), ans;
	for(int i = n; i >= 0; i--) next[i] = s[i] == '0' ? i : next[i + 1];
	
	//dbg(next);
	
	int p = n;
	while(p > 0){
		int q = next[max(0, p - m)];
		if(p == q){
			cout << -1 << endl;
			return 0;
		}
		ans.pb(p - q);
		p = q;
	}
	reverse(all(ans));
	rep(i, ans.size()) cout << ans[i] << (i==ans.size()-1?"\n":" ");
	
	return 0;
}

Measured memory_bytes: 1480
from collections import defaultdict
N, P = map(int,input().split())
S = input()

if P==5:
    ans = 0
    for i,m in enumerate(S):
        if m == '5' or m == '0':
            ans += i+1
elif P==2:
    ans = 0
    for i,m in enumerate(S):
        if int(m) % 2 ==0:
            ans += i+1
else:
    S = S[::-1]
    primdic = defaultdict(int)
    before = 0
    for i in range(0,N):
        now = (int(S[i])*pow(10,i,P)+before)%P
        primdic[now] += 1
        before = now
    # 文字なしの時はあまり0なので
    primdic[0] += 1
    ans = 0
    for value in primdic.values():
        ans += value*(value-1)//2
print(ans)

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

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    cout << a + b + c - std::max(a, std::max(b, c)) << endl;
    return 0;
}

Measured memory_bytes: 256
<?php
$N = trim(fgets(STDIN));
$K = trim(fgets(STDIN));
$X = trim(fgets(STDIN));
$Y = trim(fgets(STDIN));

if($N > $K){
    $s = ($N - $K) * $Y + $K * $X;
}else{
    $s = $N * $X;
}

echo $s;


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

ll solve(ll ai, ll aj, ll bi, ll bj) {
  if (aj > bj) {
    swap(ai,bi);
    swap(aj,bj);
  }
  ll s = 1;
  rep(i,30) s *= 3;
  ll dist = abs(ai-bi) + abs(aj-bj);
  ll res = dist;
  while (1) {
    s /= 3;
    if (s <= 0) break;
    ll nai = ai/s, nbi = bi/s;
    if (nai != nbi) break;
    ll naj = aj/s, nbj = bj/s;
    if (nai%3 == 1 && abs(naj-nbj) > 1) {
      ll up = s*nai-1;
      ll bot = nai*s + s;
      ll loss = min(ai,bi) - up;
      loss = min(loss, bot - max(ai,bi));
      res = dist + loss*2;
      break;
    }
  }
  return res;
}

int main() {
  int q;
  cin >> q;
  rep(qi,q) {
    ll ai,aj,bi,bj;
    cin >> ai >> aj >> bi >> bj;
    ai--; aj--;
    bi--; bj--;
    ll ans = 0;
    ans = max(ans, solve(ai,aj,bi,bj));
    ans = max(ans, solve(aj,ai,bj,bi));
    cout << ans << endl;
  }
  return 0;
}


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

int main(){
  int64_t A, B;
  cin >> A >> B;

  int64_t gcd = 1;
  for (int i=100000; i>1; i--){
    if(A % i == 0 && B % i == 0){
      gcd = i; break;
    }
  }

  cout << A * B / gcd << endl;
}


Measured memory_bytes: 256