akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define sz(v)   ((int)(v).size())
#define  all(v)    ((v).begin()),((v).end())
#define  allr(v)    ((v).rbegin()),((v).rend())
#define   pb         push_back
#define   mp         make_pair
#define    clr(v,d)      memset( v, d ,sizeof(v))
#define     PI                       acos(-1)
typedef  long long     ll ;
typedef  unsigned long long ull;
const double eps= (1e-9);
using namespace std;
int dcmp(long double a,long double b){   return fabsl(a-b)<=eps ? 0: (a>b)? 1:-1  ;}
int getBit(ll num, int idx) {return ((num >> idx) & 1ll) == 1;}
int setBit1(int num, int idx) {return num | (1<<idx);}
ll setBit0(ll num, int idx) {return num & ~(1ll<<idx);}
ll flipBit(ll num, int idx) {return num ^ (1ll<<idx);}
void GO(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);}
int countNumBit1(int mask) {int ret=0; while (mask) 	{mask &= (mask-1);++ret;	}return ret;}
const int N=200000+5,mod=1e9+7;
int l[N],r[N];
set< pair<int,int> > s;
multiset<int> ms;
int main(){
    GO();

    int n,m;
    cin>>n>>m;
    for(int i=0;i<n;i++){
        cin>>l[i]>>r[i];
        l[i]--;
        r[i]--;
    }
    for(int i=0;i<m;i++){
        s.insert(mp(i,i));
        ms.insert(0);
    }

    for(int i=0;i<n;i++){

        if(sz(s)==0){
            cout<<"-1\n";
            continue;
        }

        auto it= s.lower_bound(mp(l[i],-1));
        int mx=-1;
        while(it!=s.end()&&(*it).first<=r[i]){

            mx=max(mx,(*it).second);
            int diff = (*it).first-(*it).second;
            ms.erase(ms.find(diff));
            it=s.erase(it);

        }

        if(r[i]+1<m&&mx!=-1){
           // cout<<"mx "<<mx<<"\n";
            s.insert(mp(r[i]+1,mx));
            ms.insert(r[i]+1-mx);
        }
        if(sz(ms)==0){
            cout<<"-1\n";
            continue;
        }
        cout<<(*ms.begin())+i+1<<"\n";
    }
}





































































































































































































Measured memory_bytes: 23888
import java.util.*;

public class Main {
    static Scanner kbd = new Scanner(System.in);
    
    public static void main(String[] args) {	
	int n;
	while(kbd.hasNext()) {
	    n = kbd.nextInt();
	    if(n != 0)
		solve(n);
	}
    }

    static void solve(int n) {
	int x,max, min, i=n, point=0;
	x = kbd.nextInt();
	point += x;
	max = x;
	min = x;
	i--;
	while(i>0) {
	    x = kbd.nextInt();
	    point += x;
	    if(x > max) max = x;
	    if(x < min) min = x;
	    i--;
	}
	point = point - max - min;
	System.out.println(point/(n-2));
    }
}

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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

typedef long long ll;
typedef pair<int,long double> P;
typedef pair<ll,P> PP;

//-----------------------------------------------------------------------------

int n,a[100];

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

	cin>>n;
	REP(i,n) cin>>a[i];
	sort(a,a+n,greater<int>());
	int A=0,B=0;
	REP(i,n) {
		if(i&1) B+=a[i];
		else A+=a[i];
	}
	cout<<A-B<<endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
 
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3") 
#pragma GCC optimization ("unroll-loops")
 
// #include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
// const ll RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count();
// gp_hash_table<int, int> table;
 
#define ll  long long
#define vii vector< ll >
#define pb push_back
#define pii pair<ll,ll>
#define ppi pair<pii,ll>
#define all(x) x.begin(),x.end()
#define S second
#define F first
#define ins insert
#define ld long double
#define lp(l,r) for(i=l;i<=r;++i)
 
#define lpj(l,r) for(j=l;j<=r;++j)
#define lpr(l,r) for(i=r;i>=l;--i)
#define lprj(l,r) for(j=r;j>=l;--j)
 
#define swap(a,b){ auto _t=a;a=b,b=_t;}
#define flush() cout.flush()
#define popcount __builtin_popcount
#define die() return 0;
#define sz() size() 


 
 
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 
#define MD          1000000007
#define M 			200011
#define LN             14
#define fftmod      998244353
#define EPS         (double)1e-10
 
long long  md=MD;
ll inf=1e18;
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); 
 
 
inline ll exp(ll a,ll b){if(a==0&&b==0)return 1ll;if(a==0)return 0ll;ll r=1LL;while(b>0){if(b&1){r=(r%md)*(a%md);r=(r+md)%md;}b/=2;a=(a%md)*(a%md);a=(a+md)%md;}return (r+md)%md;}
ll gcd(ll a,ll b){if(b==0)return a;if(a==0)return b;return gcd(b,a%b);}
inline ll poww(ll a,ll b){ll r=1LL;while(b>0){if(b&1)r=r*a;b/=2;a=a*a;}return (ll)r;}
 
using cd=complex<double>;
const double PI=acos(-1);
 
inline ll rand(ll l,ll r){
    return l+rng()%(r-l+1);
}


int main(){
 
     
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
 
 
   // ifstream fin("input.txt");ofstream fout("outut.txt");
    ll t,i,j,m,n,s,z,k,p;string s1,s2;ll q;ll x,y;
    cin>>n;
    vector<ld> v;
    lp(1,n){
    	ld c;cin>>c;v.pb(c);
    }
    ld d1,d2=0;
    for(i=0;i<n;++i){
    	ld p1=1,p2=1;
    	for(j=0;j<n;++j){
    		if(i!=j)p2*=v[j];
    			p1*=v[j];
    	}
    	d1=p1;
    	d2=d2+p2;
    }
    d1=d1/d2;
    cout<<setprecision(14)<<d1<<"\n";


    





    	






    

}



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

int main(){
    int n,k;
    cin>>n>>k;
    string s;
    cin>>s;
    int p=0;
    rep(i,n-1){
        if(s[i]!=s[i+1]) p++;
    }
    p=max(p-2*k,0);
    cout<<n-1-p<<endl;
}

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

using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector <string> vs;

#define forl(i,a,b) for (int i = a; i < b; i++)
#define rfor(i,b,a) for (int i = b; i >= a; i--)
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define srt(x) sort(x.begin(), x.end())
#define sumup(x) accumulate(x.begin(), x.end(), 0)
#define PI 3.141592653589793238
#define MOD 1000000007

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a, b, c, k, ans;
    cin>>a>>b>>c>>k;
    if(k<=a) ans = k;
    else if(k>a && k<=a+b) ans = a;
    else if(k>a+b && k<=a+b+c) ans = a - (k - (a+b));
    //else if(k>a+b+c) ans = a-c;
    cout<<ans<<"\n";
}

Measured memory_bytes: 3660
#include<stdio.h>
#include<cstdio>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<string.h>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<time.h>
#include<set>
#include<map>
#include <iomanip>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>b;i--)
#define vint vector<int> 
#define vvint vector<vint>
#define CST(x) cout<<fixed<<setprecision(x)//小数点以下の桁数指定
#define ct(a) cout<<a<<endl
static const double pi = 3.141592653589793;
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
#define MAX 200000
#define NIL -1

int K;
long long cnt;
int dp[201][201];


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

int ans;

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

	cin >> K;


	FOR(i, 1, 201) {
		FOR(j, 1, 201) {
			dp[i][j] = gcd(i, j);
		}
	}

	FOR(i, 1, K+1) {
		FOR(j, 1, K+1) {
			FOR(k, 1, K+1) {
				int cur = dp[i][j];
				ans += dp[cur][k];
			}
		}
	}

	cout << ans << endl;

	system("pause");
	return 0;
}


Measured memory_bytes: 3320
#include<algorithm>
#include<vector>
#include<cmath>

#define MAX_N 1001

using namespace std;

int BinSearch(int v[], int vsize, int search){
	int l = 0;
	int r = vsize;
	int m = 0;
	if( v[r - 1] < search ){
		return r - 1;
	}else if(v[1] > search ){
		return 0;
	}
	while( r - 1 > l ){
		m = (r + l) / 2;

		if( v[m] > search ){
			r = m;
		}else if(v[m] == search){
			return m;
		}else{
			l = m;
		}
	}
	return m;
}

void Merge(int a[], int p ,int q, int r){
	int i, j;
	int n1 = q - p;
	int n2 = r - q;
	int *L = (int *)malloc(sizeof(int)*n1);
	int *R = (int *)malloc(sizeof(int)*n2);

	for(i = 0; i < n1; i++)
		L[i] = a[p + i];

	for(j = 0; j < n2; j++)
		R[j] = a[q + j];

	i = 0;
	j = 0;

	for(int k = p; k < r; k++){
		if( i == n1 ){
			while( j < n2 ){
				a[k] = R[j];k++;j++;
			}
			break;
		}else if( j == n2 ){
			while( i < n1 ){
				a[k] = L[i];k++;i++;
			}
			break;
		}else{
			if( L[i] <= R[j] ){
				a[k] = L[i];
				i++;
			}else{
				a[k] = R[j];
				j++;
			}
		}
	}

	free(L);
	free(R);
}

void InsertionSort(int *a, int n){
	for(int i = 1; i < n; i++){
		int v = a[i], j;
		for(j = i; j > 0; j--)
			if( v < a[j - 1])
				a[j] = a[j - 1];
			else
				break;
		a[j] = v;
	}
}

void MergeSort(int a[], int p, int r){
	if( p < r ){
		if( r - p < 10 ){
			InsertionSort(a + p, r - p);
			return ;
		}
		int q = (p + r) / 2;
		MergeSort(a, p, q);
		MergeSort(a, q, r);
		Merge(a, p, q, r);
	}
}

int main(void){
	while( true ){
		int prevQ = -1;
		int index = 0;
		int Max = 0;
		int N, M;
		int *Q;
		int V[MAX_N];

		cin >> N >> M;
		
		if( N == 0 && M == 0 ){
			break;
		}

		for(int i = 0; i < N; i++){
			cin >> V[i];
		}
		V[N] = 0;
		N++;

		Q = new int[N*N];

		for(int i = 0; i < N; i++){
			for(int j = 0; j < N; j++){
				Q[i * N + j] = V[i] + V[j];
			}
		}
		//cout << "Sorting..." << endl;
		/*for(int i = 0; i < N * N; i++){
			cout << Q[i] << '\n';
		}*/
		
		MergeSort(Q, 0, N * N);
		//stable_sort(Q.begin(), Q.end());

		//cout << "Sorted:" << endl;
		/*for(int i = 0; i < N * N; i++){
			cout << Q[i] << '\n';
		}*/

		//cout << "Uniqing..." << endl;
		//Uniq( Q );

		for(int i = 0; i < N * N; i++){
			//cout << Q[i];
			if( prevQ == Q[i] ){
				continue;
			}else{
				prevQ = Q[i];
			}
			int optim = BinSearch(Q, N*N, M - Q[i]);
			//cout << ' ' << optim << ":" << Q[optim] << '\n';
			if( optim > 0 && Q[i] + Q[optim] > M) optim--;
			Max = max( Max , Q[i] + Q[optim] > M ? 0 : Q[i] + Q[optim]);
		}

		delete[] Q;
		cout << Max << '\n';
	}
	return 0;
}

Measured memory_bytes: 8868
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Map;
import java.util.Queue;
import java.util.Set;
import java.util.StringTokenizer;

public class Main {
	// AtCoder Beginner Contest 121
	// https://atcoder.jp/contests/abc121/tasks
	public static void main(String[] args) {
		FastReader sc = new FastReader();
		int H = sc.nextInt();
		int W = sc.nextInt();
		int h = sc.nextInt();
		int w = sc.nextInt();
		
		System.out.println((H-h)*(W-w));
	}
	
	static class FastReader { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() { 
            br = new BufferedReader(new InputStreamReader(System.in)); 
        } 
  
        String next() { 
            while (st == null || !st.hasMoreElements()) { 
                try { 
                    st = new StringTokenizer(br.readLine()); 
                } catch (IOException  e) { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() { 
            String str = ""; 
            try{ 
                str = br.readLine(); 
            } catch (IOException e) { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
}


Measured memory_bytes: 21204
H=int(input())+1
A=[0]+list(map(int,input().split()))
def h(i):
 l=2*i;r,g=l+1,[i,l][l<H and A[i]<A[l]]
 if r<H and A[g]<A[r]:g=r
 if g!=i:A[i],A[g]=A[g],A[i];h(g)
for i in range(H//2,0,-1):h(i)
print(' '+' '.join(map(str,A[1:])))


Measured memory_bytes: 64176
#include<stdio.h>
#include<iostream>
#include<math.h>
#include<stdlib.h>
using namespace std;


int main(){
    int a,b,x;
    cin>>x>>a>>b;
    a=abs(x-a);
    b=abs(x-b);
    if(a<b){
        cout<<"A";
    }
    else{
        cout<<"B";
    }

    return 0;

}


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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;


int main() {
    while(1){
        list<pair<int,int>> cakes;
        int n,w,d; cin >> n >> w >> d;

        if(n==0 && w==0 && d==0){
            return 0;
        }
        cakes.push_back(make_pair(w,d));
        
        REP(i,n){
            int p,s;
            cin >> p >> s;
            p--;
            auto itr = cakes.begin();
            REP(k,p) itr++;
            pair<int,int> piece = *itr;
            cakes.erase(itr);

            int W = piece.first;
            int H = piece.second;
            s %= (W+H);

            if(s<W){
                cakes.push_back(make_pair(min(s,W-s), H));
                cakes.push_back(make_pair(max(s,W-s), H));
            }else{
                s = s-W;
                cakes.push_back(make_pair(W, min(s,H-s)));
                cakes.push_back(make_pair(W, max(s,H-s)));

            }
        }
        
        

        vector<int> result;
        int sizes = cakes.size();
        REP(i,sizes){
            pair<int,int> P = *cakes.begin();
            cakes.pop_front();
            result.push_back(P.first * P.second);
        }

        sort(ALL(result));
        REP(i,result.size()){
            int ans = result[i];
            cout << ans;
            if(i != result.size()-1){
                cout << " ";
            }
        }
        cout << endl;
    }
    

    return 0;
}


Measured memory_bytes: 3164
#include <bits/stdc++.h>
#define VI vector<int>
#define VVI vector<vector<int>>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define MOD 1000000007
#define INF 1e18
#define All(x) (x).begin(), (x).end()
typedef long long ll;
using namespace std;

int main() {
  double r;
  cin >> r;
  printf("%lf %lf\n", r * r * acos(-1), 2 * r * acos(-1));

  return 0;
}



Measured memory_bytes: 3196
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int w = sc.nextInt();
		int n = sc.nextInt();
		int[] values = new int[w];
		for(int i=0;i<values.length;i++){
			values[i] = i + 1;
		}
		for(int i = 0;i<n;i++){
			String str = sc.next();
			String[] ab = str.split(",");
			int a = Integer.parseInt(ab[0]) -1;
			int b = Integer.parseInt(ab[1]) -1;
			int temp = values[a];
			values[a] = values[b];
			values[b] = temp;
		}
		for(int i = 0;i<w;i++){
			System.out.println(values[i]);
		}
	}
}

Measured memory_bytes: 26328
from collections import deque
N, D, A = map(int, input().split())

ys = []
hs = []
for i in range(N):
    X, H = map(int, input().split())
    ys.append((X,i))
    hs.append(-(-H//A))

ys = sorted(ys, key=lambda x : x[0])
l = ys[0][0] + 2*D
li = 0
dmg = 0
r = 0
for y, i in ys:
    while (not l >= y):
        li += 1
        l = ys[li][0] + 2*D
        dmg -= hs[ys[li-1][1]]
    tr = max(0, hs[i]-dmg)
    hs[i] = tr
    dmg += tr
    r += tr
print(r)


Measured memory_bytes: 89944
from itertools import *

def binary_search(t, v, first, last):
	if last - first == 1:
		if v[first] > t:
			return first
		else:
			return last
	
	mid = (first + last) / 2
	if v[mid] <= t:
		return binary_search(t, v, mid, last)
	else:
		return binary_search(t, v, first, mid)

def ABC143D():
	N = int(raw_input())
	v = sorted(map(int, raw_input().split()))
	
	counter = 0
	for k, l in combinations(range(1, N), 2):
		# a <= b and a+b > c
		# a : (c-b, b]
		b = v[k]
		c = v[l]
		if b*2 < c:
			continue
		counter += k - binary_search(c-b, v, 0, k)
	print counter

ABC143D()


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

def matmul(a, b, mod):
    m = len(a)
    l = len(a[0])
    n = len(b[0])
    ret = [[0] * n for _ in range(m)]
    for i in range(m):
        for j in range(n):
            e = 0
            for k in range(l):
                e = (e + a[i][k] * b[k][j]) % mod
            ret[i][j] = e
    return ret

mod = 10**9+7
N, K = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(N)]
ans = [[i == j for j in range(N)] for i in range(N)]
while K > 0:
    if K & 1 == 1:
        ans = matmul(ans, a, mod)
    a = matmul(a, a, mod)
    K >>= 1
print(sum(sum(row) % mod for row in ans) % mod)

Measured memory_bytes: 43244
n, m, x, y = list(map(int, input().split()))
x_li = list(map(int, input().split()))
y_li = list(map(int, input().split()))
ans_f = 0
for z in range(x + 1, y + 1):
    x_not_f = 0
    y_not_f = 0
    for i in x_li:
        if z <= i:
            x_not_f = 1
    for i in y_li:
        if z > i:
            y_not_f = 1
    if x_not_f == 0 and y_not_f == 0:
        ans_f = 1
        break

if ans_f == 1:
    print("No War")
else:
    print("War")


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

using namespace std;

#define DUMP(x) std::cerr << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()
#define YES puts("YES")
#define Yes puts("Yes")
#define NO puts("NO")
#define No puts("No")
#define IMP puts("IMPOSSIBLE")
#define Imp puts("Impossible")
#define imp puts("impossible")
#define M1 puts("-1")
#define pb push_back

template <typename T>
ostream &operator<<(ostream &os, vector<T> &v)
{
    os << "{";
    rep(i, v.size()) os << v[i] << (i == (int)v.size() - 1 ? "" : ", ");
    os << "}";
    return os;
}
template <typename T>
T dup(T x, T y)
{
    return (x + y - 1) / y;
};
template <typename A, size_t N, typename T>
inline void arrayFill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }
struct in
{
    const size_t n = 0;
    in() = default;
    in(size_t n) : n(n){};
    template <typename T>
    operator T()
    {
        T ret;
        cin >> ret;
        return ret;
    }
    template <typename T>
    operator vector<T>()
    {
        assert(n != 0);
        vector<T> ret(n);
        for (auto &x : ret)
            cin >> x;
        return ret;
    }
};

using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using pll = pair<ll, ll>;
using setint = set<int32_t>;
using setstr = set<string>;
using qint = queue<int32_t>;
using qpint = queue<pint>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

void Main()
{
    ll a, b, k;
    cin >> a >> b >> k;
    ll aa = max(a - k, (ll)0);
    ll kk = max(k - a, (ll)0);
    ll bb = max(b - kk, (ll)0);
    cout << aa << " " << bb << endl;
}

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


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

int main()
{
  int k;
  cin>>k;
  string str;
  cin>>str;

  long long int x = 0, max = 0;

  for(unsigned long long int i = 0; i<str.size(); i++)
  {
    if(str[i] == 'I')
    x++;
    else if(str[i] =='D')
    x--;
    if(x > max)
    max = x;
  }
  cout<<max<<endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
  int H,W,A,B;
  cin >> H >> W >> A >> B;

  for(int h=0;h<H;h++){
    for(int w=0;w<W;w++){
      if((h<B && w<A)||(h>=B && w>=A))cout << 0;
      else cout << 1;
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 1280
//--- pA ---//
import java.util.*;
import java.lang.*;
import java.io.*;
public class Main {
	public static void main (String[] args) throws java.lang.Exception {
		new Solution();
	}
}
class Solution {
	Reader reader;
	PrintWriter out;
	public Solution() {
		reader = new Reader();
		out = new PrintWriter(System.out);
		while (reader.hasNext()) {
			run_case();
		}
		out.flush();
	}

	private void run_case() {
		int a = reader.ni();
		int b = reader.ni();
		int c = a * b;
		out.println(c);
		return;
	}
}


class Reader {
	BufferedReader br;
	StringTokenizer st;
	public Reader(){
		try {
			br = new BufferedReader(new InputStreamReader(System.in));
			st = new StringTokenizer(br.readLine());
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	public String next() {
		if (st.hasMoreTokens()) return st.nextToken();
		try {
			st = new StringTokenizer(br.readLine());
		} catch (Exception e) {
			e.printStackTrace();
		}
		return st.nextToken();
	}
	public boolean hasNext() {
		try {
			if (!st.hasMoreTokens() && !br.ready()) return false;
			else return true;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return false;
	}
	public int ni() {return Integer.parseInt(this.next());}
	public long nl() {return Long.parseLong(this.next());}
	public String ns() {return this.next();}
}


Measured memory_bytes: 32920
S = gets.chomp.split("")

tmp1 = []
tmp2 = []

S.size.times do |i|
  tmp1 << (i.even? ? "0" : "1")
end

S.size.times do |i|
  tmp2 << (i.odd? ? "0" : "1")
end

count1 = 0
S.size.times do |i|
  unless S[i] == tmp1[i]
    count1 += 1
  end
end

count2 = 0
S.size.times do |i|
  unless S[i] == tmp2[i]
    count2 += 1
  end
end

p [count1,count2].min


Measured memory_bytes: 16892
from sys import stdin
from collections import deque, Counter, defaultdict
import heapq

INF = int(1e10)
MOD = int(1e9 + 7)

def input():
    return stdin.readline()[:-1]

class Dijkstra:
    def __init__(self, rote_map, start_point, goal_point=None):
        self.rote_map = rote_map
        self.start_point = start_point
        self.goal_point = goal_point

    def execute(self):
        num_of_city = len(self.rote_map)
        dist = [float("inf") for _ in range(num_of_city)]
        prev = [float("inf") for _ in range(num_of_city)]

        dist[self.start_point] = 0
        heap_q = []
        heapq.heappush(heap_q, (0, self.start_point))
        while len(heap_q) > 0:
            prev_cost, src = heapq.heappop(heap_q)

            if dist[src] < prev_cost:
                continue

            for dest, cost in self.rote_map[src].items():
                if cost != float("inf") and dist[dest] > dist[src] + cost:
                    dist[dest] = dist[src] + cost
                    heapq.heappush(heap_q, (dist[dest], dest))
                    prev[dest] = src
        return prev

    def get_path(self, goal, prev):
        path = [goal]
        dest = goal

        while prev[dest] != float("inf"):
            path.append(prev[dest])
            dest = prev[dest]

        return list(reversed(path))

def main():
    from builtins import int, map
    n, m = map(int,input().split())
    route_map = [dict() for _ in range(n)]
    for i in range(m):
        u, v = map(int, input().split())
        u, v = u - 1, v - 1
        route_map[u][v] = 1
        route_map[v][u] = 1

    prev = Dijkstra(route_map, 0).execute()
    print("Yes")
    for i in range(1, n):
        print(prev[i] + 1)

if __name__ == '__main__':
    main()

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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

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

//ａをbで割る
long long mod_div(long long a,long long b){
	long long tmp = MOD - 2,c = b,ret = 1;
	while(tmp > 0){
		if(tmp & 1){
			ret *= c;ret %= MOD;
		}
		c *= c;c %= MOD;tmp >>= 1;
	}
	return a*ret%MOD;
}

#define MAX_K 333333
vector<long long> kaijo(MAX_K);
long long combination(long long n, long long r){
    if(n < r || n < 0 || r < 0)
        return 0;
	if(kaijo[0] != 1){
		kaijo[0] = 1;
		for(long long i = 1;i < MAX_K;i++)kaijo[i] = (kaijo[i-1] * i) % MOD;
	}
    long long ret = kaijo[n];
	long long tmp = (kaijo[r] * kaijo[n-r]) % MOD;
    return mod_div(ret,tmp);
}

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

	ll n, m;cin >> n >> m;
	ll ans = 1;

	for(ll i = 2;i * i <= m;i++){
		if(m % i)continue;
		int cou = 0;
		while(m % i == 0){
			cou++;
			m /= i;
		}
		ans *= combination((n-1) + cou, cou);
		ans %= MOD;
	}

	if(m > 1){
		ans *= n;
		ans %= MOD;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 2816
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T> ostream& operator<<(ostream& s,const multiset<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1'000'000'007;
const ll inf=1'000'000'000'000'000'00;
const int INF=1'000'000'000;
const double EPS=1e-10;
const double PI=acos(-1);

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int h,w;
    cin>>h>>w;
    set<Pi> st;//(今の位置,出発地点)
    multiset<int> mst;
    rep(i,w){
        st.insert(Pi(i,i));
        mst.insert(0);
    }
    rep(i,h){
        int l,r;
        cin>>l>>r;
        l--,r--;
        auto itr=st.lower_bound(Pi(l,-1));
        int ne=-1;
        while(itr!=st.end() && itr->fi<=r){//今の地点が[l[i],r[i]]のときは開始位置が大きいやつをr[i]+1に残せばok
            chmax(ne,itr->se);
            mst.erase(mst.find(itr->fi-itr->se));
            itr=st.erase(itr);
        }
        if(ne!=-1 && r+1<w){
            st.insert(Pi(r+1,ne));
            mst.insert(r+1-ne);
        }
        if(mst.empty()) cout<<-1<<endl;
        else cout<<(i+1)+*mst.begin()<<endl;
    }
}

Measured memory_bytes: 22420
#include<iostream>
#include<algorithm>

using namespace std;

void koukan(int*,int*,int,int );

int n,m;

int main(){
	while(1){
		int goukei=0,goukei_t=0;
		cin>>n>>m;
		if(!n&&!m)	break;

		int *taro=new int[n];
		int *hanako=new int [m];
		for(int i=0;i<n;i++){
			cin>>taro[i];
			goukei+=taro[i];
			goukei_t+=taro[i];
		}
		for(int j=0;j<m;j++){
			cin>>hanako[j];
			goukei+=hanako[j];
		}
		if(goukei%2==1){
			delete[] hanako;
			delete[]taro;
			cout<<-1<<endl;
			continue;
		}
		goukei/=2;
		koukan(taro,hanako,goukei,goukei_t);
		delete[] hanako;
		delete[] taro;
	}
	return 0;
}
void koukan(int *taro,int *hanako,int goukei,int tarou_mix){
	int mix=1000000;
	int cnt=0;
	pair<int,int> p[100];
	for(int i=0;i<n;i++)
		for(int j=0;j<m;j++){
			if((tarou_mix-taro[i]+hanako[j])==goukei){
				if(mix>(taro[i]+hanako[j])){
					mix=taro[i]+hanako[j];
					p[cnt].first=taro[i];
					p[cnt].second=hanako[j];
					cnt++;
					
				}
			}
		}
	if(cnt){
		cout<<p[cnt-1].first<<" "<<p[cnt-1].second<<endl;
		return;
	}
	cout<<-1<<endl;
}

Measured memory_bytes: 1200
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORR(i, m, n) for (int i = m; i >= n; --i)
#define ALL(v) (v).begin(),(v).end()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
const int inf=(1<<30)-1;
const int mod=1e9+7;
int dx[8]={1,0,-1,0,-1,-1,1,1};
int dy[8]={0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k;cin >> n >> k;
    vector<int> c(n);
    REP(i,n){
        int a;cin >> a;
        a--;
        c[a]++;
    }
    sort(ALL(c));
    reverse(ALL(c));
    int sum=0;
    REP(i,k){
        sum+=c[i];
    }
    cout << n-sum << endl;
}

Measured memory_bytes: 3932
#include <iostream>
using namespace std;
int main(void) {
	int A, B, K;
	cin >> A >> B >> K;
	for (int i = 0; i < K; ++i) {
		if (i % 2 == 0) {
			if (A % 2 == 1) --A;
			B += A / 2;
			A /= 2;
		}
		else {
			if (B % 2 == 1) --B;
			A += B / 2;
			B /= 2;
		}
	}
	cout << A << " " << B << endl;
	return 0;
}

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

using namespace std;

#define int long long
#define endl '\n'
#define MOD 1000000007
#define maxn 30

char mat[maxn][maxn];

int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
bool visited[30][30];
int h, w;
int dist[maxn][maxn];

bool isValid(int a, int b) {
    return a >= 0 and a < h and b >= 0 and b < w;
}

int bfs(int a, int b) {
    memset(visited, false, sizeof visited);
    memset(dist, 0, sizeof dist);
    queue<pair<int, int>> q;
    q.push({a, b});
    visited[a][b] = true;
    dist[a][b] = 0;

    while (!q.empty()) {
        int x = q.front().first;
        int y = q.front().second;
        q.pop();

        for (int i = 0; i < 4; i++) {
            int xx = x + dx[i];
            int yy = y + dy[i];

            if (isValid(xx, yy) and !visited[xx][yy] and mat[xx][yy] == '.') {
                dist[xx][yy] = dist[x][y] + 1;
                visited[xx][yy] = true;
                q.push({xx, yy});
            }
        }
    }
    int ans = 0;
    for (int i = 0; i < h; i++)
        for (int j = 0; j < w; j++)
            ans = max(ans, dist[i][j]);
    return ans;
}

void solve() {
    cin >> h >> w;

    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> mat[i][j];
        }
    }
    int ans = 0;
    for (int i = 0; i < h; i++)
        for (int j = 0; j < w; j++) {
            if (mat[i][j] == '.') {
                ans = max(ans, bfs(i, j));
            }
        }
    cout << ans << endl;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
//    cin >> t;

    while (t--)
        solve();
    return 0;
}

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

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n,k;
    while(cin >> n >> k) {
        int ans = k;
        for(int i = 1; i < n; i++) {
            ans *= k-1;
        }
        cout << ans << '\n';
    }
    return 0;
}

Measured memory_bytes: 256
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
typedef long long ll;

int main(){
    int n ; 
    cin >> n ; 
    vector<ll> v(100) ;
    v[0] = 2 ; 
    v[1] = 1 ; 
    for(int i=2;i<=n;i++){
    	v[i] = v[i-1] + v[i-2] ; 
    }
    cout << v[n] << endl;
    return 0 ;
}


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

int main(){
  int N;
  cin >> N;
  vector<ll> left(N);
  vector<ll> right(N);
  vector<ll> A(N);
  rep(i, N){
    cin >> A.at(i);
  }
  rep(i, N){
    if(i == 0){
      left.at(i) = A.at(i);
      right.at(i) = A.at(i);
    }
    else{
      left.at(i) = (left.at(i - 1) + A.at(i)) % MOD;
      right.at(i) = A.at(i);
    }
  }
  ll sum = 0;
  rep(i, N - 1){
    sum += ((left.at(i) % MOD) * right.at(i + 1) % MOD);
    sum %= MOD;
  }
  cout << sum << endl;
    
}


Measured memory_bytes: 7980
#pragma GCC optimize ("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
using namespace std;
using Int = long long;
typedef pair<int,int> P; typedef pair<Int,Int> Pl;
const int mod = 1e9+7;
static constexpr Int Inf = numeric_limits<Int>::max();
#define END {cout<<ans<<'\n'; return 0;}
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
#define mp make_pair
#define Pr(t) priority_queue<t>
#define gPr(t) priority_queue<t,vector<t>,greater<t>>
#define V(t) vector<t>
#define rep(i,n) for(int(i)=0; i<n; i++)
#define rer(i,l,r) for(int i=l; i<=r; i++)
#define gnr(i,l,r) for(int i=r; i>=l; i--)
#define eb emplace_back
#define pri1(a) cout<<(a)<<'\n'
#define pri2(a,n) {rep(pri2i,n-1)cout<<a[pri2i]<<' '; cout<<a[n-1]<<'\n';}
#define prip(p) cout<<p.fi<<' '<<p.se<<'\n'
template<class T> inline bool cmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool cmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int n,m,_,x,y,q;
string s,sb;
bool ok;
char ch;

template< typename T >
struct edge {
  int fr, to;
  T w;

  edge(int fr, T w) : fr(-1), to(to), w(w) {}

  edge(int fr, int to, T w) : fr(fr), to(to), w(w) {}

  edge &operator=(const int &x) {
    to = x;
    return *this;
  }

  operator int() const { return to; }
};

template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WeightedGraph = vector< Edges< T > >;
using UnWeightedGraph = vector< vector< int > >;
template< typename T >
using Matrix = vector< vector< T > >;

template< typename T >
vector< T > bellman_ford(Edges< T > &edges, int N, int fr) {
  static constexpr T INF = numeric_limits<T>::max();
  vector< T > dist(N, INF);
  dist[fr] = 0;
  for(int i = 0; i < N; i++) {
    bool upd = 0;
    for(auto e : edges) {
      if(dist[e.fr] == INF) continue;
      if(dist[e.fr] + e.w < dist[e.to]){
        dist[e.to] = dist[e.fr] + e.w;
        upd=1;
      }
    }
    if(!upd)break;
  }
  return dist;
}

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

  cin>>n>>m; Edges<Int>g;
  rep(i,m){
    cin>>x>>y>>q;
    g.eb(x-1,y-1,-q);
  }
  V(Int)d=bellman_ford(g,n,0);
  V(bool)nega(n,0);
  rep(i,n)for(auto e:g){
    if(d[e.fr]==Inf)continue;
    if(cmin(d[e.to],d[e.fr]+e.w)){
      nega[e.to]=1;
    }
    if(nega[e.fr])nega[e.to]=1;
  }
  if(nega[n-1])pri1("inf");
  else pri1(-d[n-1]);
}

Measured memory_bytes: 384
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;
typedef long long LL;

int main()
{
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	char s[20];
	scanf("%s",s);
	if(s[0] == s[2]) printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 384
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<vector>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#define ll long long
#define F(i,a,b) for(int i=(a);i<=(b);i++)
#define mst(a,b) memset((a),(b),sizeof(a))
#define PII pair<int,int>
using namespace std;
template<class T>inline void read(T &x) {
    x=0; int ch=getchar(),f=0;
    while(ch<'0'||ch>'9'){if (ch=='-') f=1;ch=getchar();}
    while (ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}
    if(f)x=-x;
}
const int inf=0x3f3f3f3f;
const int maxn=1050;
const int maxm=20000010;
int h,n,v[maxn],w[maxn],m,f[maxm];
int main()
{
	cin>>h>>n;
	m=2*h;
	memset(f,0x3f,sizeof(f));
	f[0]=0;
	for(int i=1;i<=n;i++) cin>>v[i]>>w[i],m=max(v[i],m);
	for(int i=1;i<=n;i++)
	{
		for(int j=v[i];j<=m;j++)
			f[j]=min(f[j],f[j-v[i]]+w[i]);	
	}
	int ans=inf;
	for(int i=h;i<=m;i++) ans=min(ans,f[i]);
	cout<<ans<<endl;
	return 0;
}


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

using namespace std;

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main(){
  int n,m; cin >> n >> m;
  UnionFind t(m);
  vector<bool> v(m);
  for(int i=0;i<m;i++) v[i] = false;
  for(int i=0;i<n;i++){
  	int k; cin >> k;
    int ll; cin >> ll;
    v[ll-1] = true;
    for(int j=0;j<k-1;j++){
      int l; cin >> l;
      t.unite(ll-1,l-1);
      v[l-1] = true;
    }
  }
  int id;
  for(int i=0;i<m;i++) if(v[i]){id = i; break;}
  bool f = true;
  for(int i=0;i<m;i++) if(v[i]&&!t.same(id,i)) f = false;
  if(f) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

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

using lli = long long int;
using ll = long long ;
using ld=long double;
using d= double;

bool isPrime(ll n){if(n<2)return false;for(ll i=2;i*i<=n;++i){if(n%i==0){return false;}}return true;}

int main() {
    ld a,b;
    cin>>a>>b;
    ll ans=a*b;
    cout<<ans;
	return 0;
}

Measured memory_bytes: 3736
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vii = vector<vi>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9+7;
const int INF = 2e9;
template<class T> void print(const T& t){ cout << t << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}


int main(){
  ll n;
  cin >> n;
  ll ans = 0;
  rep(i,n){
    ll a;
    cin >> a;
    ans += a - 1;
  }
  print(ans);
}


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

int main(){
    int n;
    cin >> n;
    vector<int> p(n);
    rep(i, n) cin >> p[i];
    int num =0;
    rep(i, n){
        if (p[i] != i+1) num++;
    }
    if(num<3) cout << "YES" <<endl;
    else cout <<"NO" <<endl;
    return 0;
}

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

void del_blank_column(vector<string> &board, int H, int W) {
    vector<bool> check(W, false);
    for (int i = 0; i < W; i++) {
        int count = 0;
        for (int j = 0; j < H; j++) {
            if (board.at(j).at(i) == '#') {
                break;
            }
            else {
                count++;
            }
            if (count == H) {
                check.at(i) = true;
            }
        }
    }
    for (int i = W - 1; i >= 0; i--) {
        if (check.at(i)) {
            for (int j = 0; j < H; j++) {
                board.at(j).erase(i,1);
            }
        }
    }
}

int main() {
    int H, W;
    cin >> H >> W;
    vector<string> board(H);
    string blank = "";
    for (int i = 0; i < W; i++) blank += ".";
    for (int i = 0; i < H; i++) cin >> board.at(i);
    for (int i = H - 1; i >= 0; i--) {
        if (board.at(i) == blank) {
            board.erase(board.begin() + i);
        }
    }
    del_blank_column(board, board.size(), W);
    for (int i = 0; i < board.size(); i++) cout << board.at(i) << endl;
}


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


int main() {
int N,K;
cin >> N >> K;
vector<int> vec(N);
rep(i,N) cin >> vec.at(i);

sort(vec.begin(),vec.end());
ll ans = 0;
rep(i,K) ans += vec.at(i);

cout << ans << endl;



return 0;
}


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

using namespace std;
using nagai = long long;
#define sz(x) int((x).size())

const int N=100100;
vector<int>g[N];
int n;
int c[N];
int ptr;
int ans[N];
void d(int u,int p=-1){
	ans[u]=c[ptr--];
	for(int v:g[u])
		if(v!=p)
			d(v,u);
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n;
	for(int i=0;i<n-1;++i){
		 int a,b;
		 cin>>a>>b;
		 --a,--b;
		 g[a].push_back(b);
		 g[b].push_back(a);
	}
	ptr=n-1;
	for(int i=0;i<n;++i)
		cin>>c[i];
	sort(c,c+n);
	int ans=accumulate(c,c+n-1,0);
	cout<<ans<<'\n';
	d(0);
	for(int i=0;i<n;++i){
		cout<<::ans[i]<<' ';
	}
	cout<<'\n';
	return 0;
}



Measured memory_bytes: 3584
/**
 *    author:  FromDihPout
 *    created: 2020-06-23
**/

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


void move(int start, int end, bool vertical) {
    char c;
    if (vertical && start < end) 
        c = 'U';
    else if (vertical)
        c = 'D';
    else if (start < end)
        c = 'R';
    else
        c = 'L';
        
    int a = min(start, end), b = max(start, end);
    for (int i = a + 1; i <= b; i++) {
        cout << c;
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    
    move(sy, ty, true);
    move(sx, tx, false);
    
    move(ty, sy, true);
    move(tx, sx, false);
    
    move(sx, sx - 1, false);
    move(sy, ty + 1, true);
    move(sx - 1, tx, false);
    move(ty + 1, ty, true);
    
    move(tx, tx + 1, false);
    move(ty, sy - 1, true);
    move(tx + 1, sx, false);
    move(sy - 1, sy, true);
    
    return 0;
}

Measured memory_bytes: 3596
#include <iostream>

using namespace std;

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if (a > b) swap(a,b);
    if (b > c) swap(b,c);
    if (a > b) swap(a,b);
    cout << a << ' '
         << b << ' '
         << c << endl;
    return 0;
}


Measured memory_bytes: 3112
#include<stdio.h>
#include<stdlib.h>

#define POS(i,j,k) (((i)*(1+cnt[1]+cnt[2])+(j))*(1+n)+(k))

void run(void){
  int n;
  scanf("%d",&n);
  const double p=(double)1/n;
  int cnt[3]={0,0,0};
  int i,j,k;
  for(i=0;i<n;i++){
    int a;
    scanf("%d",&a);
    cnt[a-1]++;
  }
  double *dp=(double *)calloc((1+cnt[2])*(1+cnt[1]+cnt[2])*(1+n),sizeof(double));
  for(i=0;i<=cnt[2];i++){
    for(j=0;j<=cnt[1]+cnt[2]-i;j++){
      for(k=(i==0 && j==0?1:0);k<=n-i-j;k++){
	double local=1;
	if(i>0) local+=p*i*dp[POS(i-1,j+1,k)];
	if(j>0) local+=p*j*dp[POS(i,j-1,k+1)];
	if(k>0) local+=p*k*dp[POS(i,j,k-1)];
	dp[POS(i,j,k)]=local*n/(i+j+k);
      }
    }
  }
  printf("%.9f\n",dp[POS(cnt[2],cnt[1],cnt[0])]);
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 213248
#include <cmath>
#include <algorithm>
#include <cstdio>
#include <string>
#include <iostream>
#include <vector>

using namespace std;
vector<int> memo(100000, 0);

int get_sum(int num) {
  int key = num;

  if (memo[key] == 0) {
    int sum = 0;
    while (num > 0) {
      sum += num % 10;
      num /= 10;
    }
    memo[key] = sum;
  }

  return memo[key];
}

int main() {
    int N, ans = 10000000;
    cin >> N;

    for (int i = 1; i < N; i++) {
      ans = min(ans, get_sum(i) + get_sum(N - i));
    }

    cout << ans << endl;
}


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

constexpr int INF = 1e9;

using pii = pair<int, int>;

constexpr int dx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
constexpr int dy[8] = {1, 1, 0, -1, -1, -1, 0, 1};

int main() {
    vector<string> v(21, ".................");
    int sx, sy;
    for(int i=1; i<=19; ++i) {
        string s;
        cin >> s;
        v[i] = "." + s + ".";
        for(int j=1; j<=15; ++j) {
            if(v[i][j] == 'O') {
                sy = i;
                sx = j;
            }
        }
    }
    map<vector<string>, int> d;
    using state = tuple<int, int, vector<string>>;
    d[v] = 0;
    queue<state> que;
    que.push(make_tuple(sy, sx, v));
    int res = INF;
    while(!que.empty()) {
        int y, x;
        vector<string> now;
        tie(y, x, now) = que.front();
        que.pop();
        //cout << "y: " << y << "  x: " << x << endl;
        //cout << "map: " << endl;
        //for(auto& s : now) {
        //    cout << s << endl;
        //}
        //cout << endl;
        for(int i=0; i<8; ++i) {
            auto next = now;
            int ny = y + dy[i], nx = x + dx[i];
            bool ok = false;
            while(next[ny][nx] == 'X') {
                ny += dy[i];
                nx += dx[i];
                ok = true;
            }
            if(!ok) {
                continue;
            }
            int ty = y, tx = x;
            while(ty != ny || tx != nx) {
                next[ty][tx] = '.';
                ty += dy[i];
                tx += dx[i];
            }
            next[ny][nx] = 'O';
            if(d.count(next) == 0) {
                d[next] = d[now] + 1;
                if(ny == 19 && 1 <= nx && nx <= 15 || ny == 20) {
                    res = min(res, d[next]);
                }
                if(1 <= ny && ny <= 19 && 1 <= nx && nx <= 15) {
                    que.push(make_tuple(ny, nx, next));
                }
            }
        }
    }
    cout << (res == INF ? -1 : res) << endl;
}


Measured memory_bytes: 40988