akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<cassert>

using namespace std;

#define sz(x) (int)(x.size())
#define fi(a,b) for(int i=a;i<b;++i)
#define fj(a,b) for(int j=a;j<b;++j)
#define fo(a,b) for(int o=a;o<b;++o)
#define fdi(a,b) for(int i=a-1;i>=b;--i)
#define fdj(a,b) for(int j=a-1;j>=b;--j)
#define fdo(a,b) for(int o=a-1;o>=b;--o)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
/////////////////////

int const N = 1e5 + 41;

int const K = 2e3 + 41;

int n, k;
int x[N], y[N], a[N];
char c[N];
int ans;
int d[2][K][K];
int m;

int getmod(int n){
	n %= m;
	return n;
}

void build(){
	fo(0, 2){
		fi(0, m){
			fj(0, m){
				if(i) d[o][i][j] += d[o][i-1][j];
				if(j) d[o][i][j] += d[o][i][j-1];
				if(i && j) d[o][i][j] -= d[o][i-1][j-1];
			}
		}
	}
}

int getsum(int y0, int x0, int y1, int x1, int d[K][K]){
	y1 = min(y1, m-1);
	x1 = min(x1, m-1);
	x0 = max(x0, 0);
	y0 = max(y0, 0);
	if(x0 > x1 || y0 > y1) return 0;
	int res = 0;
	if(x1 < m && y1 < m){
		res += d[y1][x1];
	}
	if(x0 && y1 < m){
		res -= d[y1][x0-1];
	}
	if(y0 && x1 < m){
		res -= d[y0-1][x1];
	}
	if(x0 && y0){
		res += d[y0-1][x0-1];
	}
	return res;
}

void solve(){
	m = k * 2;
	int b = 0;
	int w = 0;
	fi(0, n) a[i] = (c[i] == 'W' ? 0 : 1);
	fi(0, n){
		b += a[i];
		w += (1 - a[i]);
	}
	fi(0, n){
		x[i] = getmod(x[i]);
		y[i] = getmod(y[i]);
		d[a[i]][y[i]][x[i]] += 1;
	}
#ifdef _DEBUG
	/*fo(0, 2){
		printf("\n");
		fi(0, m){
			fj(0, m){
				printf("%d",d[o][i][j]);
			}
			printf("\n");
		}
	}*/
#endif
	build();
	fi(0, k) fj(0, k){
		//w
		int v00 = getsum(i, j, i+k-1, j+k-1, d[0]);
		int v01 = getsum(0, 0, i-1, j-1, d[0]);
		int v02 = getsum(0, j+k, i-1, m-1, d[0]);
		int v03 = getsum(i+k, j+k, m-1, m-1, d[0]);
		int v04 = getsum(i+k, 0, m-1, j-1, d[0]);
		//b
		int v10 = getsum(i, j, i+k-1, j+k-1, d[1]);
		int v11 = getsum(0, 0, i-1, j-1, d[1]);
		int v12 = getsum(0, j+k, i-1, m-1, d[1]);
		int v13 = getsum(i+k, j+k, m-1, m-1, d[1]);
		int v14 = getsum(i+k, 0, m-1, j-1, d[1]);
		int sum = v00 + v01 + v02 + v03 + v04;
		sum -= (v10 + v11 + v12 + v13 + v14);
		sum += b;
		ans = max(ans, sum);
	}
	fi(0, k) fj(0, k){
		//w
		int v00 = getsum(i, j, i+k-1, j+k-1, d[0]);
		int v01 = getsum(0, 0, i-1, j-1, d[0]);
		int v02 = getsum(0, j+k, i-1, m-1, d[0]);
		int v03 = getsum(i+k, j+k, m-1, m-1, d[0]);
		int v04 = getsum(i+k, 0, m-1, j-1, d[0]);
		//b
		int v10 = getsum(i, j, i+k-1, j+k-1, d[1]);
		int v11 = getsum(0, 0, i-1, j-1, d[1]);
		int v12 = getsum(0, j+k, i-1, m-1, d[1]);
		int v13 = getsum(i+k, j+k, m-1, m-1, d[1]);
		int v14 = getsum(i+k, 0, m-1, j-1, d[1]);
		int sum = v10 + v11 + v12 + v13 + v14;
		sum -= (v00 + v01 + v02 + v03 + v04);
		sum += w;
		ans = max(ans, sum);
	}
}

int main(){
#ifdef _DEBUG
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif

	scanf("%d %d",&n,&k);
	fi(0, n){
		scanf("%d %d %c\n",&x[i],&y[i],&c[i]);
	}

	solve();

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

	return 0;
}

Measured memory_bytes: 34048
#include <iostream>
#include <algorithm>
using namespace std;
int a[100];

int main(){
    int n,minj,count = 0;
    cin >> n;
    for(int i = 0;i < n;i++)
        cin >> a[i];

    for(int i = 0;i < n;i++){
        minj = i;
        for(int j = i;j < n;j++){
            if(a[j] < a[minj])
                minj = j;
        }
        if(i != minj){
            swap(a[i],a[minj]);
            count++;
        }
    }

    for(int i = 0;i < n;i++){
        if(i == 0)
            cout << a[i];
        else
            cout << ' ' << a[i];
    }
    cout << '\n' << count << endl;

    return 0;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define INF9 1000000000 //10^9
#define MOD 1000000007 //10^9+7
#define fi first
#define sc second
using ll=long long;
using pii=pair<ll,ll>;
using vi=vector<int>;

int main() {
    int n; cin >> n;
    int sum = 0;
    int tmp = n;
    while(tmp > 0) {
        sum += tmp%10;
        tmp /= 10;
    }
    // printf("n:%d sum:%d ans:%d\n",n,sum,n%sum);
    cout << (n%sum==0?"Yes":"No") << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int i,n,k,s,ans;
  scanf("%d %d %d\n",&n,&k,&s);
  if(s==1000000000){
    for(i=0;i<n;i++){
    if(i<k){
      ans=s;
    }
    else{
      ans=s-1;
    }
    if(i==0){
      printf("%d",ans);
    }
    else{
      printf(" %d",ans);
    }
  }
    return 0;
  }
  for(i=0;i<n;i++){
    if(i<k){
      ans=s;
    }
    else{
      ans=s+1;
    }
    if(i==0){
      printf("%d",ans);
    }
    else{
      printf(" %d",ans);
    }
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 1280
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<map>
#include<sstream>
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
bool check(int n){
  ostringstream os;
  os << n;
  string s=os.str();
  for(int i=0;i<s.size();i++){
    if(s[i]!=s[s.size()-i-1]){
      return false;
    }
  }
  return true;
}
int main(){
  int N=10000;
  vector<int> pn;
  rep(i,N+1){
    if(check(i))
    pn.pb(i);
  }
  int n;
  while(cin>>n){
    int ans=0;
    for(int i=0;i<pn.size();i++){
      if(abs(pn[i]-n)<abs(ans-n)){
	ans=pn[i];
      }
    }
    cout<<ans<<endl;

  }
  return 0;
}

Measured memory_bytes: 1240
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
/*
//#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
*/

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
/*
//#if __cplusplus >= 201103L
#include <array>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
*/
using namespace std;
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl

#define uni(x) x.erase(unique(all(x)),x.end())
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;

#define INF INT_MAX/3
#define MAX_N 1000
#define M_INF 1000000000
int n,m,v,i;
void solve(){
   cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin>>s;
  rep(i,s.size()-1){
    if(s[i]=='A'&&s[i+1]=='C'){

      cout<<"Yes"<<endl;
      return;
    }
  }
   cout<<"No"<<endl;
  return;

}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
 
const ll INF = 1LL<<60;
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; }
using Graph = vector<vector<int>>;

typedef pair<int, int> P;
typedef priority_queue<int, vector<int>, greater<int>> PQ;
const int MOD = 1000000007;


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

    cout << a + pow(a,2) + pow(a,3) << endl;
}

Measured memory_bytes: 4124
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)

#debug = True
debug = False

def dprint(*objects):
    if debug == True:
        print(*objects)

def print_ans(edge):
    print(len(edge))
    for e in edge:
        e0 = e[0] + 1
        e1 = e[1] + 1
        print(e0, e1)

def solve():
    N, K = map(int, input().split())
    nm1c2 = ((N - 1) * (N - 2)) // 2
    if K > nm1c2:
        print(-1)
        return

    node = [i for i in range(N)]
    edge = []

    for i in range(1, N):
        edge.append((0, i))

    dprint(edge)

    count = 0
    for i in range(1, N):
        for j in range(i+1, N):
            if nm1c2 - K - count == 0:
                print_ans(edge)
                return
            else:
                edge.append((i, j))
                count+= 1
    print_ans(edge)

solve()

Measured memory_bytes: 3992
import java.util.Scanner;

public class Main {
    public static void main(String[] arg){
        Scanner sc = new Scanner(System.in);
        while(true){
        int a = sc.nextInt();
        int b = sc.nextInt();
        if(a==0&&b==0) break;
        for(int i=0;i<a;i++){
            for(int j=0;j<b;j++){
                if(i==0||i==a-1) {
                    System.out.print("#");
                }else if(j==0||j==b-1){
                    System.out.print("#");
                }else{
                    System.out.print(".");
                }
            }
            System.out.println("");
        }
        System.out.println("");
    }
        sc.close();
    }
}


Measured memory_bytes: 34408
#!/usr/bin/env python3
import sys


def solve(a: int, b: int, c: int, d: int):
    ac = a*c
    ad = a*d
    bc = b*c
    bd = b*d
    solve = [ac, ad, bc, bd]
    solve = sorted(solve)
    return print(solve[-1])




# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    a = int(next(tokens))  # type: int
    b = int(next(tokens))  # type: int
    c = int(next(tokens))  # type: int
    d = int(next(tokens))  # type: int
    solve(a, b, c, d)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9204
package main

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

const (
	limitSecs = 2.0
)

// D
var (
	D         int
	c         [26]int
	s         [][26]int
	startTime time.Time
)

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func calcScore(t []int) int {
	var last [26]int
	score := 0
	S := 0
	for i := 0; i < 26; i++ {
		last[i] = -1
	}
	for d := 0; d < len(t); d++ {
		S += s[d][t[d]]
		last[t[d]] = d
		for i := 0; i < 26; i++ {
			S -= c[i] * (d - last[i])
		}
		score += max(1000000+S, 0)
	}
	return score
}

func solution3() []int {
	var t []int
	for d := 0; d < D; d++ {
		score := -1
		best := -1
		t = append(t, 0)
		for i := 0; i < 26; i++ {
			t[len(t)-1] = i
			newScore := calcScore(t)
			if newScore > score {
				best = i
				score = newScore
			}
		}
		t[len(t)-1] = best
	}
	return t
}

func optimize1(t []int) []int {
	var (
		d   [3]int
		old [3]int
	)
	rand.Seed(time.Now().UnixNano())
	score := calcScore(t)
	for time.Now().Sub(startTime).Seconds()+0.015 < limitSecs {
		n := rand.Intn(3) + 1
		for i := 0; i < n; i++ {
			d[i] = rand.Intn(D)
			old[i] = t[d[i]]
			t[d[i]] = rand.Intn(26)
		}
		newScore := calcScore(t)
		if newScore < score {
			for i := n - 1; i > -1; i-- {
				t[d[i]] = old[i]
			}
		} else {
			score = newScore
		}
	}
	return t
}

func main() {
	defer flush()

	startTime = time.Now()

	D = readInt()
	for i := 0; i < 26; i++ {
		c[i] = readInt()
	}
	s = make([][26]int, D)
	for i := 0; i < D; i++ {
		for j := 0; j < 26; j++ {
			s[i][j] = readInt()
		}
	}

	t := solution3()
	t = optimize1(t)
	for d := 0; d < D; d++ {
		println(t[d] + 1)
	}
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}

var stdoutWriter = bufio.NewWriter(os.Stdout)

func flush() {
	stdoutWriter.Flush()
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdoutWriter, args...)
}


Measured memory_bytes: 2192
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#ifdef _DEBUG_
	#define debug(...) printf(__VA_ARGS__)
#else
	#define debug(...) (void)0
#endif
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;

const int MAXN = 2e5 + 100;
int x[MAXN];
ll dp[MAXN];

int main() {
	int N, Q, A, B;
	scanf("%d%d%d%d", &N, &Q, &A, &B);
	x[0] = A;
	x[1] = B;
	Q++;
	for(int i = 2; i <= Q; i++)
		scanf("%d", &x[i]);
	ll add = 0;
	set<PII> S;
	S.insert(MP(x[0], 0));
	dp[0] = 0;
	for(int i = 2; i <= Q; i++) {
#ifdef _DEBUG_
		for(auto u : S)
			debug("(%d, %d)\n", u.F, u.S);
#endif
		auto p = S.upper_bound(MP(x[i], -1));
		if(p == S.end()) p--;
		ll res = dp[p -> S] + add + abs(x[i] - p -> F);
		if(p != S.begin()) {
			auto q = p;
			q--;
			res = min(res, dp[q -> S] + add + abs(x[i] - q -> F));
		}
		debug("i: %d  res: %lld\n", i, res);
		add += abs(x[i] - x[i - 1]);
		dp[i - 1] = res - add;
		p = S.upper_bound(MP(x[i - 1], -1));
		if(p -> F >= x[i - 1]) {
			while(p != S.end()) {
				if(dp[i - 1] + abs(x[i - 1] - p -> F) <= dp[p -> S]) {
					auto tmp = p;
					p++;
					S.erase(tmp);
				}
				else
					break;
			}
		}
		if(p == S.end() && p != S.begin()) p--;
		if(p != S.end() && (p -> F < x[i - 1] || p != S.begin())) {
			if(p -> F >= x[i - 1]) p--;
			while(1) {
				if(dp[i - 1] + abs(x[i - 1] - p -> F) <= dp[p -> S]) {
					if(p != S.begin()) {
						auto tmp = p;
						p--;
						S.erase(tmp);
					}
					else {
						S.erase(p);
						break;
					}
				}
				else
					break;
			}
		}
		p = S.upper_bound(MP(x[i - 1], -1));
		bool servive = true;
		if(p != S.end() && dp[p -> S] + abs(x[i - 1] - p -> F) <= dp[i - 1]) servive = false;
		if(p != S.begin()) p--;
		if(p != S.end() && dp[p -> S] + abs(x[i - 1] - p -> F) <= dp[i - 1]) servive = false;
		if(servive) S.insert(MP(x[i - 1], i - 1));
#ifdef _DEBUG_
		ll n_res = dp[0] + add + abs(x[0] - x[i]);
		int t_add = add - abs(x[i] - x[i - 1]);
		for(int j = 1; j < i; j++) {
			n_res = min(n_res, dp[j] + t_add + abs(x[j] - x[i]));
		}
		debug("n_res: %lld %c\n", n_res, res == n_res ? ' ' : '!');
		for(int j = 0; j < i; j++)
			debug("cost[%d]: %lld\n", j, dp[j] + add);
#endif
	}
	debug("add: %lld\n", add);
	ll ans = 1ll * N * Q;
	for(int i = 0; i < Q; i++) {
		debug("dp[%d]: %lld\n", i, dp[i]);
		ans = min(ans, dp[i] + add);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 2560
import math
n = int(input())
[d,x] = [int(i) for i in input().split()]
sum = x

for i in range(n):
  a = int(input())
  d1 = 1
  counter = 0
  while d1 <= d:
    d1 += a
    counter += 1
  sum += counter
print(sum)

Measured memory_bytes: 3060
N, K = map(int, input().split())
A = list(map(int, input().split()))

def is_ok(n):
    cnt = 0
    for a in A:
        if n >= a:
            continue
        cnt += a // n
    return cnt <= K

def meguru_bisect(ng, ok):
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if is_ok(mid):
            ok = mid
        else:
            ng = mid
    return ok

print(meguru_bisect(0, 10**9+1))


Measured memory_bytes: 103956
let () = Scanf.scanf "%d\n" @@ fun n ->
  let ss = Array.init n @@ fun _ ->
    Scanf.scanf "%s\n" @@ fun s -> s in
  let dp = Array.make_matrix n n (-1) in
  for i = 0 to n - 1 do
    for j = 0 to n - 1 do
      if ss.(i).[j] = '1' then dp.(i).(j) <- 1
    done
  done;
  for i = 0 to n - 1 do
    dp.(i).(i) <- 0
  done;
  try
    for k = 0 to n - 1 do
      for i = 0 to n - 1 do
        for j = 0 to n - 1 do
          if 0 <= dp.(i).(k) && 0 <= dp.(k).(j)
          then begin
            if dp.(i).(j) < 0
            then dp.(i).(j) <- dp.(i).(k) + dp.(k).(j)
            else if dp.(i).(j) mod 2 <> (dp.(i).(k) + dp.(k).(j)) mod 2
            then raise Not_found
            else dp.(i).(j) <- min dp.(i).(j) (dp.(i).(k) + dp.(k).(j))
          end
        done
      done
    done;
    Printf.printf "%d\n" @@ succ @@
    Array.fold_left (Array.fold_left max) min_int dp
  with Not_found -> print_endline "-1"



Measured memory_bytes: 896
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(n) for(ll i=0; i<n; i++)
#define INF LLONG_MAX/2

vector<ll> dp0(10000000); //繰り下がりなし
vector<ll> dp1(10000000); //繰り下がりなあり
ll n;

void state()
{
  for (ll i = 0; i < n; i++)
  {
    cout << dp0[i] << " ";
  }
  cout << endl;
  for (ll i = 0; i < n; i++)
  {
    cout << dp1[i] << " ";
  }
  cout << endl;  
}

int main()
{
  vector<int> v;
  string s;
  cin >> s;
  n = s.length();
  for (ll i = 0; i < n; i++)
  {
    v.push_back(s[i]-'0');
  }

  dp0[0] = 0;
  dp1[0] = 1;


  for (ll i = 0; i < n; i++)
  {
    ll cur = v[i];
  
    if(cur==0) dp0[i+1] = dp0[i] + cur;
    else dp0[i+1] = min(dp1[i]+10-cur, dp0[i]+cur);

/*
    if(cur==9) dp1[i+1] = dp0[i]+9-cur;
    else dp1[i+1] = min(dp1[i]+9-cur, dp0[i]+cur+1);

*/
//    dp0[i+1] = min(dp1[i]+10-cur, dp0[i]+cur);
    dp1[i+1] = min(dp1[i]+9-cur, dp0[i]+cur+1);

  }
//  state();
  
  cout << dp0[n] << endl;
  
  return 0;
}

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

int main() {
  int n;
  cin>>n;
  vector<long long>a(n+1);
  vector<long long>b(n+1);
  long long s=0;
  for(int i=1;i<=n;i++){
    cin>>a[i];
    s+=a[i];
  }
  for(int i=2;i<=n-1;i+=2) s-=2*a[i];
  b[1]=s;
  for(int i=2;i<=n;i++){
    b[i]=2*a[i-1]-b[i-1];
  }
  for(int i=1;i<=n;i++) cout<<b[i]<<" ";
}


Measured memory_bytes: 4800
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define reps(i, n) for (int i = 1; i <= (n); ++i)
#define repd(i, n) for (int i = (n)-1; i >= 0; --i)
#define repds(i, n) for (int i = (n); i > 0; --i)
#define loop(i, x, n) for (int i = (x); i < (n); ++i)
#define loops(i, x, n) for (int i = (x); i <= (n); ++i)
#define loopd(i, x, n) for (int i = (x); i > (n); --i)
#define loopds(i, x, n) for (int i = (x); i >= (n); --i)
#define itrep(i, a) for (auto i = begin(a); i != end(a); ++i)
#define itrepd(i, a) for (auto i = rbegin(a); i != rend(a); ++i)
#define each(i, x) for (auto &&i : x)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(a) ((int)a.size())
#define pow2(n) (n * n)
#define int ll
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
template <class T>
using p_queue = priority_queue<T, vector<T>, greater<T>>;
constexpr ll inf = static_cast<ll>(1e18);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e18;
constexpr double eps = 1e-8;
ll mod = static_cast<ll>(1e9 + 7);
template <class T, class... Args>
constexpr void mins(T &a, Args... args) { a = min<T>({a, args...}); }
template <class T, class... Args>
constexpr void maxs(T &a, Args... args) { a = max<T>({a, args...}); }
template <class F>
class FixPoint : private F {
public:
    explicit constexpr FixPoint(F &&f) : F(std::forward<F>(f)) {}
    template <class... Args>
    constexpr decltype(auto) operator()(Args &&... args) const { return F::operator()(*this, std::forward<Args>(args)...); }
};
template <class F>
constexpr decltype(auto) funcs(F &&f) { return FixPoint<F>{std::forward<F>(f)}; }
template <class T>
std::vector<T> vecs(int n, T &&val) { return std::vector<T>(std::forward<int>(n), std::forward<T>(val)); }
template <class... Args>
decltype(auto) vecs(int n, Args &&... args) { return std::vector<decltype(vecs(std::forward<Args>(args)...))>(std::forward<int>(n), vecs(std::forward<Args>(args)...)); }
template <class V, class T>
void fill(V &x, const T &val) { x = val; }
template <class V, class T>
void fill(vector<V> &vec, const T &val) {
    for (auto &&v : vec)
        fill(v, val);
}

void solve() {
    int a,b,c,d;
    cin >> a >> b >> c >> d;

    cout << max({a * c, a * d, b * c, b * d}) << endl;
}

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

Measured memory_bytes: 3664
import java.util.*;

public class Main {
    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {

        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        int e = sc.nextInt();

        if (a == 0) {
            System.out.println(1);
        }

        if (b == 0) {
            System.out.println(2);
        }

        if (c == 0) {
            System.out.println(3);
        }

        if (d == 0) {
            System.out.println(4);
        }

        if (e == 0) {
            System.out.println(5);
        }

        sc.close();
    }
}

Measured memory_bytes: 35800
#include <iostream>
#include <cstdio>

using namespace std;

typedef long long ll;

ll n, k, ans;
ll a[4005][4005];

int main()
{
    scanf("%lld%lld", &n, &k);
    for(ll i = 0; i < n; i++)
    {
        ll t1, t2;
        char t3;
        scanf("%lld%lld %c", &t1, &t2, &t3);
        if(t3 == 'W') t1 += k;
        t1 %= (2 * k), t2 %= (2 * k);
        a[t1][t2]++, a[t1 + 2 * k][t2]++, a[t1][t2 + 2 * k]++, a[t1 + 2 * k][t2 + 2 * k]++;
    }
    for(ll i = 0; i < 4 * k; i++)
    {
        for(ll j = 1; j < 4 * k; j++)
        {
            a[i][j] += a[i][j - 1];
        }
    }
    for(ll i = 1; i < 4 * k; i++)
    {
        for(ll j = 0; j < 4 * k; j++)
        {
            a[i][j] += a[i - 1][j];
        }
    }
    for(ll i = 0; i < 2 * k; i++)
    {
        for(ll j = 0; j < 2 * k; j++)
        {
            ll x = a[i][j] - a[i + k][j] - a[i][j + k] + a[i + k][j + k];
            ll y = a[i + k][j + k] - a[i + 2 * k][j + k] - a[i + k][j + 2 * k] + a[i + 2 * k][j + 2 * k];
            ans = max(ans, x + y);
            ans = max(ans, n - x - y);
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

#define rep(i,n) for(int i=0; i<n; i++)

int main(){
	int n, p[65000], j[65000];
	while( cin >> n, n ){
		int len = 0;
		rep(i,n){
			cin >> p[i];
			len += p[i];
		}
		rep(i,n-1)  cin >> j[i];
		sort( j, j+n-1 );
		unsigned int val = len * n;
		for( int i=n-1; i>0; i-- ){
			len += j[i-1];
			unsigned int nval = len * i;
			if( nval > val ){
				val = nval;
			}
		}
		cout << val << endl;
	}
	return 0;
}

Measured memory_bytes: 1680
#include <cstdio>
#include <cstring>
#include <string>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
using namespace std;

int main()
{
	int n, a[2000];
  int sum=0;
  scanf("%d", &n);
  for(int i=0; i<n; i++){
    scanf("%d", &a[i]);
    sum+=a[i];
  }
  int s2=sum-(sum+1)/2;
  bitset<2000001> bs;
  bs[0]=1;
  for(int i=0; i<n; i++){
    bs=bs|(bs<<a[i]);
  }
  for(int i=s2; i>=0; i--){
    if(bs[i]==1){
      printf("%d\n", sum-i);
      return 0;
    }
  }
}


Measured memory_bytes: 1152
import java.util.*;


public class Main{ 


    public static void main(String args[]) {
    Scanner s=new Scanner(System.in);
	int n=s.nextInt();
	
	int arr[]=new int[n+1];
	long presum[]=new long[n+1];
	long sum=0;
	for(int i=1;i<=n;i++) {
		arr[i]=s.nextInt();
		sum+=arr[i];
		presum[i]=sum;
	}
	
	
	long dp[][]=new long[n+1][n+1];
	
	
	for(int i=1;i<=n;i++) {
		
		dp[i][i]=0;
		
	}
	
	for(int i=1;i<=n-1;i++) {
		int row=1;
		int col=i+1;
		while(col<=n) {
			long res=Long.MAX_VALUE;
			for(int k=row;k<col;k++) {
				
				res=Math.min(res, dp[row][k]+dp[k+1][col]+sum(row,col,presum));
			}
			dp[row][col]=res;
			row++;
			col++;
		}
	}
//	for(int i=1;i<=n;i++) {
//		for(int j=1;j<=n;j++) {
//			System.out.print(dp[i][j]+" ");
//		}
//		System.out.println();
//	}
	System.out.println(dp[1][n]);
   }
   
    public static long sum(int row,int col,long presum[]) {
    	return presum[col]-presum[row-1];
    }
}

Measured memory_bytes: 38400
import collections
n = int(input())
A = [int(i) for i in input().split()]
L = collections.Counter(A)

q = int(input())
Sum = sum(A) 
for i in range(q):
    b,c = map(int,input().split())
    diff = b-c
    Sum -= diff*L[b]
    L[c] += L[b]
    L[b] = 0
    print(Sum)

Measured memory_bytes: 24196
#include<iostream>
#include<string>
#include<algorithm>
#include <vector> 
#define rep(i, n) for(int i = 0; i < (int)(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; }
using namespace std;
string s,tmp;

int main(){
    cin >> s;
    tmp=s.substr(0,4);
    if(tmp=="YAKI"){
        cout << "Yes";
    }
    else{
        cout << "No";
    }
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;
using static System.Console;


namespace atcorder2
{
    class Program
    {
        public static long Read()
        {

            return long.Parse(Console.ReadLine());
        }

        public static long[] Reads()
        {


            return Console.ReadLine().Split().Select(long.Parse).ToArray();
        }

       
        public static long gcd(long a,long b)
        {
            if (a < b) gcd(b, a);
            while (b > 0)
            {
                long z = b;
                b = a % b;
                a = z;
            }
            return a;
        }
        public static long lcm(long a,long b)
        {
            return a * b / gcd(a, b);
        }




        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            var ab = ReadLine().Split();
            var a = long.Parse(ab[0]);
            var b1 = long.Parse(ab[1].Split('.')[0])*100;
            var b2 = long.Parse(ab[1].Split('.')[1]);
            
            WriteLine(a*(b1+b2)/100);
           
            
           
          
            Console.Out.Flush();
        }
    }
}




Measured memory_bytes: 17836
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define ll long long
#define P pair<int, int>

using namespace std;

string N;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> N;

  cout << ((N.at(1) == '9' || N.at(0) == '9') ? "Yes" : "No")  << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int sum = sc.nextInt();
        for (int i = 0; i <= n; i++) {
            for (int j = 0; j <= n - i; j++) {
                int total = (10000 * i) + (5000 * j) + (n - i - j) * 1000;
                if (total == sum) {
                    System.out.println(i + " " + j + " " + (n - i - j));
                    return;
                }
            }
        }
        System.out.println("-1 -1 -1");
    }
}


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

int main() {
	int s;
	cin >> s;
	
	int a = s/100;
	s = s-(a*100);
	int b = s/10;
	s = s-(b*10);
	int c = s/1;

	cout << a+b+c << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <string>

using namespace std;

int main(){
  int n;
  double a, ans = 0;

  cin >> n;

  for(int i = 0;i < n;++i){
    cin >> a;
    ans += 1 / a;
  }

  //cout << 1 / ans << endl;
  printf("%.10f\n", 1 / ans);

  return 0;
}


Measured memory_bytes: 256
def resolve():
    X, N = [int(i) for i in input().split()]
    if N == 0:
        print(X)
        return
    p_list = [int(i) for i in input().split()]
    min_len_with_X = 200
    min_len_i = 0
    for i in range(102):
        if i in p_list:
            continue
        if abs(i - X) < min_len_with_X:
            min_len_with_X = abs(i - X)
            min_len_i = i
    print(min_len_i)

resolve()

Measured memory_bytes: 9192
N, M, C = map(int,input().split())
B = [int(i) for i in input().split()]
A = [[int(i) for i in input().split()] for _ in range(N)]
ans = 0
for i in range(N):
    ten = 0
    for j in range(M):
        ten += A[i][j] * B[j]
    ten += C
    if ten > 0:
        ans += 1

print(ans)        


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <cmath>
#include <stdio.h>
#include <sstream>
#define int_inf 1000000000 //1e9
#define ll_inf  1000000000000000000 //1e18
using namespace std;
template <typename T> std::string to_string(const T& t){
	std::ostringstream os; os<<t; return os.str();
}

int main(){
	char c[2][4];
	cin >>c[0]>>c[1];
	
	if(c[0][0]==c[1][2]&&c[1][0]==c[0][2]&&c[0][1]==c[1][1])
	cout<<"YES"<<endl;
	
	else cout<<"NO"<<endl;
	return 0;
}




Measured memory_bytes: 256
#include <iostream>

using namespace std;

#define int long long

struct node {
  int i, j;
  node *left, *right;
  long long val;
  int lazy; 
};
node *build(int i, int j) {
  if (i == j) {
   return new node{i, j, nullptr, nullptr, 0, 0}; 
  }
  node *left = build(i, (i + j) / 2);
  node *right = build((i + j) / 2 + 1, j);
  return new node{i, j, left, right, left->val + right->val, 0};   
}

void propagate(node *cur) {
  if (cur->lazy) {
    cur->val += (cur->j - cur->i + 1) * cur->lazy;
    if (cur->left) {
      cur->left->lazy += cur->lazy;
      cur->right->lazy += cur->lazy;
    }
    cur->lazy = 0;
  }
}

long long query(node *cur, int i, int j) {
  propagate(cur);
  if (cur->j < i || cur->i > j) {
    return 0ll;
  }
  if (cur->i >= i && cur->j <= j) {
    return cur->val;
  }
  return query(cur->left, i, j) + query(cur->right, i, j);
}

void update(node *cur, int i, int j, int newVal) {
  propagate(cur);
  if (cur->j < i || cur->i > j) {
    return;
  }
  if (cur->i >= i && cur->j <= j) {
    cur->lazy += newVal;
    propagate(cur);
    return;
  }
  update(cur->left, i, j, newVal);
  update(cur->right, i, j, newVal);
  cur->val = cur->left->val + cur->right->val;
}

int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, q;
  cin >> n >> q;
  node *root = build(0, n - 1);
  while (q--) {
    int c;
    int s, t, x;
    cin >> c >> s >> t;
    if (c == 0) {
      int x;
      cin >> x;
      update(root, s - 1, t - 1, x);
    } else {
      cout << query(root, s - 1, t - 1) << '\n';
    }   
  }
  return 0;
}


Measured memory_bytes: 15652
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(obj)   (obj).begin(),(obj).end()

#define debug(var)  do{std::cout << __LINE__ << "> " << #var << ": ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

void Main() {
	int N; cin >> N;
	int res = 0;
	while (N > 0) {
		if (N % 10 == 7) {
			cout << "Yes" << endl;
			return;
		}
		N /= 10;
	}
	cout << "No" << endl;
}

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


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

int main()
{
    int N;
    cin>>N;
    for(int i=1;i<=9;i++){
        for(int j=1;j<=9;j++){
            if(i*j==N){
                cout <<"Yes"<<endl;
                exit(0);
            }
        }
    }
    cout<<"No"<<endl;
}

Measured memory_bytes: 256
package main

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

func main() {
	io := NewIo()
	defer io.Flush()
	for {
		N, K, S := io.NextInt(), io.NextInt(), io.NextInt()
		if N == 0 {
			break
		}
		dp := [21][11][156]int{}
		for i := 0; i <= N; i++ {
			dp[i][0][0] = 1
		}
		for i := 1; i <= N; i++ {
			for j := 1; j <= K; j++ {
				for k := 1; k <= S; k++ {
					if k-i >= 0 {
						dp[i][j][k] += dp[i-1][j-1][k-i]
					}
					dp[i][j][k] += dp[i-1][j][k]
				}
			}
		}
		io.Println(dp[N][K][S])
	}
}

// I/O template
type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

func NewIo() *Io {
	return &Io{
		reader: bufio.NewReader(os.Stdin),
		writer: bufio.NewWriter(os.Stdout),
	}
}

func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

func (io *Io) NextLine() string {
	var buff []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buff = append(buff, line...)
		if !isPrefix {
			break
		}
	}
	return string(buff)
}

func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	s := io.tokens[io.nextToken]
	io.nextToken++
	return s
}

func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) NextFloat() float64 {
	i, err := strconv.ParseFloat(io.Next(), 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}

func (io *Io) Printf(format string, a ...interface{}) {
	fmt.Fprintf(io.writer, format, a...)
}

func (io *Io) PrintIntSlice(a []int) {
	b := make([]interface{}, 0, len(a))
	for _, x := range a {
		b = append(b, x)
	}
	io.Println(b...)
}

func (io *Io) PrintStringSlice(a []string) {
	b := make([]interface{}, 0, len(a))
	for _, x := range a {
		b = append(b, x)
	}
	io.Println(b...)
}

func Log(name string, value interface{}) {
	fmt.Fprintf(os.Stderr, "%s=%+v\n", name, value)
}

func ExampleIo() {
	io := NewIo()
	defer io.Flush()
	a := make([]int, 0, 3)
	a[0], a[1], a[2] = io.NextInt(), io.NextInt(), io.NextInt()
	io.Println(a)
	io.PrintIntSlice(a)
	Log("io", a)
}



Measured memory_bytes: 1400
def main():
    A, B, K = map(int, input().split())
    ans = []
    for v in range(A, min([A+K, B+1])):
        ans.append(v)
    for v in range(max([A, B-K+1]), B+1):
        if v not in ans:
            ans.append(v)
    print("\n".join([str(v) for v in ans]))


if __name__ == '__main__':
    main()


Measured memory_bytes: 61984
#include<bits/stdc++.h>
// #include<iostream>
// #include<vector>
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define fast() ios_base::sync_with_stdio(false); cin.tie(NULL);
typedef long long int ll;
//typedef vector<int> vi;
//using ll = long long; //only for C++11 compiler and newer
 
using namespace std;
template<typename T>
inline T Abs(T a){return a < 0 ? -a : a; }
template<typename T>
inline T Max(T a, T b){return a < b ? b : a; }
template<typename T>
inline T Min(T a, T b){return a > b ? b : a; }
 
int main(){
    //fast()
    //freopen("input.txt","r",stdin);
    string str; cin >> str;
    bool ans = false;
    for(int i = 0; i < 2; i++){
        if(str[i] != str[i + 1]){ans = true; break;}
    }
    if(ans) Yes();
    else No();
    return 0;
}

Measured memory_bytes: 256
N, A, B, C = map(int,input().split())
l = [int(input()) for i in range(N)]


def dfs(i,a,b,c):
    if i == N:
        if min(a,b,c) > 0:
            return abs(A-a) + abs(B-b) + abs(C-c) - 30  # 最初に選ぶのは合成しないから。
        else:
            return 10**9

    case1 = dfs(i+1, a, b, c)
    case2 = dfs(i+1, a+l[i], b, c) + 10
    case3 = dfs(i+1, a, b+l[i], c) + 10
    case4 = dfs(i+1, a, b, c+l[i]) + 10

    return min(case1, case2, case3, case4)

print(dfs(0,0,0,0))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

int main() {
  ll q;
  cin >> q;
  while(q--) {
    string s;
    string t;
    cin >> s >> t;
    mat dp(s.size()+1,vec(t.size()+1));
    for(ll i=0;i<s.size();i++) {
      for(ll j=0;j<t.size();j++) {
        if(s[i]==t[j]) {
          dp[i+1][j+1]=max({dp[i][j]+1,dp[i+1][j],dp[i][j+1]});
        }
        else {
          dp[i+1][j+1]=max({dp[i][j],dp[i+1][j],dp[i][j+1]});
        }
      }
    }
    cout << dp[s.size()][t.size()] << endl;
  }
}


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


void solve(long long A, long long B, long long C, long long X, long long Y){
    vector<long long> cands = {A*X+B*Y, 2*C*max(X, Y), 2*C*min(X, Y)+max(B*(Y-X), A*(X-Y))};
    cout << *min_element(cands.begin(), cands.end()) << endl;
}

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    long long X;
    scanf("%lld",&X);
    long long Y;
    scanf("%lld",&Y);
    solve(A, B, C, X, Y);
    return 0;
}


Measured memory_bytes: 256
tarou = hanako = 0
for _ in range(int(input())):
    s1, s2 = input().split()
    if s1 == s2:
        tarou += 1
        hanako += 1
    elif s1 > s2:
        tarou += 3
    else:
        hanako += 3
print(tarou, hanako)


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

int main(){
    int b,v,c;
    cin>>v;
    int numbers[v], value;
    for (b=v-1;b>=0;b-=1){
        cin>>c;
        numbers[b]=c;
    }
    for (b=0;b<v;b+=1){
        if(b+1!=v){
            cout<<numbers[b]<<" ";   
        }else{
            cout<<numbers[b]<<endl;
        }
    
    }    


}


Measured memory_bytes: 3116
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<list>
#include<set>
using namespace std;
int gcd(int a, int b) {
	int c = a % b;
	while (c != 0) {
		a = b;
		b = c;
		c = a % b;
	}
	return b;
}
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;
	}
};
typedef long long ll;

const ll M = 1000000007;

vector<ll> fac(300001); //n!(mod M)
vector<ll> ifac(300001); //k!^{M-2} (mod M)

ll mpow(ll x, ll n) {
	ll ans = 1;
	while (n != 0) {
		if (n & 1) ans = ans * x % M;
		x = x * x % M;
		n = n >> 1;
	}
	return ans;
}

ll comb(ll a, ll b) {
	if (a == 0 && b == 0)return 1;
	if (a < b || a < 0)return 0;
	ll tmp = ifac[a - b] * ifac[b] % M;
	return tmp * fac[a] % M;
}
int main() {
	int a, b;
	cin >> a >> b;
	if (a <= 5)
		cout << "0" << endl;
	else if (a < 13)
		cout << b / 2 << endl;
	else
		cout << b << endl;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h> 
#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
#define all(x) (x).begin(),(x).end()
#define _GLIBCXX_DEBUG
typedef long long ll;
using namespace std;
int main(){
  ll n;
  cin>>n;
  vector<ll> a(n),b(n);
  rep(i,n){cin>>a[i];b[i]=a[i];}
  sort(all(a));
  ll k=0;
  rep(i,n){if(a[i]!=b[i]){k++;}}
  if(k==0||k==2){cout<<"YES"<<endl;}
  else cout<<"NO"<<endl;
}

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

// iterator
#define REP(i,from, to) for(lli i=from;i<to;i++)
#define REPE(i,from, to) for(lli i=from;i<=to;i++)
#define REP_R(i,from, to) for(lli i=from;i>to;i--)
#define REPE_R(i,from, to) for(lli i=from;i>=to;i--)
#define REPIT(it,container) for(auto it = container.begin(); it != container.end(); it++)
#define REPIT_R(it,container) for(auto it = container.rbegin(); it != container.rend(); it++)

// input
#define cin1(x)             cin >> x
#define cin2(x, y)          cin >> x >> y
#define cin3(x, y, z)       cin >> x >> y >> z
#define ncin1(n, x)         REP(i, 0, n) { cin1(x[i]); }
#define ncin2(n, x, y)      REP(i, 0, n) { cin2(x[i], y[i]); }
#define ncin3(n, x, y, z)   REP(i, 0, n) { cin3(x[i], y[i], z[i]); }
#define ncinp(n, p)         REP(i, 0, n) { lli p1,p2; cin >> p1 >> p2; p[i] = P(p1, p2); }
#define ncin1_1(n, x)       REPE(i, 1, n) { cin1(x[i]); }
#define ncin2_1(n, x, y)    REPE(i, 1, n) { cin2(x[i], y[i]); }
#define ncin3_1(n, x, y, z) REPE(i, 1, n) { cin3(x[i], y[i], z[i]); }
#define ncinp_1(n, p)       REPE(i, 1, n) { lli p1,p2; cin >> p1 >> p2; p[i] = P(p1, p2); }

// output
#define cout1(x)         cout << #x << ": " << x << endl;
#define cout2(x, y)      cout << #x << ": " << x << ", " << #y << ": " << y << endl;
#define cout3(x, y, z)   cout << #x << ": " << x << ", " << #y << ": " << y << ", " << #z << ": " << z << endl;;
#define ncout1(n, x)     REP(i, 0, n) {cout << #x << "[" << i << "]: "<< x[i] << endl;}

#define coutp(p)         cout << #p << ":" <<  " (" << p.first << ", " << p.second << ")" << endl;

// sort
#define sort_r(x, y)        sort(x, y, greater<lli>()); // 降順(5,4,3,,,)

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

typedef long long int lli;
typedef pair<lli, lli> P;
typedef tuple<lli, lli, lli> tup;
typedef vector<lli> vlli;

int main() {
    lli a, b;
    cin2(a,b);

    if (a <= 8 && b <= 8) {
        cout << "Yay!" << endl;
    }
    else
        cout << ":(" << endl;
}


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

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

ll dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
ll dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};

/* Macros reg. ends here */

const ll INF = 1LL << 60;

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll n, k;
  cin >> n >> k;
  vll as(n);

  rep(i, n) cin >> as[i];
  Sort(as);
  vll bs(n);
  rep(i, n) bs[i] = as[n - 1 - i];

  auto g = [&](vll& cs, ll a, ll x) {
    ll l = -1;
    ll r = n;
    while (l + 1 < r) {
      ll m = (l + r) / 2;
      if (cs[m]*a >= x)
        r = m;
      else
        l = m;
    }
    return r;
  };
  auto f = [&](ll x) {
    ll ans = 0;
    rep(i, n) {
      ll a = as[i];
      if (a >= 0) {
        ll idx = g(as, a, x);
        ans += idx;
        if (idx > i) ans--;
      } else {
        ll idx = g(bs, a, x);
        ans += idx;
        if (idx > n - i - 1) ans--;
      }
    }
    assert(ans % 2 == 0);
    ans /= 2;
    return (ans < k);
  };

  ll l = -INF;
  ll r = INF;
  while (l + 1 < r) {
    ll m = (l + r) / 2;
    if (f(m))
      l = m;
    else
      r = m;
  }
  cout << l << endl;

  return 0;
}


Measured memory_bytes: 3456
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
using namespace std;
typedef long long lint;
typedef vector<int>vi;
typedef pair<int,int>pii;
typedef pair<lint,pii>plpii;
#define rep(i,n)for(int i=0;i<(int)(n);++i)

const int N=1010;
const lint inf=1e16;

int main(){
  int w,h,n;
  cin>>w>>h>>n;
  int mi=1e8;
  vector<pii> pts(n+2);
  pts[0]=pii(1,1);
  pts[1]=pii(w,h);
  rep(i,n){
    int x,y;
    cin>>x>>y;
    pts[i+2]=pii(x,y);
  }
  priority_queue<plpii,vector<plpii>,greater<plpii> > que;
  vector<vector<lint> > dis(n+2,vector<lint>(N,inf));
  rep(i,n){
    int d=abs(pts[i+2].first-1)+abs(pts[i+2].second-1);
    que.push(plpii(d,pii(i+2,d)));
  }
  while(!que.empty()){
    plpii top=que.top();que.pop();
    lint d=top.first;
    pii xy=top.second;
    int x=xy.first,y=xy.second;
    if(dis[x][y]<=d)continue;
    dis[x][y]=d;
    rep(i,n+2){
      if(i==x||i==0)continue;
      int c=abs(pts[i].first-pts[x].first)+abs(pts[i].second-pts[x].second);
      c=max(0,i==1?c-y:(c-y-1));
      if(c>=N)continue;
      int nx=i;
      int ny=i==1?0:c;
      if(dis[nx][ny]<=d+c)continue;
      dis[nx][ny]=d+c+1;
      que.push(plpii(d+c,pii(nx,ny)));
    }
  }
  cout<<dis[1][0]<<endl;
}



Measured memory_bytes: 5792
#include<bits/stdc++.h>
using namespace std;
template<typename T>
    bool chmin(T& a,T b){
        if(a>b){
            a=b;
            return true;
        }
        return false;
    }
int dis(int a,int b){
    return a>=b ? a-b : b-a ;
}
int main(){
    int n;
    cin>>n;
    vector<int>vec(n);
    for(int i=0;i<n;i++)cin>>vec.at(i);
    int inf=1ll<<30;
    vector<int>dp(n);
    for(int i=0;i<n;i++)dp.at(i)=inf;
    dp.at(0)=0;
    for(int i=1;i<n;i++){
        chmin(dp.at(i),dp.at(i-1)+dis(vec.at(i),vec.at(i-1)));
        if(i>1)chmin(dp.at(i),dp.at(i-2)+dis(vec.at(i),vec.at(i-2)));
    }
    cout<<dp.at(n-1)<<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>

#define DIV 998244353

using namespace std;
using ll = long long;
using ldb = long double;

typedef struct {
    vector<int> edge;
    int par;
}node_t;
vector<node_t> node;

int main() {
    int N, M;
    cin >> N >> M;
    node = vector<node_t>(N + 1);
    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        node[a].edge.push_back(b);
        node[b].edge.push_back(a);
    }

    queue<int> q;
    vector<bool> vi(N + 1);
    q.push(1);
    vi[1] = true;
    while (!q.empty()) {
        int x = q.front();
        q.pop();

        for (auto to : node[x].edge) {
            if (vi[to]) continue;
            vi[to] = true;
            node[to].par = x;
            q.push(to);
        }
    }
    cout << "Yes" << endl;
    for (int i = 2; i <= N; i++) {
        cout << node[i].par << endl;
    }
}


Measured memory_bytes: 10592