akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<utility>
#include<climits>
#include<algorithm>
using namespace std;

int count(vector<pair<int, int> > xy, int i, int j, int k, int l){
	int count = 0;
	for(auto p: xy){
		if(p.first >= i && p.first <= j && p.second >= k && p.second <= l) {
			count++;
		}
	}
	return count;
}

int main(){
	int n, K;
	cin >> n >> K;
	pair<int, int> p;
	vector<pair<int, int> > xy;
	vector<int> x;
	vector<int> y;
	long min = LONG_MAX;
	long area;
	for(int I=0; I<n; I++){
		cin >> p.first >> p.second;
		xy.push_back(p);
		x.push_back(p.first);
		y.push_back(p.second);
	}
	sort(x.begin(), x.end());
	sort(y.begin(), y.end());
	for(auto i=x.begin(); i<x.end() - 1; i++){
		for(auto j=i+1; j<x.end(); j++){
			for(auto k=y.begin(); k<y.end() - 1; k++){
				for(auto l=k+1; l<y.end(); l++){
					area = ((long)*j - *i) * (*l - *k);
					if(count(xy, *i, *j, *k, *l) >= K && area < min) {
						min = area;
					}
				}
			}
		}
	}
	cout << min;
	return 0;
}



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

int main(){

	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif

	ios::sync_with_stdio(false),cin.tie(0);
	int a;
  cin >> a;
	cout << a+a*a+a*a*a << endl;

	return 0;
}

Measured memory_bytes: 3636
n=int(input())
s=[list(map(int,list(input()))) for _ in range(n)]
g=[[]for _ in range(n)]
for i in range(n-1):
  for j in range(i+1,n):
    if s[i][j]==1:
      g[i].append(j)
      g[j].append(i)
from collections import deque
def bfs(i):#頂点iをグループ１とする。
  seen=[0]*n
  seen[i]=1
  todo=deque([[i,-1]])
  while todo:
    t,p=todo.popleft()
    l=g[t]
    for li in l:
      if li==p:
        continue
      if seen[li]==0:
        seen[li]=seen[t]+1
        todo.append([li,t])
      elif abs(seen[li]-seen[t])==1:
        pass
      else:
        return -1
  return max(seen)
ans=-1
for i in range(n):
  ans=max(bfs(i),ans)
print(ans)

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

int main(){
    string s; cin >> s;
    if (s.size()==2){
        if (s[0]==s[1]){
            cout << 1 << " " << 2 << endl;
            return 0;
        }
    }
    for (int i = 0; i < s.size()-2; i++)
    {
        if (s[i]==s[i+1]||s[i+1]==s[i+2]||s[i]==s[i+2]){
            cout << i+1 << " " << i+3 << endl;
            return 0;
        }
    }
    cout << -1 << " " << -1 << endl;
}

Measured memory_bytes: 512
#include<stdio.h>
#include<math.h>
int po(int a,float b){
  float p = pow(a,b);
  int ans = p;
  return ans;
}

int main(){
  int n,ans = 1;
  scanf("%d",&n);
  for(int i = 2;i <= po(n,0.5);i++){
    for(int j = 2;po(i,j) <= n;j++){
      int a = po(i,j);
      if(ans < a){
        ans = a;
      }
    }
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<set>
#include<climits>
#include<bitset>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef tuple<ll, ll, ll, ll> lltpl;



/******************************************************************************************/


const int IINF = 1e9 + 7;
const ll LINF = 1e18 + 7;
const ll MOD = 1e9 + 7;



template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}

const int MAX_ROW = 70;
const int MAX_COL = 100005;
struct BitMatrix {
	int H, W;
	bitset<MAX_COL> val[MAX_ROW];
	BitMatrix(int m = 1, int n = 1) : H(m), W(n) {}
	inline bitset<MAX_COL>& operator [] (int i) { return val[i]; }
};

void GaussJordan(BitMatrix& A, bool is_extended = false) {
	vector<bool> used(A.H, 0);
	for (int col = 0; col < A.W; ++col) {
		if (is_extended && col == A.W - 1) break;
		int pivot = -1;
		for (int row = 0; row < A.H; ++row) {
			if (used[row]) continue;
			if (A[row][col]) {
				pivot = row;
				break;
			}
		}
		if (pivot == -1) continue;
		for (int row = 0; row < A.H; ++row) {
			if (row != pivot && A[row][col]) A[row] ^= A[pivot];
		}
		used[pivot] = true;
	}
}
const int MD = 62;

int main() {

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


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

	ll ans = 0;

	BitMatrix BM(MD+1, N+1);//65個の方程式，各方程式に対してN+1個の変数(0か1)
	//初期化時は，MD桁で， A_1+...+A_N=0ならば，列はN+1個で初期化すること（でないと落ちる）
	vector<bool> cannot(MD+1, 0);

	for (ll mask = MD; mask >= 0; mask--)
	{
		int num = 0;
		for (int i = 0; i < N; i++)
		{
			if ((A[i] >> mask) & 1LL) {
				num++;
			}
		}

		if (num == 0) {
			//全て0
			cannot[mask] = 1;
			continue;
		}
		else if (num & 1) {
			//1が奇数個(この桁は値は一定)
			cannot[mask] = 1;
			ans += (1LL << mask);
			continue;
		}

		//ここは1が偶数個存在する場合
		for (int i = 0; i < N; i++)
		{
			if ((A[i] >> mask) & 1LL) {
				BM[MD - mask][i] = 1;
			}

		}
		BM[MD - mask][N] = 1;
	}

	GaussJordan(BM, true);

	for (int mask = MD; mask >= 0; mask--)
	{
		if (cannot[mask]) {
			continue;
		}

		bool ok = false;

		for (int i = 0; i < N; i++)
		{
			if (BM[MD - mask][i]) {
				ok = true;
			}
		}
		if (!BM[MD - mask][N]) {
			ok = true;
		}

		if (ok) {
			ans += (1LL << (mask + 1));
		}
	}

	cout << ans << endl;
	

}



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

// #define ONLINE_JUDGE

#define V vector
#define P pair

using LL = long long;
#define FOR(i, x, y) \
    for (decay<decltype(y)>::type i = (x), _##i = (y); i < _##i; ++i)
#define FORD(i, x, y) \
    for (decay<decltype(x)>::type i = (x), _##i = (y); i > _##i; --i)
#ifndef ONLINE_JUDGE
#define dbg(x...)                             \
    do {                                      \
        cerr << "\033[32;1m" << #x << " -> "; \
        err(x);                               \
    } while (0)
void err() { cerr << "\033[39;0m" << endl; }
template <template <typename...> class T, typename t, typename... A>
void err(T<t> a, A... x) {
    for (auto v : a) cerr << v << ' ';
    err(x...);
}
template <typename T, typename... A>
void err(T a, A... x) {
    cerr << a << ' ';
    err(x...);
}
#else
#define dbg(...)
#endif
#define sz(x) (int)x.size()

LL bin(LL a, LL b, LL p) {
    LL res = 1;
    a = (a % p + p) % p;
    for (; b; b >>= 1, a = a * a % p)
        if (b & 1) res = res * a % p;

    return res;
}

const int N = 1e5+50;


void solve() {
    int a, b;
    cin >> a >> b;
    if (a <= b)
        puts("unsafe");
    else
    {
        puts("safe");
    }
    
}

int main() {

    // int t;
    // cin >> t;
    // while (t--) solve();

    solve();

    return 0;
}

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

public class Main {
public static void main(String[] args) {
		
		Scanner keyboard = new Scanner(System.in); 
		
		int N  = keyboard.nextInt();
		int x  = keyboard.nextInt();
		
		 int[] a = new int[N];
		 int ame = 0;
		 long SUM = 0;
		 
		 for(int i = 0; i < N ; i++) {
			a[i] = keyboard.nextInt();
		}
		
		for(int j = 0; j < N-1; j++) {
			if(a[j] + a[j+1] > x) {
				ame = Math.min(a[j] + a[j+1] - x , a[j+1]);
				a[j+1] -= ame;
				SUM += ame;
			}
		}
		
		if(a[0] + a[1] > x) {
			SUM += (a[0] - x);
		}
		
		System.out.println(SUM);
		keyboard.close();	
	}
}


Measured memory_bytes: 49888
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using ii=pair<ll,ll>;
using vi=vector<ll>;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define INF (ll)1e18
#define all(x) (x).begin(),(x).end()
#define print(a); for(auto x:a)cout<<x<<" "; cout<<"\n";
#define mset(a); memset(a,0,sizeof(a));

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
    ll n,k;cin>>n>>k;
    ll a[n];
    for(int i=0;i<n;i++)cin>>a[i];
    sort(a,a+n);
    ll sum=0;
    for(int i=0;i<k;i++){
        sum+=a[i];
    }
    cout<<sum<<"\n";
}


Measured memory_bytes: 3584
#include <stdio.h>

int main(){


  int max=0,num,res,n,sum=0;
  int i,j;

  scanf("%d",&n);
  res=1;
  for(i=1;i<=n;i++){
    sum=0;
    num=i;
    for(j=0;;j++){
      if(num%2==1)break;
      num/=2;
      sum++;
    }
    if(sum>max){
      res=i;
      max=sum;
      //     printf("%d\n",i);
    }
  }

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

  return 0;

}


Measured memory_bytes: 128
import numpy

N, M, C = map(int, input().split())
B = list(map(int, input().split()))
B = numpy.array(B)

ans = 0
for _ in range(N):
    a = numpy.array(list(map(int, input().split())))
    if numpy.dot(a, B) + C > 0:
        ans += 1

print(ans)

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

int main(){
	int n;
	cin>>n;
	n%=10;
	if(n==2||n==4||n==5||n==7||n==9){
		cout << "hon" << "\n";
	}
	else if(n==3){
		cout << "bon" << "\n";
	}
	else{
		cout << "pon" << "\n";
	}
	return 0;
}

Measured memory_bytes: 3132
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

using namespace std;

int main() {
   int a,b,c,d;
   cin >> a >> b >> c >> d;  
   cout << min(a,b) + min(c,d) << endl;
}

Measured memory_bytes: 256
package main

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

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 buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

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

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

func (io *Io) NextLong() int64 {
	i, err := strconv.ParseInt(io.Next(), 10, 64)
	if err != nil {
		panic(err)
	}
	return i
}

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

func (io *Io) PrintLn(a ...interface{}) {
	for i, v := range a {
		if i > 0 {
			io.writer.WriteByte(' ')
		}
		fmt.Fprint(io.writer, v)
	}
	io.writer.WriteByte('\n')
}

func (io *Io) PrintfLn(format string, a ...interface{}) {
	fmt.Fprintf(io.writer, format + "\n", a...)
}

func (io *Io) PrintIntLn(a ...int) {
	for i, v := range a {
		if i > 0 {
			io.writer.WriteByte(' ')
		}
		fmt.Fprint(io.writer, v)
	}
	io.writer.WriteByte('\n')
}

func (io *Io) PrintStringLn(a ...string) {
	for i, v := range a {
		if i > 0 {
			io.writer.WriteByte(' ')
		}
		fmt.Fprint(io.writer, v)
	}
	io.writer.WriteByte('\n')
}

type Tuple2 struct {
	first, second int
}

func main() {
	io := NewIo()
	defer io.Flush()
	a, b, x := io.NextLong(), io.NextLong(), io.NextLong()
	divA := (a - 1) / x
	divB := b / x
	if a == 0 {
		fmt.Println(divB + 1)
	} else {
		fmt.Println(divB - divA)
	}
}


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

using namespace std;

using ll = long long int;
using vi = vector<int>;
#define f(n) for(int i = 0; i < n; i++)
#define fj(n) for(int j = 0; j < n; j++)
#define fk(n) for(int k = 0; k < n; k++)
#define ci(n) cin >> n;
#define ic(n) int n; cin >> n;
#define lc(n) int n; cin >> n;
#define all(a) a.begin(), a.end()
#define pri(a, n) for(int i = 0; i < n; i++) cout << a[i] << " "; cout << "\n";
#define sc(a, n) int a[n] = {0}; for(int i = 0; i < n; i++) cin >> a[i];
#define scl(a, n) ll a[n] = {0}; for(int i = 0; i < n; i++) cin >> a[i];
#define pb push_back
#define eb emplace_back
#define int long long
const int inf = 2e9, mxp = (1 << 9), maxn = (1 << 18);



void solve(int ci)
{
    int n, k;
    cin >> n >> k;
    sc(p, n)
    sort(p, p + n);
    int ans = 0;
    f(k) ans += p[i];
    cout << ans;
}

signed main()
{
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int t = 1;
    //cin >> t;
    f(t) solve(i + 1);
}


Measured memory_bytes: 3664
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main(void)
{
    long long dog_num;

    cin >> dog_num;

    long long base = 0;
    long long band = 26;
    int name_len = 1;

    while(base + band < dog_num){
        base += band;
        band *= 26;
        name_len += 1;
    }

    string name;
    dog_num -= base;
    dog_num -= 1;
    for(int i = 0; i < name_len; i++){
        name += 'a' + dog_num % 26;
        dog_num /= 26;
    }

    reverse(name.begin(), name.end());

    cout << name << endl;

    return 0;
}

Measured memory_bytes: 3600
// 22
/****************************************************
https://searleser97.gitlab.io/algorithms/template.cpp
****************************************************/

#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define fors(_, x, n, s) for (int _ = x; _ < n; _ += s)
#define forn(_, x, n) fors(_, x, n, 1)
#define rep(_, n) forn(_, 0, n)
#define forrs(_, x, n, s) for (int _ = x; _ > n; _ -= s)
#define forrn(_, x, n) forrs(_, x, n, 1)
#define rrep(_, n) forrn(_, n - 1, -1)
#define fi first
#define se second
#define pb push_back
#define pairii pair<int, int>
#define all(x) x.begin(), x.end()
#define cerr(s) cerr << "\033[48;5;196m\033[38;5;15m" << s << "\033[0m"
// typedef __int128_t lli;
typedef long long int li;
typedef long double ld;
// 12
const li inf = 1 << 60;

void _main(int tc) {
  li n, W;
  cin >> n >> W;
  vector<int> w(n), v(n);
  rep(i, n) { cin >> w[i] >> v[i]; }
  vector<vector<li>> mem(n, vector<li>(W + 1, -1));
  function<li(int, int)> knapsack = [&](int i, int k) -> li {
    if (i == n) return 0;
    if (mem[i][k] != -1) return mem[i][k];
    if (k - w[i] >= 0) mem[i][k] = v[i] + knapsack(i + 1, k - w[i]);
    mem[i][k] = max(mem[i][k], knapsack(i + 1, k));
    return mem[i][k];
  };
  cout << knapsack(0, W) << endl;
  // rrep(i, n) {
  //   rrep(k, W) {
  //     if (i == n - 1) {
  //       if (k + w[i] <= W) mem[i][k] = v[i];
  //       else mem[i][k] = 0;
  //       continue;
  //     }
  //     if (k + w[i] <= W) mem[i][k] = v[i] + mem[i + 1][k + w[i]];
  //     mem[i][k] = max(mem[i][k], mem[i + 1][k]);
  //   }
  // }
  // cout << mem[0][0] << endl;
}

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  _main(0);
  return 0;
  int tc;
  cin >> tc;
  rep(i, tc) _main(i + 1);
}

Measured memory_bytes: 79488
<?php

$A=array('S'=>array(),'H'=>array(),'C'=>array(),'D'=>array());
fscanf(STDIN,"%d",$a);
for($i=0;$i<$a;$i++) {
  fscanf(STDIN,"%c %d",$c,$d);
  $A[$c][$d]=1;
}
while($F=current($A)) {
  for($i = 1;$i<=13; $i++) {
    if(!array_key_exists($i,$F)) {
      echo key($A)." ".$i."\n";

    }
  }
  next($A);
}


Measured memory_bytes: 9256
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#define fi first
#define se second
#define pb(i) push_back(i)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
#define mes(a,b) memset(a,b,sizeof(a))
#define sbs(i,j) substr(i,j)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N = 2e5+10;
const int INF = 0x3f3f3f3f;
const int inf = - INF;
const int mod = 1e9+7;
const double pi = acos(-1.0);

int a[N];
int a1[N];
int main(){
    int k,n;
    scanf("%d%d",&k,&n);
    /*rep(i,1,k){
        scanf("%d",&a[i]);
        a[i]%=n;
    }
    int res=n;

    sort(a+1,a+1+k);
    printf("%d\n",min(n,min(a[k]-a[1],a[1]+n-a[2])));
    */
    scanf("%d",&a[1]);
    for(int i=2;i<=n;i++){
            scanf("%d",&a[i]);
            a1[i-1]=a[i]-a[i-1];
        }

        long sum=0;
        a1[n]=k+a[1]-a[n];
        int ans=0;
        for(int i=1;i<=n;i++){
            ans=max(ans,a1[i]);
            sum+=a1[i];
        }
        sum=sum-ans;
    printf("%d\n",sum);
    getchar();
    return 0;
}

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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
const int maxN = 2000005;
const int INF = 999999999;

vector<int> w[20];
char s[maxN]; 
int a[20];
int tag[10];
char t[4] = {0,3,5,7};
int n;
bool check(int x)
{
	int tot = 0;
	for(int i=1;i<=9;i++)
		tag[i] = 0;
	while(x)
	{
		a[++tot] = x%10;
		x/=10;
	}
	for(int i=1;i<=tot;i++)
	{
		tag[a[i]]++;
	}
	if(tag[3] && tag[5] && tag[7])
		return true;
	else
		return false;
}
void dfs(int x,int p)
{
	if(p>9)
		return;
	for(int i=1;i<=3;i++)
	{
		int y = x*10 + t[i];
		w[p].push_back(y);
		dfs(y,p+1);
	}
}
int main() {
	scanf("%d",&n);
	dfs(0,1);
	int ans = 0;
	for(int i=3;i<=9;i++)
	{
		for(auto z:w[i])
		{
			if(check(z) && z<=n)
				ans ++;	
			else if(z > n)
				break;	
		}
	}
	printf("%d\n",ans);
	return 0;
}


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

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  vector<int> B(N);
  long sa=0;
  for(int i=0; i<N; i++){
    cin >> A[i];
    sa+=A[i];
  }
  long sb=0;
  for(int i=0; i<N; i++){
    cin >> B[i];
    sb+=B[i];
  }
  long count=0;
  for(int i=0;i<N; i++){
    if(A[i]<B[i]) count+=ceil((B[i]-A[i])/2.0);
  }
  if(sb-sa>=count){
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
  return 0;
}

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



int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int n,k;
    cin>>n>>k;
    
    ll arr[n],ans[k+1];
    for(int i=0;i<n;i++)
	cin>>arr[i];
    sort(arr,arr+n);
    
    for(int i=0;i<=k;i++)
    {
       for(int j=0;j<n;j++)
       {
       	if(arr[j]>i)ans[i]=0;
       	else if(ans[i-arr[j]]==0)
       	{
       		ans[i]=1;
       		break;
		}
		else ans[i]=0;
	   }
	}
	
	if(ans[k]==0)cout<<"Second"<<endl;
	else cout<<"First"<<endl;
	    
	return 0;
}

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

int main()
{
    int64_t x ;
    cin >> x;

    int64_t y=0;

    for(;;){
        if(x < 500)break;
        else{
        y +=1000;
        x-=500;
        }
    }

    for(;;){
        if(x< 5)break;
        else{
        y +=5;
        x-=5;
        }
    }

    cout << y <<endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cerr<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;
int getInt(){int x;scanf("%d",&x);return x;}
template<typename T>istream& operator>>(istream&i,v(T)&v){rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v){stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,const v(T)&v){if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>istream& operator>>(istream&i,pair<T1,T2>&v){return i>>v.fi>>v.se;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,const pair<T1,T2>&v){return o<<v.fi<<","<<v.se;}
template<typename T>bool mins(T& x,const T&y){if(x>y){x=y;return true;}else return false;}
template<typename T>bool maxs(T& x,const T&y){if(x<y){x=y;return true;}else return false;}
template<typename T>ll suma(const v(T)&a){ll res(0);for(auto&&x:a)res+=x;return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;
const int D = 18;
typedef v(vl) vvl;


int n,K;

struct Db {
  vvi d; vvl s;
  Db(vi x):d(D,vi(n+1,n)),s(D,vl(n+1,0)) {
    int j = n;
    drep(i,n) {
      while (x[i]+K <= x[j-1]) --j;
      d[0][i] = j;
      s[0][i] = j;
    }
    rep(i,D-1) {
      rep(j,n) {
        d[i+1][j] = d[i][d[i][j]];
        s[i+1][j] = s[i][j]+s[i][d[i][j]];
      }
    }
  }
  int cnt;
  ll get(int l, int r) {
    int j = l;
    ll res = l;
    cnt = 1;
    int w = 1<<D;
    drep(i,D) {
      w >>= 1;
      if (d[i][j] > r) continue;
      res += s[i][j];
      j = d[i][j];
      cnt += w;
    }
    return res;
  }
};

int main() {
  scanf("%d%d",&n,&K);
  vi x(n);
  cin>>x;

  Db dl(x);
  reverse(rng(x));
  rep(i,n) x[i] = -x[i];
  Db dr(x);

  int q;
  scanf("%d",&q);
  rep(qi,q) {
    int l,r;
    scanf("%d%d",&l,&r);
    --l; --r;
    ll xr = dr.get(n-1-r,n-1-l);
    xr = dr.cnt*ll(n-1) - xr;
    ll ans = xr - dl.get(l,r) + dl.cnt;
    printf("%lld\n",ans);
  }
  return 0;
}






















Measured memory_bytes: 91668
#include <bits/stdc++.h>
typedef long long ll;
#define mod 1000000007
#define pb push_back
#define mp(a,b) make_pair(a,b)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vll vector <ll>
#define vii vector <int>
#define vpii vector <pii>
#define vpll vector <pll>
#define ff first
#define ss second
#define matrix vector <vll>
#define all(v) v.begin(),v.end()
#define PQ priority_queue
using namespace std;
bool comp(ll a, ll b) {return a > b;}
int main()
{
	//ios::sync_with_stdio(0);
	//cin.tie(0);
	int x,y,a,b,c;
	cin >> x >> y >> a >> b >> c;
	ll arr1[a], arr2[b], arr3[c];
	for(int i = 0; i < a; i++) cin >> arr1[i];
	for(int i = 0; i < b; i++) cin >> arr2[i];
	for(int i = 0; i < c; i++) cin >> arr3[i];
	sort(arr1,arr1+a,comp);
	sort(arr2,arr2+b,comp);
	sort(arr3,arr3+c,comp);
	ll ans = 0;
	int i = 0, j = 0, k = 0;
	while(i + j + k != x+y){
		if(i < min(x,a) && (arr1[i] >= arr2[j] || j == min(y,b)) && (arr1[i] >= arr3[k] || k == min(x-i+y-j,c))){
			ans+=arr1[i];
			//cout << arr1[i] << endl;
			i++;
		}
		else if( j < min(y,b) && (arr2[j] >= arr1[i] || i == min(x,a)) && (arr2[j] >= arr3[k] || k == min(x-i+y-j,c))){
			ans+=arr2[j];
			//cout << arr2[j] << endl;
			j++;
		}
		else if(k < min(x+y-i-j,c)){
			ans+=arr3[k];
			//cout << arr3[k] << endl;
			k++;
		}
	}
	cout << ans << "\n";
	return 0;
}



Measured memory_bytes: 2560
def main():
    MOD = 10**9 + 7
    N = int(input())
    T = [int(i) for i in input().split()]
    A = [int(i) for i in input().split()]
    if T[-1] != A[0]:
        return print(0)
    ma_idx_T = T.index(max(T))
    # print(ma_idx_T)
    if A[ma_idx_T] != T[ma_idx_T]:
        return print(0)
    non_fix = [True] * N
    non_fix[0] = False
    non_fix[-1] = False
    for i in range(1, N):
        if T[i-1] < T[i]:
            non_fix[i] = False
            ma_idx_T = i
        else:
            continue

    for i in range(N-1)[::-1]:
        if A[i] > A[i+1]:
            non_fix[i] = False
        else:
            continue
    ans = 1
    # print(non_fix)
    for i, f in enumerate(non_fix):
        if f:
            ans *= min(T[i], A[i])
            ans %= MOD
    print(ans % MOD)


if __name__ == '__main__':
    main()


Measured memory_bytes: 82148
# coding: utf-8
A = int(input())
B = int(input())
C = int(input())
X = int(input())

cnt = 0
for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            if i * 500 + j * 100 + k * 50 == X:
                cnt = cnt + 1
                
print(cnt)


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

int calcScore(int n, int N, int **player){
	int fi = player[n][0], se = player[n][1], th = player[n][2];

	for(int i=0; i<N; i++){
		if(i != n){
			if(player[i][0] == player[n][0]) fi = 0;
			if(player[i][1] == player[n][1]) se = 0;
			if(player[i][2] == player[n][2]) th = 0;
		}
	}
	return fi + se + th;
}

int main(){
	int N;
	int **player;

	cin >> N;

	player = new int*[N];
	for(int i=0; i<N; i++){
		player[i] = new int[3];
		cin >> player[i][0] >> player[i][1] >> player[i][2];
	}

	for(int i=0; i<N; i++) cout << calcScore(i, N, player) << endl;

	for(int i=0; i<N; i++) delete[] player[i];
	delete[] player;
	return 0;
}

Measured memory_bytes: 1196
// AtCoder ABC107: C - Candles
// 2019.9.11 bal4u

#include <stdio.h>

#if 1
int getchar_unlocked(void);
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif

int in() {  // 整数の入力
	int n = 0, c = gc();
	if (c == '-') {	c = gc();
		do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
		return -n;
	}
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

#define MIN(a,b)  ((a)<=(b)?(a):(b))
#define MAX(a,b)  ((a)>=(b)?(a):(b))
#define ABS(a)    ((a)>=0?(a):-(a))
int N, K;
int x[100005];

// 見つからなければ、一つ小さい要素を返す
int bs(int t)
{
	int m, l = 0, r = N;

    while (l < r) {
        m = (l+r) >> 1;
        if (x[m] <= t) l = m + 1; else r = m;
    }
	return l-1;
}

int main()
{
	int i, ans, t;
	
	N = in(), K = in();
	for (i = 0; i < N; i++) x[i] = in();
	if (x[0] >= 0) { printf("%d\n", x[K-1]); return 0; }
	
	ans = 0x7fffffff;
	i = bs(0); while (N-i < K) i--;
	for ( ; i >= 0; i--) {
		t = x[K+i-1]-x[i] + MIN(ABS(x[K+i-1]), ABS(x[i]));
		if (t < ans) ans = t;
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b;
    cin >> a >> b;
    cout << a + (b - a) * 2 << endl;
}

Measured memory_bytes: 256
// ABC 126 E: 1 or 2
// https://atcoder.jp/contests/abc126/tasks/abc126_e

#include <iostream>
#include <vector>
#include <algorithm>
#define NIL -1
using intpair = std::pair<int,int>;

std::vector<std::vector<intpair>> adjacency_list;
std::vector<bool> node_stat;
std::vector<int> modulo_memo;

void SetNodeRelation(int vertex) {
    node_stat.at(vertex) = false;
    for (int i=0; i<adjacency_list.at(vertex).size(); i++) {
        int next_vertex = adjacency_list.at(vertex).at(i).first;
        int edge = (adjacency_list.at(vertex).at(i).second + modulo_memo.at(vertex)) % 2;
        modulo_memo.at(next_vertex) = edge;
        if (node_stat.at(next_vertex)) {
            SetNodeRelation(next_vertex);
        }
    }
}

int main() {
    int total_card_num, total_hint_num;
    std::cin >> total_card_num >> total_hint_num;
    adjacency_list.resize(total_card_num+1);
    node_stat.assign(total_card_num+1, true);
    modulo_memo.assign(total_card_num+1, NIL);
    for (int i=0; i<total_hint_num; i++) {
        int vertex, next_vertex, edge; std::cin >> vertex >> next_vertex >> edge;
        edge %= 2;
        adjacency_list.at(vertex).push_back(std::make_pair(next_vertex, edge));
        adjacency_list.at(next_vertex).push_back(std::make_pair(vertex, edge));
    }

    int count = 0;
    for (int i=1; i<adjacency_list.size(); i++) {
        if (node_stat.at(i)) {
            modulo_memo.at(i) = 0;
            SetNodeRelation(i);
            count++;
        }
    }
    std::cout << count << "\n"; 
}

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

#define loop(i,a,b) for(ll i=a; i<b; i++)
#define rloop(i,a,b) for(ll i=a; i>b; i--)
#define all(var) var.begin(), var.end()
#define eloop(var) for(auto elem : var)
#define debug(x) cerr<<#x<<" ----> "<<x<<endl;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define TC ll _t; cin>>_t; while(_t--)
#define SET(a) memset(a,-1,sizeof(a))
#define CLR(a) memset(a, 0, sizeof(a))
#define INF 0x7fffffff
#define LINF 2000000000000000007
#define MOD 1000000007
#define MAX 100005
#define sz(var) (ll)var.size()
typedef long long ll;
typedef long double ld;
typedef vector<ll> vll;
typedef vector<pair<ll, ll> > vpl;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    // TC
    {
        ll n;
        cin>>n;
        string s;
        cin>>s;
        ll cntr=0, cntw=0;
        loop(i,0,n) {
            if(s[i]=='R')
                cntr++;
            else
                cntw++;
        }
        if(cntr==0 || cntw==0) {
            cout<<"0\n";
            return 0;
        }
        ll cnt=0;
        rloop(i,n-1,-1) {
            if(cntw) {
                cntw--;
                if(s[i]=='R')
                    cnt++;
            }
        }
        cout<<cnt<<'\n';
    }
    return 0;
}

Measured memory_bytes: 3764
#include<iostream>
#include<string>
using namespace std;
int main() {
	string S;
	string A, B, C;
	cin >> S ;
	A = S.substr(0, 4);
	B = S.substr(5, 2);
	C = S.substr(8, 2);
	if (A >= "2020") {
		cout << "TBD" << endl;
		return 0;
	}
	else if (A == "2019") {
		if (B >= "05") {
			cout << "TBD" << endl;
			return 0;
		}
		else {
			cout << "Heisei" << endl;
			return 0;
		}

	}
	else {
		cout << "Heisei" << endl;
		return 0;
	}

}


Measured memory_bytes: 256
#include<stdio.h>

int max=100;

int main(){
  int x[max][max];
  int n, i, j, u, v, num;
  scanf("%d",&n);
  for(i=0 ; i<n ; i++){
    for(j=0 ; j<n ; j++){
      x[i][j]=0;
    }
  }
  for(i=0 ; i<n ; i++){
    scanf("%d%d",&u, &num);
    u=u-1;
    for(j=0 ; j<num ; j++){
      scanf("%d", &v);
      v=v-1;
      x[u][v]=1;
    }
  }
  for(i=0 ; i<n ; i++){
    for(j=0 ; j<n ; j++){
      if(j!=0)printf(" ");
      printf("%d", x[i][j]);
    }
    printf("\n");
  }
  return 0;
}



Measured memory_bytes: 2084
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

constexpr ll infl = 10000000000000007LL;
constexpr int inf = 1000000007;

int main() {
    int n;
    cin >> n;
    vector<string> grid(n);
    for (int i = 0; i < n; ++i) {
        cin >> grid[i];
    }

    int ans = 0;
    for (int k = 0; k < n; ++k) {
        vector<vector<char>> temp_grid(n, vector<char>(n));
        for (int i = 0; i < n; ++i) {
            for (int j = 0; j < n; ++j) {
                temp_grid[i][j] = grid[(i + k) % n][j];
            }
        }

        bool symmetry = true;
        for (int i = 0; i < n; ++i) {
            for (int j = 0; j < n; ++j) {
                if (temp_grid[i][j] != temp_grid[j][i])
                    symmetry = false;
            }
        }

        if (symmetry)
            ++ans;
    }

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

Measured memory_bytes: 640
import java.util.Scanner;

// ABC098 at 2018/05/26

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solveA();
    }

    private void solveA() {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int ans = A + B;
        if (ans < A - B) {
            ans = A - B;
        }
        if (ans < A * B) {
            ans = A * B;
        }
        System.out.println(ans);
    }

    private void solveB() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        System.out.println(N);
    }

    private void solveC() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        System.out.println(N);
    }

    private void solveD() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        System.out.println(N);
    }

    private void solveE() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        System.out.println(N);
    }

    private void solveF() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        System.out.println(N);
    }

}

Measured memory_bytes: 23508
///بِسْمِ الّٰلهِ الرَّحْمٰنِ الرَحِيْمِ
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pi acos(-1.0)
int main()
{
     ios_base::sync_with_stdio(false);cin.tie(NULL);
     ll int i,n,t,j=0,p,x,a=0,b,l=0,r=0,y,k,c,sum=0,m,d;
     cin>>n;
     int ara[n+1]={};
     for(i=1;i<=n;i++){
        for(j=1;j<=n;j++){
            for(k=1;k<=n;k++){
                p=i*i+j*j+k*k+i*j+j*k+i*k;
                if(p<=n){
                    ara[p]++;
                }
                else{
                    break;
                }
            }
        }
     }
     for(i=1;i<=n;i++){
        cout<<ara[i]<<endl;
     }

     return EXIT_SUCCESS;
}


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

using ll = long long;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using pint = pair<int, int>;
#define repi(n) for (int i = 0; i < n; i++)
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, a, b) for (int i = a; i < b; i++)
#define repv(itr) for (auto&& v : itr)

const int dx[] = {-1, 0, 0, 1, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, -1, 1, -1, 1};
template <typename T>
T minptr(T begin, T end) {
  T re = begin;
  for (T i = begin + 1; i != end; i++) {
    if (*i < *re) re = i;
  }
  return re;
}
template <typename T>
T maxptr(T begin, T end) {
  T re = begin;
  for (T i = begin + 1; i != end; i++) {
    if (*i > *re) re = i;
  }
  return re;
}
int __vmax(int x) {
  return INT_MAX;
}
double __vmax(double x) {
  return 1e+300;
}
ll __vmax(ll x) {
  return LLONG_MAX;
}
int __vmin(int x) {
  return INT_MIN;
}
double __vmin(double x) {
  return -1e+300;
}
ll __vmin(ll x) {
  return LLONG_MIN;
}
template <typename T>
vector<T> lis(T begin, T end, bool allowequal = false, bool lds = false) {
  using V = typename iterator_traits<T>::value_type;
  int n = end - begin;
  vector<V> a(n, lds ? __vmin(*begin) : __vmax(*begin));
  vector<int> id(n);
  if (lds && allowequal) {
    for (int i = 0; i < n; i++) {
      id[i] = n - 1 -
              (lower_bound(a.rbegin(), a.rend(), begin[i]) - 1 - a.rbegin());
      a[id[i]] = begin[i];
    }
  } else if (lds) {
    for (int i = 0; i < n; i++) {
      id[i] = n - 1 -
              (upper_bound(a.rbegin(), a.rend(), begin[i]) - 1 - a.rbegin());
      a[id[i]] = begin[i];
    }
  } else if (allowequal) {
    for (int i = 0; i < n; i++) {
      id[i] = upper_bound(a.begin(), a.end(), begin[i]) - a.begin();
      a[id[i]] = begin[i];
    }
  } else {
    for (int i = 0; i < n; i++) {
      id[i] = lower_bound(a.begin(), a.end(), begin[i]) - a.begin();
      a[id[i]] = begin[i];
    }
  }
  int m = *maxptr(id.begin(), id.end());
  vector<T> re(m + 1);
  for (int i = n - 1; i >= 0; i--) {
    if (id[i] == m) re[m--] = begin + i;
  }
  return re;
}
// class segtree {
//  private:
//   int n;
//   bool maxmode;
//   vint* data;
//   void update(int i) {
//     (*data)[i] = maxmode ? max((*data)[i * 2 + 1], (*data)[i * 2 + 2])
//                          : min((*data)[i * 2 + 1], (*data)[i * 2 + 2]);
//     if (i) update((i - 1) / 2);
//   }

//  public:
//   segtree(int n_, bool maxmode_ = false) {
//     n = pow(2, ceil(log2(n_)));
//     cout << n << endl;
//     maxmode = maxmode_;
//     data = new vint(n * 2 - 1, maxmode ? INT_MIN : INT_MAX);
//   }
//   ~segtree() { delete data; }
//   void set(int i, int v) {
//     (*data)[n - 1 + i] = v;
//     if (n) update((n + i - 2) / 2);
//   }
//   int calc(int a, int b) {
//     // TODO
//     return 0;
//   }
// };

int main() {
  int a, b, c;
  cin >> a >> b;
  if ((a - b) % 2) {
    cout << "IMPOSSIBLE\n";
  } else {
    cout << (a + b) / 2 << endl;
  }
}


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

#define lli long long int
int	main(void)
{
	long long int n, k;
	long long int *a;
	scanf("%lld %lld", &n, &k);
	a = (long long int *)malloc(sizeof(lli)*(n));

	int i = 0;
	while (i < n)
	{
		scanf("%lld", &(a[i]));
		i++;
	}
	i = 0;
	while (i < n - k)
	{
		if (a[i] < a[k+i])
			printf("Yes\n");
		else
			printf("No\n");
		i++;
	}
	return(0);
}


Measured memory_bytes: 3652
#include<stdio.h>

int main(){
	
	int n,t,x;
	scanf("%d %d %d",&n,&x,&t);
	
	int a = n - n%x;
	int b = (n - n%x)/x;
	
	if(n%x != 0){
		printf("%d",(b+1)*t);
	}else
		printf("%d",b*t);
		
	
	return 0;
}

Measured memory_bytes: 1692
#include <bits/stdc++.h>
#define REP(i, n) for(long long i = 0; i < n; i++)
#define REPR(i, n) for(long long i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(long long i = m; i <= n; i++)
#define FORR(i, m, n) for(long long i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;



int main(){FIN

    ll n;cin>>n;
    ll cnt=0;
    vll a(n); REP(i,n) {
        cin>>a[i];
        if (a[i]<0) cnt++;
    }
    // cout<<cnt<<endl;
    ll ans=0;
    if (cnt%2==0){
        REP(i,n) ans+=abs(a[i]);
    }
    else{
        ll mn = 1e9;
        REP(i,n) {
            ans+=abs(a[i]);
            mn = min(mn, abs(a[i]));
        }
        // cout<<mn<<' '<<ans<<endl;
        ans-=mn;
        ans-=mn;
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e18;
const ll mod = 1000000007;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
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;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (a < b) {
    ll tmp = a;
    a = b;
    b = tmp;
  }
  ll r = a%b;
  while(r != 0) {
    a = b;
    b = r;
    r = a%b;
  }
  return b;
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}

int main() {
  ll n;
  cin >> n;
  vector <ll> dp(n+1);
  dp.at(0) = 2;
  dp.at(1) = 1;
  for (ll i = 2; i <= n; i++) {
    dp.at(i) = dp.at(i-1) + dp.at(i-2);
  }
  cout << dp.at(n) << endl;
}

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


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


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

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

  int A[5], Sm = INF;

  for (int i = 0; i < 5; i ++)
    std::cin >> A[i];

  std::sort(A, A + 5);

  do {
    int S = 0;

    for (int i = 0; i < 4; i ++) {
      int t = A[i];

      if (t % 10)
        t = (t / 10 + 1) * 10;

      S += t;
    }

    S += A[4];

    Sm = std::min(S, Sm);
  } while (std::next_permutation(A, A + 5));

  std::cout << Sm << std::endl;

  return 0;
}


Measured memory_bytes: 384
#include <cmath>

#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <queue>
#include <fstream>
using namespace std;

#define maxn 310
#define inf 1000000000
#define ll long long
#define mod 1000000007

int w, h;
string s[maxn];
int precalc[2][maxn][maxn];
int dp[maxn][maxn];

int cost(int k1, int k2) {
    int i = h - k1;
    int j = h - k2;
    if (i > j) {
        return precalc[0][i-j][i];
    } else {
        return precalc[1][j-i][j];
    }
}

int main() {
    // freopen("test.in", "r", stdin);

    cin >> h >> w;
    for (int i = 1; i <= h; ++i) {
        cin >> s[i];
        s[i] = "#" + s[i];
    }

    int ans = 0;
    for (int j = 1; j < w; ++j) {
        for (int dif = 0; dif <= h; ++dif) {
            for (int i = 1; i <= h; ++i) {
                precalc[0][dif][i] = precalc[0][dif][i-1] + (i-dif >= 1 && s[i][j] == s[i-dif][j+1] ? 1 : 0);
            }
        }

        for (int dif = 0; dif <= h; ++dif) {
            for (int i = 1; i <= h; ++i) {
                precalc[1][dif][i] = precalc[1][dif][i-1] + (i-dif >= 1 && s[i][j+1] == s[i-dif][j] ? 1 : 0);
            }
        }

        dp[0][0] = 0;
        for (int k1 = 0; k1 <= h; ++k1) {
            for (int k2 = 0; k2 <= h; ++k2) {
                if (k1 == 0 && k2 == 0)
                    continue;
                dp[k1][k2] = inf;
                if (k1 > 0) {
                    dp[k1][k2] = min(dp[k1][k2], dp[k1-1][k2] + cost(k1-1, k2));
                }
                if (k2 > 0) {
                    dp[k1][k2] = min(dp[k1][k2], dp[k1][k2-1] + cost(k1, k2-1));
                }
            }
        }

        ans += dp[h][h];
    }

    cout << ans;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    ll k,s;
    cin >> k >> s;
    ll ans = 0;
    for(ll i = 0; i <= k; i++){
        for(ll j = 0; j <= k; j++){
            if(s - i - j >= 0 && s - i - j <= k)
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define puts(i) cout << i << endl
#define INF INT_MAX;
#define INFL LLONG_MAX;
typedef long long ll;
using namespace std;

int main(){
  ll n,t; cin >> n >> t;
  vector<ll> time(n);
  rep(i,n) cin >> time.at(i);
  ll ans = 0;
  rep(i,n-1){
    ll diff = time.at(i+1)-time.at(i);
    ans += min(t,diff);
  }

  cout << ans+t <<endl;
}


Measured memory_bytes: 1792
a, b = map(int, input().split())

a_l = []
b_l = []

for i in range(a):
    a_l += str(b)
    
for i in range(b):
    b_l += str(a)
    
a_l = ''.join(a_l)    
b_l = ''.join(b_l)

all = []
all.append(a_l)
all.append(b_l)
all.sort()
print(all[0])

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

int main() {
	string n; cin >> n;
	int count = 1;
	for (int i = 1; i < n.length(); i++) {
		if (n[i - 1] == n[i]) {
			count++;
		}
		else {
			count = 1;
		}
		if (count == 3) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int gcd(long long a,long long b)
{
	if(b==0)
		return a;
	return gcd(b,a%b);
}
int main()
{
	long long a,b;
	cin>>a>>b;
	long long ans=(long long)(a*b);
	ans/=gcd(a,b);
	cout<<ans;
} 

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

#define mod 1000000007
#define modd 998244353
#define PI 3.1415926
#define ll long long
#define ld long double
#define pb push_back
#define popb pop_back
#define beg begin()
#define en end()
#define sz(v) (int)((v).size())
#define all(v) (v).begin(),(v).end()
#define ub upper_bound
#define lb lower_bound
#define ff first
#define ss second
#define endl "\n"
#define forn(i,a,n) for(int i=a;i<int(n);++i)
#define forb(i,a,n) for(int i=int(n)-1;i>=a;--i)
#define cout(ans) cout<< ans << "\n"
#define couts(ans) cout<< ans <<" "
#define coutss(a,b) cout<< a <<" "<< b << "\n"
#define coutsm(a,b,c) cout<< a <<" "<< b <<" "<< c << "\n"
#define maxx *max_element
#define minn *min_element


void speed()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
    cout.tie(NULL);
}

int dp[100001];

void solve()
{      
    int n,k;cin>>n>>k;
    int a[n];
    forn(i,0,n)
    {
        cin>>a[i];
    }
    forn(i,1,k+1)
    {
        forn(j,0,n)
        {
            if(i-a[j]>=0 && !dp[i-a[j]])
            {
                dp[i]=1;
            }
        }
    }
    if(dp[k])
        cout<<"First\n";
    else
        cout<<"Second\n";

}


int main()
{   
    speed();
    int tc=1;
    // cin>>tc;
    while(tc--)
    {
        solve();
    }
}

Measured memory_bytes: 4072
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007,mod2 = 998244353;

void chmin(long long &a, long long b) { if (a > b) a = b; }
void chmax(long long &a, long long b) { if (a < b) a = b; }
const long long INF = 1LL<<60;
ll gcd(ll a,ll b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}

//重みある時
using Edge = pair<int,int>;
using Graph = vector<vector<Edge> >;

int main() {
    ll a,b,k;
    cin >> a >> b >> k;
    if(k < a){
        cout << a-k << " " << b << endl;
    }else{
        ll nokori = k-a;
        if(nokori < b){
            cout << 0 << " " << b-nokori << endl;
        }else{
            cout << 0 << " " << 0 << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
using namespace std;
///////////////////library zone!!!!!!!!!!!!!!!!!!!!!!!!!!!!
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
#define EPS (1e-5)
#define bit(n,k) ((n>>k)&1)
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H& b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H & b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H & b) const { return x == b.x && y == b.y; }
	bool operator!=(const H & b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P& b) const { return cost < b.cost; }
	bool operator>(const P& b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E& b) const { return cost < b.cost; }
	bool operator>(const E& b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T & a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T & a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j % i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
int n;
int a[200000];
signed main() {
	cin >> n;
	int ma = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		ma = max(a[i], ma);
	}
	int res = 0;
	for (int i = 0; i < n; i++) {
		if (abs(ma / 2. - a[i]) < abs(ma / 2. - res)) {
			res = a[i];
		}
	}
	cout << ma << " " << res << endl;
}

Measured memory_bytes: 1024