akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
    private static final int MOD = 1_000_000_007;
    private static final String YES = "Yes";
    private static final String NO = "No";

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String S = sc.next();

        System.out.println(solve(S) ? YES : NO);
    }

    private static boolean solve(String S) {
        if (S.charAt(2) == S.charAt(3) && S.charAt(4) == S.charAt(5)) {
            return true;
        }

        return false;
    }
}

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

int main(){
	int a, b, c, x, y;
	long long sum;
	cin>>a>>b>>c>>x>>y;
	
	if((a+b) >= c*2){		//若两盒c比1a1b便宜 
		if(x >= y)				//部分ab部分c 
			sum = min(x, y)*c*2 + abs(x-y)*a;
		else if(x < y)
			sum = min(x, y)*c*2 + abs(x-y)*b;
		
		if(sum > max(x, y)*c*2)	//全买c 
			sum = max(x, y)*c*2; 
	}
	else{					//若两盒c比1a1b贵
		sum = a*x + b*y;
	}
	cout<<sum;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstddef>
#include<queue>
#include<math.h>
#include<iomanip>
using namespace std;

int main()
{
    string s;
    cin >> s;
    vector<int> a;
    for(int i = 0; i < s.size(); ++i){
        if(s.at(i) == 'A' || s.at(i) == 'C' || s.at(i) == 'G' || s.at(i) == 'T') a.push_back(i);
    }
    a.push_back(20);
    int cnt = 1, ans = 0;
    for(int i = 1; i < a.size(); ++i){
        if(a.at(i) - a.at(i - 1) == 1) cnt++;
        else{
            ans = max(ans, cnt);
            cnt = 1;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3608
a=input()
b=input()

if len(a)>len(b):
    print("GREATER")
    exit()
elif len(a)<len(b):
    print("LESS")
    exit()
else:
    for i in range(len(a)):
        if a[i]>b[i]:
            print("GREATER")
            exit()
        elif a[i]<b[i]:
            print("LESS")
            exit()
print("EQUAL")

Measured memory_bytes: 3064
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int A = scanner.nextInt() - 1;
        int B = scanner.nextInt() - 1;
        scanner.close();
        char[][] g = new char[100][100];

        for (int i = 0; i < 50; i++) {
            Arrays.fill(g[i], '#');
        }
        for (int i = 50; i < 100; i++) {
            Arrays.fill(g[i], '.');
        }

        int x = 0;
        int y = 0;
        for (int i = 0; i < A; i++) {
            g[x][y] = '.';
            y += 2;
            if (y >= 100) {
                x += 2;
                y = 0;
            }
        }
        x = 51;
        y = 0;
        for (int i = 0; i < B; i++) {
            g[x][y] = '#';
            y += 2;
            if (y >= 100) {
                x += 2;
                y = 0;
            }
        }

        System.out.println("100 100");

        for (int i = 0; i < 100; i++) {
            System.out.println(g[i]);
        }

    }

}

Measured memory_bytes: 24148
import java.util.*;

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

    int cnt = 0;
    for (int i = a; i <= b; i++) {
        if (isPalindrome(i)) {
          cnt++;
        }
    }

    System.out.println(cnt);
	}

  private static boolean isPalindrome(int x) {
    List<Integer> list = new ArrayList<Integer>();
    while (x > 0) {
      list.add(x - (x / 10 * 10));
      x /= 10;
    }

    int size = list.size();
    for (int i = 0; i < size / 2; i++) {
      if (list.get(i) != list.get(size - 1 - i)) {
				return false;
			}
    }
    return true;
  }
}


Measured memory_bytes: 28748
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

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

ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}

ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}

ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}

//-----------------------ここから-----------

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

    map<char,int> mp;
    mp['N'] = 0;
    mp['W'] = 0;
    mp['S'] = 0;
    mp['E'] = 0;
    for(int i = 0; i < s.size(); i++){
        mp[s[i]]++;
    }
    
    if(mp['N'] > 0 && mp['S'] > 0){
        if(mp['E'] > 0 ^ mp['W'] > 0){
            cout << "No" << endl;
        } else {
            cout << "Yes" << endl;
        }
    } else if(mp['E'] > 0 && mp['W'] > 0){
        if(mp['S'] > 0 ^ mp['N'] > 0){
            cout << "No" << endl;
        } else {
            cout << "Yes" << endl;
        }
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<stdio.h>

int main() {

	double a,b,c,rad;
	double PI = acos(-1);
	std::cin >> a >> b >> c;
	rad = c * PI / 180;

	printf("%8f\n", (b * a * sin(rad)) / 2);
	printf("%8f\n", a+b+sqrt(pow(b-a*cos(rad),2)+pow(a*sin(rad),2)));
	printf("%8f\n", b * sin(rad));
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = 1; i < (int)(n+1); i++)
const long long INF = 1LL << 60;
int main(){
    int N;
    cin>>N;
    int ans=10000;
    int cnt=0;
    int p=0;
    vector<int>W(N);
    rep(i,N){
        cin>>W[i];
        cnt+=W[i];
    }
    rep(i,N){
        cnt-=W[i];
        p+=W[i];
        if(abs(cnt-p)<ans){
            ans=abs(cnt-p);
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3576
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <math.h>

int main(int argc, char *argv[])
{
    int n;
    int a[100000];
    int a_min, a_min_ptr;
    int a_min_next, a_min_next_ptr;
    int i;

    scanf("%d", &n);

    a_min = INT_MAX;
    for (i = 0; i < n; i++) {
        scanf("%d", &a[i]);
        if (a[i] < a_min) {
            a_min = a[i];
            a_min_ptr = i;
        }
    }

    a_min_next = a_min;
    a_min_next_ptr = a_min_ptr;
    while(n > 1) {
        for (i = 0; i < n; i++) {
            if (i == a_min_ptr) {continue;}
            a[i] %= a_min;
            if (a[i] == 0) {
                //swap
                a[i] = a[n - 1];
                n--;
                i--; continue;
            } else {
                if (a[i] < a_min_next) {
                    a_min_next = a[i];
                    a_min_next_ptr = i;
                }
            }
        }
        a_min = a_min_next;
        a_min_ptr = a_min_next_ptr;
    }

    printf("%d\n", a_min);

    return 0;
}


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

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		if(S == "Sunny") Console.WriteLine("Cloudy");
		if(S == "Cloudy") Console.WriteLine("Rainy");
		if(S == "Rainy") Console.WriteLine("Sunny");
		
		
		
	}
	String S;
	public Sol(){
		S = rs();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 11092
from collections import deque

def bfs(colors, links):
    q = deque([(0, 0)])
    
    while q:
        v, current = q.popleft()

        if current % 2 == 0:
            colors[v] = 0
        else:
            colors[v] = 1

        for next_v, distance in links[v]:
            if colors[next_v] != -1: continue

            q.append((next_v, current + distance))
        
def solve():
    N = int(input())
    A = [list(map(int, input().split())) for _ in range(N-1)]
    cs = [-1] * N
    cs[0] = 0

    links = [[] for _ in range(N)]
    for u, v, w in A:
        v -= 1
        u -= 1
        links[v].append((u, w))
        links[u].append((v, w))

    bfs(cs, links)

    print('\n'.join(map(str, cs)))

solve()

Measured memory_bytes: 64772
#include <iostream>

using namespace std;

int main(int argc, char const* argv[])
{
	int n;
	unsigned long long answer[31];
	
	for( int i = 0;i < 31;i++ ){
		answer[i] = 0;
	}

	answer[0] = 1;
	for( int i = 0;i < 31;i++ ){
		if( i + 3 < 31 ) answer[i + 3] += answer[i];
		if( i + 2 < 31 ) answer[i + 2] += answer[i];
		if( i + 1 < 31 ) answer[i + 1] += answer[i];
	}
	while( cin >> n && n != 0 ){
		cout << answer[n] / 3650 + 1  << endl;
	}


	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod * mod;
constexpr int MAX = 200010;

using ppd = pair<pair<double, double>, double>;

double getval(double x, ppd p){
    double l, r, y;
    tie(l, r) = p.fi; y = p.se;
    if(x < l) return -x + y+l;
    else if(r < x) return x + y-r;
    else return y;
}

int main(){
    int n;
    scanf("%d", &n);
    lint t[n+1], v[n];
    t[0] = 0;
    rep(i, n) scanf("%lld", &t[i+1]);
    rep(i, n) scanf("%lld", &v[i]);
    partial_sum(t, t+n+1, t);

    ppd s[n+2];
    s[0] = {{0, 0}, 0};
    s[n+1] = {{t[n], t[n]}, 0};
    For(i, 1, n+1) s[i] = {{t[i-1], t[i]}, v[i-1]};

    vector<double> y;
    rep(i, 2*t[n]+1){
        double tmp = mod;
        rep(j, n+2) chmin(tmp, getval(i/2.0, s[j]));
        y.push_back(tmp);
    }
    double ans = 0;
    rep(i, y.size()-1) ans += 0.25 * (y[i] + y[i+1]);
    printf("%.20lf\n", ans);
}

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using ll = long long;
int mod = 1000000000+7;

int main(){

	int k,s;
	cin>>k>>s;

	int ans=0;
	for(int i=0;i<=k;i++){
		if(s-i>2*k)continue;
		for(int j=0;j<=k;j++){
			if(s-i-j>k || s-i-j<0)continue;
			ans++;
		}
	}

	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define scan(n) scanf("%d",&n)
#define ls(n) scanf("%lld",&n)
#define print(n) printf("%d ",n)
#define pln(n) printf("%d\n",n)
#define lpln(n) printf("%lld\n",n)
#define rep(i,a,n) for(int i=a;i<n;i++)
#define rev(i,a,n) for(int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define gcd __gcd
#define tc           ll t1; cin>>t1; while(t1--)
#define inp         ll n; cin>>n; ll arr[n]; rep(i,0,n) cin>>arr[i];
#define vect vector<ll>
#define sortv(v)       sort(v.begin(),v.end())
#define lower(v,n)    lower_bound(v.begin(),v.end(),n)-v.begin()
#define upper(v,n)    upper_bound(v.begin(),v.end(),n)-v.begin()
#define bitcount(n) __builtin_popcount(n)
#define ln <<endl
#define inf          1e12
#define ninf         LONG_MIN
#define fast()         ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
const   ll mod=1e9+7;
const ll N=1e5+5;




int main() 
{ 
         fast();
         #ifndef ONLINE_JUDGE
         freopen("input.txt" , "r" , stdin);
         freopen("output.txt" , "w" , stdout);
         #endif
         ll n,k;
         cin >> n >> k;
         ll arr[n];
         rep(i,0,n)
         cin >> arr[i];
         ll low=1,high=1000000000;
         ll ans=-1;
         ll count=0;
         while(low<=high)
         {
             count=0;
             ll mid=(low+high)/2;
             rep(i,0,n)
             {
                
                ll temp1=arr[i]/mid;
                
                ll rem=arr[i]-temp1*(ll)mid;
                if(rem>0)
                  temp1++;
               // cout<<temp1<<endl;
                count+=(temp1-1);

             }
           //  cout<<mid<<" "<<count<<endl;
             if(count<=k)
             {
              ans=(mid);
              high=mid-1;

             }
             else low=mid+1;
            // cout<<low<<" "<<high<<endl;
         }
         cout<<ans<<endl;
        



  return 0; 
} 


Measured memory_bytes: 5176
#include<cstdio>

int main(){
    int W,H,x,y,r;
    scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
    if(0 <= x - r && x + r <= W && 0 <= y - r && y + r <= H){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }
    return 0;
}


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

typedef long long int lli;
#define rep(i, a, b) for(lli i  = (lli)(a); i < (lli)(b);i++)
#define rip(i, a ,b) for(lli i  = (lli)(a); i >= (lli)(b);i--)
#define fastio ios_base::sync_with_stdio(0); cin.tie(0)
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define sz(v) (v).size()
#define all(v) (v).begin(), (v).end()
#define trace(x) cerr << #x << ": " << x << endl;

typedef pair<lli, lli> ii;
typedef pair<ii, lli> iii;
typedef vector<lli> vi;
typedef vector<ii> vii;

int main(){
	int n; cin>>n;
	if(n==25) cout<<"Christmas";
	else if(n==24) cout<<"Christmas Eve";
	else if(n==23) cout<<"Christmas Eve Eve";
	else cout<<"Christmas Eve Eve Eve";

	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#include <numeric>
#define IINF 1000000000
#define INF 9223372036854775807
#define MOD 1000000007
#define mod 998244353
#define INT_MAX_ 2147483647
#define EPS (1e-10)
#define REP(i, a, n) fo-r (ll i = a; i < (ll)(n); i++)
#define REPE(i, a, n) for (ll i = a; i <= (ll)(n); i++)
//#define rep(i,n)for (ll i = 0; i < (ll)(n); i++)
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
#define me memset
#define bit(n,k) ((n>>k)&1)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int,int>Pin;
typedef pair<ll,ll>Pll;
template<class T> using V=vector<T>;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T> >;
long long GCD(long long a, long long b) {return b?GCD(b,a%b):a;}
long long LCM(long long a, long long b) {return a/GCD(a,b)*b;}
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
ll cmp1(pair<ll,ll> a,pair<ll,ll> b){
        if(a.se!=b.se)
        return a.se<b.se;
        else
        return a.fi>b.fi;
}
//----------------------------------------------------------------------

//----------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------  
    //ll begin_t=clock();
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //------------------------------
    string s,t;cin>>s>>t;
    ll ans=0;
    for(ll i=0;i<s.length();i++){
        if(s[i]!=t[i])ans++;
    }
    cout<<ans<<Endl;
    //------------------------------
    //fclose(stdin);
    //fclose(stdout);
    //ll end_t=clock();cout<<"time="<<end_t-begin_t<<"ms"<<endl;
    //-------------------------------
    return 0;
}
//----------------------------------------------------------------------








































Measured memory_bytes: 3752
import sys


def prepare(n, MOD):
    f = 1
    factorials = [1]
    for m in range(1, n + 1):
        f *= m
        f %= MOD
        factorials.append(f)
    inv = pow(f, MOD - 2, MOD)
    invs = [1] * (n + 1)
    invs[n] = inv
    for m in range(n, 1, -1):
        inv *= m
        inv %= MOD
        invs[m - 1] = inv

    solo_invs = [0] + [f * i % MOD for f, i in zip(factorials, invs[1:])]

    return factorials, invs, solo_invs


def decompose_inverses(solo_invs, MOD):
    # 各整数 g に対して、g の約数である各 i について dcm[i] を全て足すと 1/g になるような数列を作成
    n = len(solo_invs)
    dcm = solo_invs[:]
    for i in range(1, n):
        d = dcm[i]
        for j in range(2 * i, n, i):
            dcm[j] -= d
    for i in range(1, n):
        dcm[i] %= MOD
    return dcm


n, *aaa = map(int, sys.stdin.buffer.read().split())
MOD = 998244353
LIMIT = max(aaa)
count = [0] * (LIMIT + 1)
double = [0] * (LIMIT + 1)
for a in aaa:
    count[a] += a
    double[a] += a * a
_, _, solo_invs = prepare(LIMIT, MOD)
dcm = decompose_inverses(solo_invs, MOD)

ans = 0
inv2 = solo_invs[2]
for d in range(1, LIMIT + 1):
    mulsum = sum(count[d::d]) ** 2 - sum(double[d::d]) % MOD
    if mulsum:
        ans = (ans + dcm[d] * mulsum * inv2) % MOD
print(ans)


Measured memory_bytes: 152148
#include <stdio.h>

int main(void)
{
    while(1){
        int i, j;
        int h, w;
        int diagonal;
        int lm_h, lm_w;
        int lm_diagonal;

        scanf("%d %d", &h, &w);

        if(h == 0 && w == 0)
            break;

        diagonal = h * h + w * w;
        lm_h = lm_w = 101;
        lm_diagonal = lm_h * lm_h + lm_w * lm_w;

        for(i = 1; i <= 150; i++){//height
            for(j = i + 1; j <= 150; j++){//width
                int temp_diagonal = i * i + j * j;
                if((temp_diagonal > diagonal) || (temp_diagonal == diagonal && i > h)){//larger
                    if((temp_diagonal < lm_diagonal) || (temp_diagonal == lm_diagonal && i < lm_h)){
                        lm_h = i;
                        lm_w = j;
                        lm_diagonal = temp_diagonal;
                    }
                }
            }
        }

        printf("%d %d\n", lm_h, lm_w);
    }

    return 0;
}

Measured memory_bytes: 600
# https://atcoder.jp/contests/abc107/tasks/abc107_b



H, W = gets.split.map(&:to_i)
ass = Array.new(H) { gets.chomp.chars }

ng_columns = []
W.times do |j|
  ng_columns << j if ass.map{|row| row[j]}.join == '.' * H
end

ass.each_with_index do |row, i|
  next if row.join == '.' * W
  ans_row = ''
  row.each_with_index do |elm, j|
    ans_row << elm unless ng_columns.include?(j)
  end
  puts ans_row
end


Measured memory_bytes: 2300
#include <bits/stdc++.h>
#define rep(i,n) for ((i)=1;(i)<=(n);(i)++)
#define per(i,n) for ((i)=n;(i)>=(1);(i)--)
#define ll long long
using namespace std;
ll n,m,i,j,l[100005],r[100005],tl,tr,ans;
priority_queue<ll> ql;
priority_queue<ll,vector<ll>,greater<ll> > qr;
int main()
{
	scanf("%lld",&n);
	rep(i,n)
	{
		scanf("%lld%lld",&l[i],&r[i]);
		if(i==1){
			ql.push(l[i]);
			qr.push(l[i]);
			tl=tr=0;
			continue;
		}
		ll lst=r[i-1]-l[i-1],cur=r[i]-l[i];
		tl-=cur;tr+=lst;
		ll l1=ql.top()+tl,r1=qr.top()+tr;
		if(l[i]<l1){
			ans+=abs(l1-l[i]);
			qr.push(l1-tr);
			ql.push(l[i]-tl);
			ql.push(l[i]-tl);
			ql.pop();
		}
		else if(l[i]>r1){
			ans+=abs(r1-l[i]);
			ql.push(r1-tl);
			qr.push(l[i]-tr);
			qr.push(l[i]-tr);
			qr.pop();
		}
		else{
			ql.push(l[i]-tl);
			qr.push(l[i]-tr);
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

int main() {
  int n;
  cin >> n;
  int a[n], ans[n];
  for (int i=0; i<n; i++)
    cin >> a[i];
  int f = 0, b = n-1;
  for (int i=0; i<n; i++) {
    if (i%2) {
      ans[b] = a[n-i-1];
      b--;
    } else {
      ans[f] = a[n-i-1];
      f++;
    }
  }
  for (int i=0; i<n; i++)
    cout << ans[i] << ' ';
  cout << '\n';
  return 0;
}

Measured memory_bytes: 3712
#include <iostream>

using namespace std;

class Jewel {
public:
    int value;
    int cost;
    int profit;
    void countProfit(){
        this->profit = value - cost;
    }
};

int main(){
    int N;
    cin >> N;
    int result = 0;

    Jewel jewels[N];
    for(int i = 0; i < N; i++){
        cin >> jewels[i].value;
    }
    for(int i = 0; i < N; i++){
        cin >> jewels[i].cost;
    }
    for(int i = 0; i < N; i++){
        jewels[i].countProfit();
        if(jewels[i].profit > 0){
            result += jewels[i].profit;
        }
    }
    cout << result << endl;
}

Measured memory_bytes: 256
import math

class SegmentTree():
    def __init__(self, n):
        self.n = n
        self.height = math.ceil(math.log2(n))
        self.nodes = [0 for i in range(pow(2, self.height+1)-1)]
        self.leaf_start = pow(2, self.height)-1

    def update(self, i, x):
        pntr = self.leaf_start + i
        self.nodes[pntr] += x
        while True:
            pntr = (pntr-1)//2
            if pntr == -1: break
            self.nodes[pntr] += x

    def __query(self, s, t, k, l, r):
        if t - s <= 0: return 0
        if r <= s or t <= l: return 0
        if l == s and t == r: return self.nodes[k]
        else:
            m = (l+r)//2
            if t <= m:
                return self.__query(s, t, k*2+1, l, m)
            elif m <= s:
                return self.__query(s, t, k*2+2, m, r)
            else:
                vl = self.__query(s, m, k*2+1, l, m)
                vr = self.__query(m, t, k*2+2, m, r)
                return vl + vr

    def find(self, s, t):
        return self.__query(s, t+1, 0, 0, pow(2, self.height))

n, q = list(map(int, input().split(' ')))
st = SegmentTree(n)
for i in range(q):
    com, x, y = list(map(int, input().split(' ')))
    if com == 0:
        st.update(x-1, y)
    elif com == 1:
        print(st.find(x-1, y-1))


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

int main(){
    int a, b, c, d, e, k; string ans;
    cin >> a >> b >> c >> d >> e >> k;
    if(e-a <= k) ans = "Yay!";
    else ans = ":(";
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define fix(n) cout<<fixed<<setprecision(n)
#define co(n) cout<<n<<endl
#define all(n) (n).begin(),(n).end()
using namespace std;
typedef long long ll;
const ll mod=1000000007;
double pi=3.1415926535;

int main(){
  int a,b,m,x,y,z;
  cin>>a>>b>>m;
  int aa[a],bb[b],am=1000000,bm=1000000,cm;
  rep(i,0,a){
    cin>>aa[i];
    am=min(am,aa[i]);
  }
  rep(i,0,b){
    cin>>bb[i];
    bm=min(bm,bb[i]);
  }
  cm=am+bm;
  rep(i,0,m){
    cin>>x>>y>>z;
    cm=min(cm,aa[x-1]+bb[y-1]-z);
  }
  co(cm);
  
  return 0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <iostream>
#include <map>
#include <string>
#include <vector>

#define rep(inc, bgn, end) for (int inc = bgn; inc < end; ++inc)
#define repe(inc, bgn, end) for (int inc = bgn; inc <= end; ++inc)

using ll = long long;
using namespace std;
int main() {
    string s, t;
    cin >> s >> t;

    int cnt = 0;
    rep(i, 0, s.size()) {
        if (s[i] != t[i]) {
            cnt++;
        }
    }

    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3912
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,half;
  cin >> a >> b >> c;
  if((a + b + c) % 2 == 0){
     half = (a + b + c) / 2;
  }else{
    cout << "No" << endl;
    return 0;
  }
  
  if(a == half || b == half || c == half){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)

using namespace std;

namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;

using ll = long long;
ll mod = pow(10, 9) + 7;

template <typename T> void output(T, ll);
ll gcd(ll, ll);
ll lcm(ll, ll);
Bint comb(Bint, Bint);
void prime_map(map<ll, ll> &, ll);

int main() {
    // source
    int n, k;
    cin >> n >> k;

    set<int> s;
    rep(i, k) {
        int temp;
        cin >> temp;
        s.insert(temp);
    }

    while (true) {
        string num = to_string(n);
        bool flag = true;
        rep(i, num.size()) {
            char temp = num[i];
            if (s.find(temp - '0') != s.end()) {
                flag = false;
            }
        }
        if (flag) {
            break;
        }
        n++;
    }

    cout << n << endl;
    return 0;
}

Bint comb(Bint a, Bint b) {
    Bint ans = 1;

    if (a < b) {
        return 0;
    }

    rep(i, b) {
        ans *= a - i;
        ans /= i + 1;
    }

    return ans;
}

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

template <typename T> T min(T a, T b) {

    if (a < b) {
        return a;
    } else {
        return b;
    }
}

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 prime_map(map<ll, ll> &m, ll num) {
    ll cache = num;
    repd(i, 2, sqrt(num) + 2) {
        if (num % i == 0) {
            if (m[i] == 0) {
                m[i] = 1;
            } else {
                m[i]++;
            }

            num /= i;
            break;
        }
    }

    if (cache == num) {
        if (m[num] == 0) {
            m[num] = 1;
        } else {
            m[num]++;
        }
        return;
    } else {
        prime_map(m, num);
    }
}


Measured memory_bytes: 256
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
typedef long long LL;

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

  int cnt = 0;
  for (int i = 0; i < S.length()-2; ++i) {
    std::string sub = S.substr(i, 3);
    if (sub == "ABC") ++cnt;
  }

  std::cout << cnt << std::endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}
int Madd(int x,int y) {return (x+y)%M;}
int Msub(int x,int y) {return (x-y+M)%M;}
int Mmul(int x,int y) {return (x*y)%M;}


signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);

  int n;
  cin>>n;
  list<int> list;
  rep(i,n){
    string s;
    cin>>s;
    if(s[0]=='i'){
      int x;
      cin>>x;
      list.push_front(x);
    }else if(s=="delete"){
      int x;
      cin>>x;
      for(auto it=list.begin();it!=list.end();it++){
        if(*it==x){
          list.erase(it);
          break;
        }
      }
    }else if(s=="deleteFirst") list.pop_front();
    else list.pop_back();
  }

  bool flag=false;
  for(auto x:list){
    if(flag) cout<<' ';
    cout<<x;
    flag=true;
  }
  cout<<endl;


}


Measured memory_bytes: 34380
#include "bits/stdc++.h"
#pragma GCC optimize("Ofast")
//for CodeForces
#pragma GCC target("avx,avx2")
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;
map<long long int, int>soinnsuu(long long int a) {
	map<long long int, int>ans;
	for (long long i = 2; i*i <= a; ++i) {
		while (a%i == 0) {
			ans[i]++;
			a /= i;
		}
	}
	if (a != 1)ans[a]++;


	return ans;
}
struct query {
	int id;
	int num;
};
int main() {
	int N,M;cin>>N>>M;
	vector<int>v(M);
	for (int i = 0; i < M; ++i) { cin >> v[i]; };
	vector<int>nums;
	int need=v[0];
	for (int i = 0; i < M - 1; ++i) {
		nums.push_back(v[i+1]-v[i]);
	}
	nums.push_back(N-v.back()+1);
	map<int,int>mp;
	for (auto n : nums) {
		mp[n]++;
	}
	vector<int>anss(100005);
	anss[1]=N-M;
	int minus=M;
	for (int i = 2; i < 100005; ++i) {
		minus-=mp[i-1];
		anss[i]=anss[i-1]-minus;
	}
	anss.erase(anss.begin());
	reverse(anss.begin(),anss.end());
	int Q;cin>>Q;
	vector<pair<int,int>>qs;
	for (int i = 0; i < Q; ++i) {
		int a;cin>>a;
		qs.push_back(make_pair(a,i));
		auto it=lower_bound(anss.begin(),anss.end(),a+1);

		int nans=(anss.end()-it);
		if(it==anss.begin())nans=-2;
		cout<<nans+1<<endl;
	}



	vector<int>real_anss(Q);
	
	return 0;
}


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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const llint INF = 1<<21;
// static const llint MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

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

    if(a%2==1&&b%2==1) cout << "Odd" << endl;
    else cout << "Even" << endl;
    return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

ll n;
vector<P> ps;

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

  cin>>n;
  rep(i,n){
  	ll a,b;
  	cin>>a>>b;
  	ps.push_back(P(a-b,a+b));
  }
  sort(all(ps),[](const P& a,const P& b){
  	return a.se < b.se;
  });

  ll crtx=-INF,res=0;
  rep(i,n){
  	if(ps[i].fi>=crtx){
  		crtx=ps[i].se;
  		res++;
  	}
  }
  cout<<res<<endl;

  return 0;
}


Measured memory_bytes: 2420
package main

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

var sc = bufio.NewScanner(os.Stdin)

func newInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func main() {

	var a, b, c, d, result int
	sc.Split(bufio.ScanWords)
	a = newInt()
	b = newInt()
	c = newInt()
	d = newInt()

	result = a * c
	if result < b*c {
		result = b * c
	}
	if result < a*d {
		result = a * d
	}
	if result < b*d {
		result = b * d
	}

	fmt.Println(result)
}


Measured memory_bytes: 1772
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

using namespace std;

#define REP(i,N) for(int i = 0; i < N; i++)

int main(){
    string kisuu,guusuu,sum="";
    cin >> kisuu >> guusuu;
    for(int i = 0; i < kisuu.size(); i++){
        sum += kisuu[i];
        if(kisuu.size() == guusuu.size())sum += guusuu[i];
        else{
            if(i != kisuu.size() - 1)sum += guusuu[i];
        }
    }
    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 256
l, r=map(int, input().split())
if r-l>672:
	p=0
else:
	p=2019
	for i in range(l, r):
		for j in range(i+1, r+1):
			p=min(p, (i*j%2019))
			if not p:
				break
		if not p:
			break
print(p)

Measured memory_bytes: 3064
#include<cstdio>
//#include<iostream>
#define M_PI		3.14159265358979323846
#include<cmath>
//using namespace std;
struct Point{ double x, y;};

void koch(int n, Point a, Point b)
{
  if(n == 0) return ;

  Point s, t, u;
  double th = M_PI * 60.0 / 180.0 ;

  s.x = (2.0 * a.x + 1.0 * b.x) / 3.0;
  s.y = (2.0 * a.y + 1.0 * b.y) / 3.0;
  t.x = (1.0 * a.x + 2.0 * b.x) / 3.0;
  t.y = (1.0 * a.y + 2.0 * b.y) / 3.0;
  u.x = (t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x;
  u.y = (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y;

  koch(n-1, a, s);
  printf("%.8f %.8f\n", s.x, s.y);
  koch(n-1, s, u);
  printf("%.8f %.8f\n", u.x, u.y);
  koch(n-1, u, t);
  printf("%.8f %.8f\n", t.x, t.y);
  koch(n-1, t, b);
}

int main()
{
  Point a, b;
  int n;
  scanf("%d", &n);
  a.x = 0;
  a.y = 0;
  b.x = 100;
  b.y = 0;

  printf("%.8f %.8f\n", a.x, a.y);
  koch(n, a, b);
  printf("%.8f %.8f\n", b.x, b.y);

  return 0;
}



Measured memory_bytes: 2668
#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>;

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

ll hlcm(ll a, ll b){
    if(a==0 || b==0) return 0;
    if(a<b)swap(a,b);
    if(a%b==0&&(a/b)%2==0) return 0;
    return a*b/gcd(b, a);
}

int main(){
    ll n, m;
    cin >> n>> m;
    vector<int> a(n), half(n);
    rep(i, n){
        cin>>a[i];
        half[i] = a[i]/2;
    }
    ll hlcm0 = half[0];
    rep(i, n-1){
        hlcm0 = hlcm(hlcm0, half[i+1]);
        if(hlcm0 > m||hlcm0==0){
            hlcm0=0;
            cout << 0 << endl;
            return 0;
        }
    }
    ll ans = (m/hlcm0 + 1) / 2;
    cout << ans << endl;
    return 0;
}

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

int main()
{
	int N, A, B;
	int P1=0, P2=0, P3=0;

	std::cin >> N >> A >> B;
	for (int i = 0; i < N; ++i) {
		int p;
		std::cin >> p;
		if (p <= A)
			++P1;
		else if (p <= B)
			++P2;
		else
			++P3;
	}
	std::cout << std::min(P1, std::min(P2, P3)) << "\n";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define pi pair<ll,ll>
#define pii pair<ll,pi>
#define pb push_back
#define mk make_pair
int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n, k;
	cin >> n >> k;
	map<int, int>m;
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		m[x]++;
	}
	vector<int>v;
	for (auto k : m) {
		v.pb(k.se);
	}
	sort(v.begin(), v.end());
	int ans = 0;
	for (int i = 0; i <= int(v.size() - k - 1); i++) {
		ans += v[i];
	}
	cout << ans << endl;
}


Measured memory_bytes: 13600
N = int(input())
T = list(map(int,input().split()))
M = int(input())
ans = sum(T)
copy = ans
for i in range(M):
    p,x = map(int,input().split())
    p -= 1
    ans -= T[p]
    ans += x
    print(ans)
    ans = copy

    


Measured memory_bytes: 9176
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define all(A) A.begin(),A.end()
typedef long long ll;

int main(){
  
  int n,a,b,c,d;
  cin >> n >> a >> b >> c >> d;
  string s;
  cin >> s;
  s = '#' + s + '#';
  for(int i=a;i<c;i++){
    if(s[i]=='#' && s[i+1]=='#'){
      cout << "No" << endl;
      return 0;
    }
  }
  for(int i=b;i<d;i++){
    if(s[i]=='#' && s[i+1]=='#'){
      cout << "No" << endl;
      return 0;
    }
  }
  if(c < d){
    cout << "Yes" << endl;
    return 0;
  }
  for(int i=b;i<=d;i++){
    if(s[i-1]=='.' && s[i]=='.' && s[i+1]=='.'){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 3848
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#include <numeric>

using namespace std;

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

    int N;
    cin >> N;

    deque<int> a;
    for (int i=0; i<N; i++) {
      int64_t c;
      cin >> c;
      if (i % 2 == 0) {
        a.push_back(c);
      } else {
        a.push_front(c);
      }
    }

    if (N % 2 == 1) {
      reverse(a.begin(), a.end());
    }
    for(auto itr = a.begin(); itr != a.end(); ++itr) {
      cout << *itr << " ";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3072
#include <iostream>
#include <stdio.h>
#include <string>

#define MAX_H 50

using namespace std;

char C[MAX_H][MAX_H];

int main() {
  int H, W;
  cin >> H >> W;
  for (int i = 0; i < H; ++i) {
    string S;
    cin >> S;
    for (int j = 0; j < W; ++j) {
      C[i][j] = S[j];
    }
  }
  for (int i = 0; i < H; ++i) {
    for (int j = 0; j < W; ++j) {
      if (C[i][j] == '#') {
        int cnt = 0;
        if (i - 1 >= 0 && C[i - 1][j] == '#') {
          ++cnt;
        }
        if (i + 1 < H && C[i + 1][j] == '#') {
          ++cnt;
        }
        if (j - 1 >= 0 && C[i][j - 1] == '#') {
          ++cnt;
        }
        if (j + 1 < W && C[i][j + 1] == '#') {
          ++cnt;
        }
        if (cnt == 0) {
          printf("No\n");
          return 0;
        }
      }
    }
  }
  printf("Yes\n");
}

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

int main(){
    /* AC (1)
    int a[101] = {};
    int now = 1, i = 1;
    while(i <= 100){
        while(i <= 100 && i < now*2)    a[i++] = now;
        now *= 2;
    }

    int n;
    cin >> n;
    cout << a[n] << endl;
    */

    int n;
    cin >> n;
    int ans = 1;
    while(ans*2 <= n)   ans*=2;
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <string.h>
#include <string>
#include <queue>
#include <stack>
using namespace std;
typedef long long int ll;
char s[13];

int main(void)
{
	int i, j;
	scanf("%s",&s[1]);
	for(i=1 ; i<=4 ; i++)
	{
		printf("%c",s[i]);
	}
	printf(" ");
	for(i=5;  i<=12 ; i++)
	{
		printf("%c",s[i]);
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
typedef long long ll;
#define forin(in, n) for(int i=0; i<n; i++) cin>>in[i]
#define forout(out, n) for(int i=0; i<n; i++) cout<<out[i]<<endl
 
int main(){
    int A[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int K; cin>>K;
    cout<<A[K-1]<<endl;
}

Measured memory_bytes: 3580
#include<stdio.h>
int main(){
int i,a;
long long n,min=1000000,max=-1000000,sum=0;
scanf("%d",&n);
for(i=0;i<n;i++){
    scanf("%d",&a);
    if(min>a){
    min=a;
    }
    if(max<a){
    max=a;
    }
    sum=sum+a;
    }
    printf("%ld %ld %ld\n",min,max,sum);
    return 0;



}

Measured memory_bytes: 1796
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():
    n,m = LI()
    route = [[] for _ in range(n+1)]
    for _ in range(m):
        a,b = LI()
        route[a].append(b)
        route[b].append(a)
    explored = set()

    sstock = collections.deque([i for i in range(1,n+1)])
    ans = 0
    while len(sstock)!=0:
        nnext = sstock.pop()
        if nnext not in explored:
            cnt = 0
            stock = collections.deque([nnext])
            explored.add(nnext)
            while len(stock) != 0:
                next = stock.pop()
                cnt += 1   
                for i in route[next]:
                    if i not in explored:
                        stock.append(i)
                        explored.add(i)
            ans = max(ans,cnt)
    print(ans)
main()            


Measured memory_bytes: 127616
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
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 hr() {
   cerr << "--------------" << endl;
}
const int INF = 1001001001;
const int MOD = 1000000007;

const int NMAX = 100005;
int num[NMAX];
int main() {
   cin.tie(0);
   ios_base::sync_with_stdio(0);

   int n;
   cin >> n;
   // vector<int> a(n);
   ll ans = 0;
   rep(i, 0, n) {
      int a;
      cin >> a;
      num[a]++;
      ans += a;
   }
   int q;
   cin >> q;
   rep(i, 0, q) {
      int b, c;
      cin >> b >> c;
      ans += -(ll)num[b] * b + (ll)num[b] * c;
      cout << ans << endl;
      num[c] += num[b];
      num[b] = 0;
   }
   return 0;
}

Measured memory_bytes: 4004
n = int(input())
d = []
for i in range(n):
    d.append(int(input()))

c = 0
lastSize = 0
while(True):
    if(len(d) != 0):
        np = max(d)
        d.remove(np)
        if(np != lastSize):
            lastSize = np
            c += 1
    else:
        break
print(c)

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

int main(){
    int n;
    string s;
    cin >> n >> s;
    if(n%2!=0) cout << "No" << endl;
    else{
        if(s.substr(0,n/2)==s.substr(n/2,n)) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
  int l, r, ans = 2018;
  scanf("%d %d", &l, &r);
  if (r - l + 1 >= 2019){
    printf("%d", 0);
    return 0;
  }else{
    for (int i = l; i < r; i++){
      for (int j = i + 1; j <= r; j++){
        if ((i % 2019) * (j % 2019) % 2019 < ans)
          ans = (i % 2019) * (j % 2019) % 2019;
      }
    }
  }
  printf("%d\n", ans);
  
  return 0;
}

Measured memory_bytes: 128
n = int(input())
a = list(map(int, input().split()))
x = 0
y = 0
z = 0
for i in range(n):
    if a[i]%4 == 0:
        x += 1
    elif a[i]%2 == 0:
        y += 1
    else:
        z += 1
if y == 0:
    if x+1 >= z:
        print("Yes")
    else:
        print("No")
else:
    if x >= z:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 62576
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }




int n;
bool impossible(vector<int> a, vector<int> b) {
    sort(all(a));
    sort(all(b));
    rep(i, n) if (a[i] > b[i]) return 1;
    return 0;
}


struct UnionFind {
    vector<double> data;
    int sz;
    UnionFind(int _sz) : data(_sz, -1) { sz = _sz; }
    bool connect(int x, int y) {
        if ((x = root(x)) == (y = root(y))) return false;
        if (data[x] > data[y]) swap(x, y);
        data[x] += data[y]; data[y] = x; sz--;
        return true;
    }
    bool issame(int x, int y) { return root(x) == root(y); }
    int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }
    int size(int x) { return -data[root(x)]; }
    int size() { return sz; }
};



bool comp(pii a, pii b) {
    return a.S < b.S;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    
    
    
    cin >> n;
    vector<int> a(n), b(n);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];
    
    if (impossible(a, b)) {
        cout << "No" << endl;
        return 0;
    }
    
    vector<pii> v(n);
    rep(i, n) v[i] = pii(a[i], b[i]);
    sort(all(v), comp);
    // cout << endl; rep(i, n) cout << v[i].F << " " << v[i].S << endl; cout << endl;
    rep(i, n) v[i].S = i;
    // cout << endl; rep(i, n) cout << v[i].F << " " << v[i].S << endl; cout << endl;
    sort(all(v));
    // cout << endl; rep(i, n) cout << v[i].F << " " << v[i].S << endl; cout << endl;
    
    UnionFind uni(n);
    rep(i, n) uni.connect(i, v[i].S);
    
    set<int> s;
    rep(i, n) {
        s.insert(uni.root(i));
    }
    // cout << sz(s) << endl;
    if (n - sz(s) < n - 1) {
        cout << "Yes" << endl;
        return 0;
    }
    
    int flg = 0;
    sort(all(a));
    sort(all(b));
    rep(i, n - 1) {
        if (b[i] < a[i + 1]) continue;
        flg = 1;
    }
    cout << (flg == 0 ? "No" : "Yes") << endl;
}

/*
 3
 3 2 5
 5 3 2
 
 */





Measured memory_bytes: 2576
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll sum[1000000+5];
void Get(ll l,ll r,ll &first,ll &second)
{
    ll res =INT_MAX;
    ll left = l;
    ll right = r-1;
    while(left<=right)
    {
        ll mid = (left+right)>>1;
        ll a = sum[mid]-sum[l-1];
        ll b = sum[r]-sum[mid];
        if(abs(a-b)<res)
        {
            res = abs(a-b);
            first= a;
            second  = b;
        }
        if(a<=b)
        {
            left = mid+1;
        }
        else
        {
            right = mid-1;
        }
    }
}
int main()
{
    ll n;
    cin>>n;
    
    for(int i=1;i<=n;i++)
    {
    	int x;
    	cin>>x;
    	sum[i] =sum[i-1]+x;
    }
    // for(int i=0;i<=n;i++)
    // {
    // 	cout<<sum[i]<<" ";
    // }
    // cout<<endl;
    ll result =INT_MAX;
    for(ll i=2;i<=n-2;i++)
    {
        ll a;
        ll b;
        Get(1,i,a,b);
        ll c,d;
        Get(i+1,n,c,d);
	//	cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl;       
        ll mx = max(max(a,b),max(c,d));
        ll mn = min(min(a,b),min(c,d));
        result = min(result,abs(mx-mn));
    }
    cout<<result<<endl;
    return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int N = sc.nextInt();
		int[] A = new int[N];
		for(int i=0; i<N; i++) {
			A[i] = sc.nextInt();
			H=H-A[i];
		}
		sc.close();
		System.out.println(H>0?"No":"Yes");
	}

}

Measured memory_bytes: 51944