akhauriyash/Code-Regression huggingface dataset:
package main

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

func main() {
	n := getInt()
	W := getInt()

	ws := make([]int, n)
	vs := make([]int, n)
	for i := 0; i < n; i++ {
		ws[i] = getInt()
		vs[i] = getInt()
	}

	dp := make([][]int, n+1)
	for i := range dp {
		dp[i] = make([]int, W+1)
	}

	for i := 1; i < n+1; i++ {
		for j := range dp[i-1] {
			if j-ws[i-1] >= 0 {
				dp[i][j] = max(dp[i][j], dp[i-1][j-ws[i-1]]+vs[i-1])
			}
			dp[i][j] = max(dp[i][j], dp[i-1][j])
		}
	}

	fmt.Println(dp[n][W])
}

func max(ns ...int) int {
	max := ns[0]
	for i := 1; i < len(ns); i++ {
		if max < ns[i] {
			max = ns[i]
		}
	}
	return max
}

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

var scanner = wordScanner()

func wordScanner() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return sc
}

func getInt() int {
	scanner.Scan()
	i, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func getIntSlice(n int) []int {
	is := make([]int, n)
	for i := range is {
		is[i] = getInt()
	}
	return is
}

func getString() string {
	scanner.Scan()
	s := scanner.Text()
	return s
}


Measured memory_bytes: 81792
from itertools import combinations_with_replacement as R

N,M,Q = map(int, input().split())
L = [tuple(map(int, input().split())) for _ in range(Q)]

print(max([sum((d if S[b-1] - S[a-1] == c else 0) for a,b,c,d in L) for S in R(range(1, M+1), N)]))

Measured memory_bytes: 73392
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
	inf            = 1000000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

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

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

func max(nums ...int) int {
	ret := nums[0]
	for _, v := range nums {
		if v > ret {
			ret = v
		}
	}
	return ret
}

func min(nums ...int) int {
	ret := nums[0]
	for _, v := range nums {
		if v < ret {
			ret = v
		}
	}
	return ret
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	h, w := nextInt(), nextInt()
	a := make([]string, h)
	for i := range a {
		a[i] = next()
	}

	cost := make([][]int, h)
	for i := range cost {
		cost[i] = make([]int, w)
		for j := range cost[i] {
			cost[i][j] = inf
		}
	}

	// タテ方向を見る
	// 上から下
	for j := 0; j < w; j++ {
		for i := 0; i < h; i++ {
			if i > 0 {
				cost[i][j] = cost[i-1][j] + 1
			}
			if a[i][j] == '#' {
				cost[i][j] = 0
			}
		}
	}
	// 下から上
	for j := 0; j < w; j++ {
		for i := h - 2; i >= 0; i-- {
			cost[i][j] = min(cost[i][j], cost[i+1][j]+1)
		}
	}

	// ヨコ方向を見る
	// 左から右
	for i := 0; i < h; i++ {
		for j := 1; j < w; j++ {
			cost[i][j] = min(cost[i][j], cost[i][j-1]+1)
		}
	}
	// 右から左
	for i := 0; i < h; i++ {
		for j := w - 2; j >= 0; j-- {
			cost[i][j] = min(cost[i][j], cost[i][j+1]+1)
		}
	}

	ans := 0
	for i := range cost {
		ans = max(ans, max(cost[i]...))
	}
	puts(ans)
}


Measured memory_bytes: 11456
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long int ll;
 
#define pii pair<int, int>
#define F first
#define S second
#define pb push_back
 
const int N = 1e5 + 5;
const int mod = 1e9+7;
const ll INF = (ll)1e18;

int main(){
    ios_base :: sync_with_stdio(0);
    cin.tie(0);
 
    int n, W;
    cin >> n >> W;
    vector<ll> dp(W+1, 0);
    for(int j = 0; j < n; j++){
        ll w, v;
        cin >> w >> v;
        vector<ll> cur(W+1, 0);
        for(int k = 0; k <= W; k++){
            cur[k] = dp[k];
            if(k >= w) cur[k] = max(cur[k], dp[k-w]+v);
        }
        dp = cur;
    }
    ll ans = 0;
    for(int j = 0; j <= W; j++) ans = max(ans, dp[j]);
    cout << ans;
    return 0;
}

Measured memory_bytes: 1804
// template version 1.12
using namespace std;
#include <iostream>
#include <bits/stdc++.h>

// varibable settings
#define infile "../test/sample-1.in"
#define int long long //{{{
const int INF=1e18;
const int MOD=1e9+7; //}}}

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define ceil(a,b) ((a)+(b)-1)/(b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
  #include "lib/dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}

int solve(){
  int n;cin>>n;
  int m = 1;
  rep(i, n) m*=2;

  vi a(m);
  multiset<int> yet;
  rep(i, m){
    cin>>a[i];
    yet.insert(a[i]);
  }

  auto last = yet.end();
  last--;
  multiset<int> fin;
  fin.insert(*last);
  yet.erase(last);

  dump(yet);
  dump(fin);
  rep(i, n){
    multiset<int> add;
    each(f, fin){
      auto r = yet.lower_bound(f);
      if (r==yet.begin()){
        cout << "No" << endl;
        return 0;
      }
      else{
        r--;
        add.insert(*r);
        yet.erase(r);
      }
    }
    each(el, add){
      fin.insert(el);
    }
    dump(yet);
    dump(fin);
  }
  cout << "Yes" << endl;

  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 20736
// Original: https://github.com/tanakh/competitive-rs
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

mod util {
    #[allow(dead_code)]
    pub fn chmin<T>(x: &mut T, y: T) -> bool
    where
        T: PartialOrd + Copy,
    {
        *x > y && {
            *x = y;
            true
        }
    }

    #[allow(dead_code)]
    pub fn chmax<T>(x: &mut T, y: T) -> bool
    where
        T: PartialOrd + Copy,
    {
        *x < y && {
            *x = y;
            true
        }
    }

    /// 整数除算切り上げ
    #[allow(dead_code)]
    pub fn roundup(a: i64, b: i64) -> i64 {
        (a + b - 1) / b
    }

    #[allow(dead_code)]
    pub fn ctoi(c: char) -> i64 {
        c as i64 - 48
    }
}

#[allow(unused_imports)]
use util::*;

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, VecDeque};

fn main() {
    input! {
        n:i64
    }
    let n = n - 1;
    let ans = n * (n + 1) / 2;
    println!("{}", ans);
}


Measured memory_bytes: 4352
<?php
list($n, $m) = ints();
for ($i = 0; $i < $m; ++$i) {
    list($a, $b) = ints();
    $a--;
    $b--;
    $g[$a][] = $b;
    $g[$b][] = $a;
}
echo dfs();
function dfs($v = 0, $used = [])
{
    global $n, $g;
    $used[$v] = true;
    if (count($used) === $n) return 1;
    if (is_null($g[$v])) return 0;
    $res = 0;
    foreach ($g[$v] as $to) {
        if ($used[$to]) continue;
        $res += dfs($to, $used);
    }
    return $res;
}
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}


Measured memory_bytes: 4728
input1 = input().split(" ")
n = int(input1[0])
m = int(input1[1])
assignlist = input().split(" ")
con1 = n>=1 and n<=1000000
con2 = m>=1 and m<=1000000
numassign = 0
holiday = 0
if con1 == True and con2 == True:
    for i in assignlist:
        i = int(i)
        if i >= 1 and i <= 10000:
            numassign = numassign + i
        else:
            numassign = numassign
    holiday = n - numassign
    if holiday >= 0:
        print(holiday)
    else:
        print(-1)
else:
    print()


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

#ifdef DEBUG
#include "inc/debug.hpp"
#else
#define debug(...) 42
#define rdfile(...) 42
#endif

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    // rdfile("test/sample-1.in");

    int N;
    cin >> N;
    cout << N * N * N << endl;

    return 0;
}

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

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

int main(void){
    int x, a;
    cin >> x >> a;
    if(x >= a) cout << 10 << endl;
    else cout << 0 << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int n,temp;
    scanf("%d",&n);
    
    int a[n-1];
    int i=0;
    int count = 0;

    for(int k=0;k<n;k++){
   	    scanf("%d",&temp);
    	a[k] = temp;
    }
    
    
    while(a[i] != 2 && count < n){
    	i = a[i]-1;
    	count = count+1;
    }
	if(a[i] == 2){
		count = count+1;
		printf("%d",count);
		printf("\n");
	}else{
		printf("-1");
		printf("\n");
	}

}

Measured memory_bytes: 512
from math import gcd

N = int(input())
A = list(map(int, input().split()))

L = [0] * N
R = [0] * N
L[0] = A[0]
R[N-1] = A[N-1]
for i in range(1, N):
    L[i] = gcd(L[i-1], A[i])
    R[N-i-1] = gcd(R[N-i], A[N-i-1])

ans = -1
for i in range(N):
    if i == 0:
        ans = max(ans, R[1])
    elif i == N-1:
        ans = max(ans, L[N-2])
    else:
        ans = max(ans, gcd(L[i-1], R[i+1]))

print(ans)

Measured memory_bytes: 20980
//
//  atcoder.cpp
//
//
///
#include <stdio.h>
#include <stdlib.h>
#include <bits/stdc++.h>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/bimap/bimap.hpp>
#include <boost/bimap/multiset_of.hpp>
#include <boost/multi_array.hpp>
#include <boost/math/common_factor.hpp>
#include <boost/algorithm/string.hpp>


#define REP(i, N) for(int i=0; i<(N); i++)
#define REC(f, ...) (void)0; const auto f = [&](const auto f, __VA_ARGS__)
using namespace std;
using namespace boost::math;

using ll = long long;
namespace bst = boost;
template<typename T> class in {
    T value;
public:
    in() { cin >> value; }
    operator const T&() const { return value; }
    operator T&() { return value; }
    in& operator=(T source) { value = source; return *this; }
};
template<> class in<string> : public string {
public:
    in() { cin >> *this; }
};
template<class T> class inseq : public T {
public:
    template<typename... Arg> inseq(Arg... arg) : T(forward<Arg>(arg)...) { for (auto&& i : *this) cin >> i; }
};
template<class T> using invec = inseq<vector<T>>;

auto solve() {
  in<int> A, B;

  int r = 0;
  
  while (A > 0) {
    r++;
    A /= B;
  }
  return r;
}

template<typename T> void plot(const T& func) { cout << func() << endl; }
template<> void plot<void()>(void(&func)()) { func(); }
template<> void plot<double()>(double(&func)()) { cout << setprecision(9) << func() << endl; }

int main() {
  plot(solve);

  return 0;
}



Measured memory_bytes: 256
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner scan=new Scanner(System.in);
    int N=scan.nextInt();
    int L=scan.nextInt();
    int[] apple=new int[N];
    int correct=0;
    for(int i=0;i<N;i++){
      apple[i]=L+i;
      correct+=apple[i];
    }
    int[] taste=new int[N];
    int min=0;
    int ans=0;
    int tmp=0;
    int tmp_correct=0;
    int tmp_taste=0;
    boolean flag=true;
    for(int i=0;i<N;i++){
      for(int j=0;j<N;j++){
        if(i==j){
          continue;
        }
        taste[i]+=apple[j];
      }
      tmp_correct=correct;
      tmp_taste=taste[i];
      if(correct<0){
        tmp_correct=-tmp_correct;
      }
      if(tmp_taste<0){
        tmp_taste=-tmp_taste;
      }
      tmp=tmp_correct-tmp_taste;
      if(tmp<0)tmp=-tmp;
      if(flag){
        min=tmp;
        ans=taste[i];
        flag=false;
      }
      if(min>tmp){
        min=tmp;
        ans=taste[i];
      }
      // System.out.println("correct:"+correct);
      // System.out.println("taste["+i+"]"+taste[i]);
      // System.out.println("eat"+tmp);
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 21972
n=int(input())
s=list(input())
l=0
r=0
al=0
ar=0
for i in range(n):
    if s[i]=='(':
        l+=1
    else:
        if l>0:
            l-=1
        else:
            al+=1
for i in range(n-1,-1,-1):
    if s[i]==')':
        r+=1
    else:
        if r>0:
            r-=1
        else:
            ar+=1
            
ans=''
for i in range(al):
    ans+='('
for i in range(n):
    ans+=s[i]
for i in range(ar):
    ans+=')'
print(ans)

            

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int n,m,a,b;
	int sum=0,big=0;
	cin>>n>>m;
	for(int u=0;u<m;u++){
		cin>>a>>b;
		sum+=max(0,n-a);
		big=max(max(0,n-a),big);
	}
	cout<<sum-big<<endl;
	return 0;
}

Measured memory_bytes: 3128
#include<stdio.h>
int main(void)
{
    int n,i,a[31];
	for(i=1;i<=30;i++) a[i]=0;
	for(i=0;i<28;i++){
	    scanf("%d",&n);
		a[n]=1;
	}
	for(i=1;i<=30;i++){
		if(a[i]==0) printf("%d\n",i);
	}
	return 0;
}

Measured memory_bytes: 2660
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
using namespace std;

typedef long long ll;
#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1;} return 0;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////


int main() {
    int n, q; cin >> n >> q;
    string s; cin >> s;
    vector<int> sum(n+1);
    rep(i,n) {
        sum[i+1] = sum[i];
        if (i+1 < n && s[i] == 'A' && s[i+1] == 'C') {
            sum[i+1]++;
        }
        // cout << sum[i+1] << endl; 
    }
    rep(i,q) {
        int l, r; cin >> l >> r;
        l--, r--;
        cout << sum[r] - sum[l] << endl;
    }
    return 0;
}

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

using namespace std;

int clr[111][111];

int n;

void color(int h, int w, int c)
{
    int x = n / w;
    int y = x % 2 ? n % w : w - 1 - n % w;
    clr[x][y] = c;
    n++;
}

signed main()
{
    //freopen("input.txt", "r", stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);
    int H, W;
    cin >> H >> W;
    int n;
    cin >> n;
    for(int i = 0; i < n; i++)
    {
        int a;
        cin >> a;
        for(int j = 0; j < a; j++)
            color(H, W, i + 1);
    }
    for(int h = 0; h < H; h++)
        for(int w = 0; w < W; w++)
            cout << clr[h][w] << " \n"[w + 1 == W];
}
//1001


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        int H,W;
        Scanner sc = new Scanner(System.in);
        while(true){
            H = sc.nextInt();
            W = sc.nextInt();
            if(H == 0 && W == 0)break;
            for(int j=0;j<W;j++){
                System.out.printf("#");
            }
            System.out.println();

            for(int i=0;i<H-2;i++){
                System.out.printf("#");
                for(int j=0;j<W-2;j++){
                    System.out.printf(".");
                }
                System.out.printf("#");
                System.out.println();
            }

            for(int j=0;j<W;j++){
                System.out.printf("#");
            }
            System.out.println();
            System.out.println();
            
        }
    }
}


Measured memory_bytes: 54728
#include <iostream>
#include <cmath>
using namespace std;
long long n, a[200001], r=0, x;
int main() {
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> x;
		a[x]++;
	}
	for(int i=0;i<200000-1;i++){
		r=max(r,a[i]+a[i+1]+a[i+2]);
	}
	cout << r;
	return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

extern inline char gc() {
    static char RR[23456], *S = RR + 23333, *T = RR + 23333;
    if(S == T) fread(RR, 1, 23333, stdin), S = RR;
    return *S ++;
}
inline int read() {
    int p = 0, w = 1; char c = gc();
    while(c > '9' || c < '0') { if(c == '-') w = -1; c = gc(); }
    while(c >= '0' && c <= '9') p = p * 10 + c - '0', c = gc();
    return p * w;
}

#define sid 100050
#define ri register int

int a[sid];
int n, ans;

int main() {
    n = read();
    for(ri i = 1; i <= n; i ++) a[read()] ++;
    for(ri i = 0; i <= 100000; i ++) {
        int ret = 0;
        if(i - 1 >= 0) ret += a[i - 1];
        ret += a[i] + a[i + 1];
        ans = max(ans, ret);
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 512
#include <iostream>

using namespace std;

int main()
{

    int test;   cin >> test;
    int AC = 0, WA = 0, TLE = 0, RE = 0;

    string stat;
    for (int i = 0; i < test; i++){

        cin >> stat;
        if (stat == "AC"){AC++;}
        if (stat == "WA"){WA++;}
        if (stat == "TLE"){TLE++;}
        if (stat == "RE"){RE++;}
    }

    cout << "AC x " << AC << endl;
    cout << "WA x " << WA << endl;
    cout << "TLE x " << TLE << endl;
    cout << "RE x " << RE << endl;

    return 0;
}


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

#define rep(i, x, n) for (int i = x; i < n; i++)
typedef long long ll;

const int INF = 1e9 + 7;

using namespace std;

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

	ll n;
	cin >> n;

	if (n % 2) {
		cout << 0 << endl;
	} else {
		ll res = 0;
		n /= 2;
		while (n) {
			res += n / 5; // kirisute
			n /= 5;
		}
		cout << res << endl;
	}

	return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<vector>
#include<set>
#include<queue>
#include<cstdlib>
#include<algorithm>

using namespace std;
#define pb push_back
#define mp make_pair
#define SZ(x) (int)(x).size()

typedef long long LL;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<LL, LL> pll;

const double eps = 1e-10;
const double PI = acos(-1.0);
//const double PI = 3.14159265358979323846264338327950288419716939937510
int dcmp(const double &x) { if (fabs(x) < eps) return 0; return x < 0 ? -1 : 1; }
const int MOD = 1e9 + 7;
const int INF = 2e9;
const double INF_d = 1e64;

template<class T> 
T qmod(T a, T b){ T ret = 1; while (b){ if (b & 1) ret *= a; b >>= 1; a *= a; } return ret; }
template<class T>
T gcd(T a, T b){ return !b ? a : gcd(b, a % b); }
template<class T>
T ex_gcd(T a, T b, T &x, T &y){
    if (!b){ x = 1, y = 0; return a; }
    T t, ret;
    ret = ex_gcd(b, a % b, x, y);
    t = x, x = y, y = t - a / b * y;
    return ret;
}
template<class T>
T inv(T t, T p){ return t == 1 ? 1 : (p - p / t) * inv(p % t, p) % p; }
// head

typedef double db;

struct point{
    db x, y;
    point(){}
    point(db a, db b): x(a), y(b){}
    point operator + (const point &p){ return point(x + p.x, y + p.y); }
    point operator - (const point &p){ return point(x - p.x, y - p.y); }
    point operator * (const db &k){ return point(x * k, y * k); }
    point operator / (const db &k){ return point(x / k, y / k); }
    db operator ^ (const point &p){ return x * p.y + y * p.x; }
    db operator * (const point &p){ return x * p.x + y * p.y; }
    bool operator == (const point &p){ return !dcmp(x - p.x) && !dcmp(y - p.y); }
    bool operator != (const point &p){ return dcmp(x - p.x) || dcmp(y - p.y); }
    bool operator < (const point &p){ return x == p.x ? y < p.y : x < p.x; }
    void read(){
        scanf("%lf%lf", &x, &y);
    }
    void print(){
        printf("%.10f %.10f\n", x, y);
    }
    point rotate(db &ang){ return point(x * cos(ang) - y * sin(ang), y * cos(ang) + x * sin(ang)); }
    point norm() { return point(-y, x); }
    db len() { return sqrt(x * x + y * y); }
    db len2(){ return x * x + y * y; }
};

point proj(point A, point B, point P){ // projection point of P in segment AB
    point AB = B - A, AP = P - A;
    return A + AB * (AP * AB / AB.len2());
}

point refl(point A, point B, point P){ // reflection point of P int segment AB
    return proj(A, B, P) * 2 - P;
}

point a, b;
int n;

int main(){
    a.read(), b.read();
    scanf("%d", &n);
    for (int i = 0; i < n; i++){
        point x; x.read();
        refl(a, b, x).print();
    }
    return 0;
}


Measured memory_bytes: 3220
n = int(input())
h = [] #happiness
for i in range(n):
 a_input, b_input, c_input = map(int, input().split())
 h.append([a_input, b_input, c_input]) 
dp = [[0 for _ in range(3)] for _ in range(n+1)]
for i in range(1, n+1):
 for j in range(3):
   for k in range(3):
     if j != k and dp[i][j] < dp[i-1][k] + h[i-1][j]:
       dp[i][j] = dp[i-1][k] + h[i-1][j]
ans = 0
for j in range(3):
 if ans < dp[n][j]:
   ans = dp[n][j]
print(ans)

Measured memory_bytes: 48804
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class D
{
	public static void Main() => (new Solver()).Solve();
}

public class Solver
{
	public void Solve()
	{
		int S = GetInt();
		WriteLine($"{S / 3600}:{(S % 3600) / 60}:{S % 60}");
	}
}

public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static decimal GetDecimal() => decimal.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(long N) => Enumerable.Range(0, (int)N).Select(_ => GetInt()).ToArray();
	public static long[] GetLongs(long N) => Enumerable.Range(0, (int)N).Select(_ => GetLong()).ToArray();
	public static double[] GetDoubles(long N) => Enumerable.Range(0, (int)N).Select(_ => GetDouble()).ToArray();
	public static decimal[] GetDecimals(long N) => Enumerable.Range(0, (int)N).Select(_ => GetDecimal()).ToArray();
	public static string[] GetStrings(long N) => Enumerable.Range(0, (int)N).Select(_ => GetString()).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) < 0)
			x = y;
	}

	public static void chmin<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) > 0)
			x = y;
	}

	public static void swap<T>(ref T x, ref T y)
	{
		T tmp = x;
		x = y;
		y = tmp;
	}
}


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

int main(){
  int flag,n,s[1001],p[1001],q[1001],r[1001],pp,qq,rr,cc;
 
  while(1){
    flag=0;
    int c[1001]={};
    cin >> n;
    if(n==0){
      break;
    }
    for(int i=0;i<n;i++){
      cin >> s[i] >> p[i] >> q[i] >> r[i];
      c[i]=4*p[i]+9*q[i]+4*r[i];
    }
    cin >> pp >> qq >> rr >> cc;
    for(int i=0;i<n;i++){
      if(p[i]<=pp && q[i]<=qq && r[i]<=rr && c[i]<=cc){
	cout << s[i] << '\n';
	flag=1;
      }
    }
    if(flag==0){
      cout << "NA\n";
    }
  }
  return 0;
}



Measured memory_bytes: 3104
/* ファイル名：ITP1_8_B.c	*/
/* 内容：与えられた数の各桁の和を計算する	*/

/* include	*/
#include <stdio.h>

/* 外部変数宣言	*/

/* プロトタイプ宣言	*/

/* 関数名:main	*/
/* 処理内容:与えられた数の各桁の和を計算する	*/
int main( void )
{
	/* 内部変数定義	*/
	/* 入力	*/
	char num[1001];	/* 与えられる整数	*/
	
	/* 処理	*/
	int sum;		/* 各桁の合計		*/
	int i;			/* ループ用変数		*/
	
	/* 無限ループ	*/
	while(1){
		sum = 0;	/* 各桁の合計の初期化	*/
		
		scanf("%s",num);	/* 整数の取得	*/
		
		/* 0が入力された場合	*/
		if(num[0] == '0'){
			break;	/* 処理を終了する	*/
		}
		/* 0以外の場合	*/
		else{
			/* 処理を続行する	*/
		}
		
		/* 整数の最後の桁までループ	*/
		for(i = 0; num[i] != '\0'; i++){
			sum += (num[i] - '0');	/* 数値に変換し、各桁の合計に加算	*/
		}
		
		/* 結果の出力	*/
		printf("%d\n",sum);
	}
	return 0;
}



Measured memory_bytes: 2068
// #pragma GCC target("avx2")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<complex>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3100000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
}
// ここから編集しろ

int main(){
	for(int i=0;i<10000;i++){printf("-1\n");fflush(stdout);}
}


Measured memory_bytes: 1104
use proconio::{fastout, input, marker::Chars};

#[fastout]
fn main() {
    input!(s: Chars);

    let mut count_0 = 0;
    let mut count_1 = 0;

    for v in &s {
        if *v == '0' {
            count_0 += 1;
        } else {
            count_1 += 1;
        }
    }

    println!("{}", std::cmp::min(count_0, count_1) * 2);
}


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


void func() {
    int N;
    cin >> N;
    vector<long  long> arr = vector<long long>(N,0);
    long  long sum = 0;
    for (int i = 1; i <= N; ++i) {
        int a;
        cin >> a;
        arr[i - 1] = a - i;
        sum += a - i;
    }
    sort(arr.begin(),arr.end());
    long long currentSum = 0;
    long long target = INT64_MAX;

    for (int j = 0; j < N; ++j) {
       target = min(target,j * arr[j] - currentSum + (sum - currentSum - arr[j] * (N - j)));
       currentSum += arr[j];
    }


    cout << target << endl;
}
int main() {
    func();
    return 0;
}


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

typedef long long ll;
ll mod = 1000000007;
const double PI = 3.141592653589793238460;
const int INF = 1e9+5;

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;
    double p[n];

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

    vector<vector<double>> dp(n+1,vector<double>(n+1));

    dp[0][0]=1.0;
    for(int i=1; i<=n; i++) dp[0][i]=0;

    for(int i=1; i<=n; i++){
        for(int j=0; j<=n; j++){
            if(j==0){
                dp[i][j] = (double)(dp[i-1][j]*(1.0-p[i-1]));
            }else{
                dp[i][j] = (double)((double)dp[i-1][j-1]*p[i-1]+(double)dp[i-1][j]*(1.0-p[i-1]));
            }
        }
    }

    // for(int i=0; i<=n; i++){
    //     for(int j=0; j<=n; j++) cout<<dp[i][j]<<' ';
    //     cout<<'\n';
    // }

    double ans = 0;
    for(int i=1; i<=n; i++){
        if(i>n-i){
            ans+=dp[n][i];
        }
    }

    cout<<setprecision(10)<<ans<<'\n';

    return 0;
}


Measured memory_bytes: 73732
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>

using namespace std;

int main()
{
    string s;
    int n, k;

    cin >> n >> s >> k;

    for (int i = 0; i < n; i++) {
        if (s[k-1] != s[i]) {
            s[i] = '*';
        }
    }

    cout << s << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
    int a,b[2000],i,j,n,m,x,y,z=0;
 
    scanf("%d",&n);
    for (size_t i = 0; i < n; i++)
    {
        scanf("%d",&b[i]);
    }
    for(i=0;i<n;i++)
      for(j=i+1;j<n;j++)
          z+=b[i]*b[j];

          printf("%d\n",z);
        return 0;
}

Measured memory_bytes: 128
N = int(input())
a = [[0] * 9 for i in range(1, 10)]
b = [[0] * 9 for i in range(1, 10)]
sum_a = 0
for A in range(1,N+1):
    list_a = str(A)
    if list_a[-1] == '0':
        continue
    a[int(list_a[0])-1][int(list_a[-1])-1] += 1
    b[int(list_a[-1])-1][int(list_a[0])-1] += 1
for i in range(9):
    for j in range(9):
        sum_a += a[i][j]*b[i][j]
print(sum_a)    
        
        

Measured memory_bytes: 3064
#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;

vector<ll> S;
int x[3] = {3, 5, 7};

bool check(ll n)
{
    REP(i, 3)
    {
        ll t = n;
        while (t > 0)
        {
            int k = t % 10;
            if (k == x[i])
                break;
            t /= 10;
            if (t == 0)
                return false;
        }
    }
    return true;
}

void create(ll n, int m)
{
    if (m == 0)
    {
        if (check(n))
            S.push_back(n);
        return;
    }
    n *= 10;
    REP(i, 3)
    {
        create(n + x[i], m - 1);
    }
    return;
}

int main()
{
    ll N;
    cin >> N;
    FOR(i, 10, 3)
    {
        create(0, i);
    }

    int ans = 0;
    REP(i, S.size())
    {
        if (N >= S[i])
        {
            ans = i + 1;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
import std.stdio, std.string, std.conv;
import std.typecons;
import std.algorithm, std.array, std.range, std.container;
import std.math;

void main() {
	auto data = readln.split;
	auto N = data[0].to!int, T = data[1].to!int;
	
	int cost = 10_000;
	foreach (i; 0 .. N) {
		data = readln.split;
		auto c = data[0].to!int, t = data[1].to!int;
		if (t <= T && c < cost) { cost = c; }
	}
	
	if (cost == 10_000) writeln("TLE");
	else writeln(cost);
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define PRINT(a)   cout << (a) << endl
#define RALL(v) rbegin(v), rend(v)

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second

#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

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

template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

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

const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;

int main(){
  int N, K;
  cin >> N >> K;

  vi a(N);

  REP(i,N)cin >> a[i];

  REP(i, K){
    vi s(N+1,0);
    REP(j,N){
      int l = max(j-a[j], 0);
      int r = min(j+a[j]+1, N);
      s[l]+=1;
      s[r]-=1;
    }
    a[0]=s[0];
    REP(j,N){
      s[j+1] = s[j] + s[j+1];
    }
    int mi = INF;
    REP(j,N){
      a[j] = s[j];
      chmin(mi, a[j]);
    }
    if(mi == N)break;
  }

  REP(i,N){
    cout << a[i] << (i==N-1 ? "\n" : " ");
  }
}



Measured memory_bytes: 4852
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()

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

int main()
{	
	string N;
	cin >> N;

	int total = 0;
	repl(i, 1, N.size())
	{
		if (N[i] == N[i - 1])
		{
			N[i] = N[i] == '0' ? '1' : '0';
			total++;
		}
	}

	cout << total << endl;

	return 0;
}

Measured memory_bytes: 512
import scala.io.StdIn

object Main extends App {

  val q = StdIn.readLine()
  
  def solve(s: String): Int = {
    val (s1, s2) = s.splitAt(s.length/2)
    if(s1 == s2) s.length
    else solve(s.tail)
  } 
  
  println(solve(q.reverse.tail))
  
}


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

int main(){
  char a;
  cin >> a;
  if(a>='A'&&a<='Z'){
    cout << "A";
  }else{
    cout << "a";
  }
}

Measured memory_bytes: 3552
n = int(input())
s = [input() for i in range(n)]

for i in range(n):
    s[i] = ''.join(sorted(s[i]))

s.sort()

memo = 1
ans = 0
for i in range(n-1):
    if s[i] == s[i+1]:
        memo += 1
    else:
        ans += memo*(memo-1)//2
        memo = 1
    
ans += memo*(memo-1)//2
print(ans)

Measured memory_bytes: 10584
#!/usr/bin/env python3
import sys, math, itertools, heapq, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
sys.setrecursionlimit(10**8)
inf = float('inf')
ans = count = 0

n,m,x,y=map(int,input().split())
X=list(map(int,input().split()))
Y=list(map(int,input().split()))
x+=1
xm=max(X)+1;ym=min(Y)
if x>y or xm>ym:
    print("War")
    exit()
if xm<=y and ym>=x:
    print("No War")
else:
    print("War")

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

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

int main(){
    int a, b;
    cin >> a >> b;
    if (a <= 5) cout << 0 << endl;
    else if (a >= 6 && a <= 12) cout << (b / 2) << endl;
    else cout << b << endl;
    return 0;
}


Measured memory_bytes: 256
import Control.Monad
import Data.List
main = do
    [h, w] <- map read . words <$> getLine :: IO [Int]
    getLine
    as <- map read . words <$> getLine
    mapM_ putStrLn $ map (intercalate " ") $ zipWith ($) (cycle [id, reverse]) $ splitRec w $ concat $ zipWith replicate as $ map show [1..]
  where
    splitRec _ [] = []
    splitRec k xs = let (t,d) = splitAt k xs in t : splitRec k d

Measured memory_bytes: 2428
n = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
#print(A)
Alice = []
Bob = []
for i in range(n):
    if i%2 != 0:
        Alice.append(A[i])
    else:
        Bob.append(A[i])
print(abs(sum(Alice) - sum(Bob)))

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


////////// 	Template structure for debugging

#define tr(...) trace(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void trace(const char* name, Arg1&& arg1){
cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void trace(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cout.write(names, comma-names) << " : " << arg1 << " | " ; 

trace(comma+1, args...);
}

#define print(...) pr(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void pr(const char* name, Arg1&& arg1){
cout << arg1 << endl;
}
template <typename Arg1, typename... Args>
void pr(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cout << arg1 << " "; 
pr(comma+1, args...);
}

void printV(vector<int> &arr)
{
for(int i=0;i<arr.size();i++)cout << arr[i] << " \n"[ i == arr.size()-1 ];
}

///////////////// Fenwick Tree 
// void update(int index,int num){

// 	while(index<=N){
// 		arr[index] += num;
// 		index += index & (-index);
// 		//cout << index << endl;
// 	}

// }

// int sum(int index){

// 	int s = 0;
// 	while(index){
// 		s += arr[index];
// 		index -= index & (-index);
// 	}
// 	return s;
// }

//////////////////////////////////////////////

/////////////////// Type definitions
typedef long long ll;
typedef pair<int,int> pi;
#define f first
#define s second
////////////////////////////////////////////////////////////////////////////

int t;

void solve(){

	

}	

int main(){

	
	int n,k;
	cin >> n >> k;
	vector<ll> arr(n),dp(n,INT_MAX);
	for(int i=0;i<n;i++)cin >> arr[i];
	dp[0] = 0;
		
	for(int i=1;i<n;i++)
		for(int j = max(0,i-k);j<i;j++)
			dp[i] = min(dp[i],dp[j]+abs(arr[i]-arr[j]));
	print(dp[n-1]);

}

Measured memory_bytes: 4856
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
using namespace std;

int main(){
    string s;
    int A, B;
    double T;
    cin>>A>>B>>T;

    cout <<((int)( T / A )) * B << endl;
 
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
#define int long long
#define V vector
#define vel V<int>
#define rep(i,n) for(int i=0;i<n;i++)
#define mkp make_pair
#define pin pair<int,int>
pin solve(V<pin>& ab, int ex) {
	if (!ex) { return mkp(0, 0); }
	V<V<pin>> qab(2);
	int sz = ab.size();
	qab[0].reserve(sz);
	qab[1].reserve(sz);
	for (pin& x : ab) {
		qab[x.second & 1].push_back(mkp(x.first / 2, x.second / 2));
		if (x.first & 1) { qab[(x.second + 1) & 1].push_back(mkp(x.first / 2, (x.second + 1) / 2)); }
	}
	int c = 0;
	for (pin& x : qab[0]) {
		int qc = (2 * x.first + x.second) % 3;
		c ^= (qc + 1);
	}
	if (!c) {
		pin ans = solve(qab[1], ex - 1);
		ans.first *= 2; ans.second *= 2; ans.second++;
		return ans;
	}
	pin ans = solve(qab[0], ex - 1);
  	c=0;
  	for (pin& x : qab[1]) {
		int qc = (2 * x.first + x.second) % 3;
		c ^= (qc + 1);
	}
  	if (!c) {
		ans.first *= 2; ans.second *= 2;
		return ans;
	}
	c = 0;
	for (pin& x : qab[1]) {
		int w = ans.second - x.second-1;
		if ((w & x.first) == w) { c ^= 1; }
	}
	ans.first *= 2; ans.first++; ans.second *= 2; ans.second -= c;
	return ans;
}
signed main() {
	cin.tie(0); ios::sync_with_stdio(false);
	long long inf = 1e17;
	int n; cin >> n;
	V<pin> ab(n);
	rep(i, n) {
		long long a, b; cin >> a >> b;
		ab[i] = { a + inf,b + inf };
	}
	pin ret = solve(ab, 59);
	cout << ret.first - inf << " " << ret.second - inf << "\n";
}


Measured memory_bytes: 10536
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(){
	int w,h,n;
	cin>>w>>h>>n;
	int x[100],y[100],f[100];
	for(int i=0;i<n;i++)cin>>x[i]>>y[i]>>f[i];
	int a=0,b=w,c=0,d=h;
	for(int i=0;i<n;i++){
		if(f[i]==1)a=max(a,x[i]);
		if(f[i]==2)b=min(b,x[i]);
		if(f[i]==3)c=max(c,y[i]);
		if(f[i]==4)d=min(d,y[i]);
	}
	cout<<max(0,b-a)*max(0,d-c)<<endl;
    return 0;
}

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

using namespace std;

typedef long long ll;

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

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

int main(void) {
    int N;
    cin >> N;

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

    sort(B.begin(), B.end());
    int fst = B[N - 1];
    int snd = B[N - 2];

    for (int i = 0; i < N; i++) {
        if (A[i] == fst) {
            cout << snd << endl;
        } else {
            cout << fst << endl;
        }
    }
    
    return 0;
}


Measured memory_bytes: 3200
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int s[105];
	int a;
	cin >> a;
	for(int i=0;i<a;i++)
	{
		cin >> s[i];
	}
	sort(s,s+a);
	cout << s[a-1]-s[0];
	return 0;
}

Measured memory_bytes: 256
S = input()
SL = [i for i in S]
sublist = [-1]*(len(S)-1)
anslist = []
ans = []
for i in range(1<<len(S)-1):
    for j in range(len(S)-1):
        if ((i>>j)&1)==1:
            sublist[j] = "+"
    anslist.append(SL[0])
    for j in range(len(S)-1):
        if sublist[j] == "+":
            anslist.append(sublist[j])
            anslist.append(SL[j+1])
        else:
            anslist.append(SL[j+1])
    ans.append(eval("".join(anslist)))
    anslist = []
    sublist = [-1]*(len(S)-1)
print(sum(ans))

Measured memory_bytes: 3064
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

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

typedef long long ll;
typedef long double ld;
typedef double db;
typedef string str;

typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef pair<db,db> pd;

typedef vector<int> vi; 
typedef vector<ll> vl; 
typedef vector<db> vd; 
typedef vector<str> vs; 
typedef vector<pi> vpi;
typedef vector<pl> vpl; 
typedef vector<pd> vpd; 

#define mp make_pair
#define f first
#define s second
#define sz(x) (int)(x).size()
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend() 
#define rsz resize
#define ins insert 
#define ft front() 
#define bk back()
#define pf push_front 
#define pb push_back
#define eb emplace_back 
#define lb lower_bound 
#define ub upper_bound 

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)

const int MX  = 2e5+5; 
const int MOD = 1e9+7; // 998244353;
const ll  INF = 1e18; 
const ld  PI  = acos((ld)-1);

const int xd[4] = {1,0,-1,0}, yd[4] = {0,1,0,-1};
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count()); 

template<class T> bool ckmin(T& a, const T& b) { 
	return b < a ? a = b, 1 : 0; 
}
template<class T> bool ckmax(T& a, const T& b) { 
	return a < b ? a = b, 1 : 0; 
} 

constexpr int pct(int x) { return __builtin_popcount(x); } // number of ones 
constexpr int bits(int x) { return 31-__builtin_clz(x); } // floor(log2(x)) 
template<class T> T cdiv(T a, T b) { return a/b+!(a<0||a%b == 0); } // division of a by b rounded up, assumes b > 0 

int fstTrue(function<bool(int)> f, int lo, int hi) {
	hi++; assert(lo <= hi); // assuming f is increasing
	while (lo < hi) { // find first index such that f is true 
		int mid = (lo+hi)/2; 
		f(mid) ? hi = mid : lo = mid+1; 
	} 
	return lo;
}

template<class T> void remDup(vector<T>& v) { 
	sort(all(v)); v.erase(unique(all(v)),end(v)); 
}

// DEBUG
void DBG() { cerr << "]" << endl; }
template<class H, class... T> void DBG(H h, T... t) {
	cerr << h; if (sizeof...(t)) cerr << ", ";
	DBG(t...); 
}
#define dbg(...) cerr << "LINE(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "]: [", DBG(__VA_ARGS__)

// FILE I/O
void setIn(str S) { freopen(S.c_str(),"r",stdin); }
void setOut(str S) { freopen(S.c_str(),"w",stdout); }
void setIO(str S = "") {
	ios_base::sync_with_stdio(0); cin.tie(0); // fast I/O
	// cin.exceptions(cin.failbit); 
	// throws exception when do smth illegal
	// ex. try to read letter into int
	if (sz(S)) { setIn(S+".in"), setOut(S+".out"); } // for USACO
}

int cmp(string x, string y) {
    int res = 0;
    F0R(i,sz(x)) res += x[i] != y[i];
    return res;
}

int32_t main() { 
	
	setIO();

    string S,T; cin >> S >> T;

    int res = MOD;
    F0R(i,sz(S)) {
        if (i+sz(T)-1 >= sz(S)) break;
        string subs = S.substr(i,sz(T));
        res = min(res,cmp(subs,T));
    }

    cout << res << "\n";

}

Measured memory_bytes: 3600
#include <stdio.h>
#include <ctype.h>
#include <string.h>

#define LENGTH 1200

int main()
{
  int i;
  char st[LENGTH] = {};

  fgets(st, LENGTH, stdin);

  for( i = 0 ; i < strlen(st) ; i++ )
  {
    if( isupper(st[i]) )
    {
      st[i] = st[i] + 32;
    }
    else if( islower(st[i]) )
    {
      st[i] = st[i] - 32;
    }
  }
  printf("%s", st);
}



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

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for(int i=0;i<N;i++){
    cin >> a[i];
  }
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  long square=0;
  long x=0,y=0 ;
  int tmpx,tmpy,I;
  bool flg=false;
  for(int i=0;i<N;i++){
    tmpx=a[i];
    for(int j=i+1;j<min(N,i+4);j++){
      if(tmpx==a[j]){
        I =i;
       x=a[j];
       flg=true;
       break;
     }
    }
    if(flg) break;
  }

//  cout << I << endl;
  flg=false;
  for(int k=I+2;k<N;k++){
    tmpy=a[k];
      //cout << tmpy << endl;
    for(int l=k+1;l<min(N,k+4);l++){
      if(tmpy==a[l]) {
        y=a[l];
        flg=true;
        break;
      }
    }
      if(flg) break;
  }

  square = x*y;
//  cout << x << endl;
//  cout << y << endl;
  cout << square << endl;


}


Measured memory_bytes: 640