akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define INF int(1e9)
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define REPONE(i, n) for(ll i = 1; i <= (int)(n); i++)
#define EACH(i, mp) for(auto i:mp)
#define FOR(i, m, n) for(int i = m;i < n;i++)
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

ll N;
int MAX_N = 10;

// 1234 -> 4 3 2 1
vector<int> each_digit(ll S) {
    int n_len = 0, n_dig[MAX_N];
    while (S > 0) {
        n_dig[n_len++] = S % 10;
        S /= 10;
    }
    vector<int> ret(n_dig, n_dig + n_len);
    return ret;
}

void solve() {
    ll ans = INF;
    REPONE(i, sqrt(N)) if (N % i == 0) ans = min(ans, max(i, N / i));
    vector<int> v = each_digit(ans);
    cout << v.size() << endl;
}

int main() {
    cin >> N;
    solve();
    return 0;
}

Measured memory_bytes: 256
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        s: String,
    }

    let s_char = s.as_str().chars().collect::<Vec<char>>();
    let (s1, s2, s3) = (s_char[0], s_char[1], s_char[2]);

    if s1 == s2 && s2 == s3 && s1 == 'R' {
        println!(3);
    } else if s1 == s2 && s1 == 'R' {
        println!(2);
    } else if s2 == s3 && s2 == 'R' {
        println!(2);
    } else if s1 == 'R' || s2 == 'R' || s3 == 'R' {
        println!(1);
    } else {
        println!(0);
    }
}


Measured memory_bytes: 2152
import std.algorithm;
import std.array;
import std.container;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

void main() {
    int n, x; scan(n, x);
    auto a = readints;
    int ans = 1;
    int d = 0;
    for (int i = 0; i < n; i++) {
        d += a[i];
        if (d <= x) ans++;
    }
    writeln(ans);
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <cstdio>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#define my_abs(x) ((x) < 0 ? -(x) : (x))
#define mp std::make_pair
#define pb push_back
#define X first
#define Y second
typedef long long ll; 
int x[105], y[105]; 
double seq[205]; 
int main()
{
	// freopen("AGC021-B.in", "r", stdin); 
	int n; 
	scanf("%d", &n); 
	for (int i = 0; i < n; i++)
		scanf("%d%d", x + i, y + i); 
	for (int i = 0; i < n; i++)
	{
		int cnt = 0; 
		for (int j = 0; j < n; j++)
		{
			if (i != j)
				seq[cnt++] = atan2(y[j] - y[i], x[j] - x[i]); 
		}
		std::sort(seq, seq + cnt); 
		for (int j = 0; j < cnt; j++)
			seq[j + cnt] = seq[j] + acos(-1) * 2; 
		double mx = 0; 
		for (int j = 1; j <= cnt; j++)
			mx += std::max(seq[j] - seq[j - 1] - acos(-1), 0.0); 
		printf("%.20lf\n", mx / acos(-1) / 2);
	}
	return 0; 
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();

		if (a < b){
			if(b < c) {
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}
		} else {
			System.out.println("No");
		}
	}

}

Measured memory_bytes: 26048
/*
ID: y1197771
PROG: test
LANG: C++
*/
#include<bits/stdc++.h>
#define pb push_back
#define FOR(i, n) for (int i = 0; i < (int)n; ++i)
#define dbg(x) cout << #x << " at line " << __LINE__ << " is: " << x << endl
typedef long long ll;
using namespace std;
typedef pair<int, int> pii;
const int maxn = 1e3 + 10;
string s = "aeiou";
void yes() {
    cout << "YES" << endl;
}
void no() {
    cout << "NO" << endl;
}
void solve() {
    while(cin >> s) {
        int n = s.size();
        int i = 0;
        reverse(s.begin(), s.end());
        bool f = 1;
        while(i < n) {
            if(s[i] == 'm') {
                string t = s.substr(i, 5);
                if(t == "maerd") {
                    i += 5;
                    continue;
                }
            }
            if(s[i] == 'e') {
                string t = s.substr(i, 5);
                if(t == "esare") {
                    i += 5;
                    continue;
                }
            }
            if(s[i] == 'r') {
                string t = s.substr(i, 6);
                if(t == "resare") {
                    i += 6;
                    continue;
                }
                t = s.substr(i, 7);
                if(t == "remaerd") {
                    i += 7;
                    continue;
                }
            }
            f = 0;
            break;
        }
        if(f) yes();
        else no();
    }
}
int main() {
    //freopen("test.in", "r", stdin);
    //freopen("test.out", "w", stdout);
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    solve();
    return 0;
}


Measured memory_bytes: 512
using System;

class Program
{
    static void Main(string[] args)
    {
        var input = Console.ReadLine();
        string[] tmpinput = input.Split(' ');
        int[] intinput = Array.ConvertAll<string, int>(tmpinput, delegate (string value) {return int.Parse(value); });
        int output1 = intinput[0] * intinput[1];
        int output2 = (intinput[0] * 2) + (intinput[1] * 2);
        Console.WriteLine(output1+" "+output2);
    }
}



Measured memory_bytes: 15896
n = int(input())
l = list(map(int, input().split()))
l.sort()
ans = 0
from bisect import bisect_left
for i in range(n):
    a = l[i]
    for j in range(i+1, n):
        b = l[j]
        x = a + b
        c = bisect_left(l, x)
        ans += c - j - 1
        
print(ans)




Measured memory_bytes: 3188
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
using ll = long long;
using ldb = long double;
using pa = pair < ll, ll >;
using vec = vector < ll >;
 
template < typename T > using index_set = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
template < typename T > using MinPriorityQueue = priority_queue < T, vector < T >, greater < T > >;

#define pb push_back
#define po pop_back
#define mp make_pair
#define mt make_tuple
#define F  first
#define S  second
#define f(i,x,n) for(ll i=x;i<n;i++) 
#define unique_sort(x) sort(all(x)), x.resize(distance(x.begin(), unique(all(x))))
#define all(c) c.begin(),c.end()
#define str string
#define edl "\n"
#define add insert
#define cot continue
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)


const int MOD = 1e9 + 7, INF = INT_MAX, N = 1e5 + 10;
const double PI = acos(-1);
const ll LINF = LLONG_MAX;
vec dp(100002,INT_MAX);ll q[100001],n;




int main() 
{

    fast();
      
    // #ifndef ONLINE_JUDGE
    //         freopen("input.txt", "r", stdin);
    //         freopen("output.txt","w",stdout);
    // #endif
    cin>>n;
    f(i,0,n)
    {
        cin>>q[i];
    }
    dp[0]=0;
    f(i,0,n)
    {
        for(ll j=i+1;j<=i+2&&j<n;j++)
        {
            dp[j]=min(dp[j],dp[i]+abs(q[i]-q[j]));
        }
    }
    cout<<dp[n-1];


  

    cerr << "Time taken: " << int((clock() * 1000.) / CLOCKS_PER_SEC) << "ms\n";
    return 0;
}


Measured memory_bytes: 1792
n = int(input())
s = str(input())

max_common = -1

for i in range(1,n):
    common = []
    x = s[0:i]
    y = s[i:]
    #print(x, y)
    
    for letter in x:
        if letter not in common and letter in y:
            common.append(letter)
    #print("common: ", common)
    
    max_common = max(len(common), max_common)
    #print()
    
print(max_common)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

// ll c[2001][2001];
// ll comb(int a, int b){
//     if(a<b||b<0) return 0;
//     if(c[a][b] != 0) return c[a][b];
//     if(a == b || b == 0) return c[a][b] = 1;
//     return c[a][b] = (comb(a-1, b-1) + comb(a-1, b)) % MOD;
// }


vector<ll> inv,fact,invfact;
void mod_build(int n=101010){
    fact.resize(n+1);
    inv.resize(n+1);
    invfact.resize(n+1);
    fact[0]=inv[0]=invfact[0]=1;
    inv[1]=1;
    REP(i,n){
        fact[i+1]=fact[i]*(i+1)%MOD;
        if(i>0)inv[i+1]=MOD-inv[MOD%(i+1)]*(MOD/(i+1))%MOD;
        invfact[i+1]=invfact[i]*inv[i+1]%MOD;
    }
}
ll perm(int n,int k){
    if(n<0||k<0||k>n)return 0;
    return fact[n]*invfact[n-k]%MOD;
}
ll comb(int n,int k){
    if(n<0||k<0||k>n)return 0;
    return (fact[n]*invfact[n-k]%MOD)*invfact[k]%MOD;
}


int main(void)
{
    int n,k;
    cin >> n >> k;
    mod_build();
    REP(i, k){
        pr((comb(n-k+1,i+1)*comb(k-1, i))%MOD);
    }
}

Measured memory_bytes: 2688
#include <iostream>
using namespace std;
//not AC
int main()
{
    int N ;
    int x,y,z;
    unsigned int Y ;
    cin >> N >> Y;
   Y /= 1000;
    for (int x = 0 ; x <= N ; x++)
    {
        for(int y = 0 ; x + y <= N ; y++)
        {
            int z = N-x-y;
            if(x*10 + y*5 + z == Y)
            {
            cout << x << ' ' << y << ' ' << z << endl;
            return 0;
            }
        }
    }
    x = y = z = -1;
    cout << x << ' ' << y << ' ' << z << endl;


   return 0;
}

Measured memory_bytes: 256
import bisect,collections,copy,heapq,itertools,math,string
import sys
def S(): return sys.stdin.readline().rstrip()
def M(): return map(int,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
A, B = M()
if A < 2*B:
    print(0)
else:
    print(A-2*B)

Measured memory_bytes: 38640
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = nextInt()
	}
	var cnt [1000001]int

	for _, e := range a {
		cnt[e]++
	}

	ans := 0
	for _, e := range a {
		f := true
		cnt[e]--
		for d := 1; d*d <= e; d++ {
			if e%d == 0 && (cnt[d] > 0 || cnt[e/d] > 0) {
				f = false
				break
			}
		}
		if f {
			ans++
		}
		cnt[e]++
	}

	fmt.Print(ans)
}


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

typedef long long int ll;
#define INF 1999999999
#define MODA 1000000007

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b, c;
    cin >> a >> b >> c;
    if(a == b)
        cout << c << endl;
    else if(a == c)
        cout << b << endl;
    else
        cout << a << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define in freopen("input.txt", "r", stdin)
#define out freopen("output.txt", "w", stdout)  
#define rep(i,n) for(int (i)=0;(i)<(n);++(i))
#define ref(i,a,b) for (int (i)=(a); (i)<=(b); ++(i))
#define INF 0xFFFFFF
#define endl '\n'
#define pp printf("Case %d: \n",t)
const unsigned int mod = 1e9+7;
const int mx=1000005;
const int maxInt = 2147483647;

int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    int n;cin >> n;
    int a[n];
    rep(i,n)cin >> a[i];
    int dp[n]={0};
    dp[1]=abs(a[1]-a[0]);
    for(int i=2;i<n;++i){
    	dp[i]=min(dp[i-2]+abs(a[i]-a[i-2]),dp[i-1]+abs(a[i]-a[i-1]));
    }
    cout << dp[n-1] << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<typename T> istream& operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream& operator<<(ostream &os, vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream& operator<<(ostream &os, set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream& operator<<(ostream &os, pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream& operator<<(ostream &os, map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
#define dbg(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl;

vector<lint> A;

lint calc(vector<lint> A, lint med)
{
    lint ans = 0;
    for (auto v : A) ans += abs(med - v);
    return ans;
}

int main()
{
    int N;
    cin >> N;
    A.resize(N);
    cin >> A;
    sort(A.begin(), A.end());

    if (N == 2)
    {
        cout << A[1] - A[0] << endl;
    }
    else if (N % 2 == 1)
    {
        lint tmp1 = calc(A, A[N / 2]) * 2 - abs(A[N / 2] - A[N / 2 + 1]);
        lint tmp2 = calc(A, A[N / 2]) * 2 - abs(A[N / 2] - A[N / 2 - 1]);
        cout << max(tmp1, tmp2) << endl;
    }
    else
    {
        N--;
        lint tmp = calc(A, A[N / 2]) * 2 - abs(A[N / 2] - A[N / 2 + 1]);
        tmp = max(tmp, calc(A, A[N / 2 + 1]) * 2 - abs(A[N / 2 + 1] - A[N / 2]));
        cout << tmp << endl;
    }
}


Measured memory_bytes: 1792
H,W = map(int,input().split())

A = [list(map(int,input().split())) for _ in range(H)]

results = []

for y in range(H):
  for x in range(W-1):
    if A[y][x] % 2 == 1:
      A[y][x] -= 1
      A[y][x+1] += 1
      results.append((y+1,x+1,y+1,x+2))

  if y != H-1 and A[y][W-1] % 2 == 1:
    A[y][W-1] -= 1
    A[y+1][W-1] += 1
    results.append((y+1, W, y+2, W))

print(len(results))
for r in results:
  print(*r)

Measured memory_bytes: 26680
#include <bits/stdc++.h>
#define mod 1000000007
#define ll long long int
using namespace std;
 
int main(){
    ios_base::sync_with_stdio(false);
    double d,t,s;
    cin >>d>>t>>s;
    if(s*t>=d){
        cout <<"Yes"<<endl;
    }
    else cout <<"No"<<endl;
}

Measured memory_bytes: 3736
using System;
using System.Collections.Generic;
using System.Dynamic;

namespace atcorder
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            if(s == s.ToUpper())
            {
                Console.WriteLine("A");
            }
            else
            {
                Console.WriteLine("a");
            }
        }
    }
}

//文字配列の取得
//string[] strArray = Console.ReadLine().Split(' ').ToArray();
//string S = strArray[0];
//string T = strArray[1];

//文字列の取得
//string s = Console.ReadLine();

//数字配列の取得
//int[] intArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
//int H = intArray[0];
//int W = intArray[1];

//数字の取得
//int N = int.Parse(Console.ReadLine());

//リスト型(int)の取得
//List<int> A = new List<int>(Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray());

//出力
//Console.WriteLine(ans);
//Console.WriteLine("Yes");
//Console.WriteLine("No");
//Console.WriteLine(cnt);



Measured memory_bytes: 26088
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N = 1e7 + 5;
const ll MOD = 1e9 + 7;
#define all(x) x.begin(),x.end()
#define pii pair<int,int>
#define pis pair<ll,string>
#define F first
#define S second
#define LCM(a,b) ((a*b)/__gcd(a,b))
#define inf 1e10
#define test ll cse;cin>>cse;for(ll _i=1;_i<=cse;_i++)
#define PI 3.14159265
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const double EPS = 1E-9;
typedef vector< vector<double> > matrix;
typedef vector<int> vi;


int prime[N];
ll solve(ll num){

    unordered_map< int, int> mapp;
    while(num > 1){
        mapp[prime[num]]++;
        num /= prime[num];
    }
    // number of factors
    ll res = 1;
    for(auto ele: mapp) res *= (ele.S + 1);

    // sum of divisors/factors
    // ll ans = 1;
    // for(auto ele: mapp){
    //     ll ai = ele.F;
    //     ll pi = ele.S;

    //     ans *= (Exp(ai,pi+1)-1)/(ai-1);
    // }
    return res;
}

void sieve(int n){
    memset(prime,0,sizeof(prime));
    prime[0] = prime[1] = 1;

    for(int i = 2; i <= n; i++){
        if(prime[i]==0){
            for(int j=i; j <= N;j+=i) prime[j] = i;
        }
    }
}


ll inv2;
ll modexp(ll x,ll n){
    ll res=1LL;
    while(n > 0){
        if(n&1) res = (res*x) % MOD;
        x = (x*x) % MOD;    n >>= 1;
    }
    return res;
}

int main() {
    fast;

    int n; cin >> n;

    if(n >= 30) cout << "Yes\n"; else cout << "No\n";
    return 0;
}

Measured memory_bytes: 3648
import sys
from collections import Counter

N, K = map(int, sys.stdin.readline().split())
A = list(map(int, sys.stdin.readline().split()))

counter = Counter(A)
counter = sorted(counter.items(), key = lambda x: x[1])

if len(counter) <= K:
    print(0)
else:
    ans = 0
    needs = len(counter) - K
    for key, count in counter:
        needs -= 1
        ans += count

        if needs == 0:
            break

    print(ans)

Measured memory_bytes: 43204
#include <algorithm>
#include <iostream>
#include <map>
#include <set>
#include <vector>
using namespace std;

int main() {
    long long N;
    cin >> N;
    string tmp;
    map<string, int> dict;
    int maximum = 0;
    for (int i = 0; i < N; i++) {
        cin >> tmp;
        if (dict[tmp] == 0) {
            dict[tmp] = 1;
        } else {
            dict[tmp] += 1;
        }
        if (dict[tmp] > maximum) {
            maximum = dict[tmp];
        }
    }
    vector<string> ans;
    for (auto itr = dict.begin(); itr != dict.end(); ++itr) {
        if (itr->second == maximum) {
            ans.push_back(itr->first);
        }
    }
    sort(ans.begin(), ans.end());
    for (int i = 0; i < ans.size(); i++) {
        cout << ans[i] << "\n";
    }
    return 0;
}


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

# In[3]:


O = input()
E = input()
password = []
for i in range(len(E)):
    password.append(O[i])
    password.append(E[i])
if len(O) > len(E):
    password.append(O[-1])
print("".join(password))



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

const int MOD = 1000000007;
#define p(var)  std::cout<<var<<std::endl
#define pp(var) std::cout<<#var" = "<<var<<std::endl
#define PI (acos(-1))
#define rep(i, n)   for (int i = 0; i <  (n); i++)
#define repeq(i, n) for (int i = 1; i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define pb push_back
using ll = long long;
template<typename T> inline T gcd(T a, T b) { return b ? gcd(b,a%b) : a;}
template<typename T> inline T lcm(T a, T b) { return a / gcd(a,  b) * b;}

/*-----8<-----8<-----*/

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


    vector<int> a;
    int tmp=0;
    bool first1=s[0]=='1';
    //int value=first1?1:0;
    rep(i,N){
        if(i==0 || s[i-1]==s[i])tmp++;
        else {a.pb(tmp);tmp=1;}
        
    }
    if(tmp>0){a.pb(tmp);}

    vector<int> rui(a.size()+1,0);
    for(int i=0;i<a.size();i++){
        rui[i+1]=rui[i]+a[i];
        //pp(rui[i+1]);
    }

    int size=K*2+1;
    int loopmax=a.size()-size+1;
    int maxval=0;

    if(loopmax<0){p(N);return 0;}

    //pp(size);pp(loopmax);
    //0始まりの場合の初期値
    if(!first1){
        maxval=rui[size-1];
        //pp(maxval);
    }
    //最後が０のとき
    if(s[s.size()-1]=='0' ){
        int tmp=rui[a.size()]-rui[a.size()-size+1];
        if(maxval<tmp)maxval=tmp;
        //pp(rui[a.size()+1]);
        //pp(rui[a.size()+1-size+1]);
        //pp(tmp);
    }



    for(int i=0;i<loopmax;i+=2){
        if(!first1 && i==0){
            i++;
            continue;
        }
        int tval=rui[i+size]-rui[i];
        if(tval>maxval)maxval=tval;
    }
    


    p(maxval);
    return 0;
    
}






Measured memory_bytes: 1272
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#define rep(index,num) for(int index=0;index<num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
typedef long long ll;
using namespace std;
typedef pair<int,int> pint;
int main(){
	int A,B;
	scan(A);scan(B);
	prin((A-1)*(B-1));
	return 0;
}


Measured memory_bytes: 256
n,k = map(int, input().split())
r,s,p = map(int, input().split())
t= input()
T = [i for i in t]

win = ''
for i in range(len(T)-k):
    if T[i]==T[i+k]:
        T[i+k]='#'
ans = 0
for i in T:
    if i=='r':ans+=p
    elif i=='s':ans+=r
    elif i=='p':ans+=s
print(ans)


Measured memory_bytes: 9856
n,d=map(int,input().split())

l=[]
for _ in range(n):
  l1=list(map(int,input().split()))
  l.append(l1)

import math

ans=[]
for a in range(n):
  for b in range(n):
    x=0
    for c in range(d):
      D=(l[a][c]-l[b][c])**2
      x+=D
    y=math.sqrt(x)
    ans.append(y.is_integer())
      
ans=(ans.count(True)-n)//2
print(ans)

Measured memory_bytes: 3064
import std.stdio;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
import std.ascii;
void times(alias fun)(int n) {
    foreach(i; 0..n) fun();
}
auto rep(alias fun, T = typeof(fun()))(int n) {
    T[] res = new T[n];
    foreach(ref e; res) e = fun();
    return res;
}
// fold was added in D 2.071.0.
template fold(fun...) if (fun.length >= 1) {
    auto fold(R, S...)(R r, S seed) {
        static if (S.length < 2) {
            return reduce!fun(seed, r);
        } else {
            return reduce!fun(tuple(seed), r);
        }
    }
}

void main() {
    writeln("A", readln.split[1].front, "C");
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,a,b,x,y,c,d,temp,ans=0;
  cin>>n>>x>>y;
  for(int i=1;i<=n;i++){
    a=i/10000;
    temp=i%10000;
    b=temp/1000;
    temp%=1000;
    c=temp/100;
    temp%=100;
    d=temp/10;
    temp%=10;
    if(x<=a+b+c+d+temp&&a+b+c+d+temp<=y)ans+=i;
  }
  cout<<ans<<endl;
  return(0);
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <vector>
#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define RFOR(i,k,n) for (int (i)=(n)-1; (i)>=(k); --(i))
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define mp make_pair
#define fst first
#define snd second
using namespace std;

int main(){
    int n;
    vector<string> s;
    while(cin>>n && n){
        s.resize(n);
        REP(i,n){
            cin >> s[i];
        }
        queue<pair<int,int> > Q;
        int lv,lvmax = 0;
        RREP(i,n){
            lv = s[i].length() - 1;
            lvmax = max(lvmax, lv);
            char c = s[i][lv];
            int num;
            if(c >= '0' && c <= '9'){
                num = c - '0';
            }
            if(c == '+' || c == '*'){
                num = -c; // ???????????¨??´??°????????????????????????????????°????????´
                lv++;
            }
            Q.push(mp(num,lv));
        }
        Q.push(mp(-1,0)); // ????????????????????§?????\???????????????????????????????????????????¨?????????\????????????

        RFOR(i,1,lvmax+1){
            while(Q.front().fst != -1){
                if(Q.front().snd == i){ // ????????±????±???????????????£????????¨??¨????????????????¨????
                    stack <int> S;
                    while(Q.front().snd == i){ // ???????????????????¨????????¨????
                        if(Q.front().fst + '+' == 0){
                            int sum = 0;
                            while(!S.empty()){
                                sum += S.top();
                                S.pop();
                            }
                            S.push(sum);
                            Q.pop();
                            break;
                        }
                        else if(Q.front().fst + '*' == 0){
                            int pro = 1;
                            while(!S.empty()){
                                pro *= S.top();
                                S.pop();
                            }
                            S.push(pro);
                            Q.pop();
                            break;
                        }
                        else{
                            S.push(Q.front().fst);
                            Q.pop();
                        }
                    }
                    Q.push(mp(S.top(),i-1)); // ????±????????????????????¨????
                }
                else { // ???????????°??????
                   Q.push(Q.front());
                   Q.pop();
                }
            }
            Q.push(Q.front());
            Q.pop();
        }
            cout << Q.front().fst << endl;
    }
    return 0;
}

Measured memory_bytes: 1220
from math import ceil
Q = int(input())

primeList = [1] * (100001)
cumA = [0] * (100001)

primeList[0] = 0
primeList[1] = 0
# primeList
for i in range(2,100001):
  if primeList[i] == 1:
    j = i + i
    while j <= 100000:
      primeList[j] = 0
      j = j + i
#print(primeList[0:100])

for i in range(1,100000):
  cumA[i+1] = cumA[i]
  if i%2 == 0 and primeList[(i+2)//2] == 1:
    cumA[i+1] += primeList[i+1]

for i in range(Q):
  l, r = map(int, input().split())
  print(cumA[r] - cumA[l-1])


Measured memory_bytes: 5108
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        //String str = sc.next();
        int N = sc.nextInt();
        int ans = 0;
        
        for(int i=1; i<=1000000; i++){
            if(N==4 || N==2 || N==1){
                ans = i+3;
                break;
            }else{
                N = f(N);
            }
        }
        System.out.println(ans);
    }
    
    public static int f(int n){
        if(n%2 == 0){
            n = n/2;
        }else{
            n = 3*n+1;
        }
        return n;
    }
}

Measured memory_bytes: 35820
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size)
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
using namespace std;
using lint = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int judge(bool j){
    if(j == true) cout << "Yes";
    else cout << "No";
    return 0;
}


int main(){
    string w;
    cin >> w;
    size_t size = w.length();
    static_cast<int>(size);
    vector<char> words;
    rep(i,size){
        words.push_back(w[i]); //文字をベクトルとして格納
    }
    sort(ALL(words));
    
    bool a = true;
    if(size % 2 ==1) {
        a = false;
        judge(a);
        return 0;
    } 
    //rep(i,words.size()) cout << words[i];

    rep(i,size){
        if(words[i] != words[i+1]) a = false; 
        i++;
    }

    judge(a);

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, _s, n) for(int i = _s, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
using namespace std;

#define repi(itr, ds) for(auto itr = ds.begin(); itr != ds.end(); itr++)
// vector
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for(T &x : vec) is >> x;
  return is;
}
// pair
template <typename T, typename U>
ostream &operator<<(ostream &os, pair<T, U> &pair_var) {
  os << "(" << pair_var.first << ", " << pair_var.second << ")";
  return os;
}
// vector
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "{";
  for(int i = 0; i < vec.size(); i++) {
    os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
  }
  os << "}\n   ";
  return os;
}
// map
template <typename T, typename U>
ostream &operator<<(ostream &os, map<T, U> &map_var) {
  os << "{";
  repi(itr, map_var) {
    os << *itr;
    itr++;
    if(itr != map_var.end()) os << ", ";
    itr--;
  }
  os << "}";
  return os;
}
// set
template <typename T>
ostream &operator<<(ostream &os, set<T> &set_var) {
  os << "{";
  repi(itr, set_var) {
    os << *itr;
    itr++;
    if(itr != set_var.end()) os << ", ";
    itr--;
  }
  os << "}";
  return os;
}

#define DUMPOUT cerr

void dump_func() { DUMPOUT << endl; }
template <class Head, class... Tail>
void dump_func(Head &&head, Tail &&... tail) {
  DUMPOUT << head;
  if(sizeof...(Tail) > 0) {
    DUMPOUT << ", ";
  }
  dump_func(std::move(tail)...);
}
#ifdef DEBUG_
#define DEB
#define dump(...)                                                             \
  DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                             \
          << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]" << endl \
          << "    ",                                                          \
      dump_func(__VA_ARGS__)
#else
#define DEB if(false)
#define dump(...)
#endif

typedef long long int ll;
const int MOD = 1e9 + 7;
const int INF = 1e9;

int main() {
  int N;
  cin >> N;
  int H[N];
  REP(i, N) cin >> H[i];

  int max_n = 0;
  REP(i, N) {
    max_n = max(max_n, H[i]);
    if(max_n - H[i] >= 2) {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;
}


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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll A[200005];
ll B[200005];

ll L[200005];
ll R[200005];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    REP(i, N) {
        cin >> A[i];
    }

    memset(R, 0, sizeof(R));
    memset(L, 0, sizeof(L));
    REP(i, N) {
        L[i + 1] = L[i] ^ A[i];
    }
    for (int i = N - 1; i >= 0; --i) {
        R[i] = R[i + 1] ^ A[i];
    }

    REP(i, N) {
        B[i] = L[i] ^ R[i + 1];
    }

    REP(i, N) {
        cout << B[i] << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 9900
io = STDIN
a,b,c=io.gets.split.map(&:to_i)
ar=[
  [a,b,c],
  [a,c,b],
  [b,a,c],
  [b,c,a],
  [c,a,b],
  [c,b,a,],
]
sum=ar.map{|x,y,z|(x-y).abs+(y-z).abs}
p sum.min


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

ll a,b,x;

int main(){
    cin >> a >> b >> x;
    if(a <= x && x <= a+b)cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
using LD = long double;
const long double PI = 3.14159265358979323846264338327950L;

LD A, B, H, M;

int main() {
    cin >> A >> B >> H >> M;
    long double rad = (long double)(30.0*H+0.5*M-6.0*M)*(long double)(PI/180.0);
    long double rsq = sqrtl((long double)(A * A + B * B) - (long double)(2 * A * B * cosl(rad))); 
    printf("%20.20Lf\n", rsq);
}


Measured memory_bytes: 4128
#include <cstdio>
#include <cctype>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;

#define ll long long
#define reg register
#define rep(i, a, b) for (reg int i = (a), i##end = (b); i <= i##end; ++i)
#define dep(i, a, b) for (reg int i = (a), i##end = (b); i >= i##end; --i)

template <typename _typer> inline _typer read() {
    _typer init = 0;
    char ch = getchar(), k = 0;
    for ( ; !isdigit(ch); ch = getchar()) k = (ch == '-');
    for ( ; isdigit(ch); ch = getchar())
        init = (init << 3) + (init << 1) + (ch ^ 48);
    return k ? -init : init;
}
const ll N = 0, INF = 1e9;

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

int main() {
    int a = read<int>(), b = read<int>(), c = read<int>();
    cout << max(0, c - (a - b)) << endl;
    return 0;
}



Measured memory_bytes: 256
N, K = map(int, input().split())
a=input().split()
L = []
for i in range(K):
    L += [int(a[i])]
S = []
for i in range(K):
    if i ==0:
        S+=[L[0]+N-L[K-1]]
    else:
        S += [L[i]-L[i-1]]
print(sum(S)-max(S))

Measured memory_bytes: 87548
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
#define print(x) cerr << (#x) << "is "<< x << "\n"
using ll = long long;
using pii = pair<int,int>;
const int MOD = 1e9+7, N = 1e5 + 10; 

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   int n;
   cin >> n;
   cout << n*n*n << '\n';
   return 0;
} 

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

int main() {
    ll X;
    cin >> X;
    map<ll, ll> mp;
    mp[0] = 0;
    for (ll i = 1; i <= 2000; i++) {
        ll t = i*i*i*i*i;
        mp[t] = i;
        mp[-t] = -i;
        if (mp.find(t-X) != mp.end()) {
            cout << i << " " << mp[t-X] << endl;
            return 0;
        }
        if (mp.find(-t-X) != mp.end()) {
            cout << -i << " " << mp[-t-X] <<  endl;
            return 0;
        }
    }
    return 0;
}


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

using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
#define REP(i,N) for(int i=0;i<N;i++)

int main()
{
    int n,m; cin>>n>>m;
    cout<<(n<m?0:10)<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio> 
#include <cstdlib> 
#include <cmath> 
#include <cstring> 
#include <climits> 
#include <cfloat> 
#include <map> 
#include <utility> 
#include <set> 
#include <iostream> 
#include <memory> 
#include <string> 
#include <vector> 
#include <algorithm> 
#include <functional> 
#include <sstream> 
#include <complex> 
#include <stack> 
#include <queue> 
#include <numeric>
#include <cassert>

#define FOR(i, min, max) for (int i = (min); i < (max); ++i) 
#define FORE(i, min, max) for (int i = (min); i <= (max); ++i) 
#define REP(i, n) for (int i = 0; i < (n); ++i) 
#define REPV(vec, i) for (int i = 0; i < (int)(vec.size()); ++i) 
#define FOR_EACH(vec, it) for (typeof((vec).begin()) it = (vec).begin(); it != (vec).end(); ++it)

using namespace std; 
static const double EPS = 1e-12; 
typedef long long ll; 

int main(void)
{
    int A, B;
    cin >> A >> B;
    cout << (ll)A*B << endl;
    return 0;
}


Measured memory_bytes: 3636
parseInt(x)=parse(Int,x)
parseMap(x::Array{SubString{String},1})=map(parseInt,x)

function main()
	a,b,k = readline() |> split |> parseMap
	count = 0
  	m = min(a,b)
	for i in 0:m-1
		if a%(m-i) == 0 && b%(m-i) == 0
			count += 1
		end
		if count == k
			println(m-i)
			break
		end
	end
end
main()

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

int main() {
  long int N,K,L;
  L = 1000000007;
  cin >> N >> K;
  vector<int> A(N);
  long int in_count = 0;
  long int out_count = 0;
  for(int i=0; i<N; i++){
    cin >> A.at(i);
  }
  //A内の転倒数の計算
  for(int i=0; i<N-1; i++) {
    for(int j=i+1; j<N; j++){
      if(A.at(i) > A.at(j)) {
        in_count++;
      }
    }
  }
  sort(A.begin(),A.end());
  for(int i=0; i<N-1; i++) {
    for(int j=i+1; j<N; j++){
      if(A.at(i) < A.at(j)) {
        out_count++;
      }
    }
  }
  in_count = (in_count * K) % L;
  out_count = (out_count * ((K * (K-1) / 2) % L)) % L;
  cout << (in_count + out_count) % L << endl;
}


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


def solve(S):
    n = len(S)
    ret = float('inf')
    for i in range(0, n - 2):
        ret = min(ret, abs(int(S[i:i + 3]) - 753))
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = str(next(tokens))  # type: int
    solve(S)

if __name__ == '__main__':
    main()


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

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

    vector<int> a(N);

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

    sort(a.begin(), a.end(), greater<int>());

    int A = 0;
    int B = 0;

    for(int i=0; i<N; i++){
        if(i%2==0) A+=a.at(i);
        else B += a.at(i);
    }

    cout << A-B << endl;
    return 0;

} 


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

#define NDEBUG
#ifdef DEBUG
#include "../cout11.h"
#undef NDEBUG
#endif
#include <cassert>

typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
#define cons make_pair


ll gcd(ll a, ll b) { while(a) swap(a, b%=a); return b; }

const ll MOD=1000000007LL;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }
// ll comb(ll n, ll k) { ll v=1; for(ll i=1; i<=k; i++) v = DIV(MUL(v, n-i+1),i); return v; }
//

#define INTSPACE 12
char _buf[INTSPACE*1000000 + 3];

int loadint() {
    if (fgets(_buf, INTSPACE+3, stdin)==NULL) return 0;
    return atoi(_buf);
}

int loadvec(vector<int>& v, int N=-1) {
    if (N == -1) {
        N = loadint();
        if (N==0) return 0;
    }
    int bufsize = INTSPACE*N + 3;
    if (fgets(_buf, bufsize, stdin)==NULL) return 0;
    v.resize(N);

    int i=0;
    bool last = false;
    for (char *p=&_buf[0]; ;) {
        char *q = p;
        while (*q > ' ') ++q;
        if (*q == 0x0D || *q == 0x0A) last = true;
        *q = 0;
        v[i++] = atoi(p);
        if (last || i == N) break;
        p = q+1;
    }
    // assert(i <= N);
    return i;
}
void read_cr() {
    fgets(_buf, 256, stdin);
}

int solve(int N, int K, vi& x) {
    int best = INT_MAX;
    for (int i=0,j=K-1; j<N; ++i,++j) {
        int dist = x[j] - x[i];
        best = min(best, dist + min(abs(x[i]), abs(x[j])));
    }
    return best;
}

int main() {
    int N, K; cin >> N >> K;
    read_cr();
    vi x(N);
    loadvec(x, N);
    cout << solve(N,K,x) << endl;
    return 0;
}


Measured memory_bytes: 1664
import sys

input = sys.stdin.readline


def func(x):
    if (x % 10 != 0):
        return (x + (10-x % 10))
    else:
        return(x)


lis = [input().rstrip() for _ in range(5)]


lis1 = []


for i in range(5):
    lis1.append([i, int(lis[i][-1])])

lis1.sort(key=lambda x: x[1])

lis2 = lis1.copy()

for i in range(5):
    if (lis1[i][1] == 0):
        lis2.append(lis1[i])
        lis2.pop(0)

s = 0

for i in range(4):
    s += func(int(lis[lis2[4-i][0]]))

s += int(lis[lis2[0][0]])

print(s)


Measured memory_bytes: 3064
#include<stdio.h>
#include<math.h>
#include<stdlib.h>

int main(void){
  int N;
  scanf("%d",&N);
  int x[N+1]={};
  int y[N+1]={};
  int t[N+1]={};
  for(int i=1;i<N+1;i++){
    scanf("%d",t+i);
    scanf("%d",x+i);
    scanf("%d",y+i);
  }
  for(int i=1;i<N+1;i++){
    int z = abs(x[i] - x[i-1])+ abs(y[i] - y[i-1]);
    if(t[i]-t[i-1]<z){
      printf("No");
      exit(0);
    }
    else if((t[i]-t[i-1]-z)%2){
      printf("No");
      exit(0);
    }
  }
  printf("Yes");
  return 0;
}


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

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

   int total;
   total = N*L + N*(N+1)/2 -N;
   int i;
   if (-L+1 <= 0)
      i = 1;
   else if (-L+1 > N)
      i = N;
   else
      i = -L+1;

   int result;
   result = total - (L+i-1);

   cout << result << endl;
}



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

#define F first
#define S second
#define FOR(i,a,b) for (int i = (a); i <= (b); ++i)
#define NFOR(i,a,b) for(int i = (a); i >= (b); --i)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
typedef long long ll; typedef pair <int, int> ii; typedef vector <int> vi; const int inf = 1e9 + 7;
#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
template <class T> void dbs(string str, T t) {cout << str << " : " << t << "\n";}
template <class T, class... S> void dbs(string str, T t, S... s) {int idx = str.find(','); cout << str.substr(0, idx) << " : " << t << ","; dbs(str.substr(idx + 1), s...);}
template <class S, class T>ostream& operator <<(ostream& os, const pair<S, T>& p) {return os << "(" << p.first << ", " << p.second << ")";}
template <class T>ostream& operator <<(ostream& os, const vector<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const set<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T> void prc(T a, T b) {cout << "["; for (T i = a; i != b; ++i) {if (i != a) cout << ", "; cout << *i;} cout << "]\n";}

vi vis, col;
int nn, cur;
vector<vi> g;
int dfs(int i, int c) {
	if (vis[i]) return col[i] == c;
	col[i] = c;
	vis[i] = 1;
	++nn, ++cur;
	bool can = 1;
	for (int j: g[i]) {
		can &= dfs(j, !c);
	}
	return can;
}
int main()
{
	ios::sync_with_stdio(0); cin.tie(0);

	int n, m; cin >> n >> m;
	g = vector<vi>(n);

	FOR (it, 1, m) {
		int x, y; cin >> x >> y;
		--x, --y;
		g[x].push_back(y), g[y].push_back(x);
	}
	col = vis = vi(n);
	ll ans = 0;
	int a = 0, b = 0, e = 0;
	FOR (i, 0, n - 1){
		if (vis[i]) continue;
		cur = 0;
		int x = dfs(i, 0);
		if (g[i].empty()) {
			++e;
			ans += 2*nn - 1;
			continue;
		}
		x = x ? 2 : 1;
		ans += x;
		if (x == 1) {
			int no = a + b;
			ans += 2*no;
			ans += cur*2LL*e;
			++a;
		}
		else {
			ans += cur*2LL*e + 2*a + 4*b;
			++b;
		}
	}
	cout << ans << "\n";

	return 0;
}

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

int main(){
    long long n, m;
    cin >> n >> m;

    long long left = 1, right = n;

    for(long long i = 0; i < m; i++){
        long long l, r;
        cin >> l >> r;
        if(l > right){
            printf("0\n");
            return 0;
        }
        else if(r < left){
            printf("0\n");
            return 0;
        }

        if(left < l){
            left = l;
        }

        if(right > r){
            right = r;
        }
        //printf("left %lld right %lld\n", left, right);  
    }
    

    cout << right - left + 1 << endl;

    return 0;
}

Measured memory_bytes: 3636
/*
 * Matheus Oliveira
 * 09:03:29 26/04/2020
 * b.cpp
*/

#include <bits/stdc++.h>
using namespace std;

#define EPS
#define INF
#define MAXN
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define sc(x) scanf("%d", &x);
#define sc2(x, y) scanf("%d %d", &x, &y);
#define sc3(x, y, z) scanf("%d %d %d", &x, &y, &z);
#define debug(x) printf("%s: %d\n", #x, x);
#define debugarr(x, bg, ed) printf("%s: ", #x); for(int i = bg; i < ed; i++) printf("%d%c", x[i], (i == ed-1) ? '\n' : ' ');

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

int main() {
	int a, b, c, d, p = 0;
	scanf("%d %d %d %d", &a, &b, &c, &d);
	
	while(a > 0 and c > 0) {
		if(p == 0) c -= b;
		else a -= d;
		p ^= 1;
	}

	if(a > 0) printf("Yes\n");
	else printf("No\n");

	return 0;
}

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

int main(){
  int A,B,C;
  char m,n;
  cin>>A>>m>>B>>n>>C;
  if(B>4){
    cout<<"TBD"<<endl;
  }
  else{
    cout<<"Heisei"<<endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n;
int a[200005];
bool k;
int main() {
	cin>>n;
	for(int i=0;i<n;i++) scanf("%d",&a[i]);
	sort(a,a+n);
	for(int i=1;i<n;i++) if(a[i]==a[i-1]) k=1;
	if(k) cout<<"NO";
	else cout<<"YES";
	return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;


public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n= sc.nextInt();
		int p=Integer.MAX_VALUE;
		double[] X = new double[n];
		double[] Y = new double[n];

		for(int i=0; i<n;i++) {
			X[i]=sc.nextDouble();
		}

		for(int i=0; i<n;i++) {
			Y[i]=sc.nextDouble();
		}
		System.out.printf("%f", mincof(n,1,X,Y));
		System.out.println();
		System.out.printf("%f", mincof(n,2,X,Y));
		System.out.println();
		System.out.printf("%f", mincof(n,3,X,Y));
		System.out.println();
		System.out.printf("%f", mincof(n,p,X,Y));
		System.out.println();
	}

	public static double mincof(int n,int p,double[] X, double[] Y) {
		double sum=0;

		if(p>3) {
			double max=Double.MIN_VALUE;
			for(int i=0; i<n;i++) {
				double d=Math.abs(X[i]-Y[i]);
				if(d>max) {
					max=d;
				}
			}
			return max;
		}else {
			for(int i=0;i<n;i++) {
				sum+=Math.pow(Math.abs(X[i]-Y[i]), p);
			}
			return  Math.pow(sum, (double)1/p);
		}


	}

}


Measured memory_bytes: 29184
import sys
input = sys.stdin.readline
def main():
    A, B, C, K = map(int, input().split())
    rest = K
    ans = 0
    ans += min(A, rest)
    if K > A:
        rest -= A
        if rest > B:
            rest -= B
            ans -= min(rest, C)
    print(ans)
if __name__ == "__main__":
    main()

Measured memory_bytes: 79184