akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define MN 210000
using namespace std;
struct na{int l,r;}p[MN];
bool cmpl(na a,na b){return a.l==b.l?a.r>b.r:a.l<b.l;}
priority_queue<int,vector<int>,greater<int> > q,_q;
int n,m,mmh;
int main(){
    cin >> n >> m;
    mmh = n;
    for (int i=1;i<=n;i++) cin >> p[i].l >> p[i].r;
    sort(p+1,p+1+n,cmpl);
    for (int i=1;i<=n;i++)
    if (p[i].l==q.size()) q.push(p[i].r),_q.push(q.top()),q.pop();else q.push(p[i].r),mmh--;
    for (int i=q.size()+1;i<=m&&!_q.empty();i++) if (_q.top()<=i) _q.pop(),mmh--;
    printf("%d\n",mmh);
}

Measured memory_bytes: 3320
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = (int)1e9+7;

const int MAXN = 55;

vector<pair<int,int> > edges[MAXN];
vector<int> path,found;

void dfs(int a, int goal,int parent){
	if(a == goal){
		found = path;
		return ;
	}
	for(pair<int,int> e : edges[a]){
		int b = e.first;
		if (b==parent)
			continue;
		path.push_back(e.second);	
		dfs(b,goal,a);
		path.pop_back();	

	}
}


int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n;
	cin>>n;
	for(int i=0;i<n-1;i++){
		int a,b;
		cin>>a>>b;
		edges[a].emplace_back(b,i);
		edges[b].emplace_back(a,i);
	}
	
	int m;
	cin>>m;
	vector<pair<int,int> > paths;
	vector<int> containMe(n-1);
	for(int i=0;i<m;i++){
		int a,b;
		cin>>a>>b;
		found = {-1};
		dfs(a,b,-1);
		assert(found != vector<int>{-1});
		assert(path.empty());
		for(int e : found){
			containMe[e] |= (1<<i);
		}
		
		
		
	}
	
	vector<long long > dp(1<<m);
	// dp[mask] -> number of ways to paint already considered edges 
	// so that exactly mask ways are satisfied;
	dp[0] = 1;
	for(int i=0;i<n-1;i++){
		vector<long long > new_dp(1<<m);
		for(int mask=0;mask<(1<<m);mask++){
			//ctrl + /dp[mask] -> new_dp[mask]; white
			// black -> dp[mask] -> new_dp[mask|edgesSatisfiedByThisEdge];
			new_dp[mask] += dp[mask];
			new_dp[mask|containMe[i]] += dp[mask];
		}
		dp = new_dp;
	}
	cout<<dp[(1<<m)-1];
	return 0;
}


































Measured memory_bytes: 16640
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<char, int> P;
typedef tuple<int, int, ll> T;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int n, m;
ll k;
ll a[200100], b[200100];

int solve() {
    int res = 0;
    ll sum_b = 0;
    for (int i = 0; i < m; i++) {
        sum_b += b[i];
    }
    int idx = m-1;
    ll sum_a = 0;
    for (int i = 0; i <= n; i++) {
        while (idx >= 0 && sum_a + sum_b > k) {
            sum_b -= b[idx];
            idx--;
        }
        if (sum_a + sum_b <= k) {
            res = max(res, idx+1+i);
        }
        sum_a += a[i];
    }
    
    return res;
}

void input() {
    cin >> n >> m >> k;
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < m; i++) cin >> b[i];
}

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

    input();
    cout << solve() << endl;
}


Measured memory_bytes: 6692
n,d=map(int,input().split())
x=[[0]*d for _ in range(n)]
count=0

for i in range(n):
    x[i]=list(map(int,input().split()))
for i in range(n-1):
    for j in range(i+1,n):
        kyori=0
        for k in range(d):
            kyori+=(x[i][k]-x[j][k])**2
        a=int(kyori**0.5)
        if a**2==kyori:
            count+=1
print(count)


Measured memory_bytes: 38512
package main

import (
	"fmt"
	"io"
	"os"
)

func answer(reader io.Reader, writer io.Writer) {
	var a, b int
	_, _ = fmt.Fscan(reader, &a, &b)
	min := 1
	max := a

	for i:=0; i< b; i++ {
		var l, r int
		_, _ = fmt.Fscan(reader, &l, &r)
		if min < l {
			min = l
		}
		if r < max {
			max = r
		}
	}
	d := max - min + 1
	if d < 0 {
		d = 0
	}
	_, _ = fmt.Fprintf(writer, "%d", d)
}

func main() {
	answer(os.Stdin, os.Stdout)
}


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

typedef uint64_t u64;
typedef int64_t i64;
typedef uint32_t u32;
typedef int32_t i32;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;

#define rep(idx, N) for (u64 idx = 0; idx < N; idx++)

int main() {
  i32 n;
  cin >> n;
  vector<i32> x(n);
  rep(i, n) { cin >> x[i]; }

  u32 ans = 0xFFFFFF, minimum = 0;

  for (int p = 1; p <= 100; p++) {
    u32 sum = 0;
    rep(i, n) { sum += (p - x[i]) * (p - x[i]); }
    if (ans > sum) {
      ans = sum;
    }
  }

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


Measured memory_bytes: 3624
#include<stdlib.h>
#include<string.h>

int main(){
  int n,**M,i,j;
  char str[1001],s_str[1001];
  scanf("%d",&n);
  while(n--){
    scanf("%s %s",str,s_str);

    M = malloc(sizeof(int *)*(strlen(s_str)+1));
    for(i=0;i<strlen(s_str)+1;i++){
      M[i] = malloc(sizeof(int)*(strlen(str)+1));
      M[i][0]=0;
    }
    for(i=0;i<strlen(str)+1;i++)M[0][i] = 0;

    for(i=1;i<strlen(s_str)+1;i++){
      for(j=1;j<strlen(str)+1;j++){
	if(str[j-1] == s_str[i-1]) M[i][j] = M[i-1][j-1]+1;
	else{
	  if(M[i-1][j] >= M[i][j-1]) M[i][j] = M[i-1][j];
	  else M[i][j] = M[i][j-1];
	}
      }
    }    
  
  printf("%d\n",M[strlen(s_str)][strlen(str)]);
  for(i=0;i<strlen(s_str)+1;i++)free(M[i]);
  free(M);
  }
  return 0;
}



Measured memory_bytes: 5488
#include<bits/stdc++.h>
#include<iostream>
#include<vector>
#include<queue>
#include<string>
#include<list>
#include<set>
#include<map>
#include<stack>
using namespace std;
typedef long long ll;
const int maxn = 2e5+10;
const ll mod = 1e9+7;
ll node[maxn];
int main()
{
	map<ll,ll> v;
	ll n;
	cin>>n;
	for(ll i=0;i<n;i++)
	{
		ll t;
		cin>>t;
		node[i] = t;
		v[t]++;
	}
	ll sum = 0;
	for(auto it = v.begin();it!=v.end();it++)
	{
		ll t = it->second;
		sum+= (1+t-1)*(t-1)/2;
	}
//	cout<<sum<<endl;
	for(ll i=0;i<n;i++)
	{
		ll t = node[i];
		if(v[t]<=1)
		{
			cout<<sum<<endl;
		}
		else
		{
			ll tt = v[t];
			cout<<sum-(tt-1)<<endl;
		}
	}
	return 0;
}
	

Measured memory_bytes: 12288
"""
~~ author : dokueki
~~ created : 10~05~2020
"""

import sys
INT_MAX = sys.maxsize
INT_MIN = -(sys.maxsize)-1
sys.setrecursionlimit(10**7)
mod = 1000000007


def IOE():
    sys.stdin = open("input.txt", "r")
    sys.stdout = open("output.txt", "w")


def main():
    n = int(sys.stdin.readline())
    ans = []
    for i in range(-118, 120):
        for j in range(-119, 119):
            if i ** 5 - j ** 5 == n:
                ans.append([i, j])

                break
    print(*ans[0])


if __name__ == "__main__":
    try:
        IOE()
    except:
        pass
    main()


Measured memory_bytes: 83348
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const int INF = 1 << 28;
const ll MOD = 1'000'000'007;
template <class T> bool chmax(T &a, const T &b) { return (a < b) ? (a = b, 1) : 0; }
template <class T> bool chmin(T &a, const T &b) { return (b < a) ? (a = b, 1) : 0; }

int main() {
    int n;
    cin >> n;
    vector<pair<string, pair<int, int>>> sp(n);
    for (int i = 0; i < n; ++i) {
        cin >> sp[i].first >> sp[i].second.first;
        sp[i].second.second = i;
    }
    auto comp = [](pair<string, pair<int, int>> l, pair<string, pair<int, int>> r) {
        if (l.first == r.first)
            return l.second.first > r.second.first;
        else
            return l.first < r.first;
    };
    sort(sp.begin(), sp.end(), comp);
    for (int i = 0; i < n; ++i) {
        cout << sp[i].second.second + 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
///=======================///
/// coder: Andy - Tohrumi ///
///=======================///

#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define fastio ios_base::sync_with_stdio(); cin.tie(0); cout.tie(0);
#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()
#define rep(i, a, b) for(__typeof(b) i = a; i < b; i++)
#define Rep(i, a, b) for(__typeof(a) i = a; i > b; i--)

using namespace std;

typedef pair<ll, ll> pll;	typedef pair<int, int> ii;
typedef vector<pll> vll;	typedef vector<string> vs;		typedef vector<ii> vii;
typedef vector<int> vi; 	typedef vector<ll> vl;

///======code start here======///

signed main() {
	fastio;
	int n; cin >> n;
	ll h[n + 1]; h[0] = 1000000000;
	rep(i, 1, n + 1) cin >> h[i];
	ll dp[n + 1]; dp[2] = 0; dp[1] = 0;
	rep(i, 2, n + 1) {
		dp[i] = min(dp[i - 1] + abs(h[i - 1] - h[i]), dp[i - 2] + abs(h[i - 2] - h[i]));
	}
	cout << dp[n] << endl;
	return 0;
}



Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
  unsigned n; cin >> n;
  vector<unsigned> a(n);
  for (int i = n; i--;) cin >> a[i];
  cout << *max_element(a.begin(), a.end()) - *min_element(a.begin(), a.end()) << endl;
}

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

struct data{
    int dist,s;
    data(){}
    data(int _dist,int _s){
        dist=_dist; s=_s;
    }
    bool operator<(const data &a)const{
        return dist>a.dist;
    }
};

struct Way{
    int to,l;
    Way(){}
    Way(int _to,int _l){
        to=_to; l=_l;
    }
};

int way_id[3000][3000];

int main(){
    int N,M,K,A,B,L,S;
    vector<Way> way[3000];
    priority_queue<data> q;
    cin>>N>>M>>K;
    for(int i=0;i<M;i++){
        cin>>A>>B>>L;
		A--; B--;
        way[A].push_back(Way(B,L));
        way[B].push_back(Way(A,L));
        way_id[A][B]=way_id[B][A]=i;
    }
    for(int i=0;i<K;i++){
        cin>>S;
        q.push(data(0,--S));
    }

	int memo[3000];
	for(int i=0;i<N;i++) memo[i]=-1;
    data q_c;
    while(!q.empty()){
        q_c = q.top();
        q.pop();
		if(memo[q_c.s]!=-1) continue;
		memo[q_c.s]=q_c.dist;
		for(int i=0;i<way[q_c.s].size();i++){
			q.push(data(q_c.dist+way[q_c.s][i].l,way[q_c.s][i].to));
		}
    }
	
	int ans=0;
    for(int i=0;i<N;i++){
		for(int j=0;j<way[i].size();j++){
			ans = max(ans,memo[i]+(memo[way[i][j].to]-memo[i]+way[i][j].l+1)/2);
		}
	}
	printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 41148
#pragma warning(disable: 4996)

#include <iostream>
#include <iomanip>
#include <random>
#include <unordered_map>
#include <functional>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <algorithm>
#include <vector>
#include <bitset>
#include <numeric>
#include <string>
#include <set>
#include <tuple>
#include <utility>
#include <regex>
#include <deque>
#include <map>
#include <queue>
using namespace std;

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };

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

	int h, w;
	cin >> h >> w;
	vector<vector<char> > field(h+2, vector<char>(w+2, '#'));
	for (int i = 0; i < h; ++i) {
		for (int j = 0; j < w; ++j) {
			char c;
			cin >> c;
			field[i + 1][j + 1] = c;
		}
	}

	vector<int> res;
	for (int sy = 1; sy <= w; ++sy) {
		for (int sx = 1; sx <= h; ++sx) {
			if (field[sx][sy] == '#') continue;
			for (int gy = 1; gy <= w; ++gy) {
				for (int gx = 1; gx <= h; ++gx) {
					vector<vector<int> > dist(h + 1, vector<int>(w + 1, -1));
					dist[sx][sy] = 0;

					queue<pair<int, int> > que;
					que.push(make_pair(sx, sy));

					while (!que.empty()) {
						pair<int, int> current_pos = que.front();
						int x = current_pos.first;
						int y = current_pos.second;
						que.pop();

						for (int direction = 0; direction < 4; ++direction) {
							int next_x = x + dx[direction];
							int next_y = y + dy[direction];
							if (field[next_x][next_y] == '#') continue;

							if (dist[next_x][next_y] == -1) {
								que.push(make_pair(next_x, next_y));
								dist[next_x][next_y] = dist[x][y] + 1;
							}
						}
					}
					res.push_back(dist[gx][gy]);
				}
			}
		}
	}
	int ans = *max_element(res.begin(), res.end());
	cout << ans;
	return 0;
}

Measured memory_bytes: 1400
import math
def get_integers(n):
    '''
    Reads in one line of input that contains n integers.
    Returns a list of n integers
    '''
    s = input()
    numbers = s.split(' ')
    r = []
    for x in numbers:
        r.append(int(x))
    return  r

a, b, c = get_integers(3)
 
ab = a+b
bc = b+c
ac = a+c
 
minimum = min(ab,bc,ac)
 
print(minimum)

Measured memory_bytes: 3064
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define dbg(x) cout<<#x"="<<x<<endl

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

#define INF 1000000000

int exc2inc(int y, int p){
  return y*(100+p)/100;
}

int inc2exc(int y, int p){
  if( y*100%(100+p) == 0 )
    return y*100/(100+p);
  else{
    int tmp=y*100/(100+p);
    while(exc2inc(tmp+1,p) <= y){
      tmp++;
    }
    return tmp;
  }
}

int main(){

  while(true){
    int x,y,s;
    cin>>x>>y>>s;
    if(x==0&&y==0&&s==0)break;

    int ans=0;
    rep(i,s/2+1){
      if(i==0)continue;
      int tmp = inc2exc(s-exc2inc(i,x), x); //i and tmp are tax-excluded value
      if(exc2inc(i,x)+exc2inc(tmp,x) != s) continue;
      ans = max(ans, exc2inc(i,y)+exc2inc(tmp,y));
      //      dbg(i);dbg(y);
    }

    cout << ans << endl;
  }

}

Measured memory_bytes: 1160
N, K = map(int,input().split())
R, S, P = map(int,input().split())
T = input()
ans = 0
check = [0] * N
for i in range(N):
  j = T[i]
  if i >= K:
    if j == check[i-K]: continue
  if j == "r": ans += P
  elif j == "s": ans += R
  else: ans += S
  check[i] = j
 
print(ans)

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

int main() {
  int N , M = 0;
  cin >> N;
  int A[N];
  
  for (int i = 0; i < N; i++) {
 	cin >> A[i];
  }
  
  int i;
  for (i = 0; ; i++){
  	for(int j = 0; j < N; j++){
    	if(A[j] % 2 == 0){
          A[j] /= 2;
        }
      	else{
        M = 1;
        break;
        }
    }
    if (M==1)
      break;
  }
  
  cout << i << endl;
}

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

int main() {
	ll A, B, C, K;
	cin >> A >> B >> C >> K;

	ll ans = 0;
	if(K <= A) ans = K;
	else if(K <= A + B) ans = A;
	else ans = 2 * A + B - K;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3624
#include<stdio.h>
#include<algorithm>
using namespace std;
int t[100];

int max(int a,int b){return a>b?a:b;}

int main(){
	int n,a,b,c;
	int i,j;
	scanf("%d",&n);
	scanf("%d %d",&a,&b);
	scanf("%d",&c);
	for(i=0;i<n;i++)scanf("%d",&t[i]);
	sort(t,t+n);
	reverse(t,t+n);
	int ans=0;
	for(i=0;i<=n;i++){
		int cal=c;
		int p=a+b*i;
		for(j=0;j<i;j++)cal+=t[j];
		ans=max(ans,cal/p);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1040
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String[] str = in.readLine().split(" ");
    int a = Integer.parseInt(str[0]);
    int b = Integer.parseInt(str[1]);
    int c = Integer.parseInt(str[2]);
    System.out.println(a<=c && b>=c?"Yes":"No");
  }
}

Measured memory_bytes: 32512
#JMD
#Nagendra Jha-4096

 
import sys
import math

#import fractions
#import numpy
 
###File Operations###
fileoperation=0
if(fileoperation):
    orig_stdout = sys.stdout
    orig_stdin = sys.stdin
    inputfile = open('W:/Competitive Programming/input.txt', 'r')
    outputfile = open('W:/Competitive Programming/output.txt', 'w')
    sys.stdin = inputfile
    sys.stdout = outputfile

###Defines...###
mod=1000000007
 
###FUF's...###
def nospace(l):
    ans=''.join(str(i) for i in l)
    return ans
 
 
 
##### Main ####
t=1
for tt in range(t):
    #n=int(input())
    n,k= map(int, sys.stdin.readline().split(' '))
    a=list(map(int,sys.stdin.readline().split(' ')))
    ans=0
    for b in a:
        if(b>=k):
            ans+=1
    print(ans)
    
    
#####File Operations#####
if(fileoperation):
    sys.stdout = orig_stdout
    sys.stdin = orig_stdin
    inputfile.close()
    outputfile.close()

Measured memory_bytes: 11892
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr long long MOD = 1000000007;
constexpr long long INF = 1LL << 60;
const long double PI = acosl(-1.0);
constexpr long double EPS = 1e-11;
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;
}
template <typename T>
class SegmentTree
{
private:
  using Fn = function<T(T, T)>;
  int N;
  vector<T> dat;
  T unit;
  Fn func;

public:
  SegmentTree() {}
  SegmentTree(int n_, Fn func_, T unit_) : func(func_), unit(unit_)
  {
    N = 1;
    while (N < n_)
      N *= 2;
    dat.assign(2 * N - 1, unit);
  }
  SegmentTree(const vector<T> &v, Fn func_, T unit_) : func(func_), unit(unit_)
  {
    N = 1;
    int sz = v.size();
    while (N < sz)
      N *= 2;
    dat.resize(2 * N - 1);
    for (int i = 0; i < N; ++i)
      dat[i + N - 1] = (i < sz ? v[i] : unit);
    for (int i = N - 2; i >= 0; --i)
      dat[i] = func(dat[i * 2 + 1], dat[i * 2 + 2]);
  }

  // k 番目の要素を a に変更
  void update(int k, T a)
  {
    k += N - 1;
    dat[k] = a;
    while (k > 0)
    {
      k = (k - 1) / 2;
      dat[k] = func(dat[k * 2 + 1], dat[k * 2 + 2]);
    }
  }

  // k 番目の要素を取得
  T get(int k) { return dat[k + N - 1]; }

  // 区間 [l, r) の和を取得
  T query(int l, int r)
  {
    T vl = unit, vr = unit;
    for (l += (N - 1), r += (N - 1); l < r; l >>= 1, r >>= 1)
    {
      if ((l & 1) == 0)
        vl = func(vl, dat[l]);
      if ((r & 1) == 0)
        vr = func(vr, dat[--r]);
    }
    return func(vl, vr);
  }
};
int main(){
    ll n;
    cin >> n;
    auto great = [](ll a, ll b) { return __gcd(a, b); };
    SegmentTree<ll> sgt(n, great, 0);
    for (ll i = 0; i < n; i++) {
        ll t;
        cin >>t;
        sgt.update(i, t);
    }
    ll ans = 0;
    for (ll i = 0; i < n; i++) {
        ll tmp = __gcd(sgt.query(0, i), sgt.query(i + 1, n));
        chmax(ans, tmp);
    }
    cout << ans << endl;
}

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

int main()
{
    string s,t;
	int ans = 0;
    cin >> s >> t;

    for (int i = 0; i < s.size(); i++)
    {
       if (s[i] != t[i])
	   {
		   ans++;
	   }
    }
	cout << ans << endl;
    
}


Measured memory_bytes: 3836
#include<stdio.h>

int main(void){int i,n;int number;long long int sum = 0;int min =0;int max = 0;
scanf("%d",&n);
for(i=0;i<n;i++){scanf("%d",&number);if(i==0){min =number;max = number;}if(number<min) min = number;if(number>max) max = number;
sum += number;}
printf("%d %d %lld\n",min,max,sum);
return 0;}

Measured memory_bytes: 2728
#![allow(non_snake_case)]

use std::io::{stdin, Read};
use std::str::FromStr;
fn read_option<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok()
}
fn read<T: FromStr>() -> T {
    let opt = read_option();
    opt.expect("failed to parse token")
}

fn main() {
    let N: i32 = read();
    let K: i32 = read();
    println!("{}", ((N + (K - 1) - 1 - K) / (K - 1)) + 1)
}


Measured memory_bytes: 2144
//#pragma GCC target("avx2")
#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << "\n";
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;

const ll MOD = 1000000007;
//const ll MOD = 998244353;
struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%MOD+MOD)%MOD){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += MOD-a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= MOD;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime MOD
    mint inv() const {
        return pow(MOD-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        return mint(*this) /= a;
    }
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    int n;
    cin >> n;

    vector<int> a(n);
    REP(i, n) cin >> a[i];

    vector<int> ca;
    int prev = -1;
    REP(i, n) {
        if (prev == a[i]) continue;
        ca.pb(a[i]);
        prev = a[i];
    }

    vector<int> last(2e5 + 5, -1);
    vector<mint> dp(ca.size(), 0);
    dp[0] = 1;
    last[ca[0]] = 0;
    FOR(i, 1, ca.size()) {
        if (last[ca[i]] > -1) dp[i] += dp[last[ca[i]]];
        last[ca[i]] = i;
        dp[i] += dp[i - 1];
    }

    print(dp[ca.size() - 1]);
}


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

using namespace std;
typedef long long ll;
//ループ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//コンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
#define D()
//定数
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

//2値の最大公約数(順序関係なし・0はダメ)
int gcd(int a, int b){
    return b ? gcd(b, a%b) :a;
}

//n個の最大公約数
int ngcd(vector<int>& a){
    int res;
    res = a.at(0);
    for(int i = 1; i< a.size() && res != 1; i++){
        res = gcd(a.at(i), res);
    }
    return res;
}

//2値の最小公倍数
int lcm(int a, int b) {
    return a / gcd(a, b) * b;
}

//n個の最小公倍数
int nlcm(vector<int> numbers){
    int res;
    res = numbers.at(0);
    for(int i = 0; i< numbers.size();i++){
        res = lcm(res, numbers[i]);
    }
    return res;
}

//素数判定O(√N)
bool isPrime(int x){
    if(x<2) return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(int i = 3; i*i <= x; i+=2) if(x%i == 0) return 0;
    return 1;
}

//桁和
int digsum(int n){
    int res = 0;
    while(n>0){
        res += n%10;
        n /= 10;
    }
    return res;
}

//約数全列挙
vector<int> enum_div(int n){
    vector<int> ret;
    for(int i = 1 ; i*i <= n ; ++i){
        if(n%i == 0){
            ret.push_back(i);
            if(i != 1 && i*i != n){
                ret.push_back(n/i);
            }
        }
    }
    return ret;
}

//繰り返し自乗法
long long int mod_pow(long long int x, long long int n, long long int mod){
    long long int res = 1;
    while(n > 0){
        if(n & 1) res = res*x%mod;
        x = x*x%mod;
        n >>= 1;
    }
    return res;
}

//文字列の中で何回文字が出てきたのかを数える
int stringcount(string s, char c) {
    return count(s.cbegin(), s.cend(), c); //覚える
}

int main(){
    ll H, W, K;
    cin >> H >> W >> K;
    vector<string> c(H);
    ll ans = 0;

    REP(i,H) cin >> c.at(i);

    REP(i, 1<<H){
        REP(j, 1<<W){
            ll count = 0;
            REP(is, H){
                REP(js, W){
                    if((i>>is&1) == 0 && (j>>js&1) == 0 && c.at(is).at(js) == '#') count++;
                }
            }
            if(K==count) ans++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3612
m,a[9][2],S[2499];
D(d,s){int i=0;if(d==m)S[s]++;else for(;i<=a[d][1];i++)D(d+1,s+i**a[d]);}
main(i){for(;scanf("%d",&m),m;){
for(i=0;i<m;i++)scanf("%d%d",a[i],a[i]+1);
memset(S,0,9996);D(0,0);
for(scanf("%d",&i);i;i--)scanf("%d",&m),printf("%d\n",S[m]);
}exit(0);}

Measured memory_bytes: 616
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<(int)(n);i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

int main(){
    int n,c,b,a;
    cin >> n >> a >> b >> c;
    vector<int> l(n); rep(i,n) cin >> l[i];
    sort(all(l));


    int ans = INF;
    do{
        for(int i=1;i<=n;i++){
            int suma=0;
            for(int ii=0;ii<i;ii++) suma+=l[ii];
            int ca = (i-1)*10 + abs(a-suma);
            if(ca > ans) continue;

            for(int j=1;i+j<=n;j++){
                int sumb = 0;
                for(int jj=0;jj<j;jj++) sumb+=l[jj+i];
                int cb = (j-1)*10 + abs(b-sumb);
                if(ca + cb > ans) continue;

                for(int k=1;i+j+k<=n;k++){
                    ll sumc = 0;
                    for(int kk = 0;kk < k; kk++) sumc += l[i+j+kk];
                    int cc = (k-1)*10 + abs(c-sumc);
                    ans = min(ans,ca+cb+cc);
                }
            }
        }
    }while(next_permutation(all(l)));
    cout << ans << endl;
}


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


int main(){
    long long int n, k;
    scanf("%lld %lld", &n, &k);

    if (n < k){
        long long int menos = k - n;
        
        if (menos < n)
            printf("%lld\n", menos);
        else
            printf("%lld\n", n);
    }
    else if (n%k == 0)
        printf("0\n");

    else{
        long long int a = n%k;
        printf("%lld\n", k - a);
    }
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  string buf;
  while(getline(cin,buf),buf!=""){
    string s=buf;
    while(getline(cin,buf),buf!="") s+=buf;
    string a;
    getline(cin,a);
    //cout<<s<<endl<<a<<endl;
     
    int n=a.size();
    vector<int> pos[n];
    for(int i=0;i<(int)s.size();i++)
      for(int j=0;j<n;j++)
    if(s[i]==a[j]) pos[j].push_back(i);
 
    bool f=1;
    for(int i=0;i<n;i++) f&=!!(pos[i].size());
    if(!f){
      cout<<0<<endl<<endl;
      getline(cin,buf);
      continue;
    }
     
    int idx[n];
    memset(idx,0,sizeof(idx));
     
    int ans=0,len=s.size()+1,head=0;
    for(int i=0;i<(int)s.size();i++){
      int nxt=i;
      for(int j=0;j<n;j++)
    nxt=max(nxt,pos[j][idx[j]]);
 
      if(nxt-i+1<len) ans=0,len=nxt-i+1,head=i;
      if(nxt-i+1==len) ans++;
 
      for(int j=0;j<n;j++){
    if(s[i]==a[j]) idx[j]++;
    if(idx[j]>=(int)pos[j].size()) goto LAB;
      }
    }
     
  LAB:
    string str=s.substr(head,len);
     
    cout<<ans<<endl;
    for(int i=0;i<(int)str.size();i++){
      if(i%72==0) cout<<endl;
      cout<<str[i];
    }
    cout<<endl<<endl;;
    //ready for next;
    getline(cin,buf);
  }
  return 0;
}

Measured memory_bytes: 3608
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<math.h>
using namespace std;
int main() {
	int X, Y, Z;	cin >> X >> Y >> Z;
	int sum = 2 * Z + Y;
	int people = 1;
	while (true) {
		sum += (Y + Z);
		if (sum > X) {
			cout << people << endl;
			cin >> X;
			return 0;
		}
		++people;
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ll long long
#define deb(x) cout<<"["<<#x<<"="<<x<<"]"<<"\n";
#define FOR(a,b) for(ll i=a;i<b;++i)
#define read(x) for(auto& i:x)cin>>i

class MAIN
{
	public:
		void run()
		{
			ll t=1;//cin>>t;
			while(t--)
			{
				ll a,b,c,d;cin>>a>>b>>c>>d;
				vector<ll> n(4);
				n[0]=a*c;
				n[1]=a*d;
				n[2]=b*c;
				n[3]=b*d;
				sort(n.rbegin(),n.rend());
				cout<<n[0];
				cout<<"\n";
			}
		}	
};

int main()
{
	fast;
	MAIN solution;
	solution.run();
	return 0;
}

Measured memory_bytes: 3648
import java.util.*;
import java.util.ArrayList;
import java.util.Collections;

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

        int H = sc.nextInt();
        int W = sc.nextInt();
        String[] a = new String[H+2];
        a[0] = "";
        a[H + 1] = "";

        for(int i=1; i<=H; i++){
            a[i] = sc.next();
        }
        for(int i=1; i<=W; i++){
            a[0] += "#";
            a[H + 1] += "#";
        }
        

        for(int i=0; i<H+2; i++){
            System.out.println("#" + a[i] + "#");
        }
    }
}

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

using namespace std;

#define MOD 1000000007

#define ll long long

#define FOR(i, a, b) for (int i=a; i<(b); i++)

#define FORd(i, a, b) for (int i=a; i<(b); --i) 

int n;

void solve(){

    int ans=0;

    FOR (i,1,n) {

        FOR (j,1,n) {

            if (i*j>=n) break;

            ans++;

        }

    }

    cout << ans << "\n";

}

int main(){

    ios::sync_with_stdio(false);

    cin.tie(0);

    cin >> n;

    solve();

    return 0; 

}

Measured memory_bytes: 3660
n = int(input())
L = [int(i) for i in input().split()]
m = int(input())
LL = []
for i in range(m):
  LL.append([int(i) for i in input().split()])

for i in range(m):
  LLL = list(L)
  LLL[LL[i][0]-1] = LL[i][1]
  print(sum(LLL))

Measured memory_bytes: 3060
from collections import defaultdict, deque
n, m, k = map(int, input().split())
friends = defaultdict(set)
block = defaultdict(set)
for _ in range(m):
    a, b = map(int, input().split())
    friends[a].add(b)
    friends[b].add(a)
for _ in range(k):
    c, d = map(int, input().split())
    block[c].add(d)
    block[d].add(c)
#print(friends)
#print(block)

roopname = []
roop = defaultdict(set)
seen = [0]*n


for i in range(n):
    if not seen[i]==0:
        continue
    seen[i] = i+1
    roopname.append(i+1)
    roop[i+1].add(i+1)
    queue = deque(friends[i+1])
    while queue:
        p = queue.popleft()
        if  not seen[p-1]==0:continue
        seen[p-1] = i+1
        roop[i+1].add(p)
        for j in friends[p]:
            if seen[j-1]==0:
                queue.append(j)
#print(roopname)
#print(roop)
#print(seen)
ans = [len(roop[seen[i]])-len(roop[seen[i]]&friends[i+1])-len(roop[seen[i]]&block[i+1])-1 for i in range(n)]

    

L=[str(a) for a in ans]
L=" ".join(L)
print(L)

Measured memory_bytes: 144196
#include <cstdio>
#include <algorithm>

long long coins[] = {0, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1};
int main()
{
	char s[1000010];
	scanf("%s", s);
	long long a = coins[s[0] - '0'];
	long long b = coins[s[0] - '0' + 1];
	for (char* p = s + 1; *p; ++p)
	{
		long long a_, b_;
		const int d = *p - '0';
		a_ = std::min(a + coins[d], b + coins[10 - d]);
		b_ = std::min(a + coins[d + 1], b + coins[9 - d]);
		a = a_;
		b = b_;
	}
	printf("%lld\n", a);
	return 0;
}


Measured memory_bytes: 1152
a = list(map(int,input().split()))

def k5tok10(x):
    global k5
    global k10
    k5 -= 2*x
    k10 += x

def k5tok1(x):
    global k5
    global k1
    k5 -= x
    k1 += x*5

k1=0
k5=0
k10=0

k5 = a[1]//5000
k1 = (a[1]%5000)//1000

if k1+k5+k10 < a[0]:
    k5tok1(-(-(a[0]-(k1+k5+k10))//4))

if k1+k5+k10 > a[0]:
    k5tok10(k1+k5+k10 - a[0])

if k5 < 0:
    print(-1,-1,-1)
else:
    print(k10,k5,k1)

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

using namespace std;

typedef long long lli;
typedef double lld;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<double> vdl;
typedef vector<vector<lli>> mat;
typedef vector<vdl> mad;
typedef unordered_map<lli,unordered_map<lli,lli>> graph;
typedef complex<double> cmp;
typedef vector<cmp> vcl;

const lli e5 = 100009;

lli n;
lli a[e5];
lli b[e5];
unordered_map<lli,lli> m;
lli l;

class bit {
private:
	vll* v;
	lli n;
public:
	bit (lli n) {
		this->v = new vll(n+1);
		this->n = n;
	}
	void add(lli i,lli val){
		for(;i <= n;i += i&-i) this->v->at(i) += val;
	}
	lli sum(lli i){
		lli ret = 0;
		for(;i > 0;i -= i&-i) ret += this->v->at(i);
		return ret;
	}
};


lli solve(lli x){
	lli inversion = 0;
	bit bt(e5);
	for(lli i = 1;i <= n;i++){
		b[i] = a[i] <= x ? -1 : 1;
	}
	for(lli i = 1;i <= n;i++){
		b[i] += b[i-1];
	}
	vll u(n+1);
	cerr << "!" << endl;
	for(lli i = 0;i <= n;i++) u[i] = b[i];
	sort(u.begin(), u.end());
	for(lli i = 0;i <= n;i++){
		m[u[i]] = i+1;
	}
	cerr << "!" << endl;
	for(lli i = 0;i <= n;i++){
		inversion += bt.sum(m[b[i]]);
		bt.add(m[b[i]],1);
	}
	return inversion;
}

int main(){
	cin >> n;
	l = n*(n+1)/2;
	for(lli i = 1;i <= n;i++) cin >> a[i];
	lli ans = INT_MAX;
	for(lli i = 1ll << 30;i > 0;i >>= 1){
		cerr << i << endl;
		lli ge = solve((ans^i));
		if(l-ge > ge) ans = ans^i;
	}
	cout << ans << endl;
}


Measured memory_bytes: 35896
using System;
using System.Collections.Generic;
using System.Linq;
namespace ABC048_C
{
    class Program
    {
        static void Main(string[] args){
            var input = Console.ReadLine().Split(' ').Select(n => long.Parse(n)).ToArray();
            var N = input[0];
            var x = input[1];
            var a = Console.ReadLine().Split(' ').Select(n => long.Parse(n)).ToArray();
            long ans = 0L;

            for(var i = 0;i < N - 1;i++){
                if(a[i] > x){
                    ans += a[i] - x;
                    a[i] = x;
                }
                if(a[i] + a[i + 1] > x){
                    ans += (a[i] + a[i + 1]) - x;
                    a[i + 1] -= (a[i] + a[i + 1]) - x; 
                }
            }

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 31452
#include<bits/stdc++.h>
#define $$ long long int
#define pb push_back
#define db pop_back
#define q2(n) (n%2)==0
#define vp vector<pair <$$,$$> >
#define vctr vector<$$>
#define in(a) scanf("%lld",&a)
#define out(a) printf("%lld ",a)
#define loop(i,m,p) for ($$ i = m; i < p; i++)
#define loopn(i,m,p) for ($$ i = p-1; i >=m; --i)

using namespace std;


int main()
{
    $$ n;
    cin>>n;
    $$ k=0;
    $$ nn=n;
    while(nn>0){
        k+=(nn%10);
        nn/=10;
    }
//    $$ k=n%9;
//    if(k==0) k=9;
    if ((n%k)==0)
    {
    	cout<<"Yes";
    }
    else
    	cout<<"No";




return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const long long INF = (long long)1e18+1;
#define DIV 1000000007


int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef TEST
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
#endif
    long idx=0;
    long H, W;
    cin >> H >> W;
    std::vector<std::vector<string>> mat(H, vector<string>(W, ""));
    for(size_t i=0;i<H; i++)
    {
        string line;
        cin >> line;
        for(size_t j=0;j<W; j++)
        {
            mat[i][j] = line[j];
        }
    }
    std::vector<std::vector<long>> mat_L(H, vector<long>(W, 0));
    for(size_t i=0;i<H; i++)
    {
        long count = 0;
        for(size_t j=0;j<W; j++)
        {
            if(mat[i][j] == "#") count = 0;
            else count++;
            mat_L[i][j] = count;
        }
    }
    std::vector<std::vector<long>> mat_R(H, vector<long>(W, 0));
    for(size_t i=0;i<H; i++)
    {
        long count = 0;
        for(size_t j=W-1;j>=0; j--)
        {
            if(mat[i][j] == "#") count = 0;
            else count++;
            mat_R[i][j] = count;
            if(j==0) break;
        }
    }
    std::vector<std::vector<long>> mat_D(H, vector<long>(W, 0));
    for(size_t j=0;j<W; j++)
    {
        long count = 0;
        for(size_t i=0;i<H; i++)
        {
            if(mat[i][j] == "#") count = 0;
            else count++;
            mat_D[i][j] = count;
        }
    }
    std::vector<std::vector<long>> mat_U(H, vector<long>(W, 0));
    for(size_t j=0;j<W; j++)
    {
        long count = 0;
        for(size_t i=H-1;i>=0; i--)
        {
            if(mat[i][j] == "#") count = 0;
            else count++;
            mat_U[i][j] = count;
            if(i==0) break;
        }
    }
    long max_path = 0;
    for(size_t i=0;i<H; i++)
    {
        for(size_t j=0;j<W; j++)
        {
            if(mat[i][j] == ".")
            {
                max_path = max(max_path, -3+mat_L[i][j]+mat_R[i][j]+mat_U[i][j]+mat_D[i][j]);
            }
        }
    }
    cout << max_path << endl;
#ifdef TEST
    end = chrono::system_clock::now();
    cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
#endif
    return 0;
}

Measured memory_bytes: 346496
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
#include <math.h> 

using namespace std;

int main(void)
{
	int A, B, C;

	int K;

	cin >> A;
	cin >> B;
	cin >> C;

	cin >> K;

	if (A >= B && A >= C)
	{
		cout << B + C + (A*(pow(2, K)));
	}
	else if (B >= C)
	{
		cout << A + C + (B*(pow(2, K)));
	}
	else
	{
		cout << A + B + (C*(pow(2, K)));
	}

}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
	
		int row = sc.nextInt();
		int col = sc.nextInt();
		
		int h = sc.nextInt();
		int w = sc.nextInt();
		
		System.out.println((row * col) - ((col * h) + (row * w) - (h*w)));
	}
}


Measured memory_bytes: 23636
from collections import *
from heapq import*
import sys
input=sys.stdin.readline
d=defaultdict(list)
n=int(input())
 
for s in range(n-1):
    a,b,c=map(int,input().split())
    d[a].append([b,c])
    d[b].append([a,c])
#defaultdict(<class 'list'>, {1: [[2, 1], [3, 1]], 2: [[1, 1], [3, 3]], 3: [[1, 1], [2, 3]]})
 
def DIJKSTRA(point,d):
    cost      = {node:float("inf") for node in d.keys()}
    Q         = []  #頂点のリスト
    cost[point]=0  #開始地点のコストをゼロとする（当たり前
    heappush(Q,(point,cost[point]))
    while Q:
        prefnd,tmpC=heappop(Q)
        if cost[prefnd]<tmpC:
            continue
        for node,c in d[prefnd]:
            altC=c+tmpC
            if cost[node]>altC:
                cost[node]=altC
                heappush(Q,(node,altC))
    return cost
 
q,k=map(int,input().split())
y=DIJKSTRA(k,d)
 
for i in range(q):
    a,b=map(int,input().split())
    print(y[a]+y[b])

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

int main(){
    int h,w,cnt=0;
    cin >> h >> w;
    vector<string> a(h);
    rep(i,h){
        cin >> a[i];
    }
    queue<pair<int,int>> q;
    int dx[]= {1,0,-1,0};
    int dy[]= {0,1,0,-1};
    vector<string> checker (h);

    rep(i,h){
        string s="";
        rep(j,w) s+="#";
        checker[i]=s;
    }

    rep(i,h) rep(j,w){
        if(a[i][j]=='#')q.push({i,j});
    }
    while(!q.empty()){
        if( a==checker ) break;
        vector<pair<int,int>> vec;
        while(!q.empty()){
            int y = q.front().first;
            int x = q.front().second;
            vec.push_back({y,x});
            q.pop();
        }
        rep(i,vec.size()) rep(j,4){
            int ny = vec[i].first + dy[j];
            int nx = vec[i].second + dx[j];
            if (0<= ny && ny<h && 0<=nx && nx < w && a[ny][nx]=='.'){
                a[ny][nx]='#';
                q.push({ny,nx});
            }
        }
        ++cnt;
    }
    cout << cnt << endl;

}

Measured memory_bytes: 17516
N,A,B = map(int,input().split())

ans = 0

X = list(map(int,input().split()))

for i in range(N-1):

    if (X[i+1] - X[i]) * A > B:

        ans += B

    else:

        ans += (X[i+1] - X[i]) * A

print (ans)


Measured memory_bytes: 62704
#include <bits/stdc++.h>
#include <stdint.h>
#include <algorithm>
#include <vector>


using namespace std;

int main() {

	int n;
	cin >> n;
	
	vector<int> len(n,0);
	
	for (int i = 0; i < n; i++){
		cin >> len.at(i);
	}
	
	std::sort(len.begin(),len.end());
	
	int tmp = 0;
	
	for (int i = 0; i < n-1; i++) {
		tmp += len.at(i);
	}
	
//	cout << "dbg tmp " << tmp << endl;
//	cout << "dbg most long " << len.at(n-1) << endl;
	
	
	
	if(tmp > len.at(n-1)) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	
	return 0;
}


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

void solve(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if (a+b==c+d) cout << "Balanced" <<endl;
    else cout << (a+b>c+d?"Left":"Right")<<endl;
}

int main(){
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
template<unsigned int mod_>
struct ModInt{
	using uint = unsigned int;
	using ll = long long;
	using ull = unsigned long long;

	constexpr static uint mod = mod_;

	uint v;
	ModInt():v(0){}
	ModInt(ll v):v(normS(v%mod+mod)){}
	explicit operator bool() const {return v!=0;}
	static uint normS(const uint &x){return (x<mod)?x:x-mod;}		// [0 , 2*mod-1] -> [0 , mod-1]
	static ModInt make(const uint &x){ModInt m; m.v=x; return m;}
	ModInt operator+(const ModInt& b) const { return make(normS(v+b.v));}
	ModInt operator-(const ModInt& b) const { return make(normS(v+mod-b.v));}
	ModInt operator-() const { return make(normS(mod-v)); }
	ModInt operator*(const ModInt& b) const { return make((ull)v*b.v%mod);}
	ModInt operator/(const ModInt& b) const { return *this*b.inv();}
	ModInt& operator+=(const ModInt& b){ return *this=*this+b;}
	ModInt& operator-=(const ModInt& b){ return *this=*this-b;}
	ModInt& operator*=(const ModInt& b){ return *this=*this*b;}
	ModInt& operator/=(const ModInt& b){ return *this=*this/b;}
	ll extgcd(ll a,ll b,ll &x,ll &y) const{
		ll u[]={a,1,0},v[]={b,0,1};
		while(*v){
			ll t=*u/ *v;
			rep(i,3) swap(u[i]-=t*v[i],v[i]);
		}
		if(u[0]<0) rep(i,3) u[i]=-u[i];
		x=u[1],y=u[2];
		return u[0];
	}
	ModInt inv() const{
		ll x,y;
		extgcd(v,mod,x,y);
		return make(normS(x+mod));
	}
	bool operator==(const ModInt& b) const { return v==b.v;}
	bool operator!=(const ModInt& b) const { return v!=b.v;}
	friend istream& operator>>(istream &o,ModInt& x){
		ll tmp;
		o>>tmp;
		x=ModInt(tmp);
		return o;
	}
	friend ostream& operator<<(ostream &o,const ModInt& x){ return o<<x.v;}
};
using mint = ModInt<924844033>;

int N,K;
mint dp[2001][2001][2];	//i,num of put,put on previ
mint f[2001];
int main(){
	f[0]=1;
	rep1(i,2000) f[i]=f[i-1]*i;
	cin>>N>>K;
	dp[0][0][0]=1;
	vector<int> ord;
	rep(k,2*K){
		for(int x=k;x<N;x+=2*K) ord.pb(x);
	}
	rep(i,N){
		int v = ord[i];
		int pv = (i==0?-1:ord[i-1]);
		rep(j,i+1) rep(p,2) if(dp[i][j][p]){
			if(v-K>=0 && (v-pv!=2*K || !p) ){
				dp[i+1][j+1][0]-=dp[i][j][p];
			}
			if(v+K<N){
				dp[i+1][j+1][1]-=dp[i][j][p];
			}
			dp[i+1][j][0]+=dp[i][j][p];
		}
	}
	mint ans;
	rep(j,N+1){
		ans+=(dp[N][j][0]+dp[N][j][1])*f[N-j];
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 31488
import Data.List

gcd' :: Int -> Int -> Int
gcd' x 0 = x
gcd' x y = gcd' y (x `mod` y)

main = do
  line <- getLine
  let input = reverse . sort . map (read :: String -> Int) . words $ line
  putStrLn $ show $ gcd' (input !! 0) (input !! 1)

Measured memory_bytes: 3644
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons;

void main()
{
    auto abk = readln.split.to!(int[]);
    auto A = abk[0];
    auto B = abk[1];
    auto K = abk[2];

    int[] res;
    for (auto i = A; i < A + K && i <= B; ++i) {
        res ~= i;
    }
    for (auto i = B; i > B - K && i >= A; --i) {
        res ~= i;
    }
    sort(res);
    foreach (i; uniq(res)) writeln(i);
}

Measured memory_bytes: 256