akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using static AtCoder.Io;
namespace AtCoder
{
    class Program
    {
        static void Main()
        {
            var abx = ReadLongArray();
            var a = abx[0];
            var b = abx[1];
            var x = abx[2];
            Console.WriteLine($"{b / x - a / x + (a % x == 0 ? 1 : 0)}");
        }
    }

    public static class Io
    {
        public static string ReadString() => Console.ReadLine();
        public static string[] ReadStringArray() => ReadString().Split(' ');
        public static int ReadInt() => int.Parse(ReadString());
        public static long ReadLong() => long.Parse(ReadString());
        public static int[] ReadIntArray() => ReadStringArray().ParseInt().ToArray();
        public static long[] ReadLongArray() => ReadStringArray().ParseLong().ToArray();
        public static IEnumerable<int> ParseInt(this IEnumerable<string> source) => source.Select(int.Parse);
        public static IEnumerable<long> ParseLong(this IEnumerable<string> source) => source.Select(long.Parse);
    }


}


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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    ll n,m,R;
    cin >> n >> m >> R;
    vector<ll> r(R);
    for(i = 0;i < R;++i){
        cin >> r.at(i);
        --r.at(i);
    }
    sort(all(r));
    vector<vector<ll>> graph(n,vector<ll> (n,1e9+7));
    for(i = 0;i < n;++i){
        graph.at(i).at(i) = 0;
    }
    for(i = 0;i < m;++i){
        ll a,b,c;
        cin >> a >> b >> c;
        --a;    --b;
        graph.at(a).at(b) = c;
        graph.at(b).at(a) = c;
    }
    ll k;
    rep(k,n){
        for(i = 0;i < n;++i){
            rep(j,n){
                graph.at(i).at(j) = min(graph.at(i).at(j), graph.at(i).at(k) + graph.at(k).at(j));
            }
        }
    }
    ll ans = 1e9 + 7;
    do{
        ll tmp = 0;
        for(i = 0;i < R-1;++i){
            ll s = r.at(i);
            ll g = r.at(i+1);
            tmp += graph.at(s).at(g);
        }
        ans = min(ans, tmp);
    }while(next_permutation(all(r)));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
import java.io.*
import java.util.*

fun solve(N: Int, X: Long) {
    val sizes = LongArray(51)
    val patties = LongArray(51)
    sizes[0] = 1
    patties[0] = 1
    for (i in 1..N) {
        sizes[i] = 2 * sizes[i - 1] + 3
        patties[i] = 2 * patties[i - 1] + 1
    }
    fun pattyAmount(n: Int, x: Long): Long {
        if (x == 0L) return 0L
        if (n == 0) return 1L
        if (x == 1L) return 0L
        if (x >= sizes[n]) return patties[n]
        if (x >= (sizes[n] + 1) / 2) {
            return (patties[n] + 1) / 2 + pattyAmount(n, x - (sizes[n] + 1) / 2 + 1)
        }
        return pattyAmount(n - 1, x - 1)
    }
    println(pattyAmount(N, X))
    return
}

fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    class Scanner(stream: InputStream) {
        private val reader = BufferedInputStream(stream).bufferedReader()
        private var st: StringTokenizer? = null
        fun next(): String {
            while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
            return st!!.nextToken()
        }
    }
    val sc = Scanner(System.`in`)
    val N = sc.next().toInt()
    val X = sc.next().toLong()
    solve(N, X)
}


Measured memory_bytes: 31520
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    string s;
    cin>>s;
    int n=s.length();
    bool ok1=false;
    bool ok2=false;
    rep(i,n){
        if(s[i]=='C'){
            ok1=true;
        }
        if(s[i]=='F'&&ok1==true){
            ok2=true;
        }
    }
    if(ok1==true&&ok2==true)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <set>
#include <vector>
#include <cstring>
#include <iostream>
using namespace std;
int main() {
    set<long long> ops[51][51];
    for (int a = 0; a <= 50; a++) {
        ops[a][a] = {0};
        for (int b = 0; b < a; b++) {
            for (int m = 1; m <= a; m++) {
                long long s = 1LL << m;
                for (long long o : ops[a%m][b])
                    ops[a][b].insert(s | o);
            }
        }
    }
    int n; cin >> n;
    int A[n], B[n];
    for (int i = 0; i < n; i++) cin >> A[i];
    for (int i = 0; i < n; i++) cin >> B[i];
    set<long long> cand[n];
    for (int i = 0; i < n; i++) {
        cand[i] = ops[A[i]][B[i]];
        if (cand[i].empty()) { cout << "-1\n"; return 0; }
    }
    long long ans = 0;
    for (long long m = (1LL << 50); m > 0; m >>= 1) {
        bool use = false;
        for (int i = 0; i < n; i++)
            if (*(cand[i].begin()) >= m) use = true;
        if (!use) continue;
        ans += m;
        for (int i = 0; i < n; i++) {
            set<long long> temp;
            for (long long o : cand[i]) temp.insert(o & ~m);
            cand[i].swap(temp);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 2304
object Main extends App {
	var N = scala.io.StdIn.readInt
	val S = scala.io.StdIn.readLine

	def find(x: List[Char]): Array[Int] = {
		val n = x.size
		val a: Array[Int] = new Array(n)

		for(i<- 0 until n){
			for(j <- 0 to i){
				x(j) match {
					case '(' => a(i) = a(i) + 1
					case ')' => a(i) = a(i) - 1
					case _ =>
				}
			}
		}

		return a;
	}

	def tail(x: List[Char], y: Char): List[Char] = {
		var temp: List[Char] = List(y)
		for(i <- x.size - 1 to 0 by -1){
			temp = x(i)::temp
		}
		temp
	}

	var s = S.toList
	var temp = find(s)
	var a = temp.min
	var b = temp(temp.size - 1)

	while(a!=0 || b!=0){
		if(b<0){
			for(i<-0 until -b){
				s = '(' :: s
			}
		}
		if(b>0){
			for(i<- 0 until b){
				s = tail(s, ')')
			}
		}
		if(a<0 && b == 0){
			for(i<- 0 until -a){
				s = '(' :: s
			}
		}

		temp = find(s)
		a = temp.min
		b = temp(temp.size - 1)
	}

	for(i<- 0 until temp.size){
		print(s(i))
	}

}

Measured memory_bytes: 26436
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
const int INF = 1001001001;
const ll LINF = 1LL << 60;

template <typename T>
void print(const T &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << ' ';
        cout << v[i];
    }
    cout << endl;
}

const ull MASK30 = (1UL << 30) - 1;
const ull MASK31 = (1UL << 31) - 1;
const ull MOD = (1UL << 61) - 1;
const ull MASK61 = MOD;
const ull POSITIVIZER = MOD * ((1UL << 3) - 1);
const unsigned int Base = 1000000007;
ull powMemo[5001];
ull hashes[5001];

//mod 2^61-1を計算する関数
ull CalcMod(ull x)
{
    ull xu = x >> 61;
    ull xd = x & MASK61;
    ull res = xu + xd;
    if (res >= MOD)
        res -= MOD;
    return res;
}

//a*b mod 2^61-1を返す関数(最後にModを取る)
ull Mul(ull a, ull b)
{
    ull au = a >> 31;
    ull ad = a & MASK31;
    ull bu = b >> 31;
    ull bd = b & MASK31;
    ull mid = ad * bu + au * bd;
    ull midu = mid >> 30;
    ull midd = mid & MASK30;
    return CalcMod(au * bu * 2 + midu + (midd << 31) + ad * bd);
}

ull Slice(int start, int length)
{
    return CalcMod(hashes[start + length] + POSITIVIZER - Mul(hashes[start], powMemo[length]));
}

void rolling_hash(string const &s)
{
    for (int i = 0; i < s.size(); i++)
    {
        hashes[i + 1] = CalcMod(Mul(hashes[i], Base) + s[i]);
    }
    powMemo[0] = 1;
    for (int i = 1; i < 5001; i++)
        powMemo[i] = CalcMod(Mul(powMemo[i - 1], Base));
}

int main()
{
    int n;
    string s;
    cin >> n >> s;
    rolling_hash(s);
    // 二分探索
    int left = -1, right = (n / 2) + 1;
    while (right - left > 1)
    {
        int length = (left + right) / 2;
        bool exist_same = false;

        // 基準文字列の始点
        for (int i = 0; i < n && !exist_same; i++)
        {
            for (int j = i + length; j < n; j++)
            {
                if (j + length > n)
                {
                    break;
                }
                if (Slice(i, length) == Slice(j, length))
                {
                    exist_same = true;
                }
            }
        }
        if (exist_same)
        {
            left = length;
        }
        else
        {
            right = length;
        }
    }
    cout << left << endl;
    return 0;
}


Measured memory_bytes: 3720
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

struct UnionFind {
	vector<int> v;
	UnionFind(int n) : v(n) { for (int i = 0; i < n; i++) v[i] = i; }
	int  find(int x) { return v[x] == x ? x : v[x] = find(v[x]); }
	void unite(int x, int y) { v[find(x)] = find(y); }
};

int main() {
	int T;
	while (cin >> T, T) {
		vi t(T);
		REP(i, T) {
			cin >> t[i];
		}
		int n;
		cin >> n;
		map<int, int> inv;
		REP(i, n) {
			int a, b;
			cin >> a >> b;
			if(!EXIST(inv,a))
				inv[a] =b;
			else
				inv[a] = min(inv[a],b);
		}
		vvi dp(101, vi(T, 10000));
		dp[1][0] = 0;
		FOR(i, 2, 101) {
			REP(j, T) {
				if (j == 0) {
					REP(k, T)
						dp[i][j] = min(dp[i][j], dp[i - 1][k] + 1);
				}

				if (inv.find(i) == inv.end()) {
					if (i >= j)
						dp[i][j] = min(dp[i][j], dp[i - 1][(j + T - 1) % T]);
				}
				else {
					if (i >= j&&t[j] <= inv[i])
						dp[i][j] = min(dp[i][j], dp[i - 1][(j + T - 1) % T]);
				}
			}
		}
		int ans = 100000;
		REP(i, T)
			ans = min(ans, dp[100][i]);
		cout << ans << endl;
	}
}

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

int main () {
    int N;
    cin >> N;
    vector<int> A(N), B(N), C(N-1);

    for (int i = 0; i < N; i++) {
        cin >> A.at(i);
    }

    for (int i = 0; i < N; i++) {
        cin >> B.at(i);
    }

    for (int i = 0; i < N - 1; i++) {
        cin >> C.at(i);
    }

    int satisfy = B.at(A.at(0) - 1);

    for (int i = 1; i < N; i++) {
        satisfy += B.at(A.at(i) - 1);

        if (A.at(i) - A.at(i - 1) == 1) {
            satisfy += C.at(A.at(i - 1) - 1);
        }

    }

    cout << satisfy << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using vl=vector<long long>;
using pii=pair<int,int>;
using pll=pair<long long,long long>;
#define ITR(i,c) for(auto i=begin(c);i!=end(c);++i)
#define FORE(x,c) for(auto &x:c)
#define FOR(i,a,n) for(int i=a,i##_len=(int)(n);i<i##_len;++i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i=(int)(n);i>=0;--i)
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)   // c++14
#define SZ(c) ((int)c.size())
#define EXIST(c,x) (c.find(x)!=end(c))
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,v) os << *i << (i==end(v)-1 ? "" : " "); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,v) is >> * i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
        is >> p.first >> p.second; return is; }
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;}
//------------------------------------------------------------------------------
struct before_main_function {
    before_main_function() {
        #ifdef int
            #undef INF
            #define INF INFLL
            #define stoi stoll
        #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
    }
} before_main_function;
//------------------------------------------------------------------------------

signed main() {
    int N;
    cin>>N;
    vector<string> s(N);
    cin>>s;
    set<string> NG;
    REP(i,N) {
        REP(j,SZ(s[i])) {
            FOR(k,1,5) {
                NG.insert(s[i].substr(j,k));
            }
        }
    }
    NG.insert("");
    for(char i='a'-1; i<='z'; i++) {
        for(char j='a'-1; j<='z'; j++) {
            for(char k='a'-1; k<='z'; k++) {
                for(char l='a'-1; l<='z'; l++) {
                    string t="";
                    if(i!='a'-1) t+=i;
                    if(j!='a'-1) t+=j;
                    if(k!='a'-1) t+=k;
                    if(l!='a'-1) t+=l;
                    if(!EXIST(NG,t)) {
                        cout<<t<<endl;
                        return 0;
                    }
                }
            }
        }
    }
    return 0;
}

Measured memory_bytes: 42432
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  int H,W;
  cin>>H>>W;
  char s[H][W];
  REP(h,H)REP(w,W)cin>>s[h][w];
  int Yoko[H][W];
  REP(h,H){
    int l=0;
    int r=0;
    while(l<W and r<W){
      if(s[h][l]=='.'){
        while(r<W){
          r++;
          if(s[h][r]=='#')break;
        }
        FOR(i,l,r)Yoko[h][i]=r-l;
        l=r;
      }else {
        Yoko[h][l]=0;
        l++;
        r=l;
      }
    }
  }
  int Tate[H][W];
  REP(w,W){
    int l=0;
    int r=0;
    while(l<H and r<H){
      if(s[l][w]=='.'){
        while(r<H){
          r++;
          if(s[r][w]=='#')break;
        }
        FOR(i,l,r)Tate[i][w]=r-l;
        l=r;
      }else {
        Tate[l][w]=0;
        l++;
        r=l;
      }
    }
  }
  int ans=0;
  REP(h,H)REP(w,W){
    ans=max(ans,Yoko[h][w]+Tate[h][w]-1);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 35456
import bisect
N = int(input())
L = list(map(int,input().split()))
L.sort()

ans = 0
i = 0
while i < N-2:
    j = i+1
    while j < N-1:
        kNG = bisect.bisect_left(L,L[i]+L[j])
        if kNG > j+1:
            ans += kNG-1-j
        j += 1
    i += 1

print(ans)

Measured memory_bytes: 3188
# -*- coding: utf-8 -*-
"""
Created on Sun Jun  7 14:28:00 2020

@author: NEC-PCuser
"""

N, M = map(int, input().split())
x, y = [], []

for i in range(M):
    x_tmp, y_tmp = map(int, input().split())
    x.append(x_tmp)
    y.append(y_tmp)

box = [1] * N 
ball_set = set()
ball_set.add(1)
start_flg = True
for i in range(len(x)):
    if x[i] in ball_set:
        ball_set.add(y[i])
    box[x[i] - 1] -= 1
    box[y[i] - 1] += 1
    if box[x[i] - 1] == 0:
        ball_set.discard(x[i])

print(len(ball_set))



Measured memory_bytes: 17992
#include <bits/stdc++.h>
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define divceil(A, B) ((A + (B - 1)) / B)
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()
#define CERR if(false) cerr

typedef long long ll;

using namespace std;

int main(){

    ll k;
    cin >> k;

    int n = 50;

    ll plus = (k + 49) / 50;

    vector<ll> v(n, n - 1 + plus);

    if(k % 50 != 0){
        rep(i, 50 - k % 50){
            int idx = 0;
            ll maxv = 0;

            rep(j, 50){
                if(maxv < v[j]){
                    idx = j;
                    maxv = v[j];
                }
            }

            rep(j, 50){
                if(j == idx){
                    v[j] = v[j] - 50;
                }else{
                    v[j] = v[j] + 1;
                }
            }
        }
    }


    cout << 50 << endl;
    rep(i,50){
        cout << v[i] << " ";
    }
    cout << endl;


    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    char a[20],b[20];
    scanf("%s%s",a,b);
    bool flag=true;
    int n=strlen(a);
    for(int i=0;i<n;i++){
        if(a[i]!=b[i]) flag=false;
    }
    if(flag) cout<<"Yes";
    else cout<<"No";
    return 0;
}


Measured memory_bytes: 3684
#include <bits/stdc++.h>
using namespace std;
//#define LOCAL
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
#define forn(i,a,b) for(ll i=a;i<b;i++)
#define ft first
#define sd second
#define sz size()
#define pb push_back
#define pob pop_back()
#define pf push_front
#define pof pop_front()
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<char,char> pcc;
typedef pair<double,double> pdd;
typedef pair<long long,long long> pll;
//cout << fixed << setprecision(12) <<x<<endl;

int main(){
fastIO;
#ifdef LOCAL
     freopen("in.txt", "r", stdin);
#endif

int a,p;
cin>>a>>p;
cout<<((a*3)+p)/2<<endl;
}


Measured memory_bytes: 3604
from __future__ import print_function
# import numpy as np
# import numpypy as np
import sys
input = sys.stdin.readline

def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return

import math
import string
import fractions
from fractions import Fraction
from fractions import gcd

def lcm(n,m):
    return int(n*m/gcd(n,m))

import re
import array
import copy
import functools
import operator

import collections
import itertools
import bisect
import heapq


from heapq import heappush
from heapq import heappop
from heapq import heappushpop
from heapq import heapify
from heapq import heapreplace

from queue import PriorityQueue as pq

def reduce(p, q):
    common = fractions.gcd(p, q)
    return (p//common , q//common )
# from itertools import accumulate
# from collections import deque

import random


def main():
    n, k, q = map(int, input().split())
    a = [0 for i in range(q)]
    
    for i in range(q):
        a[i] = int(input())
        a[i] = a[i] - 1         # participant number (index)

    # eprint("########")
    # eprint("num of participant %d men, first points all participants have %d points, collect answers %d quiz," % (n,k,q))
    # eprint("list of participants:")
    # for i in range(n):
    #     eprint("\tparticipant No.%d : p%d" % (i,i))
        
    # for i in range(q):
    #     eprint("the %d who answered collectly is participant No.%d (p%d) " % (i, a[i] ,a[i]) )
    # eprint("########")

    # output if the player _ i won or not.
    # each player wins if he has one point or above when every round ends.
    # there are q collect answers.
    # in the turn i, a_i won.
    # 

    index_p = 0 # the index of each player. # index_p is from 0 to n (0_n)

    b = [0 for index_participant in range(n)]
    for index_q in range(q):          # Q is the num of the quiz
       b[ a[index_q] ]+= 1
    for index_participant in range(n):          # N is the num of the participants
        b[index_participant] += -q + k
        if b[index_participant] > 0:
            print("Yes")
        else:
            print("No")
    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 76332
n=input()
s=list(input())
    
num_s=[]
s_sub=list(set(s))
sum=1
for i in range(len(s_sub)):
    num_s.append(s.count(s_sub[i]))
    sum*=(num_s[i]+1)
    
print((sum-1)%(10**9+7))

Measured memory_bytes: 4084
#include <cstdio>
#include <map>
#include <cmath>
#include <algorithm>

int main()
{
  long long n;
  scanf("%lld", &n);
  std::map<long long, long long> m;
  for (long long i = 0; i < n; ++i)
  {
    long long a;
    scanf("%lld", &a);
    m[a]++;
  }
  long long ans = 0;
  for (auto& p : m)
  {
    ans += (p.first > p.second ? p.second : p.second - p.first);
  }
  printf("%lld\n", ans);
  return 0;
}

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

int main(){
   int N;
   cin >> N;
   vector<int> A(N);
   for(int i=0;i<N;i++){
       cin >> A.at(i);
   }
   sort(A.begin(),A.end());
   int flag=0;
   for(int i=0;i<N-1;i++){
       if(A.at(i)==A.at(i+1)){
           flag=1;
           break;
       }
   }
   if(flag==0){
       cout <<"YES"<<endl;
   }
   else{
       cout << "NO" << endl;
   }
}

Measured memory_bytes: 1024
#include<iostream> //cinなど
#include<string> //文字列
#include<algorithm> //sort など
#include<math.h> //paw(冪乗など)
#include<set> // 集合
#include<map> //写像
#include<stdio.h> //printf
#include<stack>

using namespace std;
int main(){
  int A,B;
  cin>> A >> B;
  if(A+B < 10){
    cout<<A+B<<endl;
  }else{
    cout<< "error"<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cmath>
#include <string>
#include <vector>
#include <cstring>
#include <iomanip>
#include <bits/stdc++.h>

using namespace std;

int main(){
	int n{};
	int K{};
	cin>>n>>K;
	int arr[n]{};
	for(int i{}; i<n; i++)cin>>arr[i];
	int cost[n]{};
	cost[0]=0;
	cost[1]=abs(arr[1]-arr[0]);
	int i{2};
	while(i<n){
		int minix=INT_MAX;
		int index=i-1;
		while((i-index)<=K && index>=0){
			int m;
			m=abs(arr[i]-arr[index])+cost[index];
			minix=min(minix, m);
			index--;
		}
		cost[i]=minix;
		i++;
	}
	cout<<cost[n-1]<<endl;
}

Measured memory_bytes: 4400
#include <string.h>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()

typedef long long lint;

using namespace std;
lint inf = 1e15;

int main() {
  int N, M;
  cin >> N >> M;
  map<int, map<int, lint> > m;
  REP(i, M) {
    lint L, R, C;
    cin >> L >> R >> C;
    L--;
    R--;
    if (m[R][L] == 0)
      m[R][L] = C;
    else
      m[R][L] = min(m[R][L], C);
  }
  map<int, lint> ans;
  ans[0] = 0;
  for (auto em : m) {
    int R = em.first;
    ans[R] = inf;
    for (auto e : em.second) {
      int L = e.first;
      lint C = e.second;
      auto p = ans.lower_bound(L);
      if (p == ans.end()) continue;
      ans[R] = min(ans[R], ans[p->first] + C);
    }
    // ans[R]よりKeyが小さくValueが小さい要素を削除する
    auto itr1 = ans.lower_bound(R);
    lint v = itr1->second;
    auto itr2 = ans.lower_bound(R);
    itr2--;
    while (itr2->second >= v) {
      ans.erase(itr2);
      itr2 = ans.lower_bound(R);
      itr2--;
    }
  }
  if (ans[N - 1] == 0 or ans[N - 1] == inf) {
    cout << -1 << endl;
  } else {
    cout << ans[N - 1] << endl;
  }
  return 0;
}


Measured memory_bytes: 21632
N = int(input())

D1 = [0]*N
D2 = [0]*N
E = [0]*N

for i in range(N):
    D1[i], D2[i] = map(int, input().split())
    if D1[i] == D2[i]:
        E[i] = 1
    else:
        E[i] = 0

for i in range(N-2):
    if E[i:i+3] == [1,1,1]:
        print("Yes")
        exit()

print("No")

Measured memory_bytes: 9200
# 高橋君と青木君がモンスターを闘わせます。
# 高橋君のモンスターは体力が Aで攻撃力が Bです。 青木君のモンスターは体力が Cで攻撃力が Dです。
# 高橋君→青木君→高橋君→青木君→... の順に攻撃を行います。 攻撃とは、相手のモンスターの体力の値を自分のモンスターの攻撃力のぶんだけ減らすことをいいます。
# このことをどちらかのモンスターの体力が 0以下になるまで続けたとき、 先に自分のモンスターの体力が 0以下になった方の負け、そうでない方の勝ちです。
# 高橋君が勝つなら Yes、負けるなら No を出力してください。

A, B, C, D = map(int, input().split())

while A or C > 0:
    aoki_hitpoint = C - B
    if aoki_hitpoint <= 0:
        C = 0
        print("Yes")
        exit()
    else:
        C = aoki_hitpoint

    takahashi_hitpoint = A - D
    if takahashi_hitpoint <= 0:
        print("No")
        A = 0
        exit()
    else:
        A = takahashi_hitpoint

Measured memory_bytes: 9120
# Python3 (3.4.3)
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# function
# -------------------------------------------------------------


# -------------------------------------------------------------
# main
# -------------------------------------------------------------
N,K = map(int,input().split())
TD = [tuple(map(int,input().split())) for _ in range(N)]

# 美味しい順にソートしておく
#  t : ネタの種類
#  d : 美味しさ基礎ポイント
TD.sort(key=lambda x:x[1], reverse=True)

# 美味しい順にK個食べた場合の満足ポイント
ans = 0
s = set() # 食べたネタの集合
r = list() # すでに食べたネタ, あとで交換する用
for i in range(K):
    t,d = TD[i]
    ans += d
    if t not in s:
        s.add(t) # 食べたネタの種類の集合
    else:
        r.append(TD[i])
ans += len(s)**2

Ans = ans

# 美味しい順のK+1番目から, ネタの種類が増えるような操作を順番に試していく
for i in range(K,N):
    t0,d0 = TD[i]
    # まだ食べてないネタ and 交換用の寿司があるなら
    if t0 not in s and len(r) > 0:
        # 交換用の寿司の一番美味しさ基礎ポイントが低いものを交換するのが最善
        t1,d1 = r.pop()
        # 満足ポイントの再計算
        ans = ans - d1 + d0 - len(s)**2 + (len(s)+1)**2
        # 食べたネタの集合に追加
        s.add(t0)
        # 満足度が大きくなったか都度確認
        Ans = max(Ans,ans)

print(Ans)

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

int main() {
    int N;
    cin >> N;
    vector<int> V(N), C(N);
    rep(i, N) cin >> V[i];
    rep(i, N) cin >> C[i];
    int ans = 0;
    for (int bit = 0; bit < (1 << N); ++bit) {
        int price = 0;
        int cost = 0;
        for (int i = 0; i < N; ++i) {
            if (bit & (1 << i)) {
                price += V[i];
                cost += C[i];
            }
        }
        ans = max(ans, price - cost);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3624
#![allow(unused)]

use std::cmp::{min, max};

macro_rules! dbg {
    ($($a:expr),*) => {
        writeln!(
            std::io::stderr(),
            concat!($(stringify!($a), " = {:?}, "),*),
            $($a),*);
    }
}

//
// Based on EbTech's Scanner https://stackoverflow.com/q/56449027
//
struct Scanner<'a, R: std::io::BufRead> {
    reader: R,
    buf: String,
    iter: std::str::SplitWhitespace<'a>,
}

impl<'a, R: std::io::BufRead> Scanner<'a, R> {
    fn new(reader: R) -> Scanner<'a, R> {
        Scanner { reader: reader, buf: String::new(), iter: "".split_whitespace() }
    }

    fn get_str(&mut self) -> &str {
        if let Some(t) = self.iter.next() {
            return t;
        }
        self.buf.clear();
        self.reader.read_line(&mut self.buf).expect("I/O error");
        self.iter = unsafe { std::mem::transmute(self.buf.split_whitespace()) };
        self.get_str()
    }

    fn get<T: std::str::FromStr>(&mut self) -> T {
        self.get_str().parse().ok().expect("Parse error")
    }
}

fn main() {
    let stdin = std::io::stdin();
    solve(Scanner::new(stdin.lock()));
}

fn solve<R: std::io::BufRead>(mut sc: Scanner<R>) {
    let n: usize = sc.get();
    let ps: Vec<f64> = (0..n).map(|_| sc.get()).collect();

    // dp[i][j] = i 枚中 j 枚が表である確率
    // 最初は 0 枚中 0 枚表の確率を便宜上 1. とする
    let dp = (1..(n + 1)).fold(vec![1.], |dp, i| {
        let p = ps[i - 1];
        let mut dp_ = vec![0.; i + 1];
        dp_[0] = dp[0] * (1. - p);
        for j in 1..i {
            dp_[j] = dp[j] * (1. - p) + dp[j - 1] * p;
        }
        dp_[i] = dp[i - 1] * p;
        dp_
    });

    println!("{}", (((n + 1) / 2)..(n + 1)).map(|i| dp[i]).sum::<f64>());
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
template<class T> bool chmin(T& a,T b){if(a>b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a,T b){if(a<b) {a = b; return true;} return false;}
#define all(x) (x).begin(),(y).end()
#define debug(x)  cerr << #x << " = " << (x) << endl;

using P = pair<int,int>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vec<int> A(N),B(N);
    vvec<int> pos(N);
    vec<int> cntA(N),cntB(N);
    for(int i=0;i<N;i++){
        cin >> A[i];
        A[i]--;
        cntA[A[i]]++;
        pos[A[i]].push_back(i);
    }
    for(auto& x:B){
        cin >> x;
        x--;
        cntB[x]++;
    }
    for(int i=0;i<N;i++){
        if(cntA[i]+cntB[i]>N){
            cout << "No\n";
            return 0;
        }
    }
    vec<int> idx(N);
    iota(idx.begin(),idx.end(),0);
    sort(idx.begin(),idx.end(),[&](int i,int j){
        return (cntA[i]+cntB[i]!=cntA[j]+cntB[j]? cntA[i]+cntB[i]>cntA[j]+cntB[j]:i>j);
    });
    vec<int> a;
    for(auto& i:idx){
        for(int j=0;j<cntA[i];j++){
            a.push_back(i);
        }
    }
    sort(idx.begin(),idx.end(),[&](int i,int j){
        return (cntA[i]+cntB[i]!=cntA[j]+cntB[j]? cntA[i]+cntB[i]>cntA[j]+cntB[j]:i>j);
    });
    vec<int> b;
    for(auto& i:idx){
        for(int j=0;j<cntB[i];j++){
            b.push_back(i);
        }
    }
    reverse(b.begin(),b.end());
    int l = 0;
    for(int i=0;i<N;i++) if(a[i]==b[i]){
        swap(b[l++],b[i]);
    }
    vec<int> ans(N);
    for(int i=0;i<N;i++){
        ans[pos[a[i]].back()] = b[i];
        pos[a[i]].pop_back();
    }
    cout << "Yes\n";
    for(int i=0;i<N;i++) cout << ans[i]+1 << (i!=N-1? " ":"\n");
}

Measured memory_bytes: 20656
#include <iostream>
#include <vector>
#include <climits>
using namespace std;


int main(void){
   string a;
   string b;
   cin >> a >> b;
   
   if(a.size() > b.size()){
         cout << "GREATER" << endl;
   }else if(a.size() < b.size()){
         cout << "LESS" << endl;
   }else{// a.size()  == b.size()
         for(int i = 0;i < a.size();i++){
               if(a[i] == b[i])continue;
               if(a[i] < b[i]){
                     cout << "LESS" << endl;
                     return 0;
               }else{
                     cout << "GREATER" << endl;
                     return 0;
               }
         }
         cout << "EQUAL" << endl;
   }
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <map>
#include <unordered_map>
#include <set>
using namespace std;

typedef long long ll;

#define INF 10e17
#define rep(i,n) for(long long i=0; i<n; i++)
#define repr(i,n,m) for(long long i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<long long>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto&& itr : x) { debug(itr); }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

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

    string s;
    cin >> s;
    string s1 = s.substr(0, s.size() / 2);
    ll t;
    if (s.size() % 2) {
        t = s.size() / 2 + 1;
    } else {
        t = s.size() / 2;
    }
    string s2 = s.substr(t);
    reverse(s2.begin(), s2.end());

    // cout << s1 << " " << s2 << endl;

    ll ans = 0;
    for (int i = 0; i < s1.size(); ++i) {
        if (s1[i] != s2[i]) ans += 1;
    }
    cout << ans << endl;
}

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

int main(){

  int N, M, C;
  cin >> N >> M >> C;
  
  vector<int> B(M);
  for(int i=0; i<M; i++)
    cin >> B.at(i);
  
  int count = 0;
  int sum = 0;
  vector<int> A(M);

  for(int i=0; i<N; i++){
    for(int j=0; j<M; j++){
      
      cin >> A.at(j);
      sum += A.at(j)*B.at(j);
    
    }
    sum += C;
    if(sum > 0) count++;
    sum = 0;  
  }
  
  cout << count << endl;

}

Measured memory_bytes: 256
// ~maqsat~
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
#define F first
#define S second
#define in insert
#define pb push_back
#define eb emplace_back
#define sz(x) int(x.size())
#define all(x) x.begin(), x.end()
#define count1 __builtin_popcountl
#define debug(x) cerr << (#x) << " = " << (x) << "\n";
#define TEZ ios_base::sync_with_stdio(false),cin.tie(nullptr);
#define fre(f) if(fopen(f".in", "r")) freopen(f".in", "r", stdin),freopen(f".out", "w", stdout);
 
using namespace std;
using namespace __gnu_pbds;
 
using ll = long long;
using ull = unsigned long long;
// using big = __int128_t; // -10^38...10^38
using db = double;
using ld = long double;
typedef pair<int,int> ii;
typedef pair<ll,ll> pll;
typedef vector<ii> vii;
typedef vector<pll> vll;
typedef vector<int> vi;
typedef vector<ll> vl;
 
template <class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <class T, class U> inline void cmin(T &a, U b) { a = min(a, b); }
template <class T, class U> inline void cmax(T &a, U b) { a = max(a, b); }
template <class T, class U, class X, class Y> inline void psmn(T &a, U b, X &p, Y i) { if(b < a)a = b,p = i; }
template <class T, class U, class X, class Y> inline void psmx(T &a, U b, X &p, Y i) { if(b > a)a = b,p = i; }
 
const int oo = 0x3f3f3f3f;
const ll N = 1e5 + 345;
const ll MOD = 1e9 + 7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const db EPS = 1e-9;
const db PI = acos(-1); // 3.14159265358979323846

struct asd {
	int x, y, z;
};

int main() {
	fre(""); TEZ;

	int n;
	cin >> n;
	int a[25], b[25], c[25];
	for(int i = 0; i < n; i++) cin >> a[i];
	int sum = 0;
	for(int i = 0; i < n; i++) {
		cin >> b[i];
	}
	for(int i = 1; i < n; i++) cin >> c[i];
	for (int i = 0; i < n; ++i) {
		sum += b[a[i]-1];
		// cout << a[i] << ' ' << a[i-1] << '\n';
		if (i > 0 && a[i] - a[i-1] == 1) sum += c[a[i]-1];
	}
	cout << sum;
	return 0;
}


Measured memory_bytes: 256
N = int(input())
b = list(map(int, input().split()))
# print(a)
# print(b)
mini = 1000000
ans = 0
for i in range(N):
    if b[i] < mini:
        mini = b[i]
        ans += 1
    if b[i] == 1:
        break

print(ans)

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

typedef long long ll;

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define tt int tc; cin>>tc; while(tc--)
#define nl cout<<"\n";
#define sp cout<<" ";
#define rep(i, a, b) for(long long i=a; i<b; i++)

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
double PI = 4*atan(1);

int main()
{
    optimize();

    int n, l;
    cin>> n>> l;
    bool zero= 0;

    if( l<=0 && l+n>0)
    {
        zero =1;

        if( (-2*l)+1 <n)
        {
            n+= 2*l -1;
            l= 1-l;
        }
    }

    int ans=  l* n+ (n*(n-1))/2;

    if(!zero)
        ans-= (l>=0? l: l+n-1);


    cout << ans<< "\n";

    return 0;
}




Measured memory_bytes: 3628
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
typedef long long ll;
using namespace std;

int main(void){
  string s;
  cin>>s;
  for(int i=0;i<3;i++){
    if(s[i]==s[i+1]){
      cout<<"Bad"<<endl;
      return 0;
    }
  }
  
  cout<<"Good"<<endl;
	return 0;
}

Measured memory_bytes: 256
/**
 *    author:  otera    
**/
#include<iostream>
#include<string> 
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm> 
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

//#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

void solve() {
	string s; cin >> s;
    int n = (int)s.size();
    if(s[0] == s[n - 1]) {
        if(n % 2 == 0) {
            cout << "First" << endl;
        } else {
            cout << "Second" << endl;
        }
    } else {
        if(n % 2 == 0) {
            cout << "Second" << endl;
        } else {
            cout << "First" << endl;
        }
    }
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

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

int main() {
  ll n;
  cin >> n;
  map<P, int> mp;
  for (int i = 1; i <= n; i++) {
    string s = to_string(i);
    mp[P(s.front(), s.back())]++;
  }

  ll ans = 0;
  for (auto x : mp) {
    for (auto y : mp) {
      P xp = x.first;
      P yp = y.first;
      if (xp.first == yp.second && xp.second == yp.first)
        ans += x.second * y.second;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3668
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define PI acos(-1)

int main(){
    long long x,y,d,ans;
    bool minus_x = false,minus_y = false;
    cin >> x >> y;
    if(x < 0)minus_x = true;
    if(y < 0)minus_y = true;

    d = abs(abs(x) - abs(y));
    if(x == 0 || y == 0){
        if(x == 0 && y < 0 || y == 0 && x > 0)ans = d + 1;
        else ans = d;

    }else{
        if(abs(x) > abs(y)){
        if(minus_x && minus_y)ans = d;
        else if(minus_x || minus_y)ans = d + 1;
        else ans = d + 2;
    }
    else if(abs(x) == abs(y)){
        if(minus_x && minus_y)ans = d;
        else if(minus_x || minus_y)ans = d + 1;
        else ans = d;
    }
    else{
        if(minus_x && minus_y)ans = d + 2;
        else if(minus_x || minus_y)ans = d + 1;
        else ans = d;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
S=input()
N=len(S)
F=S[0:(N-1)//2]
B=S[(N+3)//2-1:N]

if(F==B):
    l=len(F)
    for i in range(l//2):
        if(F[i]!=F[l-1-i]):
            print("No")
            break
    print("Yes")
else:
    print("No")

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

using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for (ll i = (ll)(n) - 1; i >= 0; i--)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1LL << 62)

#define PI (acos(-1))
#define print(x) cout << x << endl
 
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll countDigit(ll n) { return floor(log10(n) + 1); } 
typedef pair <ll,ll> P;
static const ll dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};

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

template <typename T1, typename T2> 
ostream& operator<<(ostream& os, const map<T1, T2>& m) 
{ 
    for (auto p : m) os << "<" << p.first << ", " << p.second << "> "; 
    return os; 
}

int main()
{
    ll A, B, M;
    cin >> A >> B >> M;
    vector<ll> a(A);
    rep(i, A) { 
        cin >> a[i];
    }
    vector<ll> b(B);
    rep(i, B) { 
        cin >> b[i];
    }
    ll minA = *min_element(all(a));
    ll minB = *min_element(all(b));

    ll ans = minA + minB;
    rep(i, M) {
        ll x, y, c;
        cin >> x >> y >> c;
        x--; y--;
        ans = min(ans, a[x] + b[y] - c);
    }
    print(ans);
    return 0;
} 

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#include <numeric> 
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define endl "\n"
#define int long long int
#define mod 1000000007
#define INT_BITS 16
#define INF 10000000
#define pi 3.141592
#define watch(x) cout<<(#x)<<"="<<(x)<<"\n" 
#define pb push_back
//__builtin_popcount

#ifndef ONLINE_JUDGE
    #include "debug.cpp"
#endif

int32_t main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    #endif
    // fast;

   int a,b,c,d;
   cin>>a>>b>>c>>d;
   int x=b*d;
   int y=a*d;
   int z=b*c;
   int p=a*c;

   int val=max(x,max(y,max(z,p)));
   cout<<val<<endl;
    
 return 0;

}


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

using namespace std;

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

    set<int> s;

    auto add = [&] (int x)
    {
        if (x >= A && x <= B) {
            s.insert(x);
        }
    };

    for (int i = 0; i < K; ++i) {
        add(A + i);
        add(B - i);
    }

    for (auto x : s) {
        cout << x << "\n";
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}

int main(){
  int n,m;
  cin >> n >> m;
  ll sukunai = min(n,m);
  ll ooi = max(n,m);
  if (sukunai == 1){
    if(ooi == 1){
      cout << 1;
      return 0;
    }
    if(ooi == 2){
      cout << 0;
      return 0;
    }
    
    cout << ooi - 2;
    return 0;
  }
  
  if (sukunai == 2){
    cout << 0;
    return 0;
  }
  
  ll ans = (sukunai - 2) * (ooi - 2);
  cout << ans;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

template<class Itr> auto rle(Itr first, Itr last) {
  V< pair<decltype(*first), int> > res;
  for (; first != last; ++first) {
    if (res.empty() or res.back().first != *first) {
      res.emplace_back(*first, 1);
    } else {
      ++res.back().second;
    }
  }
  return res;
}

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  string s; cin >> s;
  int n = s.size();
  lint k; cin >> k;
  auto v = rle(begin(s), end(s));
  if ((int)v.size() == 1) {
    return cout << (n * k) / 2 << '\n', 0;
  }
  if (s[0] != s.back()) {
    lint res = 0;
    for (const auto& e : v) {
      res += e.second / 2;
    }
    res *= k;
    return cout << res << '\n', 0;
  }
  int m = v.size();
  lint res = 0;
  for (int i = 1; i < m - 1; ++i) {
    res += v[i].second / 2;
  }
  res *= k;
  res += v[0].second / 2;
  res += (v[0].second + v.back().second) / 2 * (k - 1);
  res += v.back().second / 2;
  cout << res << '\n';
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main(void){
    int n, i;
    double D, max = 0;
    int x[1001], y[1001];

    scanf("%d", &n);
    for(i = 0; i < n; i++){
        scanf("%d", &x[i]);
    }
    for(i = 0; i < n; i++){
        scanf("%d", &y[i]);
    }
    
    D = 0;
    for(i = 0; i < n; i++){
        D += abs(x[i] - y[i]);
    }
    printf("%f\n", D);

    D = 0;
    for(i = 0; i < n; i++){
        D += pow(abs(x[i] - y[i]), 2);
    }
    printf("%f\n", sqrt(D));

    D = 0;
    for(i = 0; i < n; i++){
        D += pow(abs(x[i] - y[i]), 3);
    }
    printf("%f\n", pow(D, 1.0/3.0));

    for(i = 0; i < n; i++){
        if(max < abs(x[i] - y[i])) max = abs(x[i] - y[i]);
    }
    printf("%f\n", max);

    return 0;
}


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

int main() {
  int tapchannels;
  int desiredchannels;

  scanf("%d %d", &tapchannels, &desiredchannels);
  
  int i = 1;
  while(tapchannels + (tapchannels - 1) * (i - 1) < desiredchannels) {
    i++;
  }

  if (desiredchannels == 1) {
    printf("0\n");
  } else {
    printf("%d\n", i);
  }
}

Measured memory_bytes: 256
import sys
from collections import deque

n,q = map(int,sys.stdin.readline().split())

dq = deque()

for x in range(n):
    x = sys.stdin.readline().split()
    dq.append([x[0],int(x[1])])
t = 0
while True:
    pr = dq.popleft()
    pr[1] -= q

    if pr[1] > 0:
        dq.append(pr)
        t += q
    else:
        t += pr[1] + q
        print(pr[0], t)

    if len(dq) == 0:
        break



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

#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define ALL(v) v.begin(), v.end()
#define SZ(x) ((ll)(x).size())

const double PI  = acos(-1.0);
const double EPS = 1e-9;
const ll INF = 1e9+10;
const ll mod = 998244353;
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; }
#define print(x) cerr << #x << " is " << x << endl;
//#define print(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl; 
int main()
{
    ll A, B, C;
    cin >> A >> B >> C;
    if (A + B > C){
        cout << "No";
    } else if (A * B > ll(1e18)/4){
        cout << "No";
    } else if (4 * A * B < (C - A - B) * (C - A - B)){
        cout << "Yes";
    } else {
        cout << "No";
    }
    return 0;
}


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

int ctoi(char c) {
    int n = c - '0';
    return n;
}

int pow_int(int x, int n) {//x^n
    if (n == 0) {
        return 1;
    }else {
        int y = x;
        for (int i = 0; i < n-1; i++) {
            x *= y;
        }
        return x;
    }
}


int main() {
    int x, n;
    cin >> x >> n;
    vector<int> p(n);
    rep(i, n) cin >> p[i];
    sort(p.begin(), p.end());
    if (n == 0) {
        cout << x << endl;
    }else {
        vector<int> vec(102, -1);
        bool flag = false;//整数iがpにある
        rep(i, 102) {
            rep(j, n) {
                flag = false;
                if (p[j] == i) {
                    flag = true;
                    break;
                }
            }
            if (!flag) vec[i] = i;
        }
        sort(vec.begin(), vec.end());
        // rep(i, 102) cout << vec[i] << endl;
        int ans = 1000;
        int memo = 1000;
        rep(i, 102) {
            if (abs(x - vec[i]) < memo) {
                ans = vec[i];
                memo = x - vec[i];
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 3600
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){
	int a[3]={},ev=0,odd=0,n=3,c=0;
	FOR(i,0,n)cin>>a[i];
	FOR(i,0,n){
		odd+=a[i]%2;
	}
	ev=n-odd;
	if(ev==1||odd==1)c++;
	FOR(i,0,n){
		if(a[i]%2==1){//ki
			if(ev==1)a[i]++;
		}else{
			if(odd==1)a[i]++;
		}
	}
	//cout<<" "<<c<<endl;
	sort(a,a+n);
	//FOR(i,0,n)cout<<a[i]<<" ";
	c+=(a[2]-a[0])/2;
	//cout<<" "<<c<<endl;
	c+=(a[2]-a[1])/2;
	cout<<c<<endl;

    return 0;
}


Measured memory_bytes: 256