akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<utility>
#include<map>
#include<algorithm>

using namespace std;
using ll = long long;

int maxtime(int x) {
	// Maximum consuming time for x-minute order
	return (x + 9) / 10 * 10;
}
int remtime(int x) {
	// Remained time for x-minute order
	return maxtime(x) - x;
}
int main() {
	int A, B, C, D, E;
	cin >> A >> B >> C >> D >> E;
	int sum = maxtime(A) + maxtime(B) + maxtime(C) + maxtime(D) + maxtime(E);
	sum -= max({ remtime(A), remtime(B), remtime(C), remtime(D), remtime(E) });
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 3588
#define _CRT_SECURE_NO_WARNINGS
#include<cstdio>
#include<vector>
#include<string>
#include<iostream>
#include<algorithm>
#include<map>
#include<iterator>
#include<set>
#include<stack>
#include<queue>
#include<fstream>
#include<iomanip>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include<cmath>
#include<list>
#include <sstream>
#include <stdio.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
using namespace std;


#define FOR(i,a,b) for(LL i = (a); i < (b); i++)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); i--)
#define ITER(it,a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a, value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL)INF;

using namespace std;

const LL MOD = 1000000007;


vector<VI> graph;
vector<bool> visited;

int dfs(int v) {
	visited[v] = true;
	int ans = 1;
	for (int x : graph[v]) {
		if (!visited[x]) {
			ans += dfs(x);
		}
	}
	return ans;
}

int main() {
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n,m;
	cin >> n >> m;
	graph = vector<VI>(n, VI());
	visited = vector<bool>(n);
	FOR(i,0,m) {
		int a,b;
		cin >> a >> b;
		a--;b--;
		graph[a].PB(b);
		graph[b].PB(a);
	}

	int ans = 0;
	FOR(i,0,n) {
		if (!visited[i]) {
			ans = max(ans, dfs(i));
		}
	}

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









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

# define p(s) std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;

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

    // 0101...
    int res1=0;
    int res2=0;
    for(int i=0;i<s.size();i++){
        if(i%2==0 && s.at(i)=='1') res1++;
        else if(i%2==1 && s.at(i)=='0') res1++;

        if(i%2==1 && s.at(i)=='1') res2++;
        else if(i%2==0 && s.at(i)=='0') res2++;
    }
    p(min(res1,res2))
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
ll mod=1e9+7;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll N,K;
	cin>>N>>K;
	bool dp[K+5];
	memset(dp,false,sizeof(dp));
	ll a[N];
	for(ll i=0;i<N;i++)
		cin>>a[i];
	
	for(ll i=0;i<=K;i++)
	{
		for(ll j=0;j<N;j++)
		{
			if (a[j]<=i)
			{
				dp[i]=dp[i] or (dp[i-a[j]]==false);
			}
		}
	}
	
	if (dp[K])
		cout<<"First";
	else
		cout<<"Second";
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define rreps(i,n,s) for(int i=s;i>=n;i--)
#define MOD 1000000007
using ll = long long;
using namespace std;
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 (a>b) { a=b; return 1; } return 0; }

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int n;
cin >> n;
vector<ll> a(3*n);
rep(i, 3*n) cin >> a[i];
sort(a.begin(), a.end(),greater<ll>());

ll ans = 0;
rep(i,n){
    ans += a[2*i+1];
}
cout << ans<<endl;

//system("pause");
return 0;
}

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

int main()
{
    int N, K;
    cin >> N >> K;
    string S;
    cin >> S;
    
    int sep_cnt = 0;
    int ans = 0;
    for(size_t i = 1; i < S.size(); ++i) {
        if(S[i-1] != S[i]) ++sep_cnt;
        size_t j = S.size() - 1 - i;

        if(S[i-1] == S[i] && S[i] == 'L') ++ans;
        if(S[j+1] == S[j] && S[j] == 'R') ++ans;
    }

    //cout << "sep_cnt:" << sep_cnt << endl;
    int K_max = ((sep_cnt % 2 == 0) ? sep_cnt/2 : sep_cnt/2 + 1);
    if(K_max <= K) ans += ((sep_cnt%2 == 0) ? sep_cnt : (sep_cnt/2)*2 + 1);
    else ans += K*2;

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

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

using namespace std;

using ll = long long;

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

    long double ans = 0;
    for (int i = 0; i < n; i++) {
        long double x;
        cin >> x;
        ans += 1 / x;
    }
    ans = 1 / ans;
    cout << fixed << setprecision(15) << ans << endl;
    return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;



int main() {
    int h, w;
    cin >> h >> w;

    vector<string> a(h);
    queue<P> que;
    vvi ch(h, vi(w, -1));
    rep(i, h) {
        cin >> a[i];
        rep(j, w) {
            if(a[i][j] == '#') {
                que.push(P(i, j));
                ch[i][j] = 0;
            }
        }
    }


    while(!que.empty()) {
        int ni = que.front().first;
        int nj = que.front().second;
        que.pop();

        if(ni && ch[ni-1][nj] == -1) {
            ch[ni-1][nj] = ch[ni][nj] + 1;
            que.push(P(ni-1, nj));
        }
        if(nj && ch[ni][nj-1] == -1) {
            ch[ni][nj-1] = ch[ni][nj] + 1;
            que.push(P(ni, nj-1));
        }
        if(ni < h-1 && ch[ni+1][nj] == -1) {
            ch[ni+1][nj] = ch[ni][nj] + 1;
            que.push(P(ni+1, nj));
        }
        if(nj < w-1 && ch[ni][nj+1] == -1) {
            ch[ni][nj+1] = ch[ni][nj] + 1;
            que.push(P(ni, nj+1));
        }

    }

    int ans = 0;
    rep(i, h) {
        rep(j, w) {
            ans = max(ans, ch[i][j]);
        }
    }

    cout << ans << endl;


}

Measured memory_bytes: 13456
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FORL(i,x) for(int i=head[x];i;i=nxt[i])
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
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; }

ll gcd(ll x, ll y)
{
    ll temp;
    while (y != 0) {
        temp = y;
        y = x % y;
        x = temp;
    }
    return (x);
}

ll lcm( ll m, ll n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}//lcm

int main() {
  int N;
  scanf("%d", &N);
  ll t[N];
  ll ans = 1LL;
  for (int i = 0; i < N; ++i) {
    scanf("%lld", &t[i]);
    ans = lcm(ans,t[i]);
  }

  cout << ans << endl;



}



Measured memory_bytes: 256
def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def s3(n):return [input().split() for _ in range(n)]
def s4(n):return [[x for x in s] for s in s2(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]
def t3(n):return [tuple(int(x) for x in input().split()) for _ in range(n)]
def p0(b,yes="Yes",no="No"): print(yes if b else no)
# from sys import setrecursionlimit
# setrecursionlimit(1000000)
from collections import Counter,deque,defaultdict
# import itertools
import math
# import networkx as nx
# from bisect import bisect_left,bisect_right
# from heapq import heapify,heappush,heappop
a,b,x=n1()

m=b*a**2
if m>=2*x:
    ans=math.atan(a*b**2/(2*x))
else:
    ans=math.atan(2*b/a-2*x/(a**3))
print(ans*180/math.pi)

Measured memory_bytes: 38384
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <stdio.h>
#include <algorithm>

using namespace std;

int main() {

	int N;
	int right = 0;
	int left = 0;

	int rightSum = 0;
	int leftSum = 0;

	int min = 0;

	cin >> N;

	for (int i = 1; i < N; i++){

		right = i;
		left = N - i;

		//std::cout << right << ", " << left << std::endl;

		while (right != 0){
			rightSum += right % 10;
			right = right / 10;
		}

		while (left != 0){
			leftSum += left % 10;
			left = left / 10;
			
		}

		if (i == 1){
			min = rightSum + leftSum;
		}
		else{
			if (min > rightSum + leftSum){
				min = rightSum + leftSum;
			}
		}


		rightSum = 0;
		leftSum = 0;

		
	}

	std::cout << min << std::endl;

	return 0;
}

Measured memory_bytes: 256
time = [0 for _ in range(5)]
wait = [0 for _ in range(5)]
for i in range(5):
    time[i] = int(input())
    wait[i] = 10 - (time[i] % 10)
    if wait[i] == 10:
        wait[i] = 0
print(sum(time) + sum(wait) - max(wait))


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#include<boost/multiprecision/cpp_int.hpp>
using namespace std;
using namespace boost::multiprecision;
#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define rep(I,N) for(auto I=0;I<(N);++I)
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define dw(I,A,B) for(auto I=(A);I>=(B);--I)
#define all(C) (C).begin(),(C).end()
#define rall(C) (C).rbegin(),(C).rend()
#define ft first
#define sd second
#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define pt pop_front
#define pk pop_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define rs resize
template<class T> T count_bit(T p){
  if(typeid(p)==typeid(int))return __builtin_popcount(p);
  else if(typeid(p)==typeid(long))return __builtin_popcountl(p);
  else return __builtin_popcountll(p);
}
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T>inline void                                      in(T &p){cin>>p;}
template<class T1,class T2>inline void                            in(T1 &p1,T2 &p2){cin>>p1>>p2;}
template<class T1,class T2,class T3>inline void                   in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T1,class T2,class T3,class T4>inline void          in(T1 &p1,T2 &p2,T3 &p3,T4 &p4){cin>>p1>>p2>>p3>>p4;}
template<class T1,class T2,class T3,class T4,class T5>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4,T5 &p5){cin>>p1>>p2>>p3>>p4>>p5;}
template<class T>inline void                                      ins(T &p){for_each(all(p),in<decltype(p[0])>);}
template<class T>inline void                             out(T p){cout<<p<<endl;}
template<class T1,class T2>inline void                   out(T1 p1,T2 p2){cout<<p1<<" "<<p2<<endl;}
template<class T1,class T2,class T3>inline void          out(T1 p1,T2 p2,T3 p3){cout<<p1<<" "<<p2<<" "<<p3<<endl;}
template<class T1,class T2,class T3,class T4>inline void out(T1 p1,T2 p2,T3 p3,T4 p4){cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<endl;}
inline                                              void out(double p){printf("%.10f\n",p);}
template<class T>inline                             void outs(T p){for_each(all(p),out<decltype(p[0])>);}

inline void solve(void){
  long N;
  in(N);
  long ans=0;
  up(i,1,N){
    if(to_string(i).size()%2==1)ans++;
  }
  out(ans);
}
int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef long double ld;
//typedef tree<int,null_type,less<int >,rb_tree_tag,tree_order_statistics_node_update>indexed_set;
template<class T1, class T2>
ostream &operator <<(ostream &os, pair<T1,T2>&p);
template <class T>
ostream &operator <<(ostream &os, vector<T>&v);
template <class T>
ostream &operator <<(ostream &os, set<T>&v);
template <class T1, class T2>
ostream &operator <<(ostream &os, map<T1,T2>&v);
#ifndef ONLINE_JUDGE
#define debug(a) cout<<#a<<" --> "<<(a)<<"\n";
#define debug2(a) cout<<#a<<" --> "<<(a)<<" ";
#define HERE cout<<"here - "<<__LINE__<<"\n";
#else
#define debug(a)
#define debug2(a)
#define HERE
#endif
const ll mod = 1e9+7;
const int N = 1e5+5;
typedef pair<int,int> pii;


void TEST_CASES(int cas)
{
    int n;
    cin>>n;
    cout<<(1000- (n%1000))%1000<<endl;

}


/*

*/

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int t=1,cas=0;
    //scanf("%d",&t);
    while(t--)
    {
        TEST_CASES(++cas);
    }
    return 0;
}



//os.order_of_key(v): returns how many elements strictly less than v
//os.find_by_order()

template<class T1, class T2>
ostream &operator <<(ostream &os, pair<T1,T2>&p)
{
    os<<"{"<<p.first<<", "<<p.second<<"} ";
    return os;
}
template <class T>
ostream &operator <<(ostream &os, vector<T>&v)
{
    os<<"[ ";
    for(int i=0; i<v.size(); i++)
    {
        os<<v[i]<<" " ;
    }
    os<<" ]";
    return os;
}

template <class T>
ostream &operator <<(ostream &os, set<T>&v)
{
    os<<"[ ";
    for(T i:v)
    {
        os<<i<<" ";
    }
    os<<" ]";
    return os;
}
template <class T1, class T2>
ostream &operator <<(ostream &os, map<T1,T2>&v)
{
    for(auto i:v)
    {
        os<<"Key : "<<i.first<<" , Value : "<<i.second<<endl;
    }
    return os;
}


Measured memory_bytes: 3644
#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
    int n,a,b,s=0,x,sum=0;
    cin>>n>>a>>b;
    if(a>b)
        swap(a,b);
    for(int i=1;i<=n;i++)
    {
        x=i;
        do
            {
                sum+=x%10;
                x/=10;
            }
        while(x!=0);
        if(sum>=a&&sum<=b)
            s+=i;
        sum=0;
    }
    cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 256
from sys import stdin
from itertools import groupby

s = stdin.readline().rstrip()
s = [str(i) for i in s]

s.sort()

lin = []
for key, value in groupby(s):
    lin.append(len(list(value)))

for i in lin:
    if i % 2 != 0:
        print("No")
        exit()

print("Yes")

Measured memory_bytes: 3188
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N,A,B=MI()
    ans = N//(A+B)*A
    remain = N - (N//(A+B)*(A+B))
    ans += min(remain,A)
    print(ans)
if __name__ == '__main__':
    main()

Measured memory_bytes: 66412
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        String[] input = br.readLine().split(" ");
        Map<Integer,Integer> map = new HashMap<>();
        for(int i=0;i<input.length;i++){
            int elem = Integer.parseInt(input[i]);
            if(map.containsKey(elem)){
                map.put(elem, map.get(elem) + 1);
            }else{
                map.put(elem, 1);
            }
        }

        int count = 0;
        Set<Integer> keys = map.keySet();
        for(int key : keys){
            int value = map.get(key);
            if(value > key){
                count += (value - key);
            }else if(value < key){
                count += value;
            }
        }

        System.out.println(count);
    }
}


Measured memory_bytes: 48592
open Printf
open Scanf

let () =
  let n, q = scanf "%d %d " (fun x y -> (x, y)) in
  (* let mxv = max_int in *)
  let mxv = 2147483647 in
  let st = Array.make 300000 mxv in
  let update x y =
    let rec iter k l r =
      if l = x && r = (x+1) then begin
          st.(k) <- y;
        end
      else
        let m = (l + r) / 2 in
        if x < m then
          iter (2*k) l m
        else
          iter (2*k+1) m r;
        st.(k) <- min st.(2*k) st.(2*k+1);
    in iter 1 0 n
  in
  let query x y =
    let rec iter k l r =
      if y <= l || r <= x then mxv
      else
        if x <= l && r <= y then st.(k)
        else
          let m = (l + r) / 2 in
          min (iter (2*k) l m) (iter (2*k+1) m r)
    in iter 1 0 n
  in
  let rec loop i =
    if i = 0 then ()
    else
      begin
        let com, x, y = scanf "%d %d %d " (fun a b c -> (a, b, c)) in
        if com = 0 then
          update x y |> ignore
        else
          printf "%d\n" (query x (y+1));
        loop (i-1)
      end
  in
  loop q

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

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

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

#ifdef DBG
void debug_(){ cout << endl; }
template<typename T, typename... Args>
void debug_(T&& x, Args&&... xs){
	cout << x << " "; debug_(forward<Args>(xs)...);
}
#define dbg(...) debug_(__VA_ARGS__)
#else
#define dbg(...)
#endif

int main() {
	ios_base::sync_with_stdio(false);
	cout << setprecision(20) << fixed;

	char c;
	cin >> c;
	if('a'<=c&&c<='z') cout << "a" << endl;
	else cout << "A" << endl;
	return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
ll d1[4] = {1, -1, 0, 0};
ll d2[4] = {0, 0, 1, -1};

int main(){
    string t;
    cin >> t;
    ll n = t.size();
    ll d = 0, pd = 0;
    rep(i, 0, n){
        if(t[i] == '?') t[i] = 'D';
    }
    cout << t << endl;
    return 0;
}

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

int main(){
	long long n,a,b;	cin>>n>>a>>b;
	// a < b

	long long ans=0, d=b-a;

	if(d%2){
		long long tmp1=0, tmp2=0;
		// 1. AもBも、1かnで合流する
		tmp1=min(n-a, b-1);

		// 2. Aが1 or Bがn に行ってから、距離を偶数にする
		tmp2+=(d-1)/2;	tmp2+=min((a-1)+1, (n-b)+1);

		ans=min(tmp1,tmp2);
	}else{
		ans=d/2;
	}

	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 256
def main():
    n ,m = map(int, input().split(' '))
    inf = 10**9
    bit_dp = [inf for _ in range(2**(n))]
    bit_dp[0] = 0
    for i in range(m):
        a, b = map(int, input().split(' '))
        c = list(map(int, input().split(' ')))
        bit_n = 0
        for i in c:
            bit_n |= 1 << i-1
        for i in range(2**(n)):
            if bit_dp[i|bit_n] > bit_dp[i] + a:
                bit_dp[i|bit_n] = bit_dp[i] + a
    if bit_dp[-1] >= inf:
        print(-1)
    else:
        print(bit_dp[-1])
if __name__ == '__main__':
    main()

Measured memory_bytes: 3188
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <utility>
#include <algorithm>
#include <functional>
#include <deque>
#define INF 1e9
#define MOD 1000000007
#define MAX_N 100001
#define mod(x) ((x % MOD) + MOD) % MOD

using namespace std;

typedef long long ll;
typedef pair<int,int> P;

int main() {
    int a, b;
    cin >> a >> b;
    if (a > b) {
        cout << a - 1 << endl;
    } else {
        cout << a << endl;
    }
    return 0;
}


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

using namespace std;

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

  int t = 0, x = 0, y = 0, n;

  cin >> n;
  for(int i = 0; i < n; ++i) {
    int u, v, k;
    cin >> k >> u >> v;

    int dist = abs(u - x) + abs(y - v);
    if(dist > k - t || dist % 2 != (k - t) % 2) {
      cout << "No";
      return 0;
    }

    x = u; y = v; t = k;
  }

  cout << "Yes" << endl;

  return 0;
}


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

int main(int argc, char* argv[])
{
  std::string s;
  int K;
  std::vector< std::string > vs;

  std::cin >> s >> K;

  int length = 1;
  for (int length = 1; length <= K; length++) {
    for (int spos = 0; spos < s.size(); spos++) {
      std::string tmp = s.substr(spos, length);
      vs.push_back(tmp);
    }
  }

  std::sort(vs.begin(), vs.end());
  std::unique(vs.begin(), vs.end());
  std::cout << vs[K-1] << std::endl;

  return 0;
}


Measured memory_bytes: 1660
N = int(input())
S = str(input())

if len(S) % 2 == 0:
  S1 = S[:N // 2]
  S2 = S[N // 2:]
  if S1 == S2:
    print('Yes')
    exit()
  else:
    print('No')
    exit()
else:
  print('No')

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
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; }

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    ll a,b,c;cin>>a>>b>>c;
    if(a%2==0||b%2==0||c%2==0){
        cout<<0<<endl;
        return 0;
    }
    cout<<min({a*b,b*c,c*a})<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>

using namespace std;


int prim[46] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199};


int main(){
  int n;
  int total = 0;
  cin >> n;
  for (int k=1;k<=n;k+=2) {
    map<int, int> prim_mp;
    int tmp = k;
    while (tmp > 1) {
      for (int i=0;i<46;i++) {
	if (tmp % prim[i] == 0) {
	  if (prim_mp.find(prim[i]) == prim_mp.end()) {
	    prim_mp[prim[i]] = 0;
	  }
	  prim_mp[prim[i]]++;
	  tmp = tmp/prim[i];
	  break;
	}
      }
    }
    int x = 1;
    for (auto it = prim_mp.begin();it != prim_mp.end();it++) {
      x *= (it->second+1);
    }
    //    cout << k << "\t" << x << endl;

    if (x == 8) {
      total++;
    }
  }
  cout << total << endl;
}


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

int main() {
	int N,T,cost=1001;
	cin >> N >> T;
	vector<int> c(N);
	vector<int> t(N);
	for(int i=0;i<N;i++){
		cin >> c.at(i) >> t.at(i);
		if(t.at(i)<=T) cost=min(cost,c.at(i));
	}
	if(cost==1001) cout << "TLE" << endl;
	else cout << cost << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;
 
#define rep(i, n) for(int i = 0; i < (int)(n);    i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()

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; }
typedef long long ll;

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }


int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  int N; std::cin >> N;
  std::string S; std::cin >> S;
  std::vector<char> z(26);
  for(int i=0; i<26; i++) z[i] = 'A' + i;

  for(int i=0; i<sz(S); i++) {
    int c = S[i] - 'A';
    c = ((c+N)%26);
    std::cout << ((char)z[c]);
  }
  std::cout << std::endl;

  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-

while True:
    n = int(input())
    if n == 0:
        break
    a = []
    for i in range(0,n):
        a.append(int(input()))
    sumMax = -100000
    for i in range(0,n):
        tmp = 0
        for j in range(i,n):
            tmp += a[j]
            sumMax = max(sumMax,tmp)
    print(sumMax)

Measured memory_bytes: 6756
from collections import deque
import sys
input = sys.stdin.readline


ss = list(input())
n = len(ss)-1

s = deque([])
for i in range(n):
    s.append(ord(ss[i]))

p = 1

q = int(input())
for i in range(q):
    inp = list(input())

    if inp[0] == '1':
        p *= -1
    else:
        c = ord(inp[4])
        f = inp[2]
        if (f == '1' and p == 1) or (f == '2' and p == -1):
            s.appendleft(c)
        else:
            s.append(c)


n = len(s)
if p == 1:
    for e in s:
        print(chr(e),end = '')
else:
    for i in range(n-1,-1,-1):
        print(chr(s[i]),end = '')

Measured memory_bytes: 80888
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define ALL(v) (v).begin(), (v).end()
#define ios() ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
constexpr ll MOD = 10e9+7;
constexpr ll INF = 1LL << 60;
constexpr int Inf = 1e9;
inline int in() {int x; cin >> x; return x;}
template <typename T> inline void out(const T& x) {cout << x << endl;}
template <class T> inline bool chmin(T &a, T b){if (a > b){a = b;return 1;}return 0;}
template <class T> inline bool chmax(T &a, T b){if (a < b){a = b;return 1;}return 0;}
//UP = 0;RIGHT = 1; DOWN = 2; LEFT =3;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b)
{
  if (a < b)
    gcd(b, a);
  int r;
  while ((r = a % b))
  {
    a = b;
    b = r;
  }
  return b;
}
void eratos(bool * isPrime,int max){
  fill(isPrime,isPrime + max,true);
  isPrime[0] = false; 
  isPrime[1] = false; 
  for(int i=2; i<=max/i; ++i) 
      if(isPrime[i]) 
          for(int j=2; j<=max/i; ++j) 
              isPrime[i*j] = false;    
}
//

signed main()
{
  ios();
  int N = in();
  int a[N];
  rep(i,N) cin >> a[i];
  int ans = 0;
  rep(i,N) ans += a[i] -1;
  cout << ans << endl;

  
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <complex>
#include <vector>
#include <cstdio>
using namespace std;
const double EPS = 1e-8;
const double INF = 1e12;
typedef complex<double> P;
namespace std {
  bool operator < (const P& a, const P& b) {
    return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
  }
}
double cross(const P& a, const P& b) {
  return imag(conj(a)*b);
}
double dot(const P& a, const P& b) {
  return real(conj(a)*b);
}

struct L : public vector<P> {
  L(const P &a, const P &b) {
    push_back(a); push_back(b);
  }
};

typedef vector<P> G;

struct C {
  P p; double r;
  C(const P &p, double r) : p(p), r(r) { }
};

P projection(const L &l, const P &p) {
  double t = dot(p-l[0], l[0]-l[1]) / norm(l[0]-l[1]);
  return l[0] + t*(l[0]-l[1]);
}
P reflection(const L &l, const P &p) {
  return p + 2.0 * (projection(l, p) - p);
}

signed main(){
	double x1,y1,x2,y2,xq,yq;
	while(scanf("%lf,%lf,%lf,%lf,%lf,%lf",&x1,&y1,&x2,&y2,&xq,&yq) != EOF){
		P a(x1,y1),b(x2,y2),c(xq,yq);
		L l(a,b);
		P d = reflection(l,c);
		printf("%.9lf %.9lf\n",d.real(),d.imag());
	}
	return 0;
}

Measured memory_bytes: 3208
import copy
def is_linking(sides):
    side = copy.copy(sides.pop())
    flag = True
    while flag:
        if not sides:
            if len(side) == n:
                return True
            else:
                return False
        for i in range(len(sides)):
            if side & sides[i]:
                side |= sides.pop(i)
                break
            elif i == len(sides) - 1:
                flag = False
    if len(side) == n:
        return True
    else:
        return False       
    
n, m = map(int, input().split())
all_sides = [set(input().split()) for _ in range(m)]
count = 0
for i in range(m):
    sides = all_sides[:i] + all_sides[i+1:]
    if is_linking(sides):
        continue
    else:
        count += 1
print(count)

Measured memory_bytes: 3444
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define forin(in) for(int i=0; i<(int)in.size(); i++) cin>>in[i]
#define forout(out) for(int i=0; i<(int)out.size(); i++) cout<<out[i]<<endl
#define rep(i, n) for(int i=0; i<(n); i++)

int main(){
    ll N; cin >> N;
    cout << N *(N-1) / 2 << endl;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
long long po(long a, long b){
    if(b==0){
        return 1;
    }
    
    long long z = po(a,b/2);
    z = mod(z*z);
    if(b%2!=0){
        z = mod(a*z);
    }
    return z;
}
 
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=std::sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}
 
long long gcd_(long long a, long long b){
  if(a<b){
    std::swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}
 
//using namespace std;
//using namespace boost::multiprecision;
//using namespace __gnu_pbds;

int main(){
  using namespace std;
  int a, b, c, d;
  cin>>a>>b>>c>>d;
  while(a > 0 && c > 0){
    c -= b;
    if(c <= 0){
      cout << "Yes" <<endl;
      break;
    }
    a -= d;
    if(a <= 0){
      cout << "No" <<endl;
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 3676
#include <bits/stdc++.h>
using namespace std;
#define M 1000000007
#define U 998244353
#define N 1000005
#define int long long
#define sz(c) (int)c.size()
#define fr first
#define ll long long 
#define sc second
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rep(i,a,n) for(int i=a ; i<n ; i++)
#define r0 return 0;
#define endl '\n'
#define INF (int)1e15
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
vector<vector<int>> mul(vector<vector<int>> a, vector<vector<int>> b)
{
  vector<vector<int>> res(a.size(), vector<int>(b[0].size()));
  for (int i = 0; i < a.size(); i++)
  {
    for (int j = 0; j < b[0].size(); j++)
    {
      for (int k = 0; k < b.size(); k++)
      {
        res[i][j] = (res[i][j]+(a[i][k]*b[k][j])%M)%M;
      }
    }
  }
  return res;
}
 
vector<vector<int>> binpow(vector<vector<int>> a, int p)
{
  p--;
  vector<vector<int>> res = a;
  while (p)
  {
    if (p & 1) res = mul(res, a);
    p >>= 1;
    a = mul(a, a);
  }
  return res;
}
signed main()
{
	ios_base::sync_with_stdio(0);
	int TESTS=1;
	// cin>>TESTS;
	while(TESTS--)
	{   
		int n,k;
		cin >> n >> k;
		vector<vector<int>> a(n, vector<int>(n));
		rep(i,0,n){
			rep(j,0,n){
				cin >> a[i][j];
			}
		}
		a = binpow(a,k);
		int ans = 0;
		rep(i,0,n){
			rep(j,0,n){
				ans = (ans + a[i][j])%M;
			}
		}
		cout<<ans;
	}
}

Measured memory_bytes: 384
# -*- coding: utf-8 -*-
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline


def isdigit(x):
    return '0' <= x <= '9'


def solve():
    W, H = map(int, input().split())
    if W == 0:
        exit()
    grid = [[v for v in input()[:-1]] for _ in range(H)]
    dp = [[-1]*W for _ in range(H)]

    max_val = 0
    for row in range(H):
        for col in range(W):
            if isdigit(grid[row][col]):
                if row > 0 and col > 0:
                    cand = max(dp[row-1][col], dp[row][col-1], 0)
                elif row == 0 and col == 0:
                    cand = 0
                elif row == 0:
                    cand = max(dp[row][col-1], 0)
                elif col == 0:
                    cand = max(dp[row-1][col], 0)

                dp[row][col] = cand*10+int(grid[row][col])

                max_val = max(max_val, dp[row][col])

    print(max_val)


while True:
    solve()



Measured memory_bytes: 5632
#include <stdio.h>

int main(void){
    int N,M;
    scanf("%d %d",&N,&M);
    int a[110];
    int i;
    int sum=0;
    int c=0;
    for(i=1;i<N+1;i++){
        scanf("%d",&a[i]);
        sum+=a[i];
    }
    for(i=1;i<N+1;i++){
        if(a[i]*4*M>=sum){
            c+=1;
        }
    
    }
    if(c>=M){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;

}

Measured memory_bytes: 1660
#include <bits/stdc++.h>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i,a,b) for (ll i=(a);i<(ll)b; i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define INF 1LL << 60
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;
const long long MOD=1000000007;

// vector<p> cut(M); vector<vector<ll> > v(4);
// cut[i].second
// cut[i].first;
// REP(i,M){
//     int a,b;cin>>a>>b;
//     cut[i] = make_pair(b,a);//last first の順番
// }
// for(int i=0; i<N;i++){
// }
// sort(cut.begin(),cut.end()), sort(v.rbegin(), v.rend()); //sort
// char '' str ""
int main(void)
{
    int N;cin>>N; std::vector<ll> A; std::vector<ll> B;
    ll sum = 0;
    for(int i=0; i<N+1;i++){
      ll aa; cin>>aa; A.push_back(aa);
    }
    for(int i=0; i<N;i++){
      ll aa; cin>>aa; B.push_back(aa);
    }
    ll AA = A[N];
    for(int i=0; i<N;i++){
      if(A[i] < B[i]){
        ll t = A[i+1]-(B[i]-A[i]);
        ll nx = A[i+1];
        A[i+1] = max((ll)0, t);
        if(t<0){
          sum += (nx+A[i]);
        }else{
          sum += B[i];
        }
      }else{
          sum += B[i];
      }
    }


    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 2548
import java.util.*;
public class Main {
	public static void main(String[] args)  {
		Scanner scan = new Scanner(System.in);
		int n = Integer.parseInt(scan.next());
		HashSet<String> set = new HashSet<>();
		for(int i = 0;i < n; ++i){
			set.add(scan.next());
		}
		System.out.println(set.size());

	}

}
//end

Measured memory_bytes: 76920
n, a, b, c = map(int, input().split())
ls = [int(input()) for _ in range(n)]

costs = []


def add(xs, cost, index):
    if index < n:
        for i in range(4):
            new_xs = xs.copy()
            new_cost = cost
            if i < 3:
                if new_xs[i] > 0:
                    new_cost += 10
                new_xs[i] += ls[index]
            add(new_xs, new_cost, index + 1)
    else:
        xs.sort()
        if xs[0] > 0:
            cost += abs(c - xs[0]) + abs(b - xs[1]) + abs(a - xs[2])
            costs.append(cost)


add([0] * 3, 0, 0)
print(min(costs))

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

int main()
{
  int set;
  cin >> set;
  for(int cnt = 0; cnt < set; cnt++)
  {
    int a, c, n, m, v, tmp, ans = 0;
    double b;
    cin >> v >> n >> m;
    for(int i = 0; i < m; i++)
    {
      tmp = 0;
      cin >> a >> b >> c;
      int vv = v;
      for(int j = 0; j < n; j++)
      {
        if(a == 0)
        {
          tmp += (int)(vv * b);
          vv -= c;
        }
        else
        {
          vv += (int)(vv * b);
          vv -= c;
        }
      }
      ans = max(ans, vv + tmp);
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 1232
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define MOD 1000000007
using Graph = vector<vector<int>>;
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
using Real = mp::number<mp::cpp_dec_float<1024>>;
 
int main (){
  int N;
  cin>>N;
  vector<vector<long long>>ai(3,vector<long long>(1000010,0));
  ai[0][1]=8;
  ai[1][1]=2;
  ai[2][1]=0;
  for(int i=2;i<1000010;i++){
    ai[0][i]=(ai[0][i-1]*8)%MOD;
    ai[1][i]=(ai[0][i-1]*2+ai[1][i-1]*9)%MOD;
    ai[2][i]=(ai[1][i-1]+ai[2][i-1]*10)%MOD;
  }
  cout<<ai[2][N];
}

Measured memory_bytes: 34552
#include <iostream>
#include<vector>
#include<algorithm>
#include<map>
using namespace std;
typedef long long ll;

const ll MOD_CONST = 1000000007;

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    
    vector<ll> s(n+1);
    for (int i = 0; i < n; i++) {
        s[i + 1] = s[i] + a[i];
    }

    
    
    vector<int> v1(n);
    int i1 = 1;
   
    for (int i = 2; i < n - 1; i++) {
        ll diff = abs(s[i] - 2 * s[i1]);
        while(abs(s[i] -2* s[i1+1]) <diff) {
            diff = abs(s[i] - 2 * s[i1 + 1]);
            i1++;
        }
        v1[i] = i1;
       
    }
    vector<int> v2(n);
    int i2 = 3;

    for (int i = 2; i < n - 1; i++) {
        ll diff = abs(s[n] - 2 * s[i2] + s[i]);
        while (abs(s[n] - 2 * s[i2 + 1] + s[i]) < diff) {
            diff = abs(s[n] - 2 * s[i2 + 1] + s[i]);
            i2++;
        }
        v2[i] = i2;

    }


    ll ans = 1000000000000000;
    for (int i = 2; i < n - 1; i++) {
        ll m1 = max(max(s[v1[i]], s[i] - s[v1[i]]), max(s[v2[i]] - s[i], s[n] - s[v2[i]]));
        ll m2 = min(min(s[v1[i]], s[i] - s[v1[i]]), min(s[v2[i]] - s[i], s[n] - s[v2[i]]));

        if (m1 - m2 < ans) {
            ans = m1 - m2;
        }
    }

    cout << ans << endl;

}  



Measured memory_bytes: 4224
#include <algorithm>
#include <iostream>
#include <sstream>
#include <utility>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <fstream>
#include <bitset>
#include <cstdio>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <ctime>
#include <stack>
#include <map>
#include <set>
#if __cplusplus > 199711L
#include <unordered_set>
#include <unordered_map>
#include <tuple>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
//	tree<key, mapped = null_type, cmp = less<key>, rb_tree_tag, tree_order_statistics_node_update> name;
//	order_of_key
//	find_by_order
#endif

using namespace std;

#define pb push_back
#define ppb pop_back
#define mp make_pair
#define fs first
#define sc second
#define abs(a) ((a) < 0 ? -(a) : (a))
#define sqr(a) ((a) * (a))

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;

inline pair<pair<bool, bool>, string> useinout();

void init() {
#ifdef SOL
	if (useinout().fs.fs)
		freopen("input.txt", "r", stdin);
	if (useinout().fs.sc)
		freopen("output.txt", "w", stdout);
#else
	srand(time(0));
	const string file = useinout().sc;
	if (!file.empty()) {
		freopen((file + ".in").c_str(), "r", stdin);
		freopen((file + ".out").c_str(), "w", stdout);
	}
#endif
}

int solve();

void finish(int exitval) {
	fflush(stdout);
#ifdef SOL
	fprintf(stderr, "\nexit value: %d\ntime: %.3lf ms\n", exitval, 1000. * clock() / CLOCKS_PER_SEC);
#endif
}

int main() {
	init();
	int exitval = solve();
	finish(exitval);
	return (0);
}

const double eps = 1e-9;
const int mod = (int) 1e+9 + 7;
const double pi = acos(-1.);
const int maxn = 100100;

inline pair<pair<bool, bool>, string> useinout() {
	return (mp(mp(0, 0), ""));
}

map<int, int> ma;
int a[maxn];

int solve() {

	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
		ma[a[i]]++;
	}

	int mx = (--(ma.end()))->first;
	int mn = mx;

	int cnt = ma[mx], zero = 0;
	for (int i = mx; i >= 0; i--) {
		cnt = ma[i];
		if (cnt) {
			if (ma[mn] < 2 || zero) {
				printf("Impossible\n");
				return (0);
			}
			mn = i;
		} else {
			zero = 1;
		}
	}
	if (mn != (mx + 1) / 2) {
		printf("Impossible\n");
		return (0);
	}
	if ((mx & 1) && ma[mn] != 2) {
		printf("Impossible\n");
		return (0);
	}
	if (!(mx & 1) && ma[mn] != 1) {
		printf("Impossible\n");
		return (0);
	}

	printf("Possible\n");

	return (0);
}

// by Andrey Kim


Measured memory_bytes: 256
from statistics import median
 
X = []
X1 = []
N=int(input())
for i in range(N):
    a, b = map(int, input().split())
    X.append(a)
    X1.append(b)
 
m1 = median(X)
m2 = median(X1)
if len(X) % 2:
    print(int((m2 - m1) + 1))
else:
    print(int(2 * (m2 - m1) + 1))

Measured memory_bytes: 28764
import java.io.*;
import java.util.*;
public class Main{
	final public static int MOD = (int)1e9+7;
	public static boolean dp[] =  new boolean[100001];
    public static void main(String[] args) throws IOException{
    	FastScanner sc = new FastScanner();
    	PrintWriter out = new PrintWriter(System.out);
    	int n= sc.nextInt();
    	int k= sc.nextInt();
    	int arr[] = new int[n];
    	for(int i=0; i<n; i++) {
    		arr[i] = sc.nextInt();
    	}
    	Arrays.sort(arr);
    	for(int i=0; i<arr[0]; i++) {
    		dp[i] = false;
    	}
    	first:for(int i=arr[0]; i<100001; i++) {
    		boolean good = false;
    		for(int j=0; j<n; j++) {
    			if(i-arr[j]<0) {
    				dp[i] = good;
    				continue first;
    			}
    			if(!dp[i-arr[j]]) good = true;
    		}
    		dp[i] = good;
    	}
    	if(dp[k])out.println("First");
    	else out.println("Second");
    	out.close();
    }
    public static class FastScanner {
    	BufferedReader br;
    	StringTokenizer st;

    	public FastScanner(String s) {
    		try {
    			br = new BufferedReader(new FileReader(s));
    		} catch (FileNotFoundException e) {
    			e.printStackTrace();
    		}
    	}

    	public FastScanner() {
    		br = new BufferedReader(new InputStreamReader(System.in));
    	}
    	
    	String nextToken() {
    		while (st == null || !st.hasMoreElements()) {
    			try {
    				st = new StringTokenizer(br.readLine());
    			} catch (IOException e) {
    				e.printStackTrace();
    			}
    		}
    		return st.nextToken();
    	}

    	String nextLine() {
    		st = null;
    		try {
    			return br.readLine();
    		} catch (IOException e) {
    			e.printStackTrace();
    		}
    		return null;
    	}

    	int nextInt() {
    		return Integer.parseInt(nextToken());
    	}

    	long nextLong() {
    		return Long.parseLong(nextToken());
    	}

    	double nextDouble() {
    		return Double.parseDouble(nextToken());
    	}
    }
}


Measured memory_bytes: 23892
#include <iostream>
#include <string>
using namespace std;
 
int main() { 
    int a, b;
    cin >> a >> b;
    int m1 = max(a, b);
    m1--;
    int m2 = max(m1, min(a, b));
    cout << m1 + m2 + 1 << '\n';
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] d = new int[n];
        for(int i=0; i<n; i++) {
            d[i] = in.nextInt();
        }
        long s = 0;
        for(int i=0; i<n; i++) {
            for(int j=i+1; j<n; j++) {
                s += d[i]*d[j];
            }
        }
        System.out.println(s);
    }
}


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

int main(){
  int N,A;
  int number2 = 0;
  cin >> N;
  cin >> A;
  while(A%2 ==0){
        A /= 2;
        number2++;
    }
  for(int i=1; i<N; i++){
    int number1 = 0;
    cin >> A;
    while(A%2 ==0){
        A /= 2;
        number1++;
    }
    if(number1 <= number2){
      number2 = number1;
    }
    else{ 
    }
  }
  cout << number2 << endl;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static class Pair{
		// indexじゃない
		public int start;
		public int end;
		Pair(int s, int e){
			start = s;
			end = e;
		}
	}
	
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int Q = Integer.parseInt(sc.next());
		String sline = sc.next();
		int[] l = new int[Q];
		int[] r = new int[Q];
		for(int i=0; i<Q; i++){
			l[i] = Integer.parseInt(sc.next());
			r[i] = Integer.parseInt(sc.next());
		}
		sc.close();
		String[] s = new String[N];
		for (int i=0; i<N; i++){
			s[i] = String.valueOf(sline.charAt(i));			
		}
		// 0からi-1番目までのACのかず;
		int[] ans = new int[N];
		
		for (int i=0; i<N-1; i++){
			if(s[i].equals("A") && s[i+1].equals("C")){
				ans[i+1] = ans[i] + 1; 
			} else {
				ans[i+1] = ans[i];
			}
		}
		
		for(int i=0; i<Q; i++){
			System.out.println(ans[r[i]-1]-ans[l[i]-1]);
		}
		
	}

}


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

int main(){
    string s;
    cin >> s;
    string key = "keyence";
    if(s == key){
        cout << "YES" << endl;
        return 0;
    }
    string tmp = "";
    for(int i = 0; i < s.size(); i++){
        if(s[i] != key[i]){
            for(int j = i; j < s.size(); j++){
                string t = tmp;
                int idx = j;
                while(idx != s.size()){
                    t += s[idx++];
                    if(t.size() > key.size()) break;
                    if(t == key && idx == s.size()){
                        cout << "YES" << endl;
                        return 0;
                    }
                } 
            }
            cout << "NO" << endl;
            return 0;
        }
        tmp += s[i];
    }
}

Measured memory_bytes: 256