akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"

#define rep(i, a) for (int i = 0; i < (a); ++i)
#define REP(i, a, b) for (int i = (a); i < (b); ++i)

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define debug_1(x1) cerr << #x1 << ": " << x1 << endl
#define debug_2(x1, x2) cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define debug_3(x1, x2, x3) cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << endl
#define debug_4(x1, x2, x3, x4) cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << endl
#define debug_5(x1, x2, x3, x4, x5) cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#define debug(...) CHOOSE((__VA_ARGS__, debug_5, debug_4, debug_3, debug_2, debug_1, ~)) (__VA_ARGS__)

using namespace std;
using ll = long long;
using P = pair<int, int>;

const ll INF = 1e14;

int euk(int a, int b) {
  if (b==0) return a;
  return euk(b, a % b);
}

void Main() {
  int n;
  cin >> n;
  vector<int> A(n);
  rep(i, n) cin >> A[i];
  sort(A.begin(), A.end());
  int g = A[0];
  rep(i, n) g = euk(g, A[i+1]);
  cout << g << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}


Measured memory_bytes: 640
import java.util.*;
import java.io.*;

public class Main {
	
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);	
		int n = sc.nextInt();
		boolean ans = false; 
	    for(int i = 0; i<n; i++) {
	    	char c = sc.next().charAt(0);
	    	if(c == 'Y') ans = true; 
	    }
	    if(ans) System.out.println("Four");
	    else System.out.println("Three"); 
	}
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void pn(){
    puts("No");
}
void py(){
    puts("Yes");
}
const int M=2e5+5;
int a[M];
ll mp[M];
int main(){
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        mp[a[i]]++;
    }
    ll ans=0;
    for(int i=1;i<=M-5;i++){
        ll x=mp[i];
        if(x>=2){
            ans+=x*(x-1)/2;
        }
    }
   /// cout<<ans<<endl;
    for(int i=1;i<=n;i++){
        if(mp[a[i]]>=2)
            cout<<ans-mp[a[i]]+1<<endl;
        else
            cout<<ans<<endl;
    }
    return 0;
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int N;
int X[111111];
int L;
int Q;

int to[20][111111];

signed main(){
    cin>>N;
    rep(i,N)cin>>X[i];
    cin>>L>>Q;

    int cur=0;
    fill_n(*to,20*111111,N);
    rep(i,N){
        while(cur<N&&X[cur]-X[i]<=L)cur++;
        to[0][i]=cur-1;
    }

    for(int i=0;i<19;i++){
        rep(j,N){
            to[i+1][j]=to[i][to[i][j]];
        }
    }

    while(Q--){
        int a,b;
        cin>>a>>b;
        if(a>b)swap(a,b);

        a--;b--;
        int ans=0;
        for(int i=19;i>=0;i--){
            if(to[i][a]<b){
                a=to[i][a];
                ans+=(1<<i);
            }
        }
        cout<<ans+1<<endl;
    }
    return 0;
}


Measured memory_bytes: 18944
#include<bits/stdc++.h>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

typedef long long LL;

const int maxn=2e5+5;

int n;

int main()
{
	scanf("%d",&n);
	if (n==1) {puts("No"); return 0;}
	
	int t=0;
	for(t=28; (1<<t)>n; t--);
	if ((1<<t)==n) {puts("No"); return 0;}
	
	puts("Yes");
	for(int i=2; i+1<=n; i+=2)
	{
		printf("%d %d\n",i,i+1);
		printf("%d %d\n",i+1,1);
		printf("%d %d\n",1,n+i);
		printf("%d %d\n",n+i,n+i+1);
	}
	printf("2 %d\n",1+n);
	
	if (!(n&1))
	{
		printf("%d %d\n",n,(1<<t)+1);
		printf("%d %d\n",n-(1<<t)+n,n+n);
	}
}

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

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

    ll digit = 0, num, max = 0;
    num = N;
    // 桁数を求める
    while(num != 0){
        num /= 10;
        digit++;
    }
    // 99999...
    ll max_d = 1;
    for(int i=1;i<=digit;i++)
        max_d = max_d * 10;
    num = max_d - 1;
    max = 9*digit;
    if(N == num){
        cout << max << endl;
        return 0;
    }
    // 89999..., 79999..., ...
    max_d = max_d/10;
    for(ll i=0;N<num;i++){
        num -= max_d;
        max--;
    }
    
    cout << max << endl;
    return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors


def main():
    N = int(input())
    D = make_divisors(N)
    mi = N
    for d in D:
        mi = min(mi, d + (N//d) - 2)
    print(mi)


if __name__ == '__main__':
    main()


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

const int N = 2e5 + 5;
const int MOD = 1e9 + 7;

int n;
ll ar[N], sum[N];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> ar[i];
        sum[i] = ar[i];
    }
    for (int i = n - 1; i > 0; i--) {
        sum[i] += sum[i + 1];
        sum[i] %= MOD;
    }
    ll ans = 0;
    for (int i = 1; i <= n; i++) {
        ans += ar[i] * sum[i + 1] % MOD;
        ans %= MOD;
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 6644
// by adiforluls
#pragma GCC optimize ("-O2")
#include<bits/stdc++.h>
using namespace std;
#define fastestiointhewest   ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ll          long long
#define ld          long double
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define mii         map<int,int>
#define vi          vector<int>
#define vll         vector<long long>
#define all(a)      (a).begin(),(a).end()
#define clz(a)      __builtin_clz(a) // count leading zeroes
#define ctz(a)      __builtin_ctz(a) // count trailing zeroes
#define popc(a)     __builtin_popcount(a) // count set bits (for ints only diff for ll)
#define lul         1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define SIZE        1000005
#define F           first
#define S           second
#define debug(x)    cerr << #x << " = " << x << endl;
#define mod         998244353

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " = " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " = " << arg1<<" |";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

#define endl        '\n'
const ld PI = acos(-1.0);
const int INF = 0x3f3f3f3f;

map<ll,ll> ma;
void solve()
{   
   int n; cin>>n;
   rep(i,0,n)
   {
     char s; cin>>s;
     ma[s]++;
   }
   ll ans=1;
   for(auto &i:ma)
   {
     ans=(ans*(i.S+1))%lul;
   }
   ans+=lul,ans%=lul;
   cout<<ans-1;
}  
int main()
{   
    fastestiointhewest;
   //  #ifndef ONLINE_JUDGE
     // freopen("input.txt", "r", stdin);
     // freopen("output.txt", "w", stdout);
   //  #endif
    int t; t=1;
    while(t--){
       solve();
    }
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"errors"
	"fmt"
	"io"
	"io/ioutil"
	"os"
	"strconv"
	"strings"
)

var (
	// ErrLineNotFound -
	ErrLineNotFound = errors.New("lines: line not found")
)

type onError int

const (
	onErrorPanic onError = iota
	onErrorError
)

// Lines represents multi line.
type Lines struct {
	r       io.Reader
	w       io.Writer
	onError onError

	store []string
}

// NewLines create lines from provided input reader.
func New(r io.Reader) *Lines {
	lines, err := newLines(r, ioutil.Discard, onErrorPanic)
	if err != nil {
		panic(err)
	}
	return lines
}

// Line represents single line.
type Line struct {
	store string
	field int
}

// Line return given n line.
func (ls *Lines) Line(n int) *Line {
	line, err := ls.line(n)
	if err != nil {
		panic(err)
	}
	return line
}

func (ls *Lines) line(n int) (*Line, error) {
	if n >= len(ls.store) {
		return nil, ErrLineNotFound
	}
	return &Line{store: ls.store[n]}, nil
}

func (l *Line) Ints() []int {
	ints, err := l.ints()
	if err != nil {
		panic(err)
	}
	return ints
}

func (l *Line) ints() ([]int, error) {
	var ints []int
	fields := strings.Fields(l.store)
	for _, s := range fields {
		i, err := strconv.Atoi(s)
		if err != nil {
			return nil, err
		}
		ints = append(ints, i)
	}
	return ints, nil
}

// Field specify current field scope.
func (l *Line) Field(n int) *Line {
	clone := l.clone()
	clone.field = n
	return clone
}

func (l *Line) Int() int {
	ints, err := l.ints()
	if err != nil {
		panic(err)
	}
	return ints[l.field]
}

func newLines(r io.Reader, w io.Writer, onError onError) (*Lines, error) {
	lines := &Lines{
		r:       r,
		w:       w,
		onError: onErrorError,
	}
	return lines, lines.init()
}

func (ls *Lines) init() error {
	s := bufio.NewScanner(ls.r)
	for s.Scan() {
		ls.store = append(ls.store, s.Text())
	}
	return s.Err()
}

func (l *Line) clone() *Line {
	clone := *l
	return &clone
}

func main() {
	lines := New(os.Stdin)

	line0 := lines.Line(0).Ints()

	x, y := line0[2], line0[3]
	xs := lines.Line(1).Ints()
	ys := lines.Line(2).Ints()

	cands := candidates(x, y)

	var oks []int
loop:
	for _, cand := range cands {
		for _, x := range xs {
			if x >= cand {
				continue loop
			}
		}

		for _, y := range ys {
			if y < cand {
				continue loop
			}
		}
		oks = append(oks, cand)
	}

	if len(oks) > 0 {
		fmt.Println("No War")
	} else {
		fmt.Println("War")
	}
}

func candidates(x, y int) []int {
	if x >= y {
		return nil
	}
	var ints []int
	for i := x + 1; i <= y; i++ {
		ints = append(ints, i)
	}
	return ints
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <map>
#include <iomanip>
#include <limits.h>

using namespace std;    
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBAG = false;

int main(){

    int r;
    cin >> r;
    cout << 3 * r * r << endl;

}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
  long long N = 0;
  long long A = 0, B = 0;
  cin >> N >> A >> B;

  long long cycle = N / (A + B);

  long long amari = N % (A + B);

  if (cycle == 0) {
    if (N < A) {
      cout << N << endl;
    } else {
      cout << A << endl;
    }
    return 0;
  }
  amari = min(amari,A);
  cout << cycle * A + amari << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
short dp[5001][5001];
int a[5000];
int b[5000];
int max(int a,int b){return a>b?a:b;}
int main(){
	int n,m;
	scanf("%d %d",&n,&m);
	int i,j;
	for(i=0;i<n;i++)scanf("%d",&a[i]);
	for(i=0;i<m;i++)scanf("%d",&b[i]);
	for(i=0;i<=n;i++)for(j=0;j<=m;j++)dp[i][j]=0;
	for(i=1;i<=n;i++){
		for(j=1;j<=m;j++){
			dp[i][j]=dp[i-1][j];
			if(a[i-1]==b[j-1])dp[i][j]=max(dp[i][j],dp[i-1][j-1]+1);
		}
	}
	int ans=0;
	for(i=0;i<=m;i++)ans=max(ans,dp[n][i]);
	printf("%d\n",ans);
	return 0;
}

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

using namespace std;

int main() {
  int c = getchar();
  while (c <= 32) c = getchar();
  int ans = 0;
  int balance = 0;
  while (c > 32) {
    int our = balance > 0 ? 'p' : 'g';
    if (our != c) {
      if (our == 'p') ++ans; else --ans;
    }
    if (balance > 0) --balance; else ++balance;
    c = getchar();
  }
  printf("%d\n", ans);
}

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

int main(){
    ll n,m;
    cin >> n >> m;
    vector <vector <ll>> ma(n);

    ll a,b;
    rep(i,m){
        cin >> a >> b;
        --a;
        --b;
        ma[a].push_back(b);
        ma[b].push_back(a);
        
    }

    vector <int> us(n,0);
    //us[0]=1;
    ll ans=0;
    queue <ll> q;
    ll qq;
    ll ka=0;
    ll l;
    
    rep(i,n){
        ka=0;
        if(us[i]==0){
            us[i]=1;
            q.push(i);
            while(q.size()){
                qq=q.front();
                //cout << qq << endl;
                q.pop();
                l=ma[qq].size();
                rep(j,l){
                    if(us[ma[qq][j]]==0){
                        us[ma[qq][j]]=1;
                        ++ka;
                        q.push(ma[qq][j]);
                    }
                }
            }
            ans=max(ans,ka);

        }
    }

    cout << ans+1 << endl;

    

    return 0;
}

Measured memory_bytes: 17556
//NAME-ADITYYA OJHA
/*
 *     Heart beats fast
 *         Colors and promises
 *             How to be brave
 *                 How can I love when I am afraid to fall...
                                             (courtesy-amnesiac_dusk)
 */
#include <bits/stdc++.h>
#define ll long long int
#define forin for(int i=0;i<n;i++)
#define forjn for(int j=0;j<n;j++)
#define pb push_back
#define vx vector<ll> x
#define vy  vector<ll> y
#define fas1  ios_base::sync_with_stdio(false)
#define fas2   cin.tie(NULL)
#define fas3   cout.tie(NULL)
#define  f   first
#define  s   second
#define mod 1000000007
 const ll N=55;

using namespace std;

//check for corner cases(for n==1)
// check for int overflow
// run on some sample cases before submitting






int main ()
{
    fas1,fas2,fas3;


     ll a,b;
      cin>>a>>b;
      cout<<a*b<<endl;


}








Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define FOR(i,a,b)  for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n)    FOR(i,0,n)
#define RER(i,n)    FOR(i,0,(n+1))
#define pb          push_back
#define mp(a,b)     make_pair((a),(b))
#define mset(m,v)   memset(m,v,sizeof(m))
using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair<int, int> > vpii;
typedef long long ll;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
typedef vector<pair<ll, ll> > vpll;
typedef vector<string> vs;
typedef long double ld;
const double EPS    = 1e-10;
const int INF       = 1e+9;
const double PI     = acos(-1);


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

    int l = a + b;
    int r = c + d;
    if ( l > r ) {
        cout << "Left" << endl;
    } else if ( l < r ) {
        cout << "Right" << endl;
    } else {
        cout << "Balanced" << endl;
    }
    return 0;
}



Measured memory_bytes: 636
use proconio::input;

fn main() {
    input!{
        x: i64,
        k: i64,
        d: i64,
    }

    let x = x.abs();

    println!("{}", 
        if (x/d) > k {
            eprintln!("tooi");
            x - d*k
        } else if (k - x/d) % 2 == 0 {
            eprintln!("temae");
            x - (x/d)*d
        } else {
            eprintln!("oku");
            (x - (x/d+1)*(d)).abs()
        }
    );
}


Measured memory_bytes: 2196
#include<bits/stdc++.h>
using namespace std;
#define SORT(c) sort((c).begin(),(c).end());
#define pb push_back
#define MP make_pair
#define pii pair<int,int>
#define pcc pair<char,char>
#define pic pair<int,char>
#define pci pair<char,int>
#define VS vector<string>
#define VI vector<int>
#define pi 3.141592653589793
#define ll long long
#define ull unsigned long long
#define w(x) int x;cin>>x;while(x--)
#define fast ios_base::sync_with_stdio(0)
#define sz size()
#define cu cout<<
#define en endl
#define sp " "
#include<cstdio>
#include<cstring>
typedef unsigned long long UL;
template<typename T>inline T  S(T a)
{
    return a*a;
}
template<class T>inline string tostring(T a)
{
    ostringstream os("");
    os << a;
    return os.str();
}
template<typename T>inline ll tolong(T a)
{
    ll res;
    istringstream os(a);
    os>>res;
    return res;
}
template<typename T>inline T gcd(T a, T b)
{
    if (b == 0)return a;
    else return gcd(b, a % b);
}
template<typename T>inline T bigmod(T a, T b, T m)
{
    if (b == 0)return 1;
    else if (b % 2 == 0)return S(bigmod(a, b / 2, m)) % m;
    else return (a % m*bigmod(a, b - 1, m)) % m;
}
const int inf = (int)1e9 + 5;
const ll linf = (ll)1e16 + 5;
const ll modd = (ll)1e9 + 7;
const int mod = 10000007;
/*#define N 20000009
bool prime[N];
vector<ll> prm;
void seive ()
{

    memset(prime, true, sizeof(prime));

    for( ll i=2; i*i<=N; i++)
    {
        if (prime[i] == true)
        {
            prm.pb(i);
            for (ll j=i*i; j<=N; j += i)
                pe[j] = false;
        }
    }
}*/
void pr (int f)
{
    if(f==1)
        cout<<"YES\n";
    else
        cout<<"NO\n";
}
/*bool isprime(ll n)
{
    if(n<2) return 0;
    if(n==2) return 1;
    else
    {
        for(int i=2; i*i<=n; i++)
            if(n%i==0) return 0;
    }
    return 1;
}*/
map<int , int >mp;
set<int  > st;
multiset<string> :: iterator it;
deque <char> q ;
int vis [10000000];
pair<int,int> a[2020];
int cnt[2];
int main()
{
    fast ;
    int h,m,hh,mm,k;
    cin >> h >> m >> hh >> mm >> k;
    int a = h*60+m;
    int b= hh*60 + mm;
    cout << abs(a - b) - k<<endl;
}



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

using namespace std;

map<int, int> mp;

int main(void)

{
    int x, n, i, a, flag = 0, dif;
    cin>>x>>n;
    if(n == 0){
        cout<<x<<endl;
    }
    else{
        for(i = 0; i < n; i++){
            cin>>a;
            dif = a-x;
            mp[dif]++;
        }
        if(mp[0] == 0){
            cout<<x<<endl;
        }
        else{
            for(i = 1; 1; i++){
                a = 0-i;
                if(mp[i] > 0 && mp[a] > 0){

                }
                else if(mp[i] == 0 && mp[a] == 0){
                    cout<<x-i<<endl;
                    break;
                }
                else{
                    if(mp[a] == 1){
                        cout<<(x+i)<<endl;
                        break;
                    }
                    else{
                        cout<<(x-i)<<endl;
                        break;
                    }
                }
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3192
#include<iostream>
#include<stdio.h>
#include<cstring>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<unordered_map>
#include<bits/stdc++.h>
#define ll long long 
#define d double
using namespace std;
 
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  int a,b;
  cin>>a>>b;
  b=b*2;
  if(b<=a){
  	
  	cout<<a-b<<endl;
  	
  }
  
  else{
  	
  	cout<<"0"<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 3592
N,M = map(int,input().split())
graph = [[0]*N for _ in range(N)]
Edge = []

for i in range(M):
  a,b = map(int,input().split())
  graph[a-1][b-1] = 1
  graph[b-1][a-1] = 1
  Edge.append([a-1,b-1])

def dfs(x):
  if(vis[x] == 1): return
  vis[x] = 1
  for i in range(N):
    if(graph[x][i] == 1):
      dfs(i)

ans = 0      
for i in range(M):
  graph[Edge[i][0]][Edge[i][1]] = 0
  graph[Edge[i][1]][Edge[i][0]] = 0
  vis = [0]*60
  dfs(0)
  for j in range(N):
    if(vis[j] == 0):
      ans += 1
      break
  graph[Edge[i][0]][Edge[i][1]] = 1
  graph[Edge[i][1]][Edge[i][0]] = 1
print(ans)

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

#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)

using namespace std;

using ll = long long;
using P = pair<int, int>;

int n, k;
vector<int> a;

bool tes(int d) {
  if (d == 0) {
    return true;
  }
  int cnt = 0;
  rep(i, n) {
    if (a.at(i) > d) {
      cnt += ceil(a.at(i) / d);
    }
  }
  return cnt <= k;
}

int main() {
  cin >> n >> k;
  a.resize(n);
  rep(i, n) cin >> a.at(i);
  sort(a.begin(), a.end());
  int lb = 0;
  int ub = 1'000'000'000;
  while (ub - lb > 1) {
    int mid = (lb + ub) / 2;
    if (tes(mid)) {
      ub = mid;
    } else {
      lb = mid;
    }
  }
  cout << ub << endl;
  return 0;
}


Measured memory_bytes: 3944
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;
typedef pair<long long, long long> pll;

#define MP make_pair
#define PB push_back
#define ALL(s) (s).begin(),(s).end()
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) 
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P) 
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) 
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s; }


int a[5];

int main() {
    while (cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4]) {
        int res = 0;
        for (int i = 0; i < 5; ++i) {
            if (a[i] < 40) a[i] = 40;
            res += a[i];
        }
        cout << res/5 << endl;
    }
    return 0;
}


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

int main(void){
	ios::sync_with_stdio(false); cin.tie(0);
	
	int a,b;
	cin>>a>>b;
	cout<<int(a+b/2)<<endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

void rotate_S(int minase_inori[6]) {
	int hayami_saori = minase_inori[0];
	minase_inori[0] = minase_inori[4];
	minase_inori[4] = minase_inori[5];
	minase_inori[5] = minase_inori[1];
	minase_inori[1] = hayami_saori;
}

void rotate_NES(int kugimiya_rie[6]) {
	int kitamura_eri = kugimiya_rie[1];
	kugimiya_rie[1] = kugimiya_rie[3];
	kugimiya_rie[3] = kugimiya_rie[4];
	kugimiya_rie[4] = kugimiya_rie[2];
	kugimiya_rie[2] = kitamura_eri;
}

int check(const int asumi_kana[6], const int iguti_yuka[6]) {
	int sakura_ayane;
	int satou_satomi[6];
	for (sakura_ayane = 0; sakura_ayane < 6; sakura_ayane++) {
		satou_satomi[sakura_ayane] = iguti_yuka[sakura_ayane];
	}
	for (sakura_ayane = 0; sakura_ayane < 4; sakura_ayane++) {
		int tateno_kanako;
		for (tateno_kanako = 0; tateno_kanako < 6; tateno_kanako++) {
			if (asumi_kana[tateno_kanako] != satou_satomi[tateno_kanako]) break;
		}
		if (tateno_kanako >= 6) {
			return 1;
		}
		rotate_NES(satou_satomi);
	}
	return 0;
}

int tokui_sora(const int utida_maaya[6], const int taneda_risa[6]) {
	int igarasi_hiromi[6];
	int horie_yui;
	for (horie_yui = 0; horie_yui < 6; horie_yui++) {
		igarasi_hiromi[horie_yui] = taneda_risa[horie_yui];
	}
	if (check(utida_maaya, igarasi_hiromi)) return 1;
	for (horie_yui = 0; horie_yui < 4; horie_yui++) {
		rotate_NES(igarasi_hiromi);
		rotate_S(igarasi_hiromi);
		if (check(utida_maaya, igarasi_hiromi)) return 1;
		rotate_S(igarasi_hiromi);
		rotate_S(igarasi_hiromi);
		rotate_S(igarasi_hiromi);
	}
	rotate_S(igarasi_hiromi);
	rotate_S(igarasi_hiromi);
	return check(utida_maaya, igarasi_hiromi);
}

int main(void) {
	int mizuhasi_kaori;
	int ootani_ikue[100][6];
	int uesaka_sumire, suzaki_aya;
	if (scanf("%d", &mizuhasi_kaori) != 1) return 1;
	for (uesaka_sumire = 0; uesaka_sumire < mizuhasi_kaori; uesaka_sumire++) {
		for (suzaki_aya = 0; suzaki_aya < 6; suzaki_aya++) {
			if (scanf("%d", &ootani_ikue[uesaka_sumire][suzaki_aya]) != 1) return 1;
		}
	}
	for (uesaka_sumire = 0; uesaka_sumire < mizuhasi_kaori; uesaka_sumire++) {
		for (suzaki_aya = uesaka_sumire + 1; suzaki_aya < mizuhasi_kaori; suzaki_aya++) {
			if (tokui_sora(ootani_ikue[uesaka_sumire], ootani_ikue[suzaki_aya])) {
				puts("No");
				return 0;
			}
		}
	}
	puts("Yes");
	return 0;
}




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

int main(){
  int N;
  cin>>N;
  vector<int> A(N),B(N),C(N-1);
  for(int &i:A)
    cin>>i;
  for(int &i:B)
    cin>>i;
  for(int &i:C)
    cin>>i;
  int j=0,k=30;
  for(int i:A){
    j+=B[i-1];
    if(i==k+1){
      j+=C[i-2];
    }
    k=i;
  }
  cout<<j<<endl;
}

Measured memory_bytes: 256
#include <ctype.h>
#include <limits.h>
#include <math.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(int argc, char **argv)
{
    int n;
    scanf("%d", &n);
    int aa[n];
    for (int i = 0; i < n; i++) {
        scanf("%d", aa + i);
    }
    for (int i = 0; i < n - 1; i++) {
        for (int j = i + 1; j < n; j++) {
            if (aa[i] < aa[j]) {
                int w = aa[i];
                aa[i] = aa[j];
                aa[j] = w;
            }
        }
    }
    int a = 0;
    int b = 0;
    for (int i = 0; i < n; i++) {
        if (i & 1) {
            b += aa[i];
        } else {
            a += aa[i];
        }
    }
    printf("%d\n", a - b);
    return EXIT_SUCCESS;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define mod 998244353

using namespace std;

struct node
{
    int len,num;
} D[100005];

bool cmp(node a,node b)
{
    return a.len<b.len;
}

long long fun(int a,int b)
{
    long long sum=1;
    while(b--)
    {
        sum*=a;
        sum=sum%mod;
    }
    return sum;
}

int main()
{
    int i,N,j=1,ans,p,NUM[100005];
    long long sum=0;
    memset(NUM,0,sizeof(NUM));
    cin>>N;
    for(i=1; i<=N; i++)
    {
        scanf("%d",&D[i].len);
        D[i].num=i;
    }
    if(D[1].len!=0)
        cout<<0<<endl;
    else
    {
        p=ans=0;
        sort(D+1,D+N+1,cmp);
        for(i=2; i<=N; i++)
        {
            if(D[i].len==j)
                ans++;
            else if(D[i].len==j+1&&ans!=0)
            {
                NUM[j]=ans;
                j++;
                ans=1;
            }
            else
            {
                p=1;
                break;
            }
        }
        NUM[j]=ans;
        /*for(i=1;i<=j;i++)
            cout<<NUM[i]<<endl;*/
        if(p==1)
            cout<<0<<endl;
        else
        {
            sum=1;
            for(i=2; i<=j; i++)
            {
                if(NUM[i-1]>1)
                    sum*=fun(NUM[i-1],NUM[i]);
                sum=sum%mod;
            }
            cout<<sum<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 1408
n = int(input())

p = [-1]*501

q = 1

for i in range(1,n):
    for j in range(i+1,n+1):
        if p[j-i] == -1:
            if j == n:
                print(q)
            else:
                print(q,end = ' ')
            ind = j-i
            while ind <= len(p)-1:
                p[ind] = q
                ind += (j-i)*2
            q += 1
        else:
            if j==n:
                print(p[j-i])
            else:
                print(p[j-i],end = ' ')


Measured memory_bytes: 3952
main=list(map(int,input().split()))
k=int(input())
for i in range(k):
    if(main[0]>=main[1]):
        main[1]=main[1]*2
    elif(main[1]>=main[2]):
        main[2]=main[2]*2
if(main[1]>main[0] and main[2]>main[1]): print('Yes')
else: print('No')

Measured memory_bytes: 8928
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<map>
#include<stack>
#include<queue>
#include<set>
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
int main(){
	ll n;
	cin>>n;
	ll b=0,c=0,d=0,e=0;
	while(n--){
		char a[100];
		cin>>a;
		if(a[0]=='A')
			b++;
		else if(a[0]=='W')
			c++;
		else if(a[0]=='T')
			d++;
		else
			e++;
	}
	cout<<"AC x "<<b<<endl;
	cout<<"WA x "<<c<<endl;
	cout<<"TLE x "<<d<<endl;
	cout<<"RE x "<<e<<endl;
}


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

using _i64 = int64_t;
using _u64 = uint64_t;
using _f64 = double;

#define _for(i, start, end) for(_i64 i = (_i64)start; i < (_i64)end; ++i)
#define _rep(i, number) _for(i, 0, number)
#define _foreach(e, data) for(auto& e : data)
#define _all(data) data.begin(), data.end()

template<typename type>
_i64 _size(const type& data) { return static_cast<_i64>(data.size()); }
template<typename type, size_t size>
_i64 _size(const type (&)[size]) { return static_cast<_i64>(size); }

enum _flag : bool { able = true, disable = false };

struct _time {
    _time(_flag flag) { check = flag; if(!check) { return; } gettime(start); }
    ~_time() {
        if(!check) { return; }; gettime(end);
        _i64 elapse = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cout << endl << "Time: " << elapse << " ms" << endl;
    }
    private:
    using _timer = chrono::time_point<chrono::system_clock>;
    _timer start, end; bool check;
    void gettime(_timer& time) { time = chrono::system_clock::now(); }
};

struct _ini { _ini() { ios::sync_with_stdio(false); cin.tie(nullptr); } } _ini;

int main() {
    {
        _time time(disable);
        _i64 n, m, l; vector<vector<_i64>> A, B, C;
        cin >> n >> m >> l;
        A.resize(n, vector<_i64>(m));
        B.resize(m, vector<_i64>(l));
        C.resize(n, vector<_i64>(l, 0));
        _rep(i, n) { _rep(j, m) { cin >> A[i][j]; } }
        _rep(i, m) { _rep(j, l) { cin >> B[i][j]; } }
        _rep(i, n) { _rep(j, l) { _rep(k, m) { C[i][j] += A[i][k] * B[k][j]; } } }
        _rep(i, n) {
            _rep(j, l) { cout << (j != 0 ? " " : "") << C[i][j]; }
            cout << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3324
#A - We Love Golf
K = int(input())
A,B = map(int, input().split())

if B-A == 0:
    if A%K==0:
        print("OK")
        exit()
    else:
        print("NG")
        exit()
else:
    pass

for i in range(A,B+1):
    if i % K == 0:
        print("OK")
        exit()
    else:
        pass
print("NG")

Measured memory_bytes: 9188
N = int(input())
W = list(map(int, input().split()))

diff = sum(W) - 2*W[0]
min_diff = abs(diff)
for i in range(1, N):
    diff = diff - 2 * W[i]
    min_diff = min(min_diff, abs(diff))
    
print(min_diff)

Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>
int cmpint(const void *x, const void *y) {
	return *(int *)x - *(int *)y;
}
int main() {
	int n[4];
	for (int i = 0; i < 4; i++) {
		scanf("%d", &n[i]);
	}
	qsort(n, 4, sizeof(int), cmpint);
	if (n[0] == 1 && n[1] == 4 && n[2] == 7 && n[3] == 9) {
		printf("YES\n");
	} else {
		printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main(){
        int n,c=1;

   string s;
   cin>>n;
    cin>>s;
    for (int i=0;i<s.length()-1;i++){
        if (s[i]==s[i+1])
            continue;
        else c++;
  }
  cout<<c<<endl;
  }

Measured memory_bytes: 512
//“ In order to be irreplaceable, one must always be different”
#include <bits/stdc++.h>
using namespace std;
# define ll long long
#define endl "\n"
# define pi 3.14159265359
# define str string
# define vll vector<ll>
# define vstr vector<str>
# define vchar vector<char>
# define pb push_back
# define popb pop_back
# define pf push_front
# define popf pop_front
# define sll set<ll>
# define schar set<char>
//find()
//erase(x) removes element x
//erase(position,position)
# define qll queue<ll>
# define qstr queue<str>
//front(),back()
# define stll stack<ll>
# define ststr stack<str>
//top()
# define dll deque<ll>
//at()
# define mll map<ll,ll>
#define mchar map<char, ll>
# define mstr map<str,ll>
# define mss map<str,str>
# define mci map<char,ll>
# define vp vector< pair<ll,ll> >
#define mp make_pair
#define ff first
#define ss second
#define pll pair<ll,ll>
# define f(x,y) for(int x=0;x<y;x++)
# define r(x,y) for(int x=y;x>=0;x--)
# define fr(x,y,z) for(int x=y;x<z;x++)
# define rr(x,y,z) for(int x=y;x>z;x--)
ll power(ll a , ll b){ll res=1;for(ll i=0; i<b; ++i){res*=a;}return res;}
ll logx(ll base, ll num){int cnt=0;while(num!=1){num/=base; ++cnt;}return cnt;}
ll gcd(ll a, ll b){
    if(b == 0)
        return a;
    return gcd(b, a % b);
}
ll lcm(ll a, ll b){
    return (a*b)/gcd(a, b);
}
void print(vll a){
    for(int i=0;i<a.size();i++){
        cout<<a[i]<<' ';
    }
    cout<<endl;
}
vll inp(int n){
    vll a;
    ll x;
    f(i,n){
        cin>>x;
        a.pb(x);
    }
    return a;
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
   long double x;
    cin>>x;
    double t=2.00000;
    cout<<t*pi*x;
}

Measured memory_bytes: 3836
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

typedef long long llong;

int main(){
  llong x; cin >> x;
  llong ans=-1;
  if(x % 11 == 0){
    ans=(x/11)*2;
  }else if(x % 11 <= 6){
    ans=(x/11)*2+1;
  }else{
    ans=(x/11)*2+2;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef _DEBUG
#include "../../../debug_print.hpp"
#else
#define debug(...)
#endif
#define sort_(a) sort(a.begin(), a.end())
#define rsort(a) sort(a.rbegin(), a.rend())
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; 0 <= i; i--)
#define for_(i, start, end) for (int i = start; i < end; i++)
#define rfor(i, start, end) for (int i = start - 1; 0 <= i; i--)
#define all(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using namespace std;
constexpr int INF32       = 1'050'000'000;
constexpr long long INF64 = 4'000'000'000'000'000'000;
constexpr int MOD7        = 1'000'000'007;
constexpr int MOD53       = 998'244'353;
constexpr double PI       = 3.14159265358979323846;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}
void scan() {}
template <class H, class... T> void scan(H &&head, T &&... args) {
    std::cin >> head;
    scan(std::forward<T>(args)...);
}
template <class T> void scan(std::vector<T> &v) {
    for (auto &&i : v) {
        scan(i);
    }
}

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

    int N, M;
    scan(N, M);
    vector<vector<int>> g(N, vector<int>(N, false));
    rep(i, M) {
        int a, b;
        scan(a, b);
        g[a - 1][b - 1] = true;
        g[b - 1][a - 1] = true;
    }
    vector<int> v(N);
    iota(all(v), 0);

    int ans = 0;
    debug(v);
    do {
        bool ok = true;
        if (v[0] != 0)
            continue;
        rep(i, N - 1) {
            int now = v[i];
            int nxt = v[i + 1];
            if (!g[now][nxt])
                ok = false;
        }
        if (ok)
            ans++;
    } while (next_permutation(all(v)));
    print(ans);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>

using namespace std;
typedef long long ll;
const int N = 200005;

int read(){
	int x = 0 , f = 1; char ch = getchar();
	while(ch < '0' || ch > '9'){if(ch == '-') f = -1; char ch = getchar();}
	while(ch >= '0' && ch <= '9'){x = x * 10 + ch - '0'; ch = getchar();}
	return x * f;
}

int n , a[N];

int main(){
	int ans = 0 , cnt = 0;
	n = read();
	for(int i = 1 ; i <= n ; i++){cnt = read(); a[cnt] = i;}
	cnt = 0;
	for(int i = 1 ; i <= n ; i++){
		if(a[i] > a[i - 1]){
			cnt++; ans = max(cnt , ans);
		}
		else cnt = 1;
	}
	printf("%d\n",n - ans);
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, M;
  cin >> N >> M;
  int acc = 0;
  int penalty = 0;
  vector<int> acc_arr(N);
  vector<int> penalty_arr(N);
  
  for(int i=0; i<M; i++){
    int p;
    string S;
    cin >> p >> S;
    if(acc_arr.at(p-1) == 1) continue;
    if(acc_arr.at(p-1) != 1 && S == "WA"){
      penalty_arr.at(p-1) += 1;
    }else if(acc_arr.at(p-1) != 1 && S == "AC"){
      acc += 1;
      penalty += penalty_arr.at(p-1);
      acc_arr.at(p-1) = 1;
    }
  }
  cout << acc << " " << penalty << endl;
}

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

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

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

ll N;
int ans = 0;
void dfs(ll acc){
    if(acc > N) return;
    ll temp = acc;
    bool b3 = false,b5 = false,b7 = false;
    while(temp > 0){
        int val = temp % 10;
        temp/=10;
        if(val == 3) b3=true;
        if(val == 5) b5=true;
        if(val == 7) b7=true;
    }
    if(b3&b5&b7) ans++;
    ll v3 = acc*10+3, v5=acc*10+5, v7=acc*10+7;
    dfs(v3); dfs(v5); dfs(v7);
}

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> N;
    dfs(0);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

int main(){
    ll N;
    cin >> N;
    vector<ll> A(N);
    rep(i,N){
        cin >> A[i];
    }
    ll prev = -1;
    ll ans = 0;
    rep(i,N){
        if(A[i] == prev + 1){
            prev++;
            if(i!=0){
                ans++;
            }
        }else if(A[i] > prev + 1){
            cout << -1 << endl;
            return 0;
        }else{
            prev = A[i];
            if(A[i] != 0){
                ans += A[i];
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define fo(i,w,n) for(int i=(int) w;i<(int) n;i++)
#define qi queue<int>
#define vi vector<int>
#define ll long long
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define fi first
#define se second
#define prq priority_queue
#define foreach(it,c) for(__typeof((c).begin()) it=c.begin();it!=c.end();it++)
using namespace std;
inline ll read(){
	ll x=0;
	int f=1;
	char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-')f=-f;
	for(;isdigit(c);c=getchar())x=x*10+(c-'0');
	return x*f;
}
inline void out(int x){
	if(x>=10)out(x/10);
	putchar(x%10+'0');
}
int n,a[101010],ans=0;
int main(){
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	cin>>n;
	fo(i,0,n)cin>>a[i];
	int x=0;
	fo(i,1,n){
		ans=max(ans,x);
		if(a[i]<=a[i-1])x++;
		else x=0;
	}
	cout<<max(ans,x)<<endl;
	return 0;
}


Measured memory_bytes: 640
import fractions
import math

A,B,C,D = map(int,input().split())
CD_lcm = C*D//fractions.gcd(C,D)
B_ans = B - B//C - B//D + B//CD_lcm
A_ans = (A-1) - (A-1)//C - (A-1)//D + (A-1)//CD_lcm
print(B_ans-A_ans)



Measured memory_bytes: 5048
#include<bits/stdc++.h>
using namespace std;
#define int long long
int n,num[100005],dp[100005][2];
signed main() {
	cin>>n;
	for (int i=1;i<=n;++i) cin>>num[i];
	dp[1][0]=num[1];
	dp[1][1]=-num[1];
	for (int i=2;i<=n;++i) {
		dp[i][0]=max(dp[i-1][0]+num[i],dp[i-1][1]-num[i]);
		dp[i][1]=max(dp[i-1][1]+num[i],dp[i-1][0]-num[i]);
	}
	cout<<dp[n][0]<<endl;
	return 0;
}

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

int main()
{
	int A,B,C,X,Y;
	int ans=2e9;
	
	cin >> A >> B >> C >> X >> Y;
	
	for(int k=0;k<=2*max(X,Y);k++)
		ans=min(max((X-k/2)*A,0)+max((Y-k/2)*B,0)+k*C,ans);
	
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
int main()
{
	int n,p,m,ans=0;
	cin >> n;
	m = 0;
	for (int i = 0; i < n; i++) {
		cin >> p;
		m = max(m, p);
		ans += p;
	}
	ans -= m / 2;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::{i32, i64, u32, u64, usize, f64};
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{VecDeque, HashMap, BTreeMap, HashSet, BTreeSet};
#[allow(unused_imports)]
use std::io::{stdout, Write, BufWriter};
#[allow(unused_imports)]
use std::mem::{swap};

fn main() {
    input!{
        n: usize,
        a: [i64; n],
    }
    let out = stdout();
    let mut out = BufWriter::new(out.lock());
    let mut counter = HashMap::new();
    for x in &a { *(counter.entry(x).or_insert(0)) += 1; }
    let s: i64 = counter.values().map(|c| c * (c - 1) / 2).sum();
    for x in &a {
        writeln!(out, "{}", s - counter[x] + 1).unwrap();
    }
}


Measured memory_bytes: 20632
from math import ceil

a = [int(input()) for _ in range(5)]

min_a = max(a)
index_min = 4
for i in range(5):
    if a[i] % 10 == 0:
        continue
    elif min_a > a[i] % 10:
        min_a = a[i] % 10
        index_min = i

ans = 0
for i in range(5):
    if i == index_min:
        continue
    ans += ceil(a[i]/10) * 10

ans += a[index_min]
print(ans)

Measured memory_bytes: 3064
from heapq import heapify, heappop, heappush
from math import ceil
inpl = lambda: list(map(int,input().split()))
N, K = inpl()
A = inpl()
total = sum(A)
H = []
remnant = K
for a in A:
    n = (K*a)//total
    remnant -= n
    H.append((-a/(n+1), n, a))
heapify(H)
for k in range(remnant):
    L, n, a = heappop(H)
    heappush(H, (-a/(n+2), n+1, a))
ans = int(ceil(-H[0][0]))
print(ans)


Measured memory_bytes: 121764
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>
#include <map>
#include <vector>
#include <deque>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iostream>
#include <iterator>
#include <memory>

using namespace std;

#if 1
#define PRINT(x) { cout << #x << ": " << (x) << endl; }
#define PRINT_CONTAINER(x)  { cout << #x << ": ";                       \
        for (size_t ix = 0; ix < (x).size(); ++ix) cout << (x)[ix] << ", "; \
        cout << endl; }
#else
#define PRINT(x)
#define PRINT_CONTAINER(x)
#endif

typedef pair<int, int> p;

int n;
vector<int> x;
vector<int> b;

int main(int argc, char *argv[]) {
    scanf("%d", &n);
    x.resize(n);
    b.resize(n);
    for (int i = 0; i < n; ++i) {
        int tmp;
        scanf("%d", &tmp);
        x[i] = tmp;
        b[i] = tmp;
    }
    sort(x.begin(), x.end());
    int m0 = x[n/2 - 1];
    int m1 = x[n/2];
    for (int i = 0; i < n; ++i) {
        if (b[i] < m1) {
            printf("%d\n", m1);
        } else {
            printf("%d\n", m0);
        }
    }
    return 0;
}


Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define maxn 2005
int d[maxn][maxn],ans[maxn],a[maxn][maxn];
signed main()
{
    //ios_base::sync_with_stdio(false);
    int n,x,y;
    cin>>n>>x>>y;
    for (int i = 1; i <n ; ++i) {
        for (int j = i+1; j <=n ; ++j) {
            d[j][i]=d[i][j]=j-i;
        }
    }
    for (int k = 1; k <=n ; ++k) {
        for (int i = 1; i <=n ; ++i) {
            d[k][i]=min(d[k][x]+d[y][i]+1,d[k][i]);
        }
    }
    //d[x][y]=1;
    for (int i = 1; i <n ; ++i) {
        for (int j = i+1; j <=n ; ++j) {
            ans[d[i][j]]++;
        }
    }
    for (int l = 1; l <n ; ++l) {
        cout<<ans[l]<<endl;
    }
    return 0;
}


Measured memory_bytes: 17280
//#include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <limits.h>
#include <string>
#include <stack>
#include <deque>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <time.h>
#include <stdio.h>

typedef long long ll;
typedef std::pair<int, int> Pii;
typedef std::pair<long long, long long> Pll;
typedef std::pair<double, double> Pdd;

#define rip(i, n, s) for (int i = (s);i < (int)( n ); i++)
#define mapa make_pair
#define all(a) a.begin(), a.end()
#define MM << " " <<

template<typename T>
using MaxHeap = std::priority_queue<T>;
template<typename T>
using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<typename T>
inline bool chmax(T &a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
template<typename T>
inline bool chmin(T &a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<typename T>
std::vector<T> vec(int len, T elem) { return std::vector<T>(len, elem); }
template<typename T>
void vdeb(std::vector<T> &da) {
	for (int i = 0;i < da.size();i++) {
		if (i == da.size() - 1) std::cout << da[i];
		else std::cout << da[i] << ' ';
	}
	std::cout << std::endl;
}
template<typename T>
void vdeb(std::vector<std::vector<T>> &da) {
	for (int i = 0;i < da.size();i++) vdeb(da[i]);
	std::cout << std::endl;
}
using namespace std;

int main(){
	int n,d,x;cin >> n >> d >> x;
	vector<int> da(n);
	rip(i,n,0) cin >> da[i];
	rip(i,n,0){
		x += (d-1)/da[i]+1;
	}
	cout << x << endl;
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!
import array

SIZE=300000; MOD= 998244353
inv = array.array('q',[0]*(SIZE+1))# inv[j] = j^{-1} mod M
fac = array.array('q',[0]*(SIZE+1))# inv[j] = j! mod M
finv = array.array('q',[0]*(SIZE+1))# inv[j] = (j!)^{-1} mod M
#inv = [0]*(SIZE+1)# inv[j] = j^{-1} mod M
#fac = [0]*(SIZE+1)# inv[j] = j! mod M
#finv = [0]*(SIZE+1)# inv[j] = (j!)^{-1} mod M
inv[1] = 1
fac[0] = fac[1] = 1
finv[0] = finv[1] = 1
for i in range(2,SIZE+1):
    inv[i] = MOD -(MOD//i)*inv[MOD%i]%MOD
    fac[i] = fac[i-1]*i%MOD
    finv[i]= finv[i-1]*inv[i]%MOD

def choose(n,r): # nCk mod MOD の計算
    if r < 0 or r > n:
        return 0
    else:
        return (fac[n]*finv[r]%MOD)*finv[n-r]%MOD
    

n,a,b,k = [int(i) for i in input().split()]
ans=0
for i in range(n+1):
    if (k-i*a)%b == 0:
        ans = (ans + choose(n,i)*choose(n,(k-i*a)//b)%MOD)%MOD
print(ans)



Measured memory_bytes: 12492