akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stdio.h>
#include <math.h> 
#include <algorithm>
#include <numeric>
#include <functional>
#include <vector>
#include <string>
#include <numeric>
#include <bitset>
#include <queue>
#include <map>

using namespace std;


int main() {

	//input
	int n;
	cin >> n;

	for (int i = n; i <= n + 130; ++i) {
		string s = to_string(i); 
		if(s[0] == s[1] && s[1] == s[2] && s[0] == s[2]){
			cout << s << endl;
			return 0;
		}
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SIZE 200005
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;
 
int A[SIZE];
int n,m,v,p;
bool check(int d)
{
	if(d>=n-p) return true;
	int lim=A[d]+m;
	ll zan=(ll) m*(ll) (v-p);
	int cnt=0;
	for(int i=0;i+p<=n;i++)
	{
		if(i==d) continue;
		ll c=min((ll) m,(ll) lim-A[i]);
		if(c<0) return false;
		zan-=c;
	}
	return zan<=0;
}
int main()
{
	scanf("%d %d %d %d",&n,&m,&v,&p);
	for(int i=0;i<n;i++) scanf("%d",&A[i]);
	sort(A,A+n);
	int l=-1,r=n;
	while(r-l>1)
	{
		int d=(l+r)/2;
		if(check(d)) r=d;
		else l=d;
	}
	printf("%d\n",n-r);
	return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] v = new int[N];
		int[] c = new int[N];
		for (int i = 0; i < N; i++)
			v[i] = sc.nextInt();
		for (int i = 0; i < N; i++)
			c[i] = sc.nextInt();

		int sum = 0;

		for (int i = 0; i < N; i++) {
			if (v[i] - c[i] > 0)
				sum += (v[i] - c[i]);
		}

		System.out.println(sum);
		sc.close();
	}
}


Measured memory_bytes: 21844
from random import randint
import sys
input = sys.stdin.readline
INF = 9223372036854775808


def calc_score(D, C, S, T):
    """
    開催日程Tを受け取ってそこまでのスコアを返す
    コンテストi 0-indexed
    d 0-indexed
    """
    score = 0
    last = [0]*26  # コンテストiを前回開催した日
    for d, t in enumerate(T):
        last[t] = d + 1
        for i in range(26):
            score -= (d + 1 - last[i]) * C[i]
        score += S[d][t]
    return score


def update_score(D, C, S, T, score, ct, ci):
    """
    ct日目のコンテストをコンテストciに変更する
    スコアを差分更新する

    ct: change t 変更日 0-indexed
    ci: change i 変更コンテスト 0-indexed
    """
    last = [0]*26  # コンテストiを前回開催した日
    for d in range(ct):
        last[T[d]] = d + 1
    prei = T[ct]  # 変更前に開催する予定だったコンテストi
    score -= S[ct][prei]
    score += S[ct][ci]
    for d in range(ct, D):
        if d != ct and T[d] == prei:
            break
        score += C[prei]*(d + 1 - ct - 1)
        score -= C[prei]*(d + 1 - last[prei])
    for d in range(ct, D):
        if d != ct and T[d] == ci:
            break
        score += C[ci]*(d + 1 - last[ci])
        score -= C[ci]*(d + 1 - ct - 1)
    T[ct] = ci
    return score, T


def local_search(D, C, S, T, today_score, d):
    pass


def greedy(D, C, S):
    T = []  # 0-indexed
    for d in range(D):
        # d日目終了時点で満足度が一番高くなるようなコンテストiを開催する
        max_score = -INF
        best_i = 0
        for i in range(26):
            T.append(i)
            score = calc_score(D, C, S, T)
            if max_score < score:
                max_score = score
                best_i = i
            T.pop()
        T.append(best_i)
    return T


if __name__ == '__main__':
    D = int(input())
    C = [int(i) for i in input().split()]
    S = [[int(i) for i in input().split()] for j in range(D)]
    T = greedy(D, C, S)
    for t in T:
        print(t+1)


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

int main() {
    string s, t;
    int ans=1000000;
    cin >> s >> t;
    for (int i=0; i<=s.size()-t.size(); i++){
        int diff=0;
        for (int j=0; j<t.size(); j++){
            if (t[j]!=s[i+j]) diff++;
        }
        ans=min(diff, ans);
    }
    cout << ans << endl;
}

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

using namespace std;

typedef long long ll;

const ll LongINF=1e13+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

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 <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

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

int main(){
    int N,M;
    cin>>N>>M;
    vector<int> X(M);
    rep(i,M)cin>>X[i];
    if(N>=M){
        cout<<0<<endl;
        return 0;
    }
    sort(X.begin(),X.end());
    int Sec=X[M-1]-X[0];
    priority_queue<int> L;
    rep(i,M-1){
        L.push(X[i+1]-X[i]);
    }
    int dif=0;
    rep(i,N-1){
        dif+=L.top();
        L.pop();
    }
    cout<<Sec-dif<<endl;
    return 0;
}

//a=97,z=122

Measured memory_bytes: 1276
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <utility>
#include <map>
#include <stack>
using namespace std;

typedef long long LL;
typedef pair<LL,LL> pii;
const int MAX_N = 1e5 + 6;

vector<int> vx,vy;

struct Point {
    int x1,y1,x2,y2;
    pii p1,p2;
    void input() {
        scanf("%d %d %d %d",&x1,&y1,&x2,&y2);
        vx.push_back(x1);vx.push_back(x2);
        vy.push_back(y1);vy.push_back(y2);
    }
    void kirino() {
        x1=lower_bound(vx.begin(),vx.end(),x1) - vx.begin();
        x2=lower_bound(vx.begin(),vx.end(),x2) - vx.begin();
        y1 = lower_bound(vy.begin(),vy.end(),y1) - vy.begin();
        y2 = lower_bound(vy.begin(),vy.end(),y2) - vy.begin();
        p1 = make_pair(x1,y1);
        p2 = make_pair(x2,y2);
    }
} pts[MAX_N];

LL d[4][MAX_N];

int r,c,n;

bool okay(pii p) {
    if (p.first == 0 || p.second ==0 || p.first==r || p.second==c) return true;
    else return false;
}

int main () {
    scanf("%d %d %d",&r,&c,&n);
    vx.push_back(0);vx.push_back(r);
    vy.push_back(0);vy.push_back(c);
    for (int i=1;n>=i;i++) {
        pts[i].input();
    }
    sort(vx.begin(),vx.end());
    sort(vy.begin(),vy.end());
    vx.resize(unique(vx.begin(),vx.end()) - vx.begin());
    vy.resize(unique(vy.begin(),vy.end()) - vy.begin());
    for (int i=1;n>=i;i++) {
        pts[i].kirino();
    }
    r=vx.size()-1;
    c=vy.size()-1;
    map<pii,int> mp;
    for (int i=1;n>=i;i++) {
        if (okay(pts[i].p1) && okay(pts[i].p2)) {
            mp[pts[i].p1 ] = i;
            mp[pts[i].p2 ] = i;
        }
    }
    stack<int> st;
    for (int j=1;c>=j;j++) {
        int i=0;
        int ret=mp[make_pair(i,j)];
        if (ret==0) continue;
        if (!st.empty() && st.top() == ret) st.pop();
        else st.push(ret);
    }
    for (int i=1;r>=i;i++) {
        int j=c;
        int ret=mp[make_pair(i,j)];
        if (ret==0) continue;
        if (!st.empty() && st.top() == ret) st.pop();
        else st.push(ret);
    }
    for (int j=c-1;j>=0;j--) {
        int i=r;
        int ret=mp[make_pair(i,j)];
        if (ret==0) continue;
        if (!st.empty() && st.top() == ret) st.pop();
        else st.push(ret);
    }
    for (int i=r-1;i>=0;i--) {
        int j=0;
        int ret=mp[make_pair(i,j)];
        if (ret==0) continue;
        if (!st.empty() && st.top() == ret) st.pop();
        else st.push(ret);
    }
    if (st.size()) puts("NO");
    else puts("YES");
}



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

const int MAXN = 2010;
const int mod = 924844033;
typedef long long LL;
void reduce(int & x) { x += x >> 31 & mod; }
int mul(int a, int b) { return (LL) a * b % mod; }
int n, K, fac[MAXN];
int f[MAXN][MAXN][2][2], g[MAXN];
int A1[MAXN], A2[MAXN];
int main() {
	std::ios_base::sync_with_stdio(false), std::cin.tie(0);
	fac[0] = fac[1] = 1;
	for (int i = 2; i != MAXN; ++i) fac[i] = mul(fac[i - 1], i);
	std::cin >> n >> K;
	const int cup = (n - 1) / K + 1;
	f[0][0][1][0] = 1;
	for (int i = 1; i <= cup; ++i) {
		for (int j = 0; j <= cup; ++j)
		for (int l = 0; l != 2; ++l)
		for (int r = 0; r != 2; ++r) if (int t = f[i - 1][j][l][r]) {
			reduce(f[i][j][r][0] += t - mod);
			if (!l) reduce(f[i][j + 1][r][0] += t - mod);
			reduce(f[i][j + 1][r][1] += t - mod);
		}
	}
	for (int i = 0; i <= cup; ++i)
		A1[i] = (f[cup - 1][i][0][0] + f[cup - 1][i][1][0]) % mod;
	for (int i = 0; i <= cup; ++i)
		A2[i] = (f[cup][i][0][0] + f[cup][i][1][0]) % mod;
	g[0] = 1;
	int up = 0;
	for (int i = 1; i <= K; ++i) {
		int dd = 0, now = i;
		while (now <= n) now += K, ++dd;
		static LL tmp[MAXN];
		int * h = dd == cup ? A2 : A1;
		memset(tmp, 0, n + 1 << 3);
		for (int j = 0; j <= up; ++j)
			for (int k = 0; k <= dd; ++k)
				tmp[j + k] += mul(g[j], h[k]);
		up += dd;
		for (int j = 0; j <= up; ++j) g[j] = tmp[j] % mod;
	}
	int ans = 0;
	for (int i = 0; i <= n; ++i)
		reduce(ans += mul(mul(g[i], fac[n - i]), i & 1 ? mod - 1 : 1) - mod);
	std::cout << ans << std::endl;
	return 0;
}


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

int main() {
  int N, x;
  cin >> N;
  x = 0;
  
  for (int i = 0; i < N; i++) {
    int l, r;
    cin >> l >> r;
    x += r - l + 1;
  }
  
  cout << x << 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;

const ll mod = 2019;

int main() {
    ll L, R; cin >> L >> R;
    ll mi = min(R-L, mod);
    ll ans = 1001001001;
    for (ll i = L; i <= L+mi-1; i++){
        ll I = i % mod;
        for (int j = i+1; j <= L+mi; j++){
            ll J = j % mod;
            ll x = (I * J) % mod;
            ans = min(ans, x);
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void){
    int n,m,ans[50] ;
    scanf ("%d%d",&n,&m) ;
    for (int i=0; i<n; i++) {
        ans[i]=0 ;
    }
    for (int i=0; i<m*2; i++) {
        int a ;
        scanf ("%d",&a) ;
        for (int j=0; j<n; j++) {
            if (a-1==j){
                ans[j]++ ;
            }
        }
    }
    for (int i=0; i<n; i++) {
        printf ("%d\n",ans[i]) ;
    }
    return 0 ;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N;
    cin >> N;
    int max_maisu=1;
    vector<int> kagami(N);
    for (int i=0;i<N;i++) {
        int d;
        cin >> d;
        kagami.at(i)=d;
    }
    sort(kagami.begin(),kagami.end());
    for (int i=0;i<N-1;i++) {
        if (kagami.at(i+1)>kagami.at(i)) max_maisu++;
    }
    cout << max_maisu << endl;

}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

long long int GCD(long long int x, long long int y) {
    if(x<y) swap(x, y);
    if(y==0) return x;
    return GCD(y, x%y);
}

long long int LCM(long long int x, long long int y) {
    return x/GCD(x, y)*y;
}

int main() {
    long long int N, M;
    cin >> N >> M;
    string S, T;
    cin >> S >> T;
    
    long long int gcd=GCD(N, M), lcm;
    lcm = M/gcd*N/gcd;
    bool flag=true;
    for(long long int i=1; i<=N/gcd*M/lcm; i++) {
        long long int n=(i-1)*lcm*gcd/M, m=(i-1)*lcm*gcd/N;
        if(S[n]!=T[m]) {
            flag=false;
            break;
        }
    }
    if(flag) {
        cout << N/gcd*M << endl;
    } else {
        cout << -1 << endl;
    }


    return 0;
    
}

Measured memory_bytes: 3728
#include <bits/stdc++.h>
using namespace std;
int main ()
{
    long long n;
    cin >> n;
    vector <long long> qw (n);
    for (int i=0; i<n; ++i)
        cin >> qw[i];
    int t=0;
    for (int i=0; i<n; ++i)
        for (int ii=i+1; ii<n; ++ii)
            for (int iii=ii+1; iii<n; ++iii)
            {
                if (qw[i]+qw[ii]>qw[iii] && qw[ii]+qw[iii]>qw[i] && qw[i]+qw[iii]>qw[ii] && qw[i]!=qw[ii] && qw[iii]!=qw[ii] && qw[iii]!=qw[i])
                {
                    t+=1;
                    //cout << i << " " << ii << " " << iii << endl;
                }
            }
    cout << t << endl;
}


Measured memory_bytes: 3632
#include<iostream>
#define THRESHOLD 20
#define PROBABILITY 0.5
#define RESTOFCARD 7

using namespace std;


int main(){
 	
 	int count,temp;
 	int myCard[3],opponentCard;
 	double ans;
 	
 	while(cin>>myCard[0]>>myCard[1]>>opponentCard){
 		count=0;
 		
		for(int i=1;i<=10;i++){
 		   if(myCard[0]!=i && myCard[1]!=i && opponentCard!=i){
 				temp=i+myCard[0]+myCard[1];
 		   		if(temp<=20){
 		   			count++;
 				}
		   }
 		}

 		ans=(double)count/(double)RESTOFCARD;
 		
 		if(ans>=PROBABILITY){
 			cout<<"YES"<<endl;
 		}
 		else{
 			cout<<"NO"<<endl;
 		}
 	}
 	
}

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

using namespace std;
using ll = long long;

#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define REP(i,n) FOR(i, 0, n)
#define FORD(i,a,n) for(int i=(a); i>=(n); i--)
#define REPD(i,n) FOR(i, n, 0)

#define ALL(o) (o).begin(), (o).end()

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T, vector<T>, greater<T> >;

const ll MOD = 1000000007;

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

	queue<ll> q;
	FOR(i,1,10) {
		q.push(i);
	}

	ll tmp;
	REP(i,k) {
		tmp = q.front(); q.pop();
		int a = tmp%10;
		if(a != 0) {
			q.push(tmp*10+a-1);
		}
		q.push(tmp*10+a);
		if(a != 9) {
			q.push(tmp*10+a+1);
		}
	}

	cout << tmp << endl;
	return 0;

}



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

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

int main() {
  int n, m;
  cin >> n >> m;
  int ans = 0;
  ans += n*(n-1) / 2;
  ans += m*(m-1) / 2;
  cout << ans << endl;
  return 0;
}


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

#define ll long long

using namespace std;

const int MOD = 1000000007;

std::vector<bool> IsPrime;

void sieve(size_t max) {
  if (max + 1 > IsPrime.size()) {
    IsPrime.resize(max + 1, true);
  }
  IsPrime[0] = false;
  IsPrime[1] = false;

  for (size_t i = 2; i * i <= max; ++i) {
    if (IsPrime[i]) {
      for (size_t j = 2; i * j <= max; ++j) {
        IsPrime[i * j] = false;
      }
    }
  }
}

int main() {
  ll x;
  scanf("%lld", &x);
  sieve(100003);

  for (ll i = x; i < IsPrime.size(); i++) {
    if (IsPrime[i]) {
      cout << i << endl;
      break;
    }
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

string itoa(int in)
{
	string str,zero;
	if (in == 0) {
		str = '0';
		return str;
	}
	while (in) {
		str = zero + (char)((in % 10) + '0') + str;
		in /= 10;
	}
	return str;
}

int main()
{
	int temp,n,i;
	string d,ch;
	cin >> n;
	for (i = 0;i < n;i++) {
		cin >> temp;
		d += (char)temp + '0';
	}
	for (i = 0;d.find(itoa(i)) != -1;i++) {	}
	cout << i << endl;
	return 0;
}

Measured memory_bytes: 1216
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>

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

using namespace std;

inline int max(int a, int b) {
	if (b > a) swap(a, b);
	return a;
}

inline int min(int a, int b) {
	if (a > b) swap(a, b);
	return a;
}




int main() {
	int n, a, b, c, d;
	vector<int> wall;
	vector<int> change;
	int c_count = 0, w_count = 0;
	bool flag = false;

	cin >> n >> a >> b >> c >> d;

	for (int i = 1; i <= n; i++) {
		char c;
		cin >> c;
		if (c == '.') {
			c_count++;
			if (c_count >= 3) {
				change.push_back(i-1);
			}
		}
		else {
			c_count = 0;
		}
		if (c == '#') {
			w_count++;
			if (w_count >= 2) {
				wall.push_back(i-1);
			}
		}
		else {
			w_count = 0;
		}
	}

	if (c > d) {
		for (auto i : change) {
			if ((i <= d) && (i >= b)) {
				flag = true;
				break;
			}
		}
	}
	else {
		flag = true;
	}

	for (auto i : wall) {
		if (((i < c) && (i > a)) || ((i < d) && (i > b))) {
			flag = false;
		}
	}

	if (flag) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

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

        int n = sc.nextInt();
        int m = sc.nextInt();

        int array[] = new int[n];

        for (int i = 0; i < n; i++) {
            array[i] = sc.nextInt();
        }

        Arrays.sort(array);

        int ans = 0;

        for (int i = 0; i < m; i++) {
            ans += array[i];
        }

        System.out.println(ans);

    }

}

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

typedef long long int ll;

ll N;
ll h, n;
ll w;

int main()
{
	scanf("%lld" , &N);
	for(h = 1; h <= 3500; h++)
		for(n = 1; n <= 3500; n++)
		{
			if((4*h*n-N*n-N*h) <= 0) continue;
			ll ans = (N*h*n) % (4*h*n-N*n-N*h);
			if(ans == 0) 
			{
				w = (N*h*n) / (4*h*n-N*n-N*h);
				printf("%lld %lld %lld\n", h, n, w);
				return 0;
			}
		}
}

Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def isSquared(n):
    for i in range(128):
        if i ** 2 > n:
            return False
        elif i ** 2 == n:
            return True
    return False


def squaredDist(x, y):
    s = 0
    for i, j in zip(x, y):
        s += (i - j)**2
    return s


def solve():
    N, D = list(map(int, input().split()))
    points = [list(map(int, input().split())) for _ in range(N)]
    count = 0
    for i in range(N):
        for j in range(i + 1, N):
            if isSquared(squaredDist(points[i], points[j])):
                count += 1
    return count


def main():
    print(solve())


if __name__ == "__main__":
    main()


Measured memory_bytes: 39280
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
int main()
{
	string s;cin>>s;
	cout<<s.substr(0,4)<<' '<<s.substr(4)<<endl;
}


Measured memory_bytes: 384
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/math/common_factor_rt.hpp>  // https://boostjp.github.io/tips/math.html
#include <boost/dynamic_bitset.hpp>  // https://boostjp.github.io/tips/dynamic_bitset.html

constexpr int64_t DIV1097 = 1000000007LL;

using namespace std;

int main()
{
    int64_t N;
    std::cin >> N;

    boost::multi_array<bool, 2> F(boost::extents[N][10]);
    for (auto p = F.data(); p < (F.origin() + F.num_elements()); ++p) {
        std::cin >> *p;
    }

    boost::multi_array<int64_t, 2> P(boost::extents[N][11]);
    for (auto p = P.data(); p < (P.origin() + P.num_elements()); ++p) {
        std::cin >> *p;
    }

    int64_t ans = INT64_MIN;
    
    // 開店のパターンごとに
    for (uint64_t t = 1; t < (1 << 10); ++t) {

        int64_t cand = 0;
        // 店との重複数えるて、スコア足しこむ
        for (size_t n = 0; n < N; ++n) {
            int64_t count = 0;
            for (size_t m = 0; m < 10; ++m) {
                count += (F[n][m] & ((t >> m) & 1)) ? 1 : 0;
            }
            cand += P[n][count];
        }

        ans = std::max(ans, cand);
    }

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>

#define REP(idx, end) for(int idx = 0; idx < end; ++idx)

using namespace std;
typedef long long lint;
const int MOD = 1000000007;

int main() {

	cin.tie(0);

	int A, B, C, D;
	cin >> A >> B >> C >> D;
  #ifdef DEBUG
  cout<< A*B*C*D;
  #endif
	if (A*B > C*D) {

		cout << A * B;
	}
	else cout << C * D;

	return 0;
}

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

#define MAX_N 2020

int main(){
  int K, A, B;
  cin >> K;
  cin >> A >> B;
  bool result = false;
  for(int i=A; i<=B; i++){
    if(i%K == 0){
      result=true;
    } 
  }
  if(result){
    cout << "OK" << endl;
  }
  else{
    cout << "NG" << endl;

  }
}

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


int main() {
  int cnt = 0;
  rep(i,3){
    char a;
    cin >> a;
    if(a=='o') cnt++;
  }
  cout << 700 + (100*cnt) << endl;
  return 0;
  
}

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

int main(){
  int m, n;
  bool haming[1000001] = {};
  int sum[1000001] = {};

  for(int i = 1; i < 1000001; i *= 2){
    for(int j = i; j < 1000001; j *= 3){
      for(int k = j; k < 1000001; k *= 5){
        haming[k] = true;
      }
    }
  }
  haming[1] = true;
  for(int i = 1; i < 1000001; i++){
    sum[i] = sum[i - 1] + haming[i];
  }

  while(cin >> m){
    if(!m) break;
    cin >> n;
    cout << sum[n] - sum[m - 1] << endl;
  }
}

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

int main() {
    int N;
    cin >> N;
    vector<ll> A(N);
    for(int i = 0; i < N; i++) {
        cin >> A.at(i);
    }

    ll cache = 1000;
    ll stock = 0;
    for(int i = 0; i < (N-1); i++) {
        if(A.at(i) < A.at(i + 1)) {
            ll buy = cache / A.at(i);
            stock += buy; 
            cache -= buy * A.at(i);
        } else if(A.at(i) > A.at(i + 1)) {
            cache += stock * A.at(i);
            stock = 0;
        }
    }
    if(stock > 0){
        cache += stock * A.at(N-1);
    }


    cout << cache << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1111111111;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

template <class T1, class T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
	os << "(" << p.first << "," << p.second << ")";
	return os;
}

template <class T1, class T2>
ostream &operator<<(ostream &os, const map<T1, T2> &mp) {
	for (const auto &e : mp) os << e << " ";
	return os;
}

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int n;
	cin >> n;

	vector<int> v(n);
	for (int i = 0; i < n; i++) {
		cin >> v[i];
	}

	map<int, int> mp_even, mp_odd;
	for (int i = 0; i < n; i++) {
		if (i & 1) mp_odd[v[i]]++;
		else mp_even[v[i]]++;
	}

	auto comp = [](auto &l, auto &r) {return l.second > r.second; };
	vector<pair<int, int>> top2_odd(2), top2_even(2);
	partial_sort_copy(mp_odd.begin(), mp_odd.end(), top2_odd.begin(), top2_odd.end(), comp);
	partial_sort_copy(mp_even.begin(), mp_even.end(), top2_even.begin(), top2_even.end(), comp);

	if (top2_odd[0].first != top2_even[0].first) cout << n - (top2_odd[0].second + top2_even[0].second) << "\n";
	else cout << n - max(top2_odd[0].second + top2_even[1].second, top2_odd[1].second + top2_even[0].second) << "\n";

	return 0;
}

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

using namespace std;

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

    int cur;
    vector<int> a_arr;
    vector<int> b_arr;
    for (int i = 0; i < N; i++) {
        cin >> cur;
        a_arr.push_back(cur);
    }
    for (int j = 0; j < N; j++) {
        cin >> cur;
        b_arr.push_back(cur);
    }

    int ans = 0;
    int64_t sum_sub = 0;
    vector<int> m;
    for (int k = 0; k < N; k++) {
        if (a_arr[k] < b_arr[k]) {
            ans++;
            int sub_b = b_arr[k] - a_arr[k];
            sum_sub += sub_b;
        } else if (a_arr[k] == b_arr[k]) {
            // do nothing
        } else {
            int sub_a = a_arr[k] - b_arr[k];
            m.push_back(sub_a);
        }
    }

    sort(m.begin(), m.end(), greater<int>());

    if (sum_sub > 0) {
        for (int l = 0; l < m.size(); ) {
            if (m[l] >= sum_sub) {
                sum_sub = 0;
                ans++;
                break;
            } else {
                sum_sub -= m[l];
                ans++;
                l++;
            }
            if (sum_sub == 0) {
                break;
            }
        }

        if (sum_sub > 0) {
            ans = -1;
        }
    }

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


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

int main() {
    int N;
    cin >> N;
    int c = 0, max_c = 0;
    vector<int> H(N);
    for(int i=0; i<N; i++) {
        cin >> H[i];
    }

    for(int i=0; i<N-1; i++) {
        if(H[i] >= H[i+1]) c++;
        else c = 0;
        max_c = max(max_c, c);
    }
    cout << max_c << endl;
}

Measured memory_bytes: 3788
n,m=map(int,input().split())
a=[list(map(int,input().split())) for _ in range(n)]
c=[list(map(int,input().split())) for _ in range(m)]
ans=[[] for _ in range(n)]
for i in range(n):
  p,q=a[i]
  for j in range(m):
    r,s=c[j]
    d=abs(p-r)+abs(q-s)
    ans[i].append((d,j+1))
  ans[i]=sorted(ans[i])
for i in ans:
  print(i[0][1])

Measured memory_bytes: 39664
#include<stdio.h>
#include<math.h>

int main()
{
    int a,b,c,d,e,f=0,g=0;
    scanf("%d %d %d", &a, &b, &c);

    for(d=1; d<=a; d++)
    {
        e=d;
        while(1)
        {
            g=g+(e%10);
            e=e/10;
            if(e==0) break;

        }
        if(g<=c & g>=b)
        {
            f=f+d;
            //printf("%d\n", d);
        }
        g=0;
    }
    printf("%d\n", f);

    return 0;

}


Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int ans,N;
  cin >> N;
  ans = N;
  int S,T;
  for(int i = 0; i <= N ; i++){
    int tmp = 0;
    S = i;
    T = N-i;
    while(S > 0){tmp += S%9; S /= 9; }
    while(T > 0){tmp += T%6; T /= 6; }
    ans = min(ans,tmp);
  }
  cout << ans << "\n";
  return 0;
}


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

int main(){
	int n, t, a;
	cin >> n >> t >> a;
	vector<int> h(n);

	double diff = __INT_MAX__;
	rep(i, n){
		cin >> h.at(i);
		diff = min(diff, abs(a-(t-h.at(i)*0.006)));
	}

	rep(i, n){
		if(diff == abs(a-(t-h.at(i)*0.006))){
			cout << i+1 << endl;
			break;
		}
	}
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;

int N, C[400][4];

pair<ll, int> f(int a, int b, int c, int d) {
    ll mi = LLONG_MAX;
    vll v{a,b,c,d};
    ll y[4] = {};
    rep(i, 4) {
        ll p = 1;
        rep(j, 4) {
            y[i] += p*v[(i + j) % 4];
            p *= 1000;
        }
        smin(mi, y[i]);
    }
    int n = (int)count(y,y+4, mi);
    return mp(mi, n);
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    while(cin >> N) {
        map<ll, int> m;
        vector<pair<ll, int>> P(N);
        rep(i, N) {
            rep(j, 4)cin >> C[i][j];
            auto p = f(C[i][0], C[i][1], C[i][2], C[i][3]);
            m[p.first] += p.second;
            P[i] = p;
        }

        ll w = 0;
        vector<pair<ll,int>> r(4);
        rep(i, N) {
            m[P[i].first] -= P[i].second;
            FOR(j, i + 1, N) {
                m[P[j].first] -= P[j].second;
                rep(k, 4) {
                    ll x = 1;
                    rep(l, 4) {
                        r[l] = f(C[i][(l + 1) % 4], C[i][l], C[j][(4-l+k) % 4], C[j][(4-l+k-1)%4]);
                        x *= m[r[l].first];
                        m[r[l].first] -= r[l].second;
                    }
                    rep(l, 4)m[r[l].first] += r[l].second;
                    w += x;
                }
                m[P[j].first] += P[j].second;
            }
        }

        cout << w << endl;
    }
}

Measured memory_bytes: 80128
#include<stdio.h>
#define MAX 251

//二分ヒープは1オリジン
int main(){
  int h, p, l, r;
  int a[MAX];
  int i;

  scanf("%d", &h);
  for(i=1;i<=h;i++){
    scanf("%d", &a[i]);
  }

  for(i=1;i<=h;i++){
    p = i / 2;
    l = 2 * i;
    r = 2 * i + 1;
    printf("node %d: ", i); //ノード番号
    printf("key = %d, ", a[i]); //key
    if(i != 1) printf("parent key = %d, ", a[p]); //根じゃないなら親ノードのkey表示
    if(l <= h) printf("left key = %d, ", a[l]); //右の子いれば表示
    if(r <= h) printf("right key = %d, ", a[r]); //左の子いれば表示
    printf("\n");
  }
  
  return 0;
}



Measured memory_bytes: 2048
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>

using namespace std;
using ll = long long;
using vi = vector<int>;

void ins() {}
template<class T,class... Rest>void ins(T& v,Rest&... rest){cin>>v;ins(rest...);}
int main() {
  int H1, M1, H2, M2, K;
  ins(H1, M1, H2, M2, K);

  cout << H2*60+M2-(H1*60+M1) - K << endl;

  return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp> //required
#include <ext/pb_ds/tree_policy.hpp> //required

using namespace __gnu_pbds; 
using namespace std;

template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; 
typedef long long  ll;
typedef vector<ll> VL;
typedef vector<int> VI;
typedef pair<ll,ll> PLL;
typedef pair<int,int> PII;
#define pb push_back

#define F first
#define S second
#define SZ(a) int((a).size())
#define ALL(a) a.begin(),a.end()
#define fr(i,x,y) for(int i=x;i<y;i++)
#define frr(i,x,y) for(int i=x-1;i>=y;i--)
#define inf 1e18+1
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const int mod=1000000007;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll power(ll a,ll b){ll ans=1;while(b!=0){if(b&1){ans*=a;}a=a*a;b>>=1;}return ans;}
ll powerm(ll a,ll b){ll ans=1;while(b!=0){if(b&1){ans*=a;ans%=mod;}a=a*a;a%=mod;b>>=1;}return ans%mod;}
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();

void solve()
{
    ll a;
    cin>>a;
    cout<<a+a*a+a*a*a<<endl;
    return  ;
}
int main()
{
    IOS;
    ll t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}
/* stuff you should look for
        * int overflow, array bounds
        * special cases (n=1?)
        * do smth instead of nothing and stay organized
        * WRITE STUFF DOWN
*/
// BITMASK:
// 1)When some constrall is of the order of 15-20, think of bitmask DP.
// 2)When some constrall is around 40, try out meet in the middle
// 3) See Strings,palindromes,prefix,suffix etc -> KMP,Z algorithm

Measured memory_bytes: 3644
#include <cstdio>

int main(){
    int n;
    scanf("%d",&n);
    
    int a[n];
    for(int i = 0; i < n; i++) {
        scanf("%d", &a[i]);
    }
    
    for(int i = n - 1;i > 0;i--){
        printf("%d ",a[i]);
    }
    printf("%d\n",a[0]);
    return 0;
}


Measured memory_bytes: 2668
#include <bits/stdc++.h>
using namespace std;
#define int long long

#define ff first
#define ss second
// #define endl "\n"
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x.size())
#define PI 3.1415926535897932384626433832795
int MOD=1e9+7;
int powmod(int a,int l, int md){int res=1;while(l){if(l&1)res=res*a%md;l/=2;a=a*a%md;}return res;}
int binpow(int a,int l){int res=1;while(l){if(l&1)res=res*a;l/=2;a=a*a;}return res;}
typedef long long ll; typedef vector<ll> vi; typedef pair<ll, ll> ii; typedef vector<ii> vii;
#define pb push_back
const ll inf = 0xFFFFFFFFFFFFFFFL; //very large number
priority_queue<int, vector<int>, greater<int> > pq; //for min priority_queue
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
clock_t time_p=clock();
void time()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int getRand(int l, int r)
{
	uniform_int_distribution<int> uid(l, r);
	return uid(rng);
}

int r,s,p;
int solve(int tt, char pp) {
	char qq;
	if(tt==0) qq='r';
	if(tt==1) qq='s';
	if(tt==2) qq='p';
	if(qq=='r' && pp=='s') return r;
	if(qq=='p' && pp=='r') return p;
	if(qq=='s' && pp=='p') return s;
	return 0;
}
signed main(void)
{
	IOS;
	int n,k;
	cin>>n>>k;
	cin>>r>>s>>p;
	string t;
	cin>>t;
	int dp[k][n/k+10][3]; //0->r, 1->s, 2->p;
	for(int i = 0; i < k; i++) {
		for(int j = 0; j < n/k+10; j++) {
			for(int l = 0; l < 3; l++)
				dp[i][j][l]=0;
		}
	}
	for(int i = 0; i < k; i++) {
		dp[i][0][0]=solve(0,t[i]);
		dp[i][0][1]=solve(1,t[i]);
		dp[i][0][2]=solve(2,t[i]);
	}
	vi ss(k);
	for(int i = 0; i < k; i++) {
		for(int j = 1; j < n/k+10; j++) {
			if(j*k+i >= n) {
				ss[i]=j;
				break;
			}
			dp[i][j][0]=max({dp[i][j-1][1],dp[i][j-1][2]})+solve(0,t[j*k+i]);
			dp[i][j][1]=max({dp[i][j-1][0],dp[i][j-1][2]})+solve(1,t[j*k+i]);
			dp[i][j][2]=max({dp[i][j-1][1],dp[i][j-1][0]})+solve(2,t[j*k+i]);
		}
	}
	int sum=0;
	for(int i = 0; i < k; i++) {
		int vv = max({dp[i][ss[i]-1][0],dp[i][ss[i]-1][1],dp[i][ss[i]-1][2]});
		sum += vv;
	}
	cout<<sum<<endl;
	// dp[0][0]=solve(0,t[0]);
	// dp[0][1]=solve(1,t[0]);
	// dp[0][2]=solve(2,t[0]);
	// for(int i =1; i < n; i++) {
	// 	if(i-k<0) {
	// 		dp[i][0]=max({dp[i-1][0]+solve()});
	// 		dp[i][1]=;
	// 		dp[i][2]=;
	// 	} else {

	// 	}
	// }
	// cout<<max({dp[n-1][0],dp[n-1][1],dp[n-1][2]})<<endl;
	time();
	return 0;
}

Measured memory_bytes: 23888
def main():
    n = int(input())
    a = list(map(int, input().split()))

    x, y = max(a), min(a)
    for i in range(n):
        if abs(a[i]-x/2) < abs(y-x/2):
            y = a[i]

    print(x, y)


if __name__ == '__main__':
    main()


Measured memory_bytes: 14060
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<functional>
#include<queue>
#include<stack>
#include<math.h>
using namespace std;
#define mod (1000000000+7)
#define N (10007)
#define INF 1e16
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P > T;

template <typename T>
struct SegmentTree{
    typedef function<T(T,T)> F;
    int n;
    F f;
    T unit;
    vector<T> dat;
    SegmentTree(){};
    SegmentTree(int newn,F f,T t):f(f),unit(t){
        init(newn);
    }
    SegmentTree(const vector<T> &v,F f,T t):f(f),unit(t){
        int n_ = v.size();
        init(n_);
        for(int i=0;i<n_;i++)dat[n+i]=v[i];
        for(int i=n-1;i;i--){
            dat[i]=f(dat[(i<<1)|0],dat[(i<<1)|1]);
        }
    }

    void init(int n_){
        n=1;
        while(n<n_)n<<=1;
        dat.assign(n<<1,unit);
    }
    
    void update(int k,T x){
        dat[k+=n]=x;
        while(k>>=1)
            dat[k]=f(dat[(k<<1)|0],dat[(k<<1)|1]);
    }
    T query(int a,int b){
        T vl=unit,vr=unit;
        for(int l=a+n,r=b+n;l<r;l>>=1,r>>=1){
            if(l&1)vl=f(vl,dat[l++]);
            if(r&1)vr=f(dat[--r],vr);
        }
        return f(vl,vr);
    }

};

ll n,q;
SegmentTree<ll>seg;

int main(void){
    cin>>n>>q;
    auto f = [](ll l,ll r){return min(l,r);};
    seg = SegmentTree<ll>(n,f,(ll)(1LL<<31)-1);
    for(ll i=0;i<q;i++){
        ll com,x,y;
        cin>>com>>x>>y;
        if(com == 0){
            seg.update(x,y);
        }
        else{
        cout<<seg.query(x,y+1)<<endl;
        }
    }
    return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	ll a, b;
	cin>>a>>b;
	cout<<a*b/__gcd(a,b)<<endl;

	return 0;
}

Measured memory_bytes: 256
//AOJ List of Top 3 Hills

#include <stdio.h>
#define TRUE 0
#define FALSE 1

int main(){
	int result[3],buf,temp[10],flag,
		i,j,k,l;
	for(i = 0; i < 10; i++){
		scanf("%d",&temp[i]);
	}
	for(l = 0; l < 3; l++){
		while(1){
			for(j = l; j < 9; j++){
				if(temp[j] < temp[j+1]){
					buf = temp[j+1];
					temp[j+1] = temp[j];
					temp[j] = buf;
				}
			}
			flag = FALSE;
			for(k = l; k < 9; k++){
				if(temp[l] < temp[k]) flag = TRUE;
			}
			if(flag == FALSE){
				result[l] = temp[l];
				break;
			}
		}
	}
	printf("%d\n%d\n%d\n",result[0],result[1],result[2]);
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;
  for (int i = 1; i < S.size(); i++) {
    if (S.at(i-1) == S.at(i)) {
      cout << "Bad" << endl;
      return 0;
    }
  }
  cout << "Good" << endl;
  return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <numeric>

#define ALL(a)  (a).begin(),(a).end()

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

int main() {
    ll n, m;
    priority_queue <int> a;
    ll ans = 0;

    cin >> n >> m;

    for (int i = 0; i < n; i++) {
        int buff;
        cin >> buff;
        a.push (buff);
    }

    for (int i = 0; i < m; i++) {
        int buff;
        buff = a.top () / 2;
        a.pop ();
        a.push (buff);
    }

    while (!a.empty()) {
        ans += a.top ();
        a.pop();
    }

    cout << ans << endl;
    
}



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

int main(){
	
	int x[1000],y[100];
	int n,i,max=0;
	double D[5],sum1=0,sum2=0;

	for(i=0;i<5;i++){
	  D[i]=0;
	}
	
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&x[i]);
	}
	for(i=0;i<n;i++){
		scanf("%d",&y[i]);
	}
	
	for(i=0;i<n;i++){
		D[0]+=abs(x[i]-y[i]);
	}
	
	for(i=0;i<n;i++){
		sum1+=(x[i]-y[i])*(x[i]-y[i]);
	}
	D[1]=sqrt(sum1);
	
	for(i=0;i<n;i++){
		sum2+=pow(abs(x[i]-y[i]),3);
	}
	D[2]=pow(sum2,0.33333333333);
	
	for(i=0;i<n;i++){
		if(max<=abs(x[i]-y[i])){
		max=abs(x[i]-y[i]);
		}
	}	
	D[3]=max;
		for(i=0;i<4;i++){
		  printf("%.8f\n",D[i]);
	}
	return 0;
}

	
	
	

Measured memory_bytes: 704
H, W, M = map(int, input().split())
bombs = set([tuple(map(int, input().split())) for _ in range(M)])

cntH = [0] * (H + 1)
cntW = [0] * (W + 1)
for h, w in bombs:
    cntH[h] += 1
    cntW[w] += 1

mxH = max(cntH)
mxW = max(cntW)

ans = mxH + mxW - 1

mxH = [h for h in range(1, H + 1) if cntH[h] == mxH]
mxW = [w for w in range(1, W + 1) if cntW[w] == mxW]

for h in mxH:
    for w in mxW:
        if not (h, w) in bombs:
            ans += 1
            print(ans)
            exit()
print(ans)


Measured memory_bytes: 83600
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define vec(k) vector<k>
#define vecvec(k) vector<vector<k> >
#define pai(k) pair<k,k>
#define mod 1000000007
#define mpai make_pair
#define p1 first
#define p2 second
#define umap(x,y) unordered_map<x,y>
string solve(string s, string t)
{
	int l1=s.length();
	int l2=t.length();

	int dp[l1+1][l2+1];
	memset(dp,0,sizeof(dp));
	for(int i=1;i<=l1;i++)
	{
		for(int j=1;j<=l2;j++)
		{
			if(s[i-1]==t[j-1])
				dp[i][j]=dp[i-1][j-1]+1;
			else
				dp[i][j]=max(dp[i-1][j], dp[i][j-1]);
		}
	}
	// cout<<dp[l1][l2];
	if(dp[l1][l2]==0)
		return "";
	int i=l1,j=l2;
	string ans="";
	while(i>0 && j>0)
	{
		if(s[i-1]==t[j-1])
			{ans=s[i-1] +ans;
				i-=1;
				j-=1;
				// cout<<"g";
			}
		else if(dp[i][j]==dp[i-1][j])
		{
			i-=1;
		}
		else
			j-=1;
	}
	return ans;
	}

int main()
{
ios_base:: sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);

string s,t;
cin>>s>>t;
string ans=solve(s,t);
cout<<ans<<"\n";

return 0;
}


Measured memory_bytes: 35456
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<bitset>
#define INF 1000000000ll
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define DUMP(a) for(long long dump=0; dump<(ll)a.size(); dump++) { cout<<a[dump]; if(dump!=(ll)a.size()-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin>>s;
	ll x,y;
	cin>>x>>y;
	ll tc=0;
	REP(i,(ll)s.size()) if(s[i]=='T') tc++;
	if(tc==0) {
		if(y==0&&x==(ll)s.size()) cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
		return 0;
	}
	REP(i,(ll)s.size()) {
		if(s[i]=='T') {
			if(i!=(ll)s.size()-1) s=s.substr(i+1,(ll)s.size()-(i+1));
			else s="";
			x-=i;
			break;
		}
	}
	vector<ll> xc;
	vector<ll> yc;
	tc=0;
	ll buf=0;
	REP(i,(ll)s.size()) {
		if(s[i]=='T') {
			if(tc%2) xc.pb(buf);
			else yc.pb(buf);
			tc++;
			buf=0;
		} else {
			buf++;
		}
	}
	if(tc%2) xc.pb(buf);
	else yc.pb(buf);
	vector<vector<bool>> dp1((ll)xc.size()+1,vector<bool>(16001,false));
	vector<vector<bool>> dp2((ll)yc.size()+1,vector<bool>(16001,false));
	dp1[0][8000]=true;
	dp2[0][8000]=true;
	REP(i,(ll)xc.size()) {
		REP(j,16001) {
			if(j+xc[i]<16001&&dp1[i][j+xc[i]]) dp1[i+1][j]=true;
			if(j-xc[i]>=0&&dp1[i][j-xc[i]]) dp1[i+1][j]=true;
		}
	}
	REP(i,(ll)yc.size()) {
		REP(j,16001) {
			if(j+yc[i]<16001&&dp2[i][j+yc[i]]) dp2[i+1][j]=true;
			if(j-yc[i]>=0&&dp2[i][j-yc[i]]) dp2[i+1][j]=true;
		}
	}
	if(dp1[(ll)xc.size()][x+8000]&&dp2[(ll)yc.size()][y+8000]) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}


Measured memory_bytes: 16256
#include<iostream>
#include <stdio.h>
#include<string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <cstdint>
#include <queue> 
#include <map>
#include <set>
#define MOD 1000000007
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;
using namespace std;

int main(){

  string s;
  cin >> s;
  int c[26] = {}; 	//アルファベット使ってる？
  
  REP(i,s.size()){
    c[s[i]-'a']++;
  }

  int flag = 0;
  if(s.size() != 26){
    REP(i,26){
      if(c[i] == 0){
        s.push_back((char)'a'+i); break;
      }
    }
  }

  else{
    REP(i,25){
      if(s[25-i] > s[24-i]){
  //      debug(i);
		char C = s[24-i]; // 降順じゃなくなったところ
        s[24-i] = 'z';  // zで初期化
        FOR(j,25-i,26){
          if(C < s[j]){
        s[24-i] = s[j];
          }
        }
        s.erase(s.end() - (i+1) , s.end());
        flag = 1;
        break;
      }
    }
    if(flag == 0){
    cout << -1 << endl; return 0;
    }
  }

    cout << s << endl;

 return 0;
}

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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  string s;
  while (cin >> s) {
    string t = s;
    reverse(t.begin(), t.end());
    cout << (s == t ? "Yes" : "No") << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main(){
	int n,i,j,c;
	while(scanf("%d",&n)!=EOF){
		if(n==0)break;
		if(n%2==0)n--;
		for(i=n;i>=13;i-=2){
			c=0;
			for(j=2;j<=sqrt(i);j++){
				if(i%j==0)c++;
				else if((i-2)%j==0)c++;
				else if((i-6)%j==0)c++;
				else if((i-8)%j==0)c++;
				if(c>0)break;
			}
			if(c==0){printf("%d\n",i);break;}
		}
	}
	return 0;
}

Measured memory_bytes: 0
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce
from operator import mul


sys.setrecursionlimit(2147483647)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


a, b, c, k = LI()
if k <= a:
    print(k)
elif a < k <= a + b:
    print(a)
else:
    print(a - (k- a - b))


Measured memory_bytes: 81392
while True:
    h, w = map(int, input().split())
    if h == 0 and w == 0:
        break
    for i in range(h):
        if i == 0 or i == h-1:
            print('#' * w)
        else:
            print('#' + '.' * (w-2) + '#')
    print('')


Measured memory_bytes: 5612
#include <cstdlib>
#include <iostream>


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

  int n, k;
  std::cin >> n >> k;
  int answer = k;
  for (int i = 0; i < n - 1; i++) {
    answer *= k - 1;
  }
  std::cout << answer << std::endl;

  return EXIT_SUCCESS;
}


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

int main(){
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;

    vector<int> v;
    int now = 1;
    int cnt = 0;
    for(int i=0; i<s.size(); i++){
        if(s[i] == (char)('0' + now)) cnt++;
        else {
            v.push_back(cnt);
            now = 1 - now;
            cnt = 1;
        }
    }
    if(cnt != 0) v.push_back(cnt);

    if(v.size() % 2 == 0) v.push_back(0);

    int add = 2*k + 1;

    int ans = 0;
    
    int left = 0;
    int right = 0;
    int tmp = 0;
    for(int i=0; i<v.size(); i+=2){
        int NextLeft = i;
        int NextRight = min(i + add, (int)v.size());

        while(NextLeft > left){
            tmp -= v[left];
            left++;
        }

        while(NextRight > right){
            tmp += v[right];
            right++;
        }

        ans = max(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1020
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
 
int main(){
    int n,a,b,i;
    cin>>n>>a>>b;
    cout<<min(a,b)<<" "<<max(0,a+b-n);

    return 0;
}


Measured memory_bytes: 256