akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main(){
	int x, a, b;
	scanf("%d%d%d", &x, &a, &b);
	
	int lineA;
	
	if ( a < x){
		lineA = x -a;
     }
     	
	else if (a > x){
		lineA= a - x;
	}
	
	int lineB;
	
	if ( b < x){
		lineB = x - b;
     }
     	
	else if (b > x){
		lineB= b - x;
	}
	
	if (lineA < lineB){
		printf("A\n");
	}
	else if (lineB < lineA){
		printf("B\n");
	}
	return 0;
}

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

#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define REP(i, n)  for(int i=0;i<(n);++i)
#define REPr(i, n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m, n) for(int i = (n);i >=(m);--i)
#define PB push_back
#define MP make_pair
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x, y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
using namespace std;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
const ll MOD = 1e9+7;

ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

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

template<class T>
inline bool chmax(T &a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
///////////////////////////////////////////////
/*⁽⁽(ી₍₍⁽⁽(ી( ˆεˆ )ʃ)₎₎⁾⁾ʃ)₎₎*/
int main(){
	ll L,R;
	ll L2,R2;
	cin >> L >> R;
	L2 = (L-1) / 2019;
	R2 = R / 2019;
	if (L2 != R2){
		cout << 0 << endl;
		return 0;
	}

	ll ans = 1e16;
	FORq(i,L,R){
		FORq(j,L,R){
			if (i == j) continue;
			chmin(ans,((ll)i*(ll)j) % 2019);
		}
	}

	cout << ans << "\n";
	return 0;
}


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

int main(){
    int N, M;  cin >> N >> M;
    int max_day = 1e5+1;
    vector<priority_queue<int>> job_pool(max_day, priority_queue<int>());
    for(int i=0; i<N; i++){
        int A, B;  cin >> A >> B;
        job_pool[A].push(B);
    }

    int ans = 0;
    for(int day=M-1; day>=0; day--){
        while(!job_pool[M-day].empty()){
            int job = job_pool[M-day].top();
            job_pool[M-day].pop();
            job_pool[0].push(job);
        }
        if(job_pool[0].empty()) continue;
        int selected_job = job_pool[0].top();
        job_pool[0].pop();
        ans += selected_job;
    }
    cout << ans << endl;
}


Measured memory_bytes: 6400
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            SolveA();
            //SolveB();
            //SolveC();
            //SolveD();
        }
        private const long MOD = 1000000007;
       
        static void SolveA()
        {
            int n = ReadAndParseInt();
            int[] a = ReadAndParseIntArr();
            long ans = 0;
            while(true)
            {
                if (!IsEven(a)) { break; }
                for(int i=0;i<a.Length;++i)
                {
                    a[i] /= 2;
                }
                ans++;
            }

            Console.WriteLine(ans);
        }
        private static bool IsEven(int[] a)
        {
            for(int i=0;i<a.Length;++i)
            {
                if( a[i] % 2 == 1) { return false; }
            }
            return true;
        }

        #region よく使う便利関数
        private static bool isPrime(long x)
        {
            if( x == 2) { return true; }
            if( x < 2 || x % 2 == 0) { return false; }
            long i = 3;
            while( i * i <= x)
            {
                if( x % i == 0) { return false; }
                i = i + 2;
            }
            return true;
        }
        private static long lcm(long x, long y)
        {
            return x / gcd(x, y) * y;
        }
        private static long gcd(long x, long y)
        {
            return y > 0 ? gcd(y, x % y) : x;
        }

        private static int ReadAndParseInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static int[] ReadAndParseIntArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        }
        private static long ReadAndParseLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadAndParseLongArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        }
        #endregion
    }
}

Measured memory_bytes: 13140
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <numeric>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>



using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const double EPS = 1e-10;
long long const MOD = 1000000007;

long long mod_pow(long long x, long long n) {
    long long res = 1;
    for(int i = 0;i < 60; i++){
        if(n >> i & 1) res = res * x % MOD;
        x = x * x % MOD;
    }
    return res;
}

template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

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

void fastInput() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}
struct edge {
    int to, cap, rev;
};

vector<vector<edge>> G; // 最大流のグラフ(頂点数で初期化)
vector<int> used; // DFSで頂点を使ったかどうか(上と同じ頂点数で初期化)

// fromからtoへ向かう容量capの辺をGに追加する
void add_edge(int from, int to, int cap) {
    G[from].push_back({to, cap, (int)G[to].size()});
    G[to].push_back({from, 0, (int)G[from].size()-1});
}

// 増加パスをDFSで探す
int dfs(int v, int t, int f) {
    if (v == t) return f;
    used[v] = 1;
    for (int i = 0; i < G[v].size(); i++) {
        edge &e = G[v][i];
        if (!used[e.to] && e.cap > 0) {
            int d = dfs(e.to, t, min(f, e.cap));
            if (d > 0) {
                e.cap -= d;
                G[e.to][e.rev].cap += d;
                return d;
            }
        }
    }
    return 0;
}

// sからtへの最大流を求める
int max_flow(int s, int t) {
    const int INF = 10000000;
    int flow = 0;
    for (;;) {
        fill(used.begin(), used.end(), 0);
        int f = dfs(s, t, INF);
        if (f == 0) return flow;
        flow += f;
    }
}

int solve(int N, int M) {
    vector<int> blue(N+1);
    vector<int> red(M+1);
    for (int i = 1; i <= N; i++) {
        cin >> blue[i];
    }
    for (int i = 1; i <= M; i++) {
        cin >> red[i];
    }
    G = vector<vector<edge>>(1+N+M+1);
    used = vector<int> (1+N+M+1);
    for (int i = 1; i <= N; i++) {
        add_edge(0, i, 1);
    }
    for (int i = 1; i <= M; i++) {
        add_edge(N+i, N+M+1, 1); 
    }
    for (int i = 1; i <= N; i++) {
        for (int j = 1; j <= M; j++) {
            int GCD = gcd<int>(blue[i], red[j]);
            if (GCD > 1) {
                add_edge(i, N+j, 1);
            }
        }
    }
    int ret = max_flow(0, N+M+1);
    return ret;
}

int main(void) {
    int M, N;
    vector<int> ans;
    while (1) {
        cin >> N >> M;
        if (N == 0) break;
        ans.push_back(solve(N, M));
    }
    for (auto &i : ans) {
        cout << i << endl;
    }
}


Measured memory_bytes: 7448
N = int(input())
v = list(map(int,input().split()))

nv = sorted(v)

for i in range(N-1):
    dammy = (nv[0] + nv[1]) / 2
    nv[1] = dammy
    del nv[0]
    nv = sorted(nv)

print(nv[0])

Measured memory_bytes: 38384
using System;
using System.Linq;

namespace ALDS1_4_A {
    class Program {
        static void Main(string[] args) {
            Console.ReadLine();
            var S = Console.ReadLine().Split(' ').Select(int.Parse);
            Console.ReadLine();
            var T = Console.ReadLine().Split(' ').Select(int.Parse);
            var c = T.Where(t => S.Contains(t)).Count();
            Console.WriteLine(c);
        }
    }
}

Measured memory_bytes: 10364
import java.util.*;

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

	public static void main(String[] args) throws Exception {
		int n =sc.nextInt();
		int m = sc.nextInt();
		
		map = directed(n, m);
		int[] dp = new int[n+1];
		boolean[] vis = new boolean[n+1];
		for(int i = 1 ;i <= n;i++) {
			find(i , vis , dp);
		}
		int ans = 0 ;
		for(int val : dp)ans = Math.max(ans , val);
		
		
		
		
		
  System.out.println(ans);
	}
	
	private static int find(int i, boolean[] vis , int[] dp) {
		if(vis[i])return dp[i];
		int max = -1 ;
		for(int nbr : map.get(i)) {
			max = Math.max(max , find(nbr, vis , dp) );
		}
		vis[i]=true;
		dp[i] = max+1;
		return dp[i];
	}

	static TreeMap<Integer , ArrayList<Integer> > map ;

	public static TreeMap<Integer , ArrayList<Integer> > directed(int n , int m  ) throws Exception{
		TreeMap<Integer , ArrayList<Integer> > map = new TreeMap<>();
		for(int i = 1 ;i<=n ;i++)map.put(i, new ArrayList<Integer>());
		for(int i = 1 ;i <= m ;i++) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			map.get(a).add(b);
		}
		return map;
	}
}

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

// x番の組織が親組織に提出する枚数を返す
// childrenは組織の関係を表す2次元配列(参照渡し)
int rewrite(vector<vector<char>> &map, int x, int y) {
  int cnt= 0;
  for(int i=-1; i<=1; i++){
    for(int j=-1; j<=1; j++){
      if( map.at(x+i).at(y+j)=='#' ){
        cnt++;
      }
    }
  }

  return cnt;
}

int main() {
  int H,W;
  cin >> H >> W;

  vector<vector<char>> Map(H+2, vector<char>(W+2)); // 外枠つき(元の盤面は1-indexedになる)
  for (int i=0; i<H; i++) {
    for(int j=0; j<W; j++){
      cin >> Map.at(i+1).at(j+1);
    }
  }

  for (int i=1; i<=H; i++) { // 1-indexed
    for(int j=1; j<=W; j++){ // 1-indexed
      if( Map.at(i).at(j)=='.' ){
        cout << rewrite(Map,i,j);
      }
      else{
        cout << '#';
      }
    }
    cout << endl;
  }
}

Measured memory_bytes: 256
import sys
dic = {}
txt = sys.stdin.read().strip().split()
for t in txt:
    if t in dic:
        dic[t] += 1
    else:
        dic[t] = 1
s = sorted(dic.items(),key=lambda x:x[1],reverse=1)
fre = s[0][0]
t = sorted(dic.items(),key=lambda x:len(x[0]),reverse=1)
longest = t[0][0]
print("%s %s" % (fre,longest))

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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    ll a,b; cin >> a >> b;
    if(a*b <= 0)out("Zero");
    else if((b-a)%2== 0 && a<0)out("Negative");
    else out("Positive");
}


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

using namespace std;

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

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

    vector<string> Ss(N);
    rep(i, N){
        cin >> Ss.at(i);
    }

    vector<string> judges = {"AC", "WA", "TLE", "RE"};
    vector<int> judges_cout(4, 0);
    rep(i, N){
        bool RE = true;
        rep(j, 3){
            if(Ss.at(i) == judges.at(j)){
                judges_cout.at(j)++;
                RE = false;
                break;
            }
        }
        if(RE) judges_cout.at(3)++;
    }
    rep(i, 4){
        cout << judges.at(i) << " x " << judges_cout.at(i) << endl;
    }
}

Measured memory_bytes: 6420
N = int(input())
a = list(map(int, input().split()))

minus_cnt = 0
abs_min = float('inf')
abs_sum = 0
for ai in a:
    if ai<0:
        minus_cnt += 1
    abs_min = min(abs_min, abs(ai))
    abs_sum += abs(ai)

if minus_cnt%2==0:
    print(abs_sum)
else:
    print(abs_sum - 2*abs_min)


Measured memory_bytes: 14224
import java.util.Scanner;

public class Main {

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long sum = sc.nextInt();
        int min = (int)sum,max = (int)sum;
        for(int i = 1;i < n;++i){
            int a = sc.nextInt();
            if(max < a) max = a;
            else if(a < min) min = a;
            sum += a;
        }
        System.out.printf("%d %d %d\n",min,max,sum);
    }

}

Measured memory_bytes: 41188
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;

int lbound(vector<long long>&v, long long b){
	int s = 0, e = v.size() - 1;
	int l = v.size();
	int m;
	while(e - s > 1){
		m = (s + e) / 2;
		if(v[m] >= b){
			e = m;
		}
		else{
			s = m;
		}
	}
	if(v[max(s - 1, 0)] >= b) return max(s - 1, 0);
	else if(v[s] >= b) return s;
	else if(v[min(s + 1, l - 1)] >= b) return min(s + 1, l - 1);
	else return v.size();
}

int ubound(vector<long long>&v, long long b){
	int s = 0, e = v.size() - 1;
	int l = v.size();
	int m;
	while(e - s > 1){
		m = (s + e) / 2;
		if(v[m] <= b){
			s = m;
		}
		else{
			e = m;
		}
	}
	if(v[max(s - 1, 0)] > b) return max(s - 1, 0);
	else if(v[s] > b) return s;
	else if(v[min(s + 1, l - 1)] > b) return min(s + 1, l - 1);
	else return v.size();
}

long long N;
vector<long long> A;

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

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

	sort(A.begin(), A.end());

	long long ans = 0;
	for(long long i=A[0]; i<=A[N-1]; i++){
		int u = ubound(A, i + 1);
		int v = lbound(A, i - 1);
		if(ans < u - v){
			ans = u - v;
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 1400
N, H = [int(i) for i in input().split()]
ken_a = 0
ken_b = []
for _ in range(N):
    a,b = input().split()
    if int(a) >= H or int(b) >= H:
        print(1)
        quit()
    if ken_a < int(a):
        ken_a = int(a)
    ken_b.append(int(b))
res = 0
for b_ in sorted(ken_b,reverse=True):
    if b_ > ken_a:
        H = H - b_
        res += 1
        if H <= 0:
            print(res)
            quit()

res = res + (H//ken_a)
if H%ken_a != 0:
    res += 1
print(res)

Measured memory_bytes: 8260
package main

// ABC160E - Red and Green Apples (解説実装)
// https://atcoder.jp/contests/abc160/tasks/abc160_e

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	X := nextInt(sc)
	Y := nextInt(sc)
	A := nextInt(sc)
	B := nextInt(sc)
	C := nextInt(sc)
	R := make([]int, A)
	G := make([]int, B)
	W := make([]int, C)
	for i := range R {
		R[i] = nextInt(sc)
	}
	sort.Sort(sort.Reverse(sort.IntSlice(R)))
	for i := range G {
		G[i] = nextInt(sc)
	}
	sort.Sort(sort.Reverse(sort.IntSlice(G)))
	for i := range W {
		W[i] = nextInt(sc)
	}
	T := make([]int, X+Y+C)
	for i := 0; i < X; i++ {
		T[i] = R[i]
	}
	for i := 0; i < Y; i++ {
		T[X+i] = G[i]
	}
	for i := 0; i < C; i++ {
		T[X+Y+i] = W[i]
	}
	sort.Sort(sort.Reverse(sort.IntSlice(T)))
	ans := 0
	for i := 0; i < X+Y; i++ {
		ans += T[i]
	}
	fmt.Println(ans)
}
func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	t, _ := strconv.Atoi(sc.Text())
	return t
}


Measured memory_bytes: 8576
mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

    class Bit:
        def __init__(self, n):
            self.size = n
            self.tree = [0] * (n + 1)

        def sum(self, i):
            s = 0
            while i > 0:
                s += self.tree[i]
                i -= i & -i
            return s

        def add(self, i, x):
            while i <= self.size:
                self.tree[i] += x
                i += i & -i

        def lower_bound(self, w):
            if w <= 0:
                return 0
            x = 0
            k = 1 << (self.size.bit_length() - 1)
            while k:
                if x + k <= self.size and self.tree[x + k] < w:
                    w -= self.tree[x + k]
                    x += k
                k >>= 1
            return x + 1

    N = int(input())
    A = []
    for _ in range(N):
        A.append(input().rstrip('\n'))

    TF = []
    for a in A:
        if "." not in a:
            t = f = 0
            a = int(a)
            while True:
                if a%2 == 0:
                    t += 1
                    a //= 2
                else:
                    break
            while True:
                if a%5 == 0:
                    f += 1
                    a //= 5
                else:
                    break
        else:
            a0, a1 = a.split(".")
            if int(a1) == 0:
                t = f = 0
                a0 = int(a0)
            else:
                a1 = [s for s in a1]
                while a1:
                    if a1[-1] == "0":
                        a1.pop()
                    else:
                        break
                a1 = "".join(a1)
                t = f = -len(a1)
                a0 = int("".join([a0, a1]))
            while True:
                if a0%2 == 0:
                    t += 1
                    a0 //= 2
                else:
                    break
            while True:
                if a0%5 == 0:
                    f += 1
                    a0 //= 5
                else:
                    break
        TF.append((t, f))

    Q = []
    for q in TF:
        t, f = q
        Q.append((t, f, 0))
        Q.append((-t, -f, 1))
    Q.sort(key=lambda x: x[2])
    Q.sort(key=lambda x: x[1], reverse=True)
    Q.sort(key=lambda x: x[0], reverse=True)
    bit = Bit(50)
    ans = 0
    for t, f, x in Q:
        if x == 0:
            bit.add(f+10, 1)
        else:
            ans += bit.sum(50) - bit.sum(f+10-1)
            if t <= 0 and f <= 0:
                ans -= 1
    print(ans // 2)


if __name__ == '__main__':
    main()


Measured memory_bytes: 177652
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (long long i = (a); i <= (b); i++)
#define FORD(i,a,b) for (long long i = (a); i >= (b); i--)
#define REP(i,a) FOR(i,0,(long long)(a)-1)
#define reset(a,b) memset(a,b,sizeof(a))
#define all(x) x.begin(), x.end()
#define uni(x) x.erase(unique(all(x)), x.end());
#define BUG(x) cout << #x << " = " << x << endl
#define BUGP(x) cout << #x << " = " << x._1 << ", " << x._2 << endl
#define PR(x,a,b) {cout << #x << " = "; FOR (_,a,b) cout << x[_] << ' '; cout << endl;}
#define CON(x) {cout << #x << " = "; for(auto _i:x) cout << _i << ' '; cout << endl;}
#define mod 1000000007
#define pi acos(-1)
#define eps 1e-8
#define pb push_back
#define sqr(x) (x) * (x)
#define _1 first
#define _2 second

long long n, lis[200005], ans;

int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  REP (i, n) cin >> lis[i];
  long long r = 0, cur = lis[0];
  REP (i, n) {
    while (r + 1 < n && cur + lis[r + 1] == (cur ^ lis[r + 1])) r++, cur += lis[r];
    ans += r - i + 1;
    cur -= lis[i];
  }
  cout << ans;
}


Measured memory_bytes: 1792
#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>;
using G = vector<vector<int>>;

int main(){
  int n,k;
  //さいころ
  cin >> n >> k;
  double p = 0;
  //各さいころの期待値
  vector<double> E(n,0);
  rep(i,n){
      cin >> p;
      E[i] = (p*(p + 1) / 2) / p;
  }
  //累積和
  vector<double> s(n+1,0);
  for(int i=0;i < n;++i) s[i+1] = s[i] + E[i];
  double ans = 0;
  for(int left=0;left<n+1;left++){
      double total = 0;
      int right = left + k;
      if(right> n+1) {
          break;
      }
      total = s[right] - s[left];
      ans = max(total, ans);
  }
  printf("%.12lf\n", ans);
}

Measured memory_bytes: 3328
N = int(input())
inputs = [int(i) for i in input().split()]

dp = [10 ** 9 for _ in range(N)]
dp[0] = 0

for i in range(1, N):
    if i == 1:
        dp[i] = abs(inputs[i] - inputs[i-1])
    else:
        dp[i] = min(dp[i-1] + abs(inputs[i] - inputs[i-1]), dp[i-2] + abs(inputs[i] - inputs[i-2]))

print(dp[-1])


Measured memory_bytes: 13776
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int main(){
    string s;R(s);
    if(s=="Sunny")W("Cloudy");
    else if(s=="Cloudy")W("Rainy");
    else W("Sunny");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define rep(i, a, n) for (int i = (a); i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    int n, m, c;
    cin >> n >> m >> c;
    int b[30];
    rep(i, 0, m) cin >> b[i];
    int a[30][30];
    rep(i, 0, n) rep(j, 0, m) cin >> a[i][j];

    int ans = 0;
    rep(i, 0, n) {
        int tmp = c;
        rep(j, 0, m) {
            tmp += a[i][j] * b[j];
        }
        if (tmp > 0) ans++;
    }
    cout << ans << endl;
}

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

int main()
{
	int a , b , i , j , ans , xans , yans ;
  	cin >> a >> b ;
  	xans = 1 ;
  	yans = 1 ;
  	for(i=a;i>=a-1;i--){
      xans = xans * i;
	}
  
  	xans = xans / 2 ; 
  
  	for(j=b;j>=b-1;j--){
      yans = yans * j ;
    }
  
  	yans = yans / 2 ;
  
  	ans = xans + yans ;
  
  	cout << ans << endl;  

return 0;
}

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

using namespace std;
typedef long long ll;

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define FORD(i, a, b) for (ll i = (a); i >= (b); i--)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

void solve() {
  int r, g, b;
  string ans = "";
  cin >> r >> g >> b;
  if ((r * 100 + g * 10 + b) % 4 == 0) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}

signed main() {
  solve();

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <string.h>
#include <string>
#include <math.h>
#include <cmath>
#include <cstring>
#include <sstream>
#include <stdlib.h>
#include <iomanip>
#include <vector>

using namespace std;

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

	int p = 0,q = 0;

	p = c - a;
	q = d - b;

	int x = 0,y = 0,X = 0,Y = 0;

	x = c - q;
	y = d + p;
	X = x - p;
	Y = y - q;

	cout << x << " " << y << " " << X << " " << Y << endl;
}





Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long a,b,ans;
int main(){
    scanf("%lld %lld",&a,&b);
    if(a == 0 ||b==0){
        if(a > b){
            printf("%lld\n",abs(a-b)+1);
            exit(0);
        }
        printf("%lld\n",abs(a-b)); 
        return 0;
    }
    if(a > 0 && b > 0){
        if(a<b) printf("%lld\n",abs(a-b));
        else printf("%lld\n",abs(a-b) + 2);
	}
    if(a > 0 && b < 0|| a < 0 && b > 0)printf("%lld\n",abs(abs(a)-abs(b))+1);
    if(a < 0 && b < 0){
        if(a==b)printf("0\n");
        if(a>b) printf("%lld\n",abs(abs(a)-abs(b))+2);
        if(a<b) printf("%lld\n",abs(abs(a)-abs(b)));
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MAX 1000001
using namespace std;
void frac_init(vector<int> &frac){
    int flag;
    int n[MAX];
    for(int i=0; i<MAX; i++){
        n[i]=1;
    }
    for(int num=2; num<MAX; num++){
        if(n[num]==1){
            frac.push_back(num);
            for(int i=num; i<MAX; i+=num){
                n[i]=0;
            }
        }
    }
}
int main(){
    long long N,Norig;
    int stack[41],s;
    int f,e,ans=0;
    vector<int> frac;
    frac_init(frac);
    stack[0]=0;
    for(int i=0; i<9; i++){
        for(int j=(i*(i+1))/2; j<((i+1)*(i+2))/2; j++){
            if(j>40) break;
            stack[j]=i;
        }
    }
    cin >> N;
    Norig=N;
    for(int i=0; i<frac.size(); i++){
        f=frac.at(i);
        e=0;
        while(N%f==0){
            N/=f;
            e++;
        }
        ans+=stack[e];
        if(N==1) break;
    }
    if(N>1) ans++;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 7656
#include<iostream>
#include<algorithm>
#include<math.h>
#include<set>
#include<vector>
#include<map>
#include <numeric>
#include <iomanip>
#include<vector>
typedef long long ll;
ll Isprime(ll x) {
	ll i;
	if (x < 2)return 0;
	else if (x == 2) return 1;
	if (x % 2 == 0) return 0;
	for (i = 3; i*i <= x; i += 2) {
		if (x%i == 0) return 0;
	}
	return 1;
}
using namespace std;
int main() {
	string S;
	cin >> S;
	if (S == "KIHBR" ||
		S == "AKIHBR" ||
		S == "KIHABR" ||
		S == "KIHBAR" ||
		S == "KIHBRA" ||
		S == "AKIHABR" ||
		S == "AKIHBRA" ||
		S == "AKIHBAR" ||
		S == "KIHABAR" ||
		S == "KIHABRA" ||
		S == "KIHBARA" ||
		S == "AKIHABAR" ||
		S == "AKIHABRA" ||
		S == "AKIHBARA" ||
		S == "KIHABARA" ||
		S == "AKIHABARA"
		)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
	

Measured memory_bytes: 256
/*
 * 	If you gave me a chance
 * 		I'll take it
 * 			It's a shot in the dark
 * 				But I will make it:D
 */
#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#ifndef rd
#define endl '\n'
#endif
#ifdef rd
#define trace(...) cout<<"Line:"<<__LINE__<<" "; __f(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cout<<name<<" : "<<arg1<<endl;
}
template<typename Arg1, typename ... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma=strchr(names+1,',');
	cout.write(names,comma-names)<<" : "<<arg1<<" | ";
	__f(comma+1,args...);
}
#else
#define trace(...)
#endif
#define deb cout<<"Line: "<<__LINE__<<" plz "
#define pb push_back
#define fi first
#define se second
#define int long long
typedef long long ll;
typedef long double f80;
#define double long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define sz(x) ((long long)x.size())
#define fr(a,b,c) for(int a=b; a<=c; a++)
#define rep(a,b,c) for(int a=b; a<c; a++)
#define trav(a,x) for(auto &a:x)
#define all(con) con.begin(),con.end()
const ll infl=2e18;
const int infi=2e9;
const int mod=1e9+7;
typedef vector<int> vi;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> oset;
mt19937 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
auto clk=clock();
int rng(int lim) {
	uniform_int_distribution<int> uid(0,lim-1);
	return uid(rang);
}

int a[205];
int hol[205][100005];
void solve() {
	int n,x;
	cin>>n>>x;
	fr(i,1,n) {
		cin>>a[i];
	}
	hol[1][x]=1;
	sort(a+1,a+n+1);
	reverse(a+1,a+n+1);
	fr(i,1,n) {
		for(int j=1; j<=100000; j++) {
			hol[i+1][j%a[i]]=(hol[i+1][j%a[i]]+hol[i][j])%mod;
			hol[i+1][j]=(hol[i+1][j]+hol[i][j]*(n-i))%mod;
		}
	}
	int ans=0;
	fr(i,1,100000) {
		ans=(ans+i*hol[n+1][i])%mod;
	}
	cout<<ans<<endl;
}
signed main() {
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	srand(chrono::high_resolution_clock::now().time_since_epoch().count());
	int t=1;
//	cin>>t;
	while(t--)
		solve();
#ifdef rd
	cerr<<endl<<endl<<(double)(clock()-clk)/CLOCKS_PER_SEC<<endl;
#endif
	return 0;
}


Measured memory_bytes: 158464
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
typedef int64_t Int;
typedef pair<Int, Int> P;

const Int MOD = 1000000007;
const Int MAX = 200010;

Int pow2[MAX];

void pow2init() {
    pow2[0] = 1;
    for (int i=1; i<MAX; i++) {
        pow2[i] = pow2[i-1] * 2 % MOD;
    }
}


P iwashi(Int A, Int B) {
    if (A == 0 && B == 0) return make_pair(0,0);
    else {
        if (A == 0) return make_pair(0,1);
        else if (B == 0) return make_pair(1,0);
        else {
            Int GCD, a, b;
            GCD = __gcd(abs(A),abs(B));
            a = abs(A) / GCD;
            b = abs(B) / GCD;
            if (A > 0 && B > 0) return make_pair(a,b);
            if (A > 0 && B < 0) return make_pair(a, -b);
            if (A < 0 && B > 0) return make_pair(a, -b);
            if (A < 0 && B < 0) return make_pair(a,b);
        }
    }
    return make_pair(0,0);
}

P teki(P x) {
    return iwashi(x.second, -x.first);
}

int main(){ 
    Int N;
    cin >> N;
    vector<Int> vec_A(N), vec_B(N);
    rep(i,N) cin >> vec_A[i] >> vec_B[i];

    set<P> s;
    map<P, Int> f;
    set<P>::iterator ite;;

    rep(i,N) {
        P temp;
        temp = iwashi(vec_A[i],vec_B[i]);
        f[temp]++;
        ite = s.find(teki(temp));
        if (ite == s.end()) {
            s.insert(temp);
        }
    }

    /*for (ite = s.begin(); ite!= s.end(); ++ite) {
        cout << (*ite).first << " " << (*ite).second << endl;
    }*/

    pow2init();

    Int ans = 1;

    for (ite = s.begin(); ite != s.end(); ++ite) {
        if (*ite == make_pair((Int)0,(Int)0)) {
            continue;
        }
        else {
            ans = ans * ((pow2[f[*ite]] + pow2[f[teki(*ite)]] - 1) % MOD) % MOD;
        }
    }

    ans = (ans + f[make_pair((Int)0,(Int)0)] + MOD - 1) % MOD;

    cout << ans << endl;
}

Measured memory_bytes: 45300
import java.io.*;
import java.math.*;
import java.util.*;
import java.lang.*;

// import java.text.DecimalFormat; 
// import java.text.DecimalFormatSymbols; 
 
 
// Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail
 
public class Main {
    
    
    public static void main(String args[] ) throws Exception {
        // StringBuffer str = new StringBuffer();
        // PrintWriter pw=new PrintWriter(System.out);
        FastScanner sc = new FastScanner();
        
        long x,k,d;
        x = sc.nextLong();
        k = sc.nextLong();
        d = sc.nextLong();
        boolean f=true;
        if(x<0){
            f=true;
            x=0L-x;
        }
        long rem = x%d;
        long mov=x/d;
        if(k<=mov+1){
            long ans = x-k*d;
            if(ans<0)
                ans=0-ans;
            System.out.println(ans);
        } else  {
            long ans = x-d*mov;
            long op = k-mov;
            if((op&1)==0){
                System.out.println(ans);
            } else{
                ans = ans-d;
                if(ans<0)
                    ans = 0-ans;  
                System.out.println(ans);
            }
        }
        
        
        
        
        
        
        // str.append(ans);
        
        
        
        
        // pw.println(str.toString());
        
        // pw.close();
    }
     
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		
		public String next() {
			while (!st.hasMoreElements())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		public String next(int k) {
			try {
				return br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return "Not able to read";
		}
		
		int nextInt() {
			return Integer.parseInt(next());
		}
		
		long nextLong() {
			return Long.parseLong(next());
		}
		
		double nextDouble() {
			return Double.parseDouble(next());
		}
		
	    
	}
   
}

Measured memory_bytes: 32748
#include <stdio.h>
int main(void){
    int year,month,date;
    while (scanf("%d %d %d",&year,&month,&date)!=EOF) {
        if (year<1868||(year==1868&&(month<9||(month==9&&date<8)))) {
            printf("pre-meiji\n");
        } else if (year<1912||(year==1912&&(month<7||(month==7&&date<30)))) {
            printf("meiji %d %d %d\n",year-1867,month,date);
        } else if (year<1926||(year==1926&&(month<12||(month==12&&date<25)))) {
            printf("taisho %d %d %d\n",year-1911,month,date);
        } else if (year<1989||(year==1989&&(month<1||(month==1&&date<8)))) {
            printf("showa %d %d %d\n",year-1925,month,date);
        } else {
            printf("heisei %d %d %d\n",year-1988,month,date);
        }
    }
    return 0;
}

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

enum Sauce{ NOT_DETERMINED = 0, Tomato = 1, Cream = 2, Basil = 3 };
enum Seq{ SAME, DIFF };

const int divisor = 10000;

class Pasta{
public:
	Pasta(int _N);
	~Pasta();

	Sauce* sauceary;
	int schedule(int i, Sauce yesterday, Seq seq);

private:
	int N;
	int*** memo;
};

Pasta::Pasta(int _N){
	N = _N;
	sauceary = new Sauce[N + 1];
	memo = new int**[N + 1];

	for (int i = 0; i <= N; i++) sauceary[i] = NOT_DETERMINED;

	for (int i = 0; i <= N; i++){
		memo[i] = new int*[4];
		for (int j = 0; j < 4; j++){
			memo[i][j] = new int[2];
			memo[i][j][SAME] = -1;
			memo[i][j][DIFF] = -1;
		}
	}
}

Pasta::~Pasta(){
	delete[] sauceary;
	delete[] memo;
}

int Pasta::schedule(int i, Sauce yesterday, Seq seq){
	if (i == N + 1) return 1;
	if (memo[i][yesterday][seq] >= 0) return memo[i][yesterday][seq];

	if (seq == SAME && yesterday == sauceary[i]){
		memo[i][yesterday][SAME] = 0;
		return 0;
	}

	if (sauceary[i] == NOT_DETERMINED){
		int tmpmemo = 0;

		for (int si = 1; si <= 3; si++){
			if ((Sauce)si == yesterday && seq == SAME) continue;
			else if ((Sauce)si == yesterday && seq == DIFF) tmpmemo += schedule(i + 1, (Sauce)si, SAME) % divisor;
			else tmpmemo += schedule(i + 1, (Sauce)si, DIFF) % divisor;
		}
		memo[i][yesterday][seq] = tmpmemo % divisor;
		return tmpmemo;
	}
	else {
		if (yesterday == sauceary[i]) memo[i][yesterday][seq] = schedule(i + 1, sauceary[i], SAME) % divisor;
		else memo[i][yesterday][seq] = schedule(i + 1, sauceary[i], DIFF) % divisor;
			
		return memo[i][yesterday][seq];
	}
}

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

	Pasta* pasta = new Pasta(N);

	for (int i = 0; i < K; i++){
		int A, B;
		cin >> A >> B;
		pasta->sauceary[A] = (Sauce)B;
	}

	/*int ans;
	if (pasta->sauceary[1] == NOT_DETERMINED){
		ans = pasta->schedule(2, Tomato, DIFF) + pasta->schedule(2, Cream, DIFF) + pasta->schedule(2, Basil, DIFF);
	}
	else {
		ans = pasta->schedule(2, pasta->sauceary[1], DIFF);
	}*/

	cout << pasta->schedule(1, NOT_DETERMINED, DIFF)%divisor << endl;

	delete pasta;
	return 0;
}

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

using namespace std;

int main() {
    int K, N, A[200000] = {};
    cin >> K >> N;
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }

    int max = A[0] + (K - A[N-1]);
    for (int i = 1; i < N; ++i) {
        if (max < (A[i] - A[i - 1])) {
            max = A[i] - A[i - 1];
        }
    }

    cout << K - max;

    return 0;
}


Measured memory_bytes: 1024
import java.util.*;
public class Main{
   public static void main(String[] args) {
     Scanner sc = new Scanner(System.in);
     int N = sc.nextInt();
     int M = sc.nextInt();
     int L,R,lhold,rhold,ans;
     L = 0;
     R = N;
     for(int i = 0;i<M;i++){
       lhold = sc.nextInt();
       rhold = sc.nextInt();
       if(L<lhold){
         L = lhold;
       }
       if(R>rhold){
         R = rhold;
       }
     }
     if(L<=R){
       ans = R-L+1;
     }else{
       ans = 0;
     }
     System.out.println(ans);


   }
}


Measured memory_bytes: 63432
#include <stdio.h>

int main(void)
{
    char s[101];
    int i;
    long k;
    scanf("%s%ld",s,&k);
    if(k==1)printf("%c",s[0]);
    else{
        for(i=0;i<k;i++){
            if(s[i]!='1'){
                printf("%c",s[i]);
                break;
            }
        }
        if(i==k)puts("1");
    }
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<queue>
using namespace std;
static const int N = 100;
static const int INFTY = (1<<21);

int n,M[N][N];
int d[N];

void bfs(int s){
  queue<int> q;
  q.push(s);
  for(int i=0;i<n;i++) d[i] = INFTY;
  d[s] = 0;
  int u;
  while(!q.empty()){
    u = q.front(); q.pop();
    for(int v=0;v<n;v++){
      if(M[u][v] == 0) continue;
      if(d[v] != INFTY) continue;
      d[v] = d[u] + 1;
      q.push(v);
    }
  }
  for(int i=0;i<n;i++){
    cout << i+1 << " " << ((d[i] == INFTY) ? (-1) : d[i]) << endl;
  }
}

int main(){
  int u, k, v;

  cin >> n;
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++) M[i][j] = 0;
  }

  for(int i=0;i<n;i++){
    cin >> u >> k;
    u--;
    for(int j=0;j<k;j++){
      cin >> v;
      v--;
      M[u][v] = 1;
    }
  }

  bfs(0);

  return 0;
}



Measured memory_bytes: 3140
// -*- coding:utf-8-unix -*-

use proconio::input;

fn main() {
    input! {
        k: u8,
        s: String,
    }

    let v: Vec<char> = s.chars().collect();

    for i in 0..v.len().min(k as usize) {
        print!("{}", v[i as usize]);
    }

    if v.len() > k as usize {
        print!("...");
    }
    println!("");
}


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

#define rep(i, j, n) for(int i=j;i<n;++i)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define INF 1e9
const int mod = 1e9 + 7;

typedef long long i64;
typedef pair<int, int> pi;

template <class T> using vt = vector<T>;
template <class T> using vvt = vector<vector<T>>;

i64 gcd(i64 n, i64 m) {return (m == 0? n : gcd(m, n % m));}
i64 lcm(i64 n, i64 m) {return (n / gcd(n, m) * m);}
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};

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

  int w, h;
  char c;
  cin >> w >> h >> c;

  vt<string> ans(h);
  ans[0] = ans[h - 1] = "+" + string(w - 2, '-') + "+";
  rep(i, 1, h - 1) ans[i] = "|" + string(w - 2, '.') + "|";
  ans[(h - 1) / 2][(w - 1) / 2] = c;

  rep(i, 0, h) cout << ans[i] << endl;
}



Measured memory_bytes: 3248
# A = [list(map(int, input().split())) for _ in range(3)]
# n = int(input())
# B = [int(input()) for _ in range(n)]
# X = list(map(int, input().split()))
# n, m = map(int, input().split())
S = list(input())
if S[0] != S[1] or S[1] != S[2]:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REP(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  cout << max(A * B, C * D) << endl;
  return 0;
}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int a[n+1],b[n+1];
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		b[a[i]]=i;
	}
	for(int i=1;i<=n;i++)
	{
		cout<<b[i]<<" ";
	}
	return 0;
}

Measured memory_bytes: 1536
N = int(input())
S  = input()
cur = 0
ans = 0
for i in range(len(S)):
    if S[i] == 'I':
        cur += 1
        ans = max(ans, cur)
    elif S[i] == 'D':
        cur -= 1
        ans = max(ans, cur)
        
print(ans)

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

int main(){
  int H, W;
  cin >> H >> W;
  
  string S[H];
  for(int i=0; i<H; ++i){ cin >> S[i]; }

  int d[H][W];

  for(int h=0; h<H; ++h) {
    int m=-1;
    for(int w=0; w<W; ++w) {
      if (S[h][w]=='.'){ d[h][w] = w-m; }
      else{ d[h][w] = 0; m=w; }
    }
  }

  for(int h=0; h<H; ++h) {
    int m=W;
    for(int w=W-1; w>=0; --w) {
      if (S[h][w]=='.'){ d[h][w] += m-w; }
      else{ m=w; }
    }
  }

  for(int w=0; w<W; ++w) {
    int m=-1;
    for(int h=0; h<H; ++h) {
      if (S[h][w]=='.'){ d[h][w] += h-m; }
      else{ m=h; }
    }
  }

  for(int w=0; w<W; ++w) {
    int m=H;
    for(int h=H-1; h>=0; --h) {
      if (S[h][w]=='.'){ d[h][w] += m-h; }
      else{ m=h; }
    }
  }
  

  int max_l=0;
  for(int h=0; h<H; ++h)
  for(int w=0; w<W; ++w)
    max_l = max(max_l, d[h][w]-3);

  cout << max_l << endl;

  return 0;
}


Measured memory_bytes: 19968
import sys
def I(): return int(sys.stdin.readline().rstrip())


N = I()
divisor = []
for i in range(int(N**.5),0,-1):
    if N % i == 0:
        if i != N//i:
            print(max(len(str(i)),len(str(N//i))))
        else:
            print(len(str(i)))
        break


Measured memory_bytes: 63488
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <vector>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;

template<typename T>
struct BIT {
  vector<T> data;
  BIT() {}
  BIT(int n) : data(n+1, 0) {}
  void init(int n) { data.assign(n+1, 0); }
  T sum(int ed) const {
    for(T res(0); ; ed &= ed-1) if(ed) res += data[ed]; else return res;
  }
  void add(int i, const T& x) {
    for(++i; i < (int)data.size(); i += i&-i) data[i] += x;
  }
};



struct K {
  char c;
  int v;
};

int n;
K vs[4010];

int toPos[2][2010];

int memo[2010][2010];
BIT<int> bit(4010);
int solve(int i1, int i2) {
  int& res = memo[i1][i2];
  if(res < 0) {
    if(i1 == n && i2 == n) {
      res = 0;
    } else {
      res = 1e9;
      if(i1 < n) {
        int pos = toPos[0][i1];
        int cost = pos-bit.sum(pos)+(i1+i2) - (i1+i2); // 現在の位置→所定の位置
        bit.add(pos, 1);
        res = min(res, solve(i1+1, i2) + cost);
        bit.add(pos, -1);
      }
      if(i2 < n) {
        int pos = toPos[1][i2];
        int cost = pos-bit.sum(pos)+(i1+i2) - (i1+i2); // 現在の位置→所定の位置
        bit.add(pos, 1);
        res = min(res, solve(i1, i2+1) + cost);
        bit.add(pos, -1);
      }
    }
  }
  return res;
}


int main(void) {
  scanf("%d", &n);
  REP(i, 2*n) {
    scanf(" %c %d", &vs[i].c, &vs[i].v);
    toPos[vs[i].c == 'B'][--vs[i].v] = i;
  }
  memset(memo, -1, sizeof memo);
  int res = solve(0, 0);
  printf("%d\n", res);
  return 0;
}


Measured memory_bytes: 16384
#include <iostream>
#include <bits/stdc++.h>
#define mod 998244353
typedef long long ll;

using namespace std;

void Fastio(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

ll fact[1000006], inv[1000006];

ll fp(ll base, ll exp)
{
    if (exp == 0)
        return 1;
    ll ans = fp(base, exp / 2);
    ans = (ans * ans) % mod;
    if (exp % 2 != 0)
        ans = (ans * (base % mod)) % mod;
    return ans;
}

void calcFacAndInv(ll n)
{
    fact[0] = inv[0] = 1;
    for (ll i = 1; i <= n; i++)
    {
        fact[i] = (i * fact[i - 1]) ;
        inv[i] = fp(fact[i], mod - 2);
    }
}

ll ncr(ll n, ll r)
{
    return ((fact[n] * inv[r]) % mod * inv[n - r]) % mod;
}

ll npr(ll n, ll r)
{
    return (fact[n] * inv[n - r]) % mod;
}

long double  NCR(int n, int m){
    long double res = 1;
    m = min(m, n - m);
    for(int i = 0; i < m; i++){
        res = res * ( n - i) / (i + 1);
 }
    return res;
}
ll tol(string a){
    ll res=0;
    while(a[0]=='0'){
        a.erase(a.begin());
    }
    if(a=="")a="0";
    for(int i=0; i<a.size(); i++){
        res*=10; res+=a[i]-'0';
    }
    return res;
}
int check(string a, string b){
    for(int i=0; i<a.size(); i++){
        if(a[i]>b[i])return 1;
        if(b[i]>a[i])return -1;
    }
    return 0;
}
class data{
public:
    ll v,d,p;
    data(){}
    data(ll vv, ll dd, ll pp){
        v=vv;  d=dd; p=pp;
    }
};

int primeFactors(int n)
{
    ll c=0;
    while (n % 2 == 0)
    {
        c++;
        n = n/2;
    }
    for (int i = 3; i*i <= n; i = i + 2)
    {
        while (n % i == 0)
        {
            c++;
            n = n/i;
        }
    }
    if (n > 2)
        c++;
    return c;
}

int main()
{
    Fastio();
    int n; cin>>n;
    int arr[n];
    for(int i=0; i<n; i++){cin>>arr[i];}
    ll dp[n]={0};
    dp[1]=abs(arr[1]-arr[0]);
    for(int i=2; i<n; i++){
        ll ans1, ans2;
        ans1=abs(arr[i]-arr[i-1])+dp[i-1];
        ans2=abs(arr[i]-arr[i-2])+dp[i-2];
        dp[i]=min(ans1,ans2);
    }
    cout<<dp[n-1]<<'\n';

    return 0;
}


Measured memory_bytes: 1408
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 1000005
#define inf 1e9
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

ll a,b,c,k;

int main()
{
	cin>>a>>b>>c>>k;
	if(k%2==0) cout<<a-b<<endl;
	else cout<<b-a<<endl;
	return 0;
}

Measured memory_bytes: 3616
a1, a2, a3 = map(int, input().split(' '))


c123 = abs(a3 - a2) + abs(a2 - a1)
c132 = abs(a2 - a3) + abs(a3 - a1)
c213 = abs(a3 - a1) + abs(a1 - a2)
c231 = abs(a1 - a3) + abs(a3 - a2)
c312 = abs(a2 - a1) + abs(a1 - a3)
c321 = abs(a1 - a2) + abs(a2 - a3)

print(min([c123, c132, c213, c231, c312, c321]))


Measured memory_bytes: 3064