akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"bufio"
	"fmt"
	"math"
	"math/rand"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

func floatScanner() float64 {
	n, _ := strconv.ParseFloat(Scanner(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func stringSliceScanner(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scanner()
	}
	return a
}
func intSliceScanner(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = intScanner()
	}
	return a
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}

var mod int
var t float64

func main() {
	mod = 1000000007
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	d := intScanner()
	c := intSliceScanner(26)
	s := make([][]int, d)
	for i := 0; i < d; i++ {
		s[i] = intSliceScanner(26)
	}
	best := -mod
	bestSchedule := make([]int, d)
	changeNum := 10
	for x := 0; x < 1; x++ {
		schedule := make([]int, d)
		for i := 0; i < d; i++ {
			schedule[i] = rand.Intn(26)
		}
		score := calcScore(schedule, c, s, d)
		t = float64(score) * 100.
		for y := 0; y < 140000; y++ {
			changes := make([]int, changeNum)
			pres := make([]int, changeNum)
			for i := 0; i < changeNum; i++ {
				changes[i] = rand.Intn(d)
				pres[i] = schedule[changes[i]]
				schedule[changes[i]] = rand.Intn(26)
			}
			nextScore := calcScore(schedule, c, s, d)
			if prob(score, nextScore) >= math.Abs(rand.Float64()) {
				score = nextScore
			} else {
				for i := 0; i < changeNum; i++ {
					schedule[changes[i]] = pres[i]
				}
			}
			if nextScore >= best {
				best = nextScore
				copy(bestSchedule, schedule)
			}
			t *= 0.999
		}
	}
	for i := 0; i < d; i++ {
		fmt.Println(bestSchedule[i] + 1)
	}
}
func calcScore(schedule []int, c []int, s [][]int, d int) int {
	score := 0
	last := make([]int, 26)
	for i, v := range schedule {
		score += s[i][v]
		for j, _ := range last {
			last[j]++
		}
		last[v] = 0
		for j, v := range last {
			score -= c[j] * v
		}
	}
	return score
}
func prob(before int, after int) float64 {
	if before <= after {
		return 1.0
	}
	return math.Exp((float64(after) - float64(before)) / float64(t))
}


Measured memory_bytes: 6352
import Control.Applicative
import Control.Monad
import Control.Monad.ST
-- import qualified Data.ByteString as BS
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import qualified Data.Foldable as Foldable
import qualified Data.Set as Set
--import qualified Data.Sequence as Sequence
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Fixed
import Data.Tuple
--import Data.Array
import Data.Array.Unboxed
--import Data.Array.IArray
import Data.Array.MArray
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
import Text.Printf
-- import System.IO.Unsafe
 
-- templete
readInt = read :: String -> Int
readInteger = read :: String -> Integer
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getInteger = readLn :: IO Integer
getIntegers = map readInteger . words <$> getLine
getDouble = readLn :: IO Double
getDoubles = map readDouble . words <$> getLine
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
tjoin :: (Show a, Show b) => (a, b) -> String
tjoin (x, y) = show x ++ (' ' : show y)
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
apply4 :: (a -> a -> a -> a -> b) -> [a] -> b
apply4 f [x,y,z,w] = f x y z w
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
binMap :: (a -> a -> b) -> [a] -> [b]
binMap f (x:xs@(y:_)) = f x y : binMap f xs
binMap _ _ = []
splitRec :: Int -> [a] -> [[a]]
splitRec _ [] = []
splitRec n xs = let (y,ys) = splitAt n xs in y : splitRec n ys
infixl 7 `divCeil`
divCeil :: Integral a => a -> a -> a
x `divCeil` y = (x+y-1) `div` y
coverC :: Ord a => (a, a) -> a -> Bool
coverC (l,r) x = l<=x && x<=r
coverH :: Ord a => (a, a) -> a -> Bool
coverH (l,r) x = l<=x && x<r
ibsearch :: (Int -> Bool) -> (Int,Int) -> Int
ibsearch f (ok,ng) = if abs (ok-ng) <= 1 then ok else let mid = (ok + ng) `div` 2 in ibsearch f (if f mid then (mid,ng) else (ok,mid))
whenM :: Monad m => m Bool -> m () -> m ()
whenM c a = c >>= flip when a
unconsU :: [a] -> (a, [a])
unconsU (x:xs) = (x, xs)
-- templete

f x h = xx ^ 2 + 2 * xx * sqrt (hh^2 + (xx/2)^2) 
  where
    xx = fromIntegral x
    hh = fromIntegral h

main = do
    x <- getInt
    unless (x==0) $ f x <$> getInt >>= (printf "%.15f\n" :: Double -> IO ()) >> main


Measured memory_bytes: 4040
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    H, W, M = map(int, rl().split())
    hw = [list(map(lambda n: int(n) - 1, rl().split())) for _ in range(M)]
    
    sum_h, sum_w = [0] * H, [0] * W
    for h, w in hw:
        sum_h[h] += 1
        sum_w[w] += 1
    max_h, max_w = max(sum_h), max(sum_w)
    cnt = sum_h.count(max_h) * sum_w.count(max_w)
    
    for h, w in hw:
        if sum_h[h] == max_h and sum_w[w] == max_w:
            cnt -= 1
    ans = max_h + max_w
    print(ans if cnt else ans - 1)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 127724
#include <bits/stdc++.h>
#include <string>
#define ft first
#define sc second
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) (a)=max(a, b)
#define chmin(a, b) (a)=min(a, b)
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;


/*
 for(i=0; i<N; i++)
   cin >> a[i];
*/


int main(void) {
  ll i, j, k;
  
  ll N, K, C;
  cin >> N >> K >> C; C++;
  string s;
  cin >> s;
  
  ll dp[MAX*2][2]={}, ep[MAX*2][2]={};
  
  for(i=0; i<N; i++) {
    if(s[i]=='o') {
      dp[i][1]=dp[i][0]+1;
      if(i+C<N) chmax(dp[i+C][0], dp[i][1]);
      chmax(dp[i+1][0], dp[i][0]);
    }else {
      chmax(dp[i+1][0], dp[i][0]);
    }
  }
  
  for(i=N-1; i>=0; i--) {
    if(s[i]=='o') {
      ep[i][1]=ep[i][0]+1;
      if(i-C>=0) chmax(ep[i-C][0], ep[i][1]);
      if(i-1>=0) chmax(ep[i-1][0], ep[i][0]);
    }else {
      if(i-1>=0) chmax(ep[i-1][0], ep[i][0]);
    }
  }
  
  for(i=1; i<N; i++) chmax(dp[i][0], max(dp[i-1][0], dp[i-1][1]));
  for(i=N-2; i>=0; i--) chmax(ep[i][0], max(ep[i+1][0], ep[i+1][1]));
  
  for(i=0; i<N; i++) {
    if(s[i]=='x') continue;
    
    if(i==0) {
      if(ep[0][0]<K) pt(i+1);
    }else {
      if(dp[i][0]+ep[i][0]<K) pt(i+1);
    }
  }
  
  
  
}



Measured memory_bytes: 8196
#include<stdio.h>
#include<string.h>
int main()
{
 int b,j,k,len,c;

 char a[200],sub[200];
 
 for(;;){
         scanf("%s",a);
         if(strcmp(a,"-")==0)break;
                                len=strlen(a);
                                scanf("%d",&b);
                                for(j=0;j<b;j++){
                                                 scanf("%d",&c);
                                                 for(k=0;k<c;k++)sub[k]=a[k];
                                                 for(k=c;k<len;k++)a[k-c]=a[k];
                                                 for(k=len-c;k<len;k++)a[k]=sub[k-(len-c)];
                                                 }
                                 printf("%s\n",a);
       }
 return 0;

}


 


Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define per(i,n) for(int i = n-1; i >= 0; i--)
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;

bool dp[110000];

int main() {
  int n, k;
  cin >> n >> k;
  vi a(n);
  rep(i,n) cin >> a.at(i);
  dp[0] = false;
  for(int i = 1; i<=k; i++) {
    bool ok = false;
    rep(j,n) {
      if(i-a[j]<0) continue;
      if(!dp[i-a[j]]) ok = true;
      if(ok) dp[i] = true;
      else dp[i] = false;
    }
  }
  if(dp[k]) cout << "First" << endl;
  else cout << "Second" << endl;
  return 0;
}

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

using namespace std;

int main(void){
  string a,b,c;
  cin >> a >> b >> c;
  int A,B,C;
  A=a.length(),B=b.length(),C=c.length();
  if(a[A-1]==b[0] && b[B-1]==c[0]){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

// vector print(debug or stdout)
template <class Iit>
void vout(const Iit &begin,const Iit &end,ostream &out) {
    for(auto it = begin; it != end; it++) {
        auto tmp = it;
        if (++tmp == end) out << *it << '\n';
        else out << *it << " ";
    }
}

int main(void)
{
    IOS
    int N; cin >> N;
    list<int> B;
    REP(i,N) {
        int b; cin >> b;
        B.push_back(b);
    }

    vector<int> ans;
    REP(i,N) {
        // vout(ALL(ans),cerr);
        auto it = B.end(); it--;
        RREP(j,N-i) {
            if (j == 0) {
                OUT(-1)
                return 0;
            }
            if(*it == j) {
                ans.push_back(j);
                B.erase(it);
                break;
            }
            it--;
        }
    }
    reverse(ALL(ans));
    REP(i,N) OUT(ans[i])

    return 0;
}

Measured memory_bytes: 256
import sys
readline = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
#mod = 998244353
INF = 10**18
eps = 10**-7

N,M = map(int,readline().split())
k = 2**N
dp = [[INF]*k for i in range(M+1)]
dp[0][0] = 0

for i in range(M):
    a,b = map(int,readline().split())
    c = list(map(int,readline().split()))
    d = sum(1<<(ci-1) for ci in c)
    for j in range(k):
        dp[i+1][j] = min(dp[i][j],dp[i+1][j])
        dp[i+1][j|d] = min(dp[i][j|d],dp[i][j]+a,dp[i+1][j|d])

print(dp[M][2**N-1] if dp[M][2**N-1] != INF else -1)




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

class Main{
    public static void main(String[] args) throws IOException{
        final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        final String[] in = br.readLine().split(" ");
        final int n = Integer.parseInt(in[0]);
        final int k = Integer.parseInt(in[1]);
        final int[] w = new int[n];
        for(int i = 0; i<n; i++){
            w[i] = Integer.parseInt(br.readLine());
        }
        int l = 0;
        for(final int e:w)
            if(l<e) l = e;
        int r = 0;
        for(int i = k-1; i<n; i++)
            r += w[i];
        r = Math.max(l, r);

        while(l<r){
            final int mid = (l+r)>>>1;
            if(check(w, k, mid)){
                r = mid;
            }else{
                l = mid+1;
            }
        }
        System.out.println(l);
    }
    static private boolean check(int[] w, int k, int p){
        int t = 0;
        int wt = 0;
        for(int i = 0, n = w.length; i<n; i++){
            if(wt+w[i]>p){
                ++t;
                wt = w[i];
                if(t>=k) return false;
            }else{
                wt += w[i];
            }
        }
        return true;
    }
}

Measured memory_bytes: 35228
#include<stdio.h>
#include<string.h>
int main(void){
  int a, b;
  char s[20],t[20];
  char u[20];

  scanf("%s %s", s, t);
  scanf("%d %d", &a, &b);
  scanf("%s", u);

  if(strcmp(s,u)==0){
    a = a - 1;
  }else if(strcmp(u,t)==0){
    b = b - 1;
  }

  printf("%d %d\n",a,b);
}

Measured memory_bytes: 128
parseInt(x) = parse(Int, x)
parseBigInt(x) = parse(BigInt, x)
parseFloat(x) = parse(Float64, x)
parseBigFloat(x) = parse(BigFloat, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    n=parseInt(readline())
    souwa=[0 for i in 1:10^4+1]
    for i in 1:10^4
        souwa[i+1]=souwa[i]+i
    end
    for i in 1:10^4+1
        if souwa[i]>=n
            ans=1:i-1
            for j in ans
                if souwa[i]-n!=j
                    println(j)
                end
            end
            break
        end
    end
end
main()

Measured memory_bytes: 167092
A, B = map(int, input().split())

def gcd(n, m):
    if m == 0:
        return n
    return gcd(m, n % m)

def primeCount(N):
    R = int(N**(0.5)) + 1  # 素数の範囲
    primes = {}  # 素数のリスト
    n = N
    for num in range(2, R):
        primes[num] = 0
        while n % num == 0:
            n //= num
            primes[num] += 1
    if n > 1 :
        primes[n] = 1
    return { key : val for key, val in primes.items() if val > 0}  # フィルターをかける

G = gcd(A, B)
P = primeCount(G)

ans = 1 + len(P.keys())
print(ans)


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

using namespace std;

/* template */

using ll = long long;

void debug_out() { std::cout << std::endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cout << "debug: "; debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif

#define rep(i, a, n) for (int i = (int)(a); i < (int)(n); i++)
#define rrep(i, a, n) for (int i = ((int)(n-1)); i >= (int)(a); i--)
#define Rep(i, a, n) for (long long i = (long long)(a); i< (long long)(n); i++)
#define RRep(i, a, n) for (long long i = ((long long)(n-1ll)); i>=(long long)(a); i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}

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

struct edge{
    int from;
    int to;
    ll weight;
    edge(int f,int t,ll w) : from(f), to(t), weight(w){ }
};


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

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

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

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

ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}

constexpr ll LNF = 1LL<<50;

constexpr int INF = 1e9+7;

const long double PI=3.14159265358979323846;


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

/* template */

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n,d; cin >> n >> d;
    ll p = d*d;
    ll ans = 0;
    rep(i,0,n){
        ll x,y; cin >> x >> y;
        ll q = x*x + y*y;
        if(p>=q){
            ans++;
        }
    }
    cout << ans << endl;
} 

Measured memory_bytes: 3656
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <numeric>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = n;i >= m;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 999999999
#define MINF -999999999
#define ALL(n) n.begin(),n.end()

int main() {
	ll n, b[5] = {},ans = 0;
	string s;
	char a[5] = { 'M','A','R','C','H' };
	cin >> n;
	REP(i, n) {
		cin >> s;
		REP(j, 5)if (s[0] == a[j]) b[j]++;
	}
	REP(i, 3) {
		FOR(j,i + 1, 4) {
			FOR(k,j + 1, 5) {
				ans += b[i] * b[j] * b[k];
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
int res;
string s;
cin>>s;
  if(s[0]=='1')
    res++;
  if(s[1]=='1')
    res++;
  if(s[2]=='1')
    res++;
  cout<<res<<endl;
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(shoki,i,n) for(int i=shoki; i<n; i++)
#define _GLIBCXX_DEBUG
using ll = long long;
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vector<int>>;

int main(){
    int A, B; cin>>A>>B;
    int ans = -1;
    rep(1,i,1001){
        int taxa = i*0.08;
        int taxb = i*0.1;
        if(taxa==A && taxb==B){
            ans = i;
            break;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <limits.h>

int binarysearch(int x, int n, int *a) {
  if (n <= 1) {
    return 1;
  }
  int tmp = n/2;
  if(a[tmp] <= x) {
    return tmp + binarysearch(x, (n+1)/2, a+tmp);
  } else {
    return binarysearch(x, (n+1)/2, a);
  }
}

int main() {
  int n, x, ans;
  scanf("%d%d", &n, &x);
  int l, d[n+2];
  d[0] = 0;
  d[n+1] = INT_MAX;
  for (size_t i = 0; i < n; i++) {
    scanf("%d", &l);
    d[i+1] = d[i] + l;
  }
  ans = binarysearch(x, n+2, d);
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 128
import math
A,B = (int(x) for x in input().split())
LowEight = math.ceil((25*A)/2)
CheckL8  = math.floor(LowEight/10)
LowTen   = 10*B
CheckL10 = math.floor(LowTen*2/25)

if   (CheckL8==B) and (CheckL10==A):
    minC = LowEight
elif (CheckL8!=B) and (CheckL10==A):
    minC = LowTen
elif (CheckL8==B) and (CheckL10!=A):
    minC = LowEight
elif (CheckL8!=B) and (CheckL10!=A):
    minC = -1
print(minC)

Measured memory_bytes: 3188
import java.util.*;


public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0 ; i < n; i++) {
            a[i] = sc.nextInt();
        }
        sc.close();
        int cnt = 0;
        for (int i = 0; i < n; i += 2) {
            if (a[i] % 2 == 1) cnt++;
        }
       
        System.out.println(cnt);
    }
}



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

using namespace std;
using ll =long long;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}
const ll INF = 1LL << 60;

//Write From this Line

const int mod = 1e9+7;
int main()
{
	ll n , x ;
	cin >> n >> x ;
	vector<ll> a(n);
	rep(i,n) cin >> a[i];
	//左から貪欲
	ll ans = 0 ;
	rep(i,n){
		int now = 0;
		if(i == 0){
			now = 0;
		} else {
			now = a[i-1] ;
		}
		if(now + a[i] <= x){
			//none
		} else{
			//溢れた分だけ＋
			int ove = now + a[i] - x;
			ans += ove;
			a[i] -= ove ;
		} 
	}
	cout << ans << endl;
}


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

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

	int a, b;
	cin >> a;
	b = a%100; a /= 100;
	if (0 < a and a < 13){
		if (0 < b and b < 13) cout << "AMBIGUOUS\n";
		else cout << "MMYY\n";
	}
	else{
		if (0 < b and b < 13) cout << "YYMM\n";
		else cout << "NA\n";
	}
}

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

template <class T> using V = vector<T>;
template <class S, class T> using P = pair<S, T>;
template <class... T> using TP = tuple<T...>;

using ll = long long;
using db = double;
using ldb = long db;
using str = string;
using vll = V<ll>;
using vvll = V<V<ll>>;
using pll = P<ll,ll>;
using tpll = TP<ll,ll,ll>;
using vpll =V<pll>;
using vst = V<str>;
using vch = V<char>;

#define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++)
#define rFOR(i,a,b) for(ll i=(b);i>(ll)(a);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) __lcm(a,b)
#define co(a) cout<<a<<endl
#define ci(a) cin>>a
#define pb(a) push_back(a)
#define pob pop_back()
#define mp make_pair
#define mt make_tuple
#define pbmp(a,b) push_back(mp(a,b))
#define subs(a,b) substr(a,b)
#define cfs(a) cout<<fixed<<setprecision(a)
#define INF 1e16
#define mod 1e9+7
//vvll v(n,vll(m)) n行m列
//A.erase(A.begin()+i) 配列Aのi番目を消せる
//std::binary_search(v.bgn,v.en,a);
//abs(a,b)   pow(a,n)  to_string  stoll
//auto Iter=lower_bound(v.bgn,v.en,a);
//lower//upper  co(*Iter)co(Iter-v.bgn);

const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
void Comuse() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
#define comuse Comuse()
ll combi(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
  ll a,b;
  cin>>a>>b;
  if((a+b)%2==0){
    co((a+b)/2);
  }
  else{
    co("IMPOSSIBLE");
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define I64 "%I64d"
#define RAN(v)v.begin(),v.end()
#define pb push_back
#define lb lower_bound
#define ub upper_bound
using namespace std;
typedef long long ll;
template<class T>
inline void upd1(T&a,T b){a>b?a=b:0;}
template<class T>
inline void upd2(T&a,T b){a<b?a=b:0;}
struct ano{
	operator ll(){
		ll x=0,y=0,c=getchar();
		while(c<48)
			y=c==45,c=getchar();
		while(c>47)
			x=x*10+c-48,c=getchar();
		return y?-x:x;
	}
}buf;
int main(){
	int n=buf,s=1,t=1;
	while(n--)
		s*=buf&1?1:2,t*=3;
	printf("%d\n",t-s);
}

Measured memory_bytes: 256
//header{{{
#include<bits/stdc++.h>
  
using namespace std;
 
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define setout(n,x) setw(n+1) << setfill(x)
#define Fixed fixed << setprecision(10)
#define int int64_t
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod = 1e9+7; 
constexpr int MOD = 998244353;

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

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A, class B> using umap = unordered_map<A,B>;
  
int gcd(int a,int b){ return b ? gcd(b,a % b) : a;}
int lcm(int a,int b){ return a / gcd(a,b) * b;}

constexpr int dx[] = {1,0,-1,0,1,1,-1,-1};
constexpr int dy[] = {0,-1,0,1,1,-1,-1,1};
//}}}

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

    int n;
    cin >> n;
    vector<int> a(n),b(n);

    rep(i,n){
        cin >> a[i];
    }
    rep(i,n){
        cin >> b[i];
    }

    int sum1 = 0,sum2 = 0,asum = 0,bsum = 0;

    rep(i,n){
        if(b[i] < a[i]){
            sum1 += a[i] - b[i];
        }else{
            sum2 += (b[i] - a[i]) / 2;
        }
        asum += a[i];
        bsum += b[i];
    }

    if(asum > bsum || sum1 > sum2) cout << "No\n";
    else cout << "Yes\n";

  	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <stack>
#include <algorithm>
#include <functional>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <sstream>
using namespace std;

#define REP(i,a,n) for(i=a; i<n; i++)
#define rep(i,n) REP(i,0,n)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define foreach(it,x) for(typeof(x.begin()) it=x.begin(); it!=x.end(); it++)


bool primes[1000010]; // false is prime.
bool ok[1000010];

void build_prime(){
    int i,j;

    primes[0] = primes[1] = true;
    for(i=2; i*i<=1000000; i++){
        if( !primes[i] ){
            for(j=i*2; j<=1000000; j+=i) primes[j] = true;
        }
    }
}

int main(){
    int n,x,i,j,k;
    int dish[33];

    build_prime();

    while( scanf("%d%d",&n,&x), n|x ){

        rep(i,n) scanf("%d",dish+i);
        sort(dish, dish+n);

        int res = 0;
        memset(ok, false, sizeof(ok));
        ok[0] = true;
        for(i=0; i<n; i++){
            for(j=dish[i]; j<=x; j++){
                ok[j] |= ok[j-dish[i]];
                if( !primes[j] && ok[j] ) res = max(res, j);
            }
        }

        if( res == 0 ){ puts("NA"); }
        else{ printf("%d\n",res); }
    }

    return 0;
}

Measured memory_bytes: 2832
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;

const long double PI = (acos(-1));
const long double EPS = 0.0000000001;

long double a, b, x;

void input() {
    cin >> a >> b >> x;
}

long double f(long double a, long double b, long double theta) {
    if(theta > PI / 2.0 - EPS) {
        return 0.0;
    }
    long double ret;
    if(a * tan(theta) <= b) {
        ret = a * a * b - a * a * a * tan(theta) / 2.0;
    } else {
        ret = b * b / tan(theta) * a / 2.0;
    }
    return ret;
}

void solve() {
    input();
    long double ok = PI / 2.0;
    long double ng = 0.0;
    for(int _ = 1; _ <= 100000; _++) {
        long double mid = (ok + ng) / 2.0;
        if(f(a, b, mid) < x) ok = mid;
        else ng = mid;
    }
    cout << fixed << setprecision(10) << ok / PI * 180 << endl;
    return;
}

int main() {
    solve();
    return 0;
}


Measured memory_bytes: 512
#include<stdio.h>
#include<iostream>
#include<list>
#include<map>
#include<vector>
#include<algorithm>
#include<string.h>
#include<math.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << x << endl;
using namespace std;

int main(){
    double rad = 90 / 180 * M_PI, north = 0, east = 0;
    double inputMeter, inputAngle;
    char garbage;

    while(cin >> inputMeter >> garbage >> inputAngle, inputMeter){
            east+= cos(rad) * inputMeter;
            north+= sin(rad) * inputMeter;
        rad+= inputAngle / 180 * M_PI;
    }
    cout << static_cast<int>(north) << endl << static_cast<int>(east) << endl;
}

Measured memory_bytes: 1228
//this code is created by Neel11
//YEET!
#include<bits/stdc++.h>

using namespace std;

#define testcases ll t;cin>>t;while(t--)
#define queries ll q;cin>>q;while(q--)
#define ll long long 
#define loop(i,x,n) for(ll i=x;i<n;i++)
#define ff first
#define ss second
#define pb push_back
#define elif else if
#define flush cout<<endl;
#define mod 1000000007





int main(){
  string day;
  cin>>day;
  
  if(day == "SUN")
    cout<<7;
  if(day == "MON")
    cout<<6;
  if(day == "TUE")
    cout<<5;
  if(day == "WED")
    cout<<4;
  if(day == "THU")
    cout<<3;
  if(day == "FRI")
     cout<<2;
  if(day == "SAT")
    cout<<1;
  cout<<endl;
  
}


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

int main()
{
    int cmp;
    char nyuryoku[11];
    char uketori[5];
    char yakiire[] = "YAKI";

    scanf("%s",nyuryoku);

    strncpy(uketori,nyuryoku,4);

    cmp = strcmp(uketori,yakiire);

    if(cmp == 0)
    {
        printf("Yes");
    }else{
        printf("No");
    }
return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define rep(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define all(x) (x).begin(),(x).end()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;
const ll MOD = 998244353;
typedef pair<ll, ll> LP;
 
ll POW(ll m,ll n)
{
  if(n<0) return 0;
  if(n==0) return 1;
  return m*POW(m,n-1)%MOD;
}

ll gcd(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}
 
ll KAI(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI(m-1)%MOD;
}
 
ll CON(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return m*CON(m-1,n)/(m-n);
}

ll extGCD(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll d = extGCD(b, a%b, y, x);
    y -= a / b * x;
    return d;
}

inline ll mod(ll a, ll m) {
    return (a % m + m) % m;
}

ll modinv(ll a, ll m) {
    ll x, y;
    extGCD(a, m, x, y);
    return mod(x, m);
}
 
int main()
{
  ll n,x,a[150],p;
  cin >> n >> x;
  p=0;
  rep(i,n)cin >>a[i];
  sort(a,a+n);
  rep(i,n){x=x-a[i];
           if(x>=0){p++;
                  }
          }
  if(x<=0)printf("%lld",p);
  else printf("%lld",p-1);
}

Measured memory_bytes: 256
s = int(input())
i = 1
def collatz(x):
	if x%2 == 0:
		return int(x/2)
	else:
		return int(3*x+1)

while True:
	if s in [1,2,4]:
		break
	else:
		s = collatz(s)
		i += 1

print(str(i+3))

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

int main() {
	int N;
	cin >> N;
	vector<int> v(N);
	for (int i = 0; i < N; i++) {
		cin >> v[i];
	}
	sort(v.rbegin(), v.rend());
	int Alice = 0, Bob = 0;
	for (int i = 0; i < N; i++) {
		//最初にAliceがカードをとる
		if (i % 2 == 0) {
			Alice += v[i];
		}
		else {
			Bob += v[i];
		}
	}
	cout << Alice - Bob << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char* argv[])
{
    unordered_multiset<string> words;
    string key, tmps;
    cin >> tmps;
    for (auto var : tmps)
    {
        key += string(1,tolower(var));
    }
    while(1)
    {
        string lowercase;
        cin >> tmps;
        for (auto var : tmps)
        {
            lowercase += string(1,tolower(var));
        }
        if(tmps=="END_OF_TEXT") break;
        words.insert(lowercase);
    }
    cout << words.count(key) << endl;

    return 0;
}



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

int main(){

    ios_base::sync_with_stdio(false);
cin.tie(NULL);

    string s;
    int n;
    cin>>s>>n;
    
    bool r = 1;
    int cnt = 0;
    vector<char> v[2];
    for(int i = 0; i < n; i++){
        int t;
        cin>>t;
        if(t==1){
            r = !r;
            cnt++;
        } else{
            int tt;cin>>tt;
            char c;
            cin>>c;
            if(tt==1){
                if(r) v[0].push_back(c);
                else v[1].push_back(c);
            } else {
                if(r) v[1].push_back(c);
                else v[0].push_back(c);
            }
        }
    }
    string res;
    for(int i = (int)v[0].size()-1; i>=0; i--){
        res+=v[0][i];
    }
    res+=s;
    for(int i = 0; i < (int)v[1].size(); i++){
        res+=v[1][i];
    }
    if(cnt%2) reverse(res.begin(),res.end());
    cout<<res;
}


Measured memory_bytes: 1448
#include<iostream>

using namespace std;

int main()
{
    int N;
    cin>> N;
    int a[N][2];
    for(int i = 0; i < N; i++)
    {   
        for(int j = 0; j < 2; j++)
            cin >> a[i][j];
    }
    int count = 0;
    for(int i = 0; i < N; i++)
    {
                if(a[i][0] == a[i][1])
                {
                    count++;
                    if(count == 3)
                    {
                        cout<<"Yes";
                        return 0;
                    }
                }
                else
                {
                    count = 0;                   
                }
    }
    cout<< "No";
    return 0;
}

Measured memory_bytes: 3632
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <iomanip>	
#include <deque>
#include <set>
#include <climits>
#include <memory>
#include <numeric>
#include <utility>


#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
#define fore(i,a) for(auto &i:a)
#define INF INT_MAX/2;
#define PI 3.14159265358979323846264338327950L;
const int INF2 = 1001001001;
typedef long long ll;
using namespace std;
using vi = vector<int>;
using vll = vector<ll>;
ll mod = 1e9 + 7;
//ll llmax = 10000000000000000000ll;
using namespace std;
using Graph = vector<vector<int>>;



int cnt_digit(ll N)
{
	int digit = 0;

	while (N > 0)
	{
		N /= 10;
		digit++;
	}
	return digit;
}


 // 最大公約数計算
 
ll gcd(ll a, ll b)
{
	if (b == 0) {
		return a;
	}
	else {
		return gcd(b, a % b);
	}
}
// 最小公倍数の計算

ll lcm(ll a, ll b)
{
	ll g = gcd(a, b);

	return a / g * b;
}

struct union_find
{
	vector<int> par, r;
	union_find(int n)
	{
		par.resize(n);
		r.resize(n);
		init(n);
	}


	void init(int n)
	{
		for (int i = 0; i < n; i++) par[i] = i;
		for (int i = 0; i < n; i++) r[i] = 0;
	}

	int find(int x)
	{
		if (par[x] == x)return x;
		else return find(par[x]);
	}

	void unite(int x, int y)
	{
		x = find(x);
		y = find(y);

		if (r[x] < r[y])
		{
			par[x] = y;
		}
		else
		{
			par[y] = x;
			if (r[x] == r[y])
			{
				r[x]++;
			}
		}
	}
};

const int MAX_N = 110000;

int memo[MAX_N];

int rec(int n) {
	if (n == 0)return 0;
	if (memo[n] != -1)return memo[n];

	int res = n;

	for (int pow6 = 1; pow6 <= n; pow6 *= 6)res = min(res, rec(n - pow6) + 1);

	for (int pow9 = 1; pow9 <= n; pow9 *= 9)res = min(res, rec(n - pow9) + 1);

	return memo[n] = res;
}

int calc(int x) {
	int ret = 0;
	while (x % 2 == 0) {
		x /= 2;
		ret++;
	}

	return ret;
}

int a[12][12];
int D;
ll G;
vector<ll> P, C;

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	ll k;

	cin >> s >> k;
	rep(i, 0, min((ll)s.size(), k)) {
		if (s[i] >= '2') {
			cout << s[i] << endl;
			return 0;
		}

	}
	cout << '1' << endl;

}
	

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
//long long
using ll = long long;
 
// pair<int, int>
using PII = pair<int, int>;
 
//最大値、mod
const int MOD = 1000000007;
const int INF = 1000000000;
const long long LINF = 1e18;
const int MAX = 510000;
 
//出力系
#define print(x) cout << x << endl
#define prints(x) cout << fixed << setprecision(10) << x << endl
#define printc(x) cout << setw(2) << setfill('0') << x << endl;
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()
 
//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
 
//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
 
// 最小公倍数
unsigned lcm(unsigned a, unsigned b){
    return a / gcd(a, b) * b; 
}
 
// a = max(a, b), a = min(a, b)
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; }
 
// 累乗(MODをとる)
ll pow_mod(ll num, ll pow, ll mod) {
    ll prod = 1;
    num %= mod;
    while (pow > 0) {
        if (pow & 1) prod = prod * num % mod;
        num = num * num % mod;
        pow >>= 1;
    }
    return prod;
}
 
 
 
// 二項係数(MODとる、1 ≦ k ≦ n ≦ 10^7 程度)
// COMinit()
// COM(x, y)
// とコンビで使う
 
// テーブルを作る前処理
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
int dx[4] = {0, 0, 1, -1}, dy[4] = {1, -1, 0, 0};

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

ll solve2(ll a){
    return (a + 1) / 2 % 2;
}

ll solve(ll a){
    if(a % 2 == 1) return solve2(a);
    else return solve2(a + 1) ^ (a + 1);
}

int main(){
    ll A, B;
    cin >> A >> B;
    cout << (solve(B) ^ solve(A - 1)) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define FOR(i, s, n) for(int (i)=(s); (i)<(int)(n); (i)++)
#define REP(i, n) for(int (i)=0; (i)<(int)(n); (i)++)
#define REV(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
typedef long long int lli;
const lli inf = 1e18;

int main(){
	int n;
	cin >> n;
	vector<int> x(n), cp;
	REP(i, n) cin >> x[i];
	cp = x;
	sort(x.begin(), x.end());
	int m1 = x[n/2-1], m2 = x[n/2];
	REP(i, n){
		if(cp[i] <= m1) cout << m2 << endl;
		else cout << m1 << endl;
	}
	return 0;
}


Measured memory_bytes: 3712
#include<stdio.h>
int main()
{
    int n, d, x, j,k,p=0;
    scanf("%d", &n);
    scanf("%d %d", &d, &x);
    int a[n], i;
    for(i = 0; i < n; i++){
        scanf("%d", &a[i]);
    }
    i=0;
    for(k = 0; k <n; k++){
        for(j = 0;; j++){

            if((j*a[i]+1) <= d) p++;
            if((j*a[i]+1) > d) break;
        } i++;
    }
    printf("%d\n", p+x);
    return 0;
}


Measured memory_bytes: 128
#include<stdio.h>

#define max(a,b) ((a)>(b)?(a):(b))

int main(){
int n,a[2][100],i,j;
scanf("%d",&n);
for(i=0;i<n;i++)scanf("%d",&a[0][i]);
for(i=0;i<n;i++)scanf("%d",&a[1][i]);
int b[100]={0};
for(i=0;i<n;i++){
for(j=0;j<n;j++){
if(j<i)b[i]+=a[0][j];
else if(i==j)b[i]+=a[0][j]+a[1][j];
else if(i<j)b[i]+=a[1][j];
}
}
int ans=0;
for(i=0;i<n;i++){
ans=max(ans,b[i]);
}
printf("%d\n",ans);
return 0;
}

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

using i64 = int64_t;

#define rep(i, x, y) for (i64 i = i64(x), i##_max_for_repmacro = i64(y); i < i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf = 1.01e9;
const i64 inf64 = 4.01e18;
const double eps = 1e-9;

template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "(" << p.first << ", " << p.second << ")";
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

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

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

template<typename T, size_t size> void fill(T (&ary)[size], const T& val){
    fill_n((T*)ary, size, val);
}

void solve() {
    //const i64 mod = 1'000'000'007;
    i64 A,B;
    cin >> A >> B;
    
    if(A<=5) cout << 0 << endl;
    else if(A<=12) cout << B/2 << endl;
    else cout << B << endl;
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 256
import sys
from collections import deque
sys.setrecursionlimit(10 ** 5)
input = sys.stdin.readline


def main():
    N, Q = map(int, input().split())
    edge = [[] for i in range(N)]
    ops = []
    ans = [0] * N

    for _ in range(N - 1):
        a, b = map(int, input().split())
        edge[a - 1].append(b - 1)
        edge[b - 1].append(a - 1)
    for _ in range(Q):
        ops.append(tuple(map(int, input().split())))

    for op in ops:
        node = op[0] - 1
        pnt = op[1]
        ans[node] += pnt

    stack = deque()
    stack.append((0, -1))

    while stack:
        st = stack.pop()
        node, parent = st[0], st[1]
        children = edge[node]
        for child in children:
            if child == parent:
                continue
            ans[child] += ans[node]
            stack.append((child, node))

    print(*ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 86332
#include <iostream>
#include <queue>
#include <vector>
#define SIZE 100000
using namespace std;
typedef pair<int, int> P;
int n, m, d[SIZE], used[SIZE];
P edge[SIZE];
vector<int> v[SIZE], w[SIZE];
vector<P> ans;
void f(int x){
    for(int i=0;i<w[x].size();i++){
        int y = w[x][i];
        f(y);
        if(d[y] % 2 == 1){
            d[y]++;
            ans.push_back(P(y, x));
        }else{
            d[x]++;
            ans.push_back(P(x, y));
        }
    }
}
int main(void){
    cin >> n >> m;
    queue<int> q;
    for(int i=0;i<m;i++){
        int a, b;
        cin >> a >> b;
        edge[i] = P(--a, --b);
        v[a].push_back(i);
        v[b].push_back(i);
    }

    if(m % 2 == 1){
        cout << -1 << endl;
        return 0;
    }

    fill(d, d+n, 0);
    fill(used, used+n, 0);
    q.push(0);
    used[0] = 1;
    while(!q.empty()){
        int x = q.front();
        q.pop();
        for(int i=0;i<v[x].size();i++){
            P p = edge[v[x][i]];
            int y = p.first;
            if(y == -1)continue;
            edge[v[x][i]] = P(-1, -1);
            if(y == x)y = p.second;
            if(used[y] == 0){
                w[x].push_back(y);
                q.push(y);
                used[y] = 1;
            }else{
                ans.push_back(P(x, y));
                d[x]++;
            }
        }
    }

    f(0);
    m = min(m, (int)ans.size());
    for(int i=0;i<m;i++){
        cout << ans[i].first+1 << " " << ans[i].second+1 << endl;
    }
}


Measured memory_bytes: 18680
import Control.Applicative ((<$>), (<*>))
import Control.Monad
import Data.List
import Data.Array

main :: IO ()
main = do
  xs <- getc split
  mapM_ print $ solve xs

solve :: [[String]] -> [Int]
solve = map noi

noi :: [String] -> Int
noi ss = fst $ foldl count (0, iarr) idx
  where
    iarr = listArray ((0,0),(11,11)) $ concat ss
    idx = [(i,j)|i <- [0..11], j <- [0..11]]

count :: (Int, Array (Int,Int) Char) -> (Int,Int) -> (Int, Array (Int,Int) Char)
count (x, arr) (i,j)
  | arr ! (i,j) == '1' = (x+1, clear arr (i,j))
  | otherwise = (x, arr)

clear :: Array (Int,Int) Char -> (Int,Int) -> Array (Int,Int) Char
clear arr (i,j)
  | i < 0 || i > 11 || j < 0 || j > 11 = arr
  | arr ! (i,j) == '0' = arr
  | otherwise = foldl clear (arr // [((i,j),'0')]) [(i+1,j),(i,j+1),(i-1,j),(i,j-1)]
    
split :: [String] -> [[String]]
split ss
  | null bs = [as]
  | otherwise = as : split (tail bs)
  where
    (as, bs) = span (/= "") ss

getc :: ([String] -> a) -> IO a
getc f = f . lines <$> getContents

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

int main(){
  string s, t;
  cin >> s >> t;
  int end = t.size() - 1;
  t.erase(end);
  if (s == t) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <numeric>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
#include <utility>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1e9 + 7
#define INF 1e9
#define SENTINEL 2e9
#define PIE 3.14159265358979323

template <class T>
inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}
template <class T>
inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template <class T>
inline T GCD(T a, T b){if (b == 0) return a; else return GCD(b, a % b);}
template <class T>
inline T LCM(T a, T b) {return (a * b) / GCD(a, b);}

int main(){
    int n,k;
    cin >> n>>k;
    vector<bool> s(n,true);
    int d;
    int a;
    rep(i,k){
        cin >> d;
        rep(j,d){
            cin >> a;
            a--;
            s[a] = false;
        }
    }
    int count = 0;

    rep(i,n){
        if (s[i])
            count++;
    }
    cout << count << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int V, E;
    cin >> V >> E;
    vector<vector<long long>> dp(V, vector<long long>(V, 1e+15));
    for (int i = 0; i < V; i++)
    {
        dp[i][i] = 0;
    }

    for (int i = 0; i < E; i++)
    {
        int s, t, d;
        cin >> s >> t >> d;
        dp[s][t] = d;
    }
    for (int i = 0; i < V; i++)
    {
        for (int j = 0; j < V; j++)
        {
            for (int k = 0; k < V; k++)
            {
                if(dp[j][i] != 1e+15 && dp[i][k] != 1e+15)
                {
dp[j][k] = min(dp[j][k], dp[j][i] + dp[i][k]);
                }
            }
        }
    }
    for (int i = 0; i < V; i++)
    {
        if (dp[i][i] < 0)
        {
            cout << "NEGATIVE CYCLE" << endl;
            return 0;
        }
    }

    for (int i = 0; i < V; i++)
    {
        for (int j = 0; j < V; j++)
        {
            if (dp[i][j] != 1e+15)
            {
                cout << dp[i][j];
            }
            else
            {
                cout << "INF";
            }
            if (j != V - 1)
            {
                cout << " ";
            }
        }
        cout << endl;
    }
}


Measured memory_bytes: 3248