akhauriyash/Code-Regression huggingface dataset:
# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
#from heapq import heappop, heappush
#from collections import defaultdict
sys.setrecursionlimit(10**7)
#import math
#from itertools import product, accumulate, combinations, product
#import bisect
#import numpy as np
#from copy import deepcopy
#from collections import deque
#from decimal import Decimal
#from numba import jit

INF = 1 << 50
EPS = 1e-8
mod = 10 ** 9 + 7

def run():
    a,b,c,d = map(int, sysread().split())
    print(max([a*c, a*d, b*c, b*d]))
if __name__ == "__main__":
    run()


Measured memory_bytes: 9224
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()
#define SENTINEL 1<<30

using namespace std;

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

void Merge(vector<int> & a, int left, int mid, int right )
{
	int n1 = mid - left;
	int n2 = right - mid;

	vector<int> L(n1 + 1, 0 ), R (n2 + 1, 0 );
	rep (i, n1 ) L[i] = a[left + i];
	rep (i, n2 ) R[i] = a[mid + i];

	L[n1] = SENTINEL;
	R[n2] = SENTINEL;

	int i = 0, j = 0;
	for (int k = left; k < right; k++ ){
		if (L[i] <= R[j] ){
			a[k] = L[i];
			i++;
		}else{
			a[k] = R[j];
			j++;
		} // end if
		cnt++;	
	} // end for
}

void Merge_Sort (vector<int> &a, int left, int right )
{
	if (left + 1 < right ){
		int mid = (left + right )/2;
		Merge_Sort (a, left, mid );
		Merge_Sort (a, mid, right );
		Merge (a, left, mid, right );
	} // end if
}

int main()
{
	ios_base::sync_with_stdio(0);
	int n; cin >> n;
	vector<int> a (n, 0 );
	rep (i, n ) cin >> a[i];

	cnt = 0;
	Merge_Sort(a, 0, n );
	rep (i, n ) cout << a[i] << (i != n - 1 ? ' ' : '\n' );
	cout << cnt << endl;	
		
	return 0;
}

Measured memory_bytes: 5076
S = input()
if len(S) == 1:
  print(int(S))
  exit()
else:
  def count(n):
    a = 0
    if len(n) == 1:
      return 0
    else:
      for i in range(1, len(n)):
        a += int(n[:i]) * 2 ** (len(n[i:]) - 1) + int(n[i:]) + count(n[i:])
      return a
  print(int(S) + count(S))

Measured memory_bytes: 38256
import sys
import  math
import fractions
from collections import deque
from collections import defaultdict
stdin = sys.stdin
     
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

N,u,v=nm()
u=u-1
v=v-1
INF=10**18
edge=[[] for i in range(N)]

def bfs(start,edge):
    d=[INF]*N
    d[start]=0
    q=deque([start])
    while (q):
        e=q.popleft()
        for i in edge[e]:
            if(d[e]+1<d[i]):
                d[i]=d[e]+1
                q.append(i)   
    return d


for i in range(N-1):
    A,B=nm()
    edge[B-1].append(A-1)
    edge[A-1].append(B-1)


d_A=bfs(u,edge)
d_B=bfs(v,edge)

ans=0
for i in range(N):
    #if(d_A[0]%2==d_B[0]%2):
    #    continue
    #else:
    if(d_A[i]<d_B[i]):
        tmp=max(d_A[i],d_B[i])
        ans=max(ans,tmp)

print(ans-1)


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

int main(){
  int n;
  cin >> n;
  vector <ll> v(100,0);
  v.at(0)=2;
  v.at(1)=1;
  if(n==1)cout << 1<<endl;
  else{
    r(i,n){
      v.at(i+2)=v.at(i)+v.at(i+1);
    }
    cout << v.at(n)<<endl;
  }
}

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

int main()
{
	ll k;
	cin >> k;
	vector<ll> ans(50);
	ll mk = k%50;
	for(int i =0;i<50;i++)
	{
		ans[i]=k/50;
	}

	for(int i = 0;i<50;i++)
	{
		ans[i] += 50 - i - 1;
	}
	for(int i = 0;i<mk;i++)
	{
		ans[i]++;
	}
	cout << 50 << endl;
	for(int i =0;i<50;i++)
	{
		if(i)cout << ' ';
		cout << ans[i];
	}
	cout << endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <math.h>
#include <algorithm>
#define ll long long
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pld pair<ld, ld>
#define f first
#define s second
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define eb emplace_back
#define in insert
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define FOR(i, n, x) for(int i = x; i < n; i++)
#define OUT(a, e) FOR(i, e, 0) cout << a[i] << ' '
#define OUTV(a) for(auto i : a) cout << i << ' ';
#define maxim(a, n, mx) FOR(i, n, x)mx = max(mx, a[i]);



using namespace std;

int main()
{
    fast;
    int n; cin >> n;
    int a[n];
    FOR(i, n, 0)cin >> a[i];
    int fr = a[0];
    FOR(i, n, 1)fr = (a[i]^fr);
    if(fr)cout << "No";
    else cout << "Yes";
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
 
#define pii pair<int, int>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long 
#define ld long double
#define sz(v) int(v.size())
#define all(v) v.begin(), v.end()
 
#define y1 what

using namespace std;
 
const int N = (int) 4e5 + 10;
const int M = (int) 1e6 + 10;
const ll LINF = (ll) 2e18;
const int INF = (int) 1e9 + 7;
const double EPS = (double) 1e-9;
const double PI =  3.14159265359;

int n, q, ans;
int a[N], cnt[N], clr[N];

void add(int id) {
    int i = a[id];
    if (i - cnt[i] >= 1) {
        if (clr[i - cnt[i]] == 0)
            ans++;
        clr[i - cnt[i]]++;
    }
    cnt[i]++;
}

void del(int id) {
    int i = a[id];
    if (i - cnt[i] + 1 >= 1) {
        clr[i - cnt[i] + 1]--;
        if (clr[i - cnt[i] + 1] == 0)
            ans--;
    }
    cnt[i]--;
}

int main() {
    #define fn "euler"
    #ifdef witch                                                            
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #else
        //freopen(fn".in", "r", stdin);
        //freopen(fn".out", "w", stdout);
    #endif      
    srand(time(0));
    cin >> n >> q;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        add(i);
    }
    while (q--) {
        int x, y;
        cin >> x >> y;
        del(x);
        a[x] = y;
        add(x);
        cout << n - ans << endl;
    }
    return 0;
}

Measured memory_bytes: 4736
# abc177_c.py
# https://atcoder.jp/contests/abc177_c


# [開発時用] ログ関数
def lg(value):
    flag = False
    # flag = True
    if flag:
        print(str(value))


# [開発時用] exit処理
def xt(log):
    lg('★exit() - ' + str(log))
    exit()


# 本体
def get_results():

    # 引数処理部
    lines = list()
    # 仕様でn行と決まっている場合(の例)
    lines_count = 2
    # 先頭行のNで行数が決まる場合(の例)
    # line = input()
    # lines.append(line)
    # N = int(line)
    # lines_count = N
    for _ in range(lines_count):
        lines.append(input())

    # 演算部
    # S = lines[0]
    N = int(lines[0])
    # N, M = list(map(int, lines[0].split()))
    values = list(map(int, lines[1].split()))
    # values = list(map(int, lines[2].split()))
    # values = list()
    # for i in range(N):
    #     values.append(int(lines[i]))
    # valueses = list()
    # for i in range(N):
    #     valueses.append(list(map(int, lines[i+1].split())))

    lg(f'values=[{values}]')

    targets = list()
    # [1, 2, 3] => targets = [3, 5]
    su = 0
    for j in range(1, N):
        # targets.append(3)
        # targets.append(5)
        su += values[N - j]
        targets.append(su)

    su = 0
    for i in range(N-1):
        # for j in range(i+1, N):
        #     target += values[j]
        su = (su + values[i] * targets[N-2-i]) % (10**9+7)

    return [su]


# 主処理
def main():
    results = get_results()

    for result in results:
        print(result)


# 起動処理
if __name__ == '__main__':
    main()


Measured memory_bytes: 33520
#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>

using namespace std;

#define F(i , a , b) for(int (i) = (a) ; (i) <= (b) ; (i)++)
#define pb push_back
#define ll long long
#define E(a) cerr << #a << " = " << a << '\n'
#define X first
#define Y second
#define INF 10000000000000

const int MAX_N = 100000 + 10 , mod = 1000000007;

ll n,x,a[MAX_N],ans;

int32_t main(){

    //    freopen("input.txt" , "r" , stdin);
    //    freopen("output.txt" , "w" , stdout);
    //    cout << setprecision(10) << fixed;

    cin >> n >> x;
    for(int i = 1 ; i <= n ; i++){
        cin >> a[i];
    }
    for(int i = 1 ; i < n ; i++){
        if(a[i]+a[i+1] > x){
            ans += (a[i]+a[i+1]-x);
            if(x>a[i]) a[i+1] = x-a[i];
            else a[i+1] = 0;
        }
    }
    cout << ans;



    return 0;
}


Measured memory_bytes: 1024
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<map>
#include<cstring>
#include<string>
using namespace std;
typedef long long LL;
const int  MaxN = 200000;

int tim[MaxN + 10];
int main()
{
	int N, T, sum = 0;
	cin >> N >> T;
	for(int i = 1;i <= N;i++) cin >> tim[i];
	if(N == 1) cout << T << endl;
	else{
		for(int i = 2;i <= N;i++){
			int t = tim[i] - tim[i-1];
			if(t < T) sum += t;
			else sum += T;
		}
		sum += T;
		cout << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner

fun main(args: Array<String>){
    val scanner = Scanner(System.`in`)
    val quantity = scanner.nextInt()
    val result = D0427D(
                    valueArray = Array(quantity){ scanner.nextInt() }
                 ).judge()
    println(result)
}

class D0427D(
  val valueArray: Array<Int>
){
    fun judge(): Long{
        val minus = valueArray.filter { it < 0 }
        val abs   = valueArray.map { Math.abs(it).toLong() }
        return if (minus.size % 2 == 0) abs.sum()
               else                     abs.sum() - abs.min()!!*2
    }
}

Measured memory_bytes: 52964
import bisect, copy, heapq, math, sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
def celi(a,b):
    return -(-a//b)
sys.setrecursionlimit(5000000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n=int(input())
a=list(map(int,input().split()))
ans=0
l,r=0,0
cnt=0
xor=0
for i in range(n):
    l=i
    if l==r:
        cnt+=a[i]
        xor+=a[i]
        r+=1
    while r+1<=n and xor^a[r]==cnt+a[r]:
        xor^=a[r]
        cnt+=a[r]
        r+=1
    # print(l,r,cnt,xor)
    cnt-=a[i]
    xor-=a[i]
    ans+=r-l
print(ans)

Measured memory_bytes: 104228
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <math.h>
#include <queue>
using namespace std;
typedef long long ll;


int main() {
  double R;
  cin >> R;

  double ret = 2 * R * M_PI;
  printf("%lf\n", ret);
  return 0;
}

Measured memory_bytes: 3788
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main(){
	string s;
	vector<bool> flag(26,false);
	cin >> s;

	for(auto c : s){
		flag[c - 'a'] = true;
	}

	for(int i = 0; i < 26; ++i){
		if(flag[i] == false){
			cout << static_cast<char>('a' + i) << endl;
			return 0;
		}
	}

	cout << "None" << endl;

	return 0;
}

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

using namespace std;

int main(){
    int64_t n;
    vector<int64_t> A(3);
    cin >> n;
    for (auto &a: A) cin >> a;
    vector<string> S(n);
    copy_n(istream_iterator<string>(cin), n, S.begin());
    vector<array<int, 2>> B(n);
    for (int i = 0; i < n; i++){
        if (S[i] == "AB")
            B[i] = {0, 1};
        if (S[i] == "AC")
            B[i] = {0, 2};
        if (S[i] == "BC")
            B[i] = {1, 2};
    }

    vector<int> ans;

    for (int i = 0; i < n; i++){
        int j = B[i][0], k = B[i][1];
        if (A[j] == 1 and A[k] == 1 and i < n - 1){
            if (!(B[i + 1][0] == j or B[i + 1][1] == j))
                swap(j, k);
        } else {
            if (A[j] > A[k])
                swap(j, k);
        }

        ans.push_back(j);
        A[j]++; A[k]--;

        if (A[j] < 0 or A[k] < 0){
            puts("No");
            return 0;
        }
    }

    puts("Yes");
    for (const auto &a: ans){
        cout << char(a + 'A') << endl;
    }
}

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

int main(){
    string s;
    int K;
    cin>>s>>K;
    for(int i=0;i<s.size()-1;i++){
        int b=26-(s[i]-'a');
        if(b!=26&&K>=b){
            K-=b;
            s[i]='a';
        }
    }
    K%=26;
    while(K>0){
        int r=s[s.size()-1]-'a';r++;r%=26;
        s[s.size()-1]='a'+r;
        K--;
    }
    cout<<s<<endl;
    return 0;
}


Measured memory_bytes: 640
def resolve():
    import itertools
    AE = [int(input()) for _ in range(5)]
    minA = float("inf")
    for ae in itertools.permutations(AE):
        sumA = 0
        for dish in ae:
            if sumA % 10 != 0:
                sumA += 10 - (sumA % 10)
            sumA += dish
        minA = min(minA, sumA)
    print(minA)


resolve()


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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1777777777ll
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;



int main() {
    string a, b;
    cin >> a >> b;
    li x = atoi((a + b).c_str());
    li sx = sqrt(x);
    cout << (sx * sx == x ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 256
use std::io::*;
use std::str::*;

fn main() {
    let n: u32 = read_one();
    let ans: u32 = [105, 135, 165, 189, 195].iter().map(|&x| {if n < x {0} else {1}}).sum();
    println!("{}", ans);
}

fn read_one<T: std::str::FromStr>() -> T {
    let mut s = stdin().bytes().map(|c| c.unwrap() as char)
                       .skip_while(|c| c.is_whitespace())
                       .take_while(|c| !c.is_whitespace())
                       .collect::<String>();
    s.trim().parse().ok().unwrap()
}

Measured memory_bytes: 4352
using System;

public class Test
{
	public static void Main( )
	{
		int n = int.Parse( Console.ReadLine() );
		int[] nums = new int[n+1];
		for( var i=0; i<n; i++ ) {
			nums[i] = int.Parse( Console.ReadLine() );
		}
	
		int cnt = n;
		for( var i=0; i<n; i++ ) {
			if( 2 == nums[i] || 3 == nums[i] ) { continue; }
			if( 0 == nums[i]%2 ) {
				cnt--;
				continue;
			}

			for( var j=3; j<=Math.Sqrt( nums[i] ); j+=2 ) {
				if( 0 == nums[i]%j ) {
					cnt--;
					break;
				}
			}
		}
		
		Console.WriteLine( cnt );
	}
}

Measured memory_bytes: 9120
#include <bits/stdc++.h>
#define rep(n) for(lint I = 0; (I) < (lint)(n); ++(I))
#define repeat(i, n) for(lint i = 0; (i) < (lint)(n); ++(i))
#define repeat_to(i, n) for(lint i = 0; (i) <= (lint)(n); ++(i))
#define repeat_from(i, m, n) for(lint i = (m); (i) < (lint)(n); ++(i))
#define repeat_from_to(i, m, n) for(lint i = (m); (i) <= (lint)(n); ++(i))
#define el cout<<endl
#define dump(x) cout<<" "<<#x<<"="<<x
#define vdump(v) for(size_t I=0; I<v.size(); ++I){cout<<" "<<#v<<"["<<I<<"]="<<v[I];} cout<<endl
using namespace std;
using lint = long long;
using ld = long double;

int main(void) {
    lint n; cin >> n;
    vector<lint> a(n); repeat(i, n) cin >> a[i];
    
    lint s = accumulate(a.begin(), a.end(), 0LL);
    
    repeat_from_to(k, s - n * (n - 1), s) {
        if (k < 0) continue;
        lint z = 0;
        repeat(i, n) {
            lint b = (a[i] + k) % (n + 1);
            if (b == n) goto LABEL;
            z += b;
        }
        if (z == s - k) {
            cout << k << endl;
            break;
        }
    LABEL:;
    }
    return 0;
}

Measured memory_bytes: 256
s = list(input())
t = input()
counter = len(s)

FLAG = False

for i in range(counter):
  r  = ""
  for a in s:
    r += a
  if r == t:
    FLAG = True
    break
  else:
    tmp = s[0]
    s.pop(0)
    s.append(tmp)

if FLAG:
  print("Yes")
else:
  print("No")

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

int64_t pow_mod(int64_t a, int64_t b, int64_t c){
    if(b == 0) return 1;
    else if(b % 2 == 0){
        int64_t t = pow_mod(a, b / 2, c);
        return t * t % c;
    }
    else return a * pow_mod(a, b - 1, c) % c;
}

int main(){
    int64_t n, a, b;
    cin >> n >> a >> b;
    int64_t mod = 1000000007;
    int64_t all, Xa = 1, Xb, Ya = 1, Yb;
    all = pow_mod(2, n, mod) - 1;
    for(int i=0; i<a; i++){
            Xa *= n - i;
            Xa %= mod;
    }
    Xb = Xa;
    for(int i=a; i<b; i++){
        Xb *= n - i;
        Xb %= mod;
    }
    for(int i=1; i<=a; i++){
        Ya *= i;
        Ya %= mod;
    }
    Yb = Ya;
    for(int i=a+1; i<=b; i++){
        Yb *= i;
        Yb %= mod;
    }
    Ya = pow_mod(Ya, mod - 2, mod);
    Yb = pow_mod(Yb, mod - 2, mod);
    
    cout << (all - Xa * Ya % mod - Xb * Yb % mod + mod * 2) % mod << endl; 

}

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

bool pairCompare(const pair<int, int> &f, const pair<int, int> &s) {
  return f.second < s.second;
}

int main(int argc, char *argv[]) {
  int n, l;
  cin >> n >> l;

  int expect = 0;
  vector<int> a(n);
  vector<pair<int, int>> b(n);
  for (int i = 0; i < n; ++i) {
    expect += l + i;
    a[i] = l + i;
    b[i] = pair<int, int>(i, abs(l+i));
  }

  sort(b.begin(), b.end(), pairCompare);

  cout << expect - a[b[0].first] << endl;

  return 0;
}

Measured memory_bytes: 256
import sys;input=lambda:sys.stdin.readline().rstrip();aint=lambda:int(input());ints=lambda:list(map(int,input().split()))
import math;floor,ceil=math.floor,math.ceil
from collections import deque
Yes=lambda b:print('Yes')if b else print('No');YES=lambda b:print('YES')if b else print('NO')
is_even=lambda x:True if x%2==0 else False

def main():
  n,r = ints()
  if n>=10:
    print(r)
  else:
    print(r+100*(10-n))

      
if __name__ == '__main__':
  main()

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

map<int, int> n(int h, int w) {
    map<int, int> mp;
    if(h % 2 == 0 && w % 2 == 0) {
        mp[4] = h * w;
    } else if(h % 2 && w % 2) {
        mp[1] = 1;
        mp[2] = h + w - 2;
        mp[4] = h * w - mp[1] - mp[2];
    } else if(h % 2) {
        mp[2] = w;
        mp[4] = w * (h - 1);
    } else {
        mp[2] = h;
        mp[4] = h * (w - 1);
    }
    return mp;
}

int main() {
    int H, W;
    cin >> H >> W;
    map<char, int> cnt;
    rep(i, H) rep(j, W) {
        char c; cin >> c;
        cnt[c]++;
    }
    auto mp = n(H, W);
    for(auto &i : {4, 2, 1}) {
        for(int c = 'a'; c <= 'z'; ++c) {
            while(cnt[c] >= i && mp[i] >= i) {
                cnt[c] -= i;
                mp[i] -= i;
            }
        }
    }
    cout << (!mp[1] && !mp[2] && !mp[4] ? "Yes" : "No") << '\n';
    return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <set>

using namespace std;

int main(){
  int s;
  cin >> s;
  set<int> st;
  int x=s;
  //setの中にあるxの個数が0個の間
  while (st.count(x)==0){
    st.insert(x);//集合の中にxをいれる
    if (x%2==0){
      x/=2;
    }
    else {
      x=x*3+1;
    }
  }
  cout << (st.size()+1) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define int long long
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
signed main()
{
    SPEED;
    int h,c=0,i,p=1,s=0;
  	cin>>h;
  	while(h!=0)
    {
      c++;
      h/=2;
    }
    for(i=0;i<c;++i)
    {
      s+=p;
      p*=2;
    }
    cout<<s;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int a[333][333],num[333];
bool err[333];
int main()
{	
	int n,m;scanf("%d%d",&n,&m);
	for (int i=1;i<=n;i++)
	for (int j=1;j<=m;j++)
		scanf("%d",&a[i][j]);
	int ans=n;
	for (int t=1;t<=m;t++)
	{
		for (int i=1;i<=m;i++) num[i]=0;
		for (int i=1;i<=n;i++)
		{
			int w=1;while (err[a[i][w]]) w++;
			num[a[i][w]]++;
		}
		int mx=0,id;
		for (int i=1;i<=m;i++) if (num[i]>mx) {mx=num[i];id=i;}
	 	ans=min(ans,mx);
	 	err[id]=true;
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<vector>
using namespace std;
typedef long long llong;
int main(){
    string A, B, C;
    cin >> A >> B >> C;

    vector<string> s;
    s.push_back(A);
    s.push_back(B);
    s.push_back(C);

    int order = 0;
    int ans;
    string Ord;
    while (1){
        if (s[order].size() == 0){
            ans = order;
            break;
        }
        
        Ord = s[order][0];
        s[order].erase(0, 1);
        if (Ord == "a") order = 0;
        else if (Ord == "b") order = 1;
        else order = 2;
    }

    if (ans == 0) cout << 'A' << endl;
    else if (ans == 1) cout << 'B' << endl;
    else cout << 'C' << endl;
    return 0;
}

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

using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}


int main(){
  long long N;
  cin >> N;
  long long A[N];
  long long B[N];
  long long C[N];
  for(int i = 0; i < N; i++) cin >> A[i];
  for(int i = 0; i < N; i++) cin >> B[i];
  for(int i = 0; i < N; i++) cin >> C[i];

  sort(A,A+N);
  sort(B,B+N);
  sort(C,C+N);

  long long ans = 0;
  for(int i = 0 ; i < N; i++){
    ans += (lower_bound(A,A+N, B[i]) - A) * (C + N - upper_bound(C,C+N,B[i]));
  }

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


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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repp(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perr(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)

typedef long long LL;
typedef long double LD;

int main(){
  int n;
  cin >> n;
  int m,d,v,s;
  vector<int> y(360,0);
  rep(i,n){
    cin >> m >> d >> v >> s;
    d+=30*m;
    rep(j,s){
      y[(d+v+j)%360]=max(y[(d+v+j)%360],s-j-1);
    }
    rep(j,v){
      y[(d+j)%360]=max(y[(d+j)%360],s);
    }
    rep(j,s){
      y[(d-j-1+360)%360]=max(y[(d-j-1+360)%360],s-j-1);
    }
  }
  int ans=IINF;
  rep(i,360){
    ans=min(ans,y[i]);
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3096
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=-1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

a,B,c,D=get_i
i=1
until a<=0 or c<=0
    if i.odd?
        c-=B
    else
        a-=D
    end
    i+=1
end
if a<=0
    puts "No"
else
    puts "Yes"
end

Measured memory_bytes: 14380
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int mod = 1e9 + 7;
int n, m, l[105], r[105];
ll h[105], a[105], dp[105][2];
ll Pow(ll a, int x) {
	ll res = 1;
	while (x) {
		if (x & 1) (res *= a) %= mod;
		(a *= a) %= mod;
		x >>= 1; 
	}
	return res;
}
int main() {
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> h[i];
		a[i] = h[i];
	}
	sort(a + 1, a + 1 + n);
	m = unique(a + 1, a + 1 + n) - a - 1;
	for (int i = m; i >= 1; i--) {
		for (int j = 1; j <= n; j++) {
			if (h[j] > a[i]) {
				if (h[j - 1] > a[i]) {
					dp[j][0] = dp[j - 1][0];
					dp[j][1] = dp[j - 1][1];
				}
				if (h[j - 1] == a[i]) {
					dp[j][0] = (dp[j][0] + dp[j][1]) % mod;
					dp[j][1] = (2 * dp[j][1]) % mod;
					dp[j][0] = dp[j - 1][0] * dp[j][0] % mod;
					dp[j][1] = dp[j - 1][1] * dp[j][1] % mod * Pow(2, mod - 2) % mod;
				}
				if (h[j - 1] < a[i]) {
					dp[j][0] = (dp[j][0] + dp[j][1]) % mod;
					dp[j][1] = (2 * dp[j][1]) % mod;
				}
			}
			if (h[j] == a[i]) {
				if (h[j - 1] >= h[j]) {
					dp[j][0] = dp[j - 1][0] * 2 % mod;
					dp[j][1] = dp[j - 1][1];
				} 
				else {
					dp[j][0] = 2;
					dp[j][1] = 2;
				}
			}
		}
		for (int j = n; j >= 1; j--) {
			if (h[j] >= a[i] && h[j + 1] >= a[i]) {
				dp[j][0] = dp[j + 1][0];
				dp[j][1] = dp[j + 1][1];
			}
		}
		for (int j = n; j >= 1; j--) {
			int k = a[i] - a[i - 1] - 1;
			dp[j][0] = (dp[j][0] + dp[j][1] * (Pow(2, k) - 1) % mod) % mod,
			dp[j][1] = dp[j][1] * Pow(2, k) % mod;
		}
	}
	cout << dp[1][0];
}


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

int main() {
    int n, m; cin >> n >> m;
    int a[100000];
    double sum=0;
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i];
        sum += a[i];
    }
    sort(a, a+n, greater<int>());
    double need = sum / 4 / m;
    for (int i = 0; i < m; ++i)
    {
        if (a[i] < need)
        {
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";
}

Measured memory_bytes: 256
/*dismint|jjc*/
#include <bits/stdc++.h>
using namespace std;
#define forl(V, S, E) for(int V = S; V < E; V++)
#define ford(V, S, E) for(int V = S; V >= E; V--)
#define fore(E, X) for(auto &E:X)
#define println(X) cout << X << endl
#define printe(X) for(auto &E:X) cout << E << " "; cout << endl
typedef unordered_map<int, unordered_set<int>> graph;
typedef long long ll;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	string s; cin >> s;
	if(s == "Sunny") println("Cloudy");
	else if(s == "Cloudy") println("Rainy");
	else println("Sunny");
}


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

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

int x = 0;
int ans = 0;
for (int i = 0; i < N; i++) {
    if(S[i] == 'I') {
        x++;
    } else if (S[i] == 'D') {
        x--;
    }
    ans = max(ans, x);
}
cout << ans << endl;

}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,sse3,sse4,popcnt,abm,mmx")

//#include<bits/stdc++.h>
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <cassert>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>

#define _USE_MATH_DEFINES
#define ll long long
#define ins Not Needed Thing
#define ull unsigned long long
#define ld long double
#define Accepted 0
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define sz(x) (int)(x.size())
#define all(x) x.begin(),x.end()
#define F first
#define S second
#define SORRY FUL Accepted 
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0)
#define Toktama Kazakhstan 

using namespace std;

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 3e5 + 123;                                          
const int PRI = 555557;
const int pri = 997;

int tests = 1;

vector < pair < int, int > > st;
int L[N], R[N];
int a[N], n;

inline void Solve () {
	//easy
	cin >> n;
	for (int i = 1; i <= n; i ++)
		cin >> a[i];

	for (int i = 1; i <= n; i ++) {
		while (st.size() && st.back().F > a[i])
			st.pop_back();

		if(st.empty()) L[i] = 1;
		else L[i] = st.back().S + 1;	
		
		st.pb(mp(a[i], i));
	}

	st.clear();
	
	for (int i = n; i >= 1; i --) {
		while (st.size() && st.back().F > a[i])
			st.pop_back();

		if(st.empty()) R[i] = n;
		else R[i] = st.back().S - 1;	
		
		st.pb(mp(a[i], i));
	}
	ll ans = 0;
	for (int i = 1; i <= n; i ++) {
		int cnt1 = R[i] - i;
		int cnt = i - L[i];
		int now = R[i] - L[i] + 1;
		ans += 1ll * ((now * (now + 1ll)) / 2ll - (cnt * (cnt + 1ll)) / 2ll - (cnt1 * (cnt1 + 1ll)) / 2ll) * a[i]; 
	}

	cout << ans;
}

int main () {
	SpeedForce;
//	freopen(".in", "r", stdin);
//	freopen(".out", "w", stdout);	
	// cin >> tests;
	while(tests --) {
		Solve ();
		// Ee Zadrot
	}

	return Accepted; 
}

Measured memory_bytes: 4468
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long a,b,c;
    cin >> a >> b >> c;
    int cnt = 0;
    while(true){
        if(a%2==1)break;
        if(b%2==1)break;
        if(c%2==1)break;
        long long tmpA = a/2, tmpB = b/2, tmpC = c/2;
        a+=tmpB+tmpC;
        b+=tmpA+tmpC;
        c+=tmpA+tmpB;
        if((a==b)&&(b==c)){
            cout << -1 << endl;
            return 0;
        }
        cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3556
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define print(x) cout << x << endl;
using namespace std;
typedef long long ll;

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

    double res = 0.0;
    rep(i, n) {
        double x;
        string u;
        cin >> x >> u;

        if (u == "JPY") res += x;
        else res += x * 380000.0;
    }

    cout << fixed << setprecision(10) << res << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    int n,k;
    cin>>n;
    int ara[n+1][4],dp[n+1][3];
    int i;
    for(i=0; i<n; i++)
    {
        cin>>ara[i][0]>>ara[i][1]>>ara[i][2];
        dp[i][0]=dp[i][1]=dp[i][2]=0;
    }
    dp[0][0]=ara[0][0];
    dp[0][1]=ara[0][1];
    dp[0][2]=ara[0][2];
    for(i=1; i<n; i++)
    {
        for(int j=0; j<3; j++)
        {
            for(k=0; k<3; k++)
            {
                if(j!=k)
                {
                    dp[i][k]=max(dp[i][k],dp[i-1][j]+ara[i][k]);
                }
            }
        }
    }
    cout<<max(dp[i-1][0],max(dp[i-1][1],dp[i-1][2]))<<endl;
    return 0;
}


Measured memory_bytes: 2944
m=10**9+7
n=int(input())
f=1
i=s=r=0
d=[]
for i in range(n):
 f=f*(i+1)%m
 s+=pow(i+1,m-2,m)
 d.append(s)
a=input().split()
for i in range(n):
 r+=int(a[i])*(d[i]+d[~i]-1)
print(r*f%m)

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

using namespace std;

using ll = long long;

int main() {

  ll n, d;
  cin >> n >> d;
  ll ans = 0;
  while(n--){
    ll x, y; cin >> x >> y;
    if(x * x + y * y <= d * d){
        ans++;
    }
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <cstdio>
#include <algorithm>
const int N = 1e5;
const int inf = 1e9;
using namespace std;
int n,k,s;
int main()
{
    scanf("%d%d%d",&n,&k,&s);
    for (int i = 1;i <= k;i++)
        cout<<s<<" ";
    if (s == inf)
        for (int i = 1;i <= n - k;i++)
            cout<<1<<" ";
    else
        for (int i = 1;i <= n - k;i++)
            cout<<s + 1<<" ";
    return 0;
}

Measured memory_bytes: 1280
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

N, K, L = map(int, input().split())
uf1 = UnionFind(N)
uf2 = UnionFind(N)
for _ in range(K):
    p, q = map(int, input().split())
    uf1.union(p-1, q-1)
for _ in range(L):
    r, s = map(int, input().split())
    uf2.union(r-1, s-1)

pairs = [(uf1.find(i), uf2.find(i)) for i in range(N)]
from collections import Counter
pairs_counter = Counter(pairs)
ans = [pairs_counter[pair] for pair in pairs]
print(*ans)


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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) std::cout << x << '\n'
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define sz(x) ((int)(x).size())
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = (int)1e9;
const ll  inf = (ll)1e18;
const int mod = 1000000007;
const int MAX_N = 100010;
const double PI = acos(-1);

int A[20];
int x[20][20];
int y[20][20];

int counter(int x) {
	if (x == 0) return 0;
	return counter(x >> 1) + (x & 1);
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	/*------------------------------*/

	int N;
	cin >> N;

	for (int i = 1; i <= N; i++) {
		cin >> A[i];
		for (int j = 1; j <= A[i]; j++) {
			cin >> x[i][j] >> y[i][j];
		}
	}

	int ans = 0;
	for (int bits = 1; bits < (1 << N); bits++) {
		bool ok = true;
		for (int i = 1; i <= N; i++) {
			if (!(bits & (1 << (i - 1)))) continue;
			for (int j = 1; j <= A[i]; j++) {
				if (((bits >> (x[i][j] - 1)) & 1) ^ y[i][j]) {
					ok = false;
				}
			}
		}
		if (ok) chmax(ans, counter(bits));
	}

	out(ans);

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<queue>
#include<climits>
#include<set>
#include<map>
#include<stack>
#define ll long long
using namespace std;

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

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
Int md = 1000000007;
Int facct(int p){
    Int sum = 1;
    for (int i = 1; i <= p; ++i)
    {
        sum = (i*sum)%md;
    }
    return sum;
}

long long inv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

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

    int n,k; cin>>n>>k; 
    for (int i = 1; i <= k; i++){
        if(n-k<i-1){
            cout<<0<<'\n';
        }else{
            Int blue,red;
            blue=(facct(k-1)%md)*inv(facct(k-i)*facct(i-1),md)%md;
            red =(facct(n-k+1)%md)*inv(facct(n-k-i+1)*facct(i),md)%md;
            cout<<(blue*red)%md<<'\n';
        }
    }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define ll long long
ll how(ll a,ll b){
    ll count=0,i=1;
    while(i<=a){
        count++;
        i*=b;
    }
    return count;
}
int main(){
    ll n;
    ll k;
    scanf("%lld%lld",&n,&k);
    ll ans=how(n,k);
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 128
n = int(input())
s = [(input()) for _ in range(n)]
m = int(input())
t = [(input()) for _ in range(m)]
d = {}
for c in s+t:
	d[c] = 0
for c in s:
	d[c] += 1
for c in t:
	d[c] -= 1
res = 0
for k in set(s+t):
	res = max(res, d[k])
print(res)

Measured memory_bytes: 3064
n, q = map(int, input().split())

word = input()

counter = [0] * n

for i in range(1, len(word)):
    counter[i] = counter[i-1]
    if word[i-1] + word[i] == 'AC':
        counter[i] += 1

for i in range(q):
    start, end = map(int, input().split())
    print(counter[end-1] - counter[start-1])


Measured memory_bytes: 6060
#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX=200000;

int main(){
    int R[MAX],n;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> R[i];
    }
    
    int maxv = -2000000000;
    int minv = R[0];
    
    for(int i=1;i<n;i++){
        maxv = max(maxv,R[i]-minv);
        minv = min(minv,R[i]);
    }
    cout << maxv <<  endl;
    return 0;
}



Measured memory_bytes: 3876
#include<iostream>
using namespace std;
int main(){
	int i, j, x, y;	
	while( cin >> x >> y ){
		
	if( x == 0 && y == 0 )
	break;

	for(i=0;i<x;i++) {
		
		for(j=0;j<y;j++) {
			
			if(i % 2 == 0){
				
			if(j % 2 == 0)
			cout << "#";
			else
			cout << ".";
			
		}
		
		if(i % 2 == 1){
				
			if(j % 2 == 0)
			cout << ".";
			else
			cout << "#";
			
		}
		
	}
	cout << "\n";
	}
	cout << "\n";
}
	return 0;
}


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

const int MAX_N = 101010;
const int INF = 1145141919;
int N, K;
int h[MAX_N];
int cost[MAX_N];

int main(){

    for(int i = 1; i < MAX_N; i++)cost[i] = INF;
    cin >> N >> K;
    for(int i = 0; i < N; i++)cin >> h[i];
    for(int i = 0; i < N; i++){
        for(int k = 1; k <= K; k++){
            cost[i + k] = min(cost[i + k], cost[i] + abs(h[i] - h[i + k]));
        }
    }
    cout << cost[N - 1] << endl;

    return 0;
}

Measured memory_bytes: 1024
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  int a, b, c, d; cin >> a >> b >> c >> d;
  while (true) {
    c -= b;
    if (c <= 0) {
      cout << "Yes\n";
      return 0;
    }
    a -= d;
    if (a <= 0) {
      cout << "No\n";
      return 0;
    }
  }
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
bool mod[105];
int A, B, C;
int main()
{
    scanf("%d%d%d", &A, &B, &C);
    int sum = A % B;
    memset(mod, 0, sizeof(mod));
    while (!mod[sum]) {
        mod[sum] = 1;
        sum  = (sum + A) % B;
    }
    if (mod[C]) printf("YES\n");
    else printf("NO\n");
    return 0;
}


Measured memory_bytes: 256
#define SORT(v) sort(v.begin(), v.end())
#include "iostream"
#include "map"
#include "vector"
#include <stack>
#include "cstdlib"
#include <algorithm>
#include <cstdarg>
#include <cstdio>
// #include "ane.cpp"

#define INF (int)1e9
#define NMAX 55
#define MMAX 55
#define MOD 100000
using namespace std;

// コメントアウトするとdb_printf()を実行しない
#define DEBUG
// デバッグ用printf
void db_printf(const char* format, ...){
    #ifndef DEBUG
    return;
    #endif
    va_list arg;
    va_start(arg, format);
    vprintf(format, arg);  // コンソールに出力
    va_end(arg);
}
// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
typedef pair<int, int> P;

int N,M,dp[NMAX][MMAX] = {};
int S[NMAX][NMAX]={}, T[MMAX][MMAX] = {};

static const int di[] = {-1, 0, 1, -1, 1, -1, 0, 1};
static const int dj[] = {-1, -1, -1, 0, 0, 1, 1, 1};

int ans = 0;
bool check(int i, int j){
    // if(i + M > N || j + M > N) return false;
    for (int k = 0; k < M; ++k)
    {
        for (int l = 0; l < M; ++l)
        {
            if ( i+k > N-1 || j+l > N-1 || S[i+k][j+l] != T[k][l])
            {
                return false;
            }
        }
    }
    return true;
}
void solve(){
    // 解答アルゴリズム
    for (int i = 0; i < N; ++i)
    {
        for (int j = 0; j < N; ++j)
        {
            if(check(i, j)){
                cout << "Yes" << endl;
                return;
            }
        }
    }
    cout << "No" << endl;
}
void debug(){
    // デバッグ用出力
    for (int i = 0; i < N; ++i)
    {
        for (int j = 0; j < N; ++j)
        {
            cout << S[i][j];
        }
        cout << endl;
    }
    for (int i = 0; i < M; ++i)
    {
        for (int j = 0; j < M; ++j)
        {
            cout << T[i][j];
        }
        cout << endl;
    }
}
void answer(){
    // 解答出力
    cout << ans << endl;
}
int main(int argc, char const *argv[])
{
    // 入力の読み込み，番兵法
    ios::sync_with_stdio(false);

    Fill(dp, -1);

    cin >> N >> M;
    for (int i = 0; i < N; ++i)
    {
        for (int j = 0; j < N; ++j)
        {
            char ch;
            scanf(" %c", &ch);
            S[i][j] = (ch == '#');
        }
    }
    for (int i = 0; i < M; ++i)
    {
        for (int j = 0; j < M; ++j)
        {
            char ch;
            scanf(" %c", &ch);
            T[i][j] = (ch == '#');
        }
    }
    solve();
    #ifdef DEBUG
    // debug();
    #endif
    // answer();

    return 0;
}

Measured memory_bytes: 888
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <queue>

using namespace std;
#define inf 101010

struct edge {
    int to, len, lim;
};

struct state {
    double sum;
    int pace, cur, pre;
    
    bool operator<(const state& rhs) const {
        return sum > rhs.sum;
    }
};

int n,m,s,g;
double dp[31][31][31];
vector<edge> e[31];

void solve() {
    priority_queue<state> que;
    state st;
    st.sum = 0, st.pace = 1, st.cur = s, st.pre = s;
    que.push(st);
    
    while (!que.empty()) {
        state st = que.top(); que.pop();
        if (st.cur == g && st.pace == 1) {
            printf("%.9lf\n",st.sum);
            return;
        }
        
        for (int i = 0; i < e[st.cur].size(); i++) {
            int to = e[st.cur][i].to, len = e[st.cur][i].len, lim = e[st.cur][i].lim;
            if (to == st.pre) continue;
            
            state t;
            t.cur = to, t.pre = st.cur;
            
            for (int i = -1; i <= 1; i++) {
                t.pace = st.pace + i;
                if (st.cur == s && st.pre == s && i != 0) continue;
                if (t.pace == 0 || t.pace == 31 || lim < t.pace) continue;
                t.sum = st.sum + len / (double)t.pace;
                if (dp[st.cur][to][t.pace] > t.sum) {
                    dp[st.cur][to][t.pace] = t.sum;
                    que.push(t);
                }
            }
        }
    }
    cout << "unreachable" << endl;
}

int main(void) {
    while (cin>>n>>m && n) {
        cin >> s >> g;
        s--, g--;
        for (int i = 0; i < 31; i++) for (int j = 0; j < 31; j++) for (int k = 0; k < 31; k++) dp[i][j][k] = inf;
        for (int i = 0; i < 31; i++) e[i].clear();
        
        for (int i = 0; i < m; i++) {
            int a,b,c,d;
            edge t;
            cin >> a >> b >> c >> d;
            a--, b--;
            t.to = b, t.len = c, t.lim = d;
            e[a].push_back(t);
            t.to = a;
            e[b].push_back(t);
        }
        solve();
    }
}

Measured memory_bytes: 3860
def main():
  i = int(input())
  x = list(map(int,input().split()))
  ret = True
  for v in x:
    if isEven(v):
      if not(canDevideThreeOrFive(v)):
        ret = False
        break
  if ret:
    print("APPROVED")
  else:
    print("DENIED")

def isEven(x):
  if x%2 == 0:
    return True
  return False

def canDevideThreeOrFive(x):
  if x%3 == 0 or x%5 == 0:
    return True
  return False

main()


Measured memory_bytes: 38384
a,b,c,d,e,f = map(int, input().split())

ab_list = set()

for i in range(0,f//100+1,a):
    for j in range(0, f//100-i+1, b):
        ab_list.add(100*(i+j))

ab_max = max(ab_list)

sug_max = int(ab_max*(e/100))

cd_list = set()

for i in range(0,sug_max+1, c):
    for j in range(0, sug_max-i+1, d):
        cd_list.add(i+j)

water = list(ab_list)
water.sort()

sugar = list(cd_list)
sugar.sort()

max_noudo = -1
ans = [0,-1]
for w in water:
    for s in sugar:
        if w==0 and s==0:
            continue
        if 100*s <= e*w and w+s <= f:
            noudo = s/(w+s)
            if noudo > max_noudo:
                max_noudo = noudo
                ans = [w+s, s]
                
print(*ans)

Measured memory_bytes: 3188