akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<deque>
#include<cstdio>
using namespace std;

int main(){
    int num_query;
    scanf("%d",&num_query);
    deque<int> int_array;
    int command,direction, val;
    
    for(int i = 0; i < num_query;i++){
        scanf("%d",&command);
        if(command == 0){                       // push
            scanf("%d %d",&direction,&val);
            if(direction == 0){                 // push front
                int_array.push_front(val);
            }else{                              // push back
                int_array.push_back(val);
            }
        }else if(command == 1){                 // random access
            scanf("%d",&val);
            printf("%d\n",int_array[val]);
        }else if(command == 2){                 // pop
            scanf("%d",&direction);
            if(direction == 0){                 // pop front
                int_array.pop_front();
            }else{                              // pop back
                int_array.pop_back();
            }
        }
        
    }

    return 0;
}


Measured memory_bytes: 4632
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;

using ll = long long;
using ld = long double;
const int INF = 1e9;
const double EPS = 1e-9;
const ll MOD = 998244353;

ll repeatSquaring(ll n, ll p)
{
  if (p == 0)
    return 1;
  if (p % 2 == 0)
  {
    ll t = repeatSquaring(n, p / 2) % MOD;
    return t * t % MOD;
  }
  return n * repeatSquaring(n, p - 1) % MOD;
}

int main()
{
  long long N;
  scanf("%lld", &N);
  std::vector<long long> D(N);
  ll arr[100010] = {};
  for (int i = 0; i < N; i++)
  {
    scanf("%lld", &D[i]);
    arr[D[i]]++;
  }
  ll ans = 1;
  int cnt = arr[0];
  if (arr[0] != 1 || D[0] != 0)
  {
    cout << 0 << endl;
    return 0;
  }
  for (int i = 1; i < N; ++i)
  {
    if (cnt == N)
      break;
    ans = ans * repeatSquaring(arr[i - 1], arr[i]) % MOD;
    cnt += arr[i];
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1792
import sys
file= lambda location: {True:sys.stdin, False:open(location,"r")}[location==""]

location=""#Enter location here
#sys.stdin=file(location)
raw_input=sys.stdin.readline

N=int(raw_input())
A=raw_input().strip()
B=raw_input().strip()
C=raw_input().strip()
ans=0
for i in xrange(N):
	m=len(set(A[i]+B[i]+C[i]))
	ans=ans+(m-1)
print ans

Measured memory_bytes: 2568
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  ll n = 0;
  cin >> n;
  vector<ll> m(n);
  ll wa = 0;
  for(int i = 0;i < n;i++){
    cin >> m[i];
    wa += m[i];
  }
  sort(m.begin(),m.end());
  wa -= m[n - 1];
  if(wa > m[n - 1])cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
// inputに入力データ全体が入る
function Main(input) {
	input = input.split("\n");
	const [left, right] = input[0].split(" ");
        if (+left <= 8 && right <= 8) {
          console.log('Yay!')
        } else {
          console.log(':(')
        }
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include<stdio.h>
#define MAX 500000
#define SENTINEL 2000000000

int L[MAX/2+2],R[MAX/2+2];
int count;

void merge(int A[],int n,int left,int mid,int right){
  int i,j,k;
  int n1 = mid - left;
  int n2 = right - mid;
  for ( i = 0; i < n1; i++ )
    L[i] = A[left + i];
  for ( i = 0; i < n2; i++ )
    R[i] = A[mid + i];
  L[n1] = R[n2] = SENTINEL;
  i = j = 0;
  for ( k = left; k < right; k++ ){
    count++;
    if ( L[i] <= R[j] ){
      A[k] = L[i++];
    } else {
      A[k] = R[j++];
    }
  }
}

void mergeSort(int A[],int n,int left,int right){
  int mid;
  if ( left+1 < right ){
    mid = (left + right)/2;
    mergeSort(A,n,left,mid);
    mergeSort(A,n,mid,right);
    merge(A,n,left,mid,right);
  }
}

int main(){
  int A[MAX],n,i;
  scanf("%d",&n);
  count = 0;
  for ( i = 0 ; i < n ; i++ ){
    scanf("%d",&A[i]);
    if (A[i] >= SENTINEL ){
      return 1;
    }
  }
  mergeSort(A,n,0,n);

  for ( i = 0 ; i < n ; i++ ){
    if ( i ) printf(" ");
    printf("%d",A[i]);
    }
  printf("\n");

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

  return 0;
}



Measured memory_bytes: 5712
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<vector<int>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VP = vector<P>;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

void dfs(VVI &g, P np, int v, int p, VI &dist){
    for(int d: g[v]){
        if (d == p) continue;
        if (dist[d] != -1) continue;
        if (np.first == d && np.second == v) continue;
        if (np.first == v && np.second == d) continue;
        dist[d] = dist[v] + 1;
        dfs(g, np, d, v, dist);
    }
}

int main(){
    int n, m;
    cin >> n >> m;
    VVI g(n);
    VP np(m);
    rep(i, m){
        int a, b;
        cin >> a >> b;
        a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
        np[i] = P(a, b);
    }

    int ans = 0;
    rep(i,m){
        int v = 0;
        while(np[i].first == v || np[i].second == v) v++;
        VI dist(n, -1);
        dist[v] = 0;
        dfs(g, np[i], v, -1, dist);
        rep(i,n) if (dist[i] == -1){
            ans++;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3588
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		int i;
		int check5=0;
		int check7=0;
		Scanner sc = new Scanner(System.in);
		List<Integer> abc = new ArrayList<Integer>();
		abc.add(0,sc.nextInt()); 
		abc.add(1,sc.nextInt()); 
		abc.add(2,sc.nextInt()); 
		for(i=0;i<3;i++) {
			if(abc.get(i)==5) {
				check5++;
			}else if (abc.get(i)==7) {
				check7++;
			}	
		}
		if(check5==2 & check7==1) {
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}
	}
}

Measured memory_bytes: 21332
//Compete against Yourself.
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 2e9;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 25;

//625

int n, m;
char a[N][N];
int dist[411][411];

const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, 1, 0, -1};
const int dxb[4] = {-1, 1, 1, -1};
const int dyb[4] = {-1, 1, -1, 1};
const int DX[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
const int DY[8] = {-1, 0, 1, 1, 1, 0, -1, -1};

bool valid(int x, int y){
   return x >= 0 and y >= 0 and x < n and y < m;
}

inline int getEncode(int x, int y){
   return x * m + y;
}

void bfs(int sourcex, int sourcey){
   queue<vector<int>> q;
   q.push({sourcex, sourcey});
   int vals = getEncode(sourcex, sourcey);
   dist[getEncode(sourcex, sourcey)][getEncode(sourcex, sourcey)] = 0;

   map<int, bool> seen;
   while(!q.empty()){
      vector<int> v = q.front();
      int x = v[0], y = v[1];
      q.pop();
      int encodexy = x*m + y;
      if(seen.count(encodexy))
         continue;
      seen[encodexy] = 1;
      for (int i = 0; i < 4; ++i)
      {
         int nx = x + dx[i];
         int ny = y + dy[i];
         if(!valid(nx, ny))continue;
         if(a[nx][ny] == '#')continue;
         int encodenxy = getEncode(nx, ny);
         if(dist[vals][encodenxy] > dist[vals][encodexy]){
            dist[vals][encodenxy] = dist[vals][encodexy] + 1; 
            q.push({nx, ny});
         }
      }
   }
}

#define dis dist

void build(int n = 401){
   for (int k = 0; k <=n ; ++k)
      for (int i = 0; i <= n; ++i)
         for (int j = 0; j <= n ; ++j){
            if(dist[i][k] > 1e6 or dist[k][j] > 1e6)continue;
            dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]);
         }
}

int32_t main(){_
   
   cin>>n>>m;
   
   for (int i = 0; i < n; ++i)
   {
      for (int j = 0; j < m; ++j)
      {
         cin >> a[i][j];
      }
   }

   memset(dist, 63, sizeof dist);

   for (int i = 0; i < n; ++i)
   {
      for (int j = 0; j < m; ++j)
      {
         if(a[i][j] == '#')continue;
         dist[getEncode(i,j)][getEncode(i,j)] = 0;
         for (int k = 0; k < 4; ++k)
         {  
            int nx = i + dx[k];
            int ny = j + dy[k];
            if(!valid(nx, ny) or a[nx][ny] == '#')
               continue;
            dist[getEncode(i,j)][getEncode(nx,ny)] = 1;
         }
      }
   }

   build();
   int ans = 0;
   for (int i = 0; i < 405; ++i)
   {
      for (int j = 0; j < 405; ++j)
      {
         if(dist[i][j] > 1e6)continue;
         smax(ans, dist[i][j]);
      }
   }

   cout<<ans;
   return 0;
}

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

int *tmp;

long long  merge(int *a, int low, int mid, int high){
        for(int i=low;i<high;i++) tmp[i]=a[i];
        int i=low, j=mid, k=low;
        long long c=0;
        while(i<mid||j<high){
                if(i==mid) a[k++] = tmp[j++];
                else if(j==high) a[k++] = tmp[i++];
                else{
                        if(tmp[i]<=tmp[j]) a[k++] = tmp[i++];
                        else {
                                c += mid-i;
                                a[k++] = tmp[j++];
                        }
                }
        }
        return c;
}

long long  mergesort(int *a, int low, int high){
        if(low>=high-1) return 0;
        int mid = low+(high-low)/2;
        long long c1 = mergesort(a, low, mid);
        long long c2 = mergesort(a, mid, high);
        long long c3 = merge(a, low, mid, high);
        return c1+c2+c3;
}

int main(){
        int n;
        cin>>n;
        int a[n];
        for(int i=0;i<n;i++) cin>>a[i];
        tmp = new int[n];
        long long c = mergesort(a,0,n);
        cout<<c<<endl;
        delete tmp;
        return 0;
}


Measured memory_bytes: 4336
//abc108_c.cpp
//Sat Sep  1 20:28:32 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

	ll temp = k;
	ll same = 0;
	ll half = 0;
	while (temp <= n){
		same++;
		half++;
		temp += k;
	}
	if (temp - k/2 <= n){
		half++;
	}
	if (k%2==1){
		half = 0;
	}

//	cout << same << " " << half << endl;

	ll ans = same*same*same+half*half*half;


	cout << ans << endl;
//	printf("%.4f\n",ans);
}

Measured memory_bytes: 256
import math
m,d = map(int,input().split())
count = 0
for i in range(m+1):
  for j in range (d+1):
    d_10 = math.floor(j/10)
    d_1 = j-10*d_10
    if d_1 >= 2 and d_10 >= 2 and d_1 * d_10 == i:
      count += 1
print(count)
    

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=n;i<N;i++)
#define p(S) cout<<S<<endl
#define ck(a,b) (0<=(a)&&(a)<(b))

using namespace std;


int main(){
	const int INF = 100000;
	int N,M,L,K,A,H;//A:start,H:goal
	while(cin>>N>>M>>L>>K>>A>>H,N){
		bool reito[100]={false};
		int time[101][101];
		REP(i,0,N) REP(j,0,N) time[i][j]=INF;
		REP(i,0,L){
			int a;
			cin>>a;
			reito[a]=true;
		}
		reito[A]=reito[H]=true;
		REP(i,0,K){
			int a,b;
			cin>>a>>b;
			cin>>time[a][b];
			time[b][a]=time[a][b];
		}
		REP(k,0,N)	REP(i,0,N)	REP(j,0,N){
			if(i==j) continue;
			time[i][j]=min(time[i][j],time[i][k]+time[k][j]);
		}
		REP(i,0,N) REP(j,0,N){
			if(i==j) continue;
			if(!reito[i]||!reito[j]||time[i][j]>M){
				time[i][j]=INF;
			}
		}
		REP(k,0,N)	REP(i,0,N)	REP(j,0,N){
			if(i==j) continue;
			time[i][j]=min(time[i][j],time[i][k]+time[k][j]);
		}
		if(time[A][H]==INF){
			p("Help!");
		}else{
			p(time[A][H]+max(0,time[A][H]-M));
		}
	}

}

Measured memory_bytes: 3120
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;

int main(){

	int p[8], n[8], least, cnt;
	const int a[8] = {4,1,4,1,2,1,2,1};
	vector<int> vc;
	string str[8];

	while(cin >> p[0]){
		for(int i=1; i<8; i++){
			cin >> p[i];
		}
		
		cnt = 0;
		fill(n, n+8, 0);
		for(int i=0; i<8; i++){
			for(int j=0; j<8; j++){
				if(a[(i+j)%8] < p[j]){
					n[i] += p[j] - a[(i+j)%8];
				}
			}

			if(i == 0 || n[i] < n[least]){
				least = i;
				cnt = 1;
				vc.clear();
				vc.push_back(i);
			}
			else if(n[i] == n[least]){
				cnt++;
				vc.push_back(i);
			}
		}

		if(cnt == 1){
			for(int i=0; i<8; i++){
				cout << a[(vc[0] + i) % 8];
				if(i == 7) cout << endl;
				else cout << " ";
			}
		}
		else {
			for(int i=0; i<cnt; i++){
				str[i] = "";
				for(int j=0; j<8; j++){
					str[i] += a[(vc[i] + j) % 8] + '0';
				}
			}
			sort(str, str+cnt);
			for(int i=0; i<8; i++){
				cout << str[0][i];
				if(i == 7) cout << endl;
				else cout << " ";
			}
		}
	}

	return 0;

}

Measured memory_bytes: 1236
#define taskname ""
#include <bits/stdc++.h>

using namespace std;

const int maxN = 1e5;

int n;
string s;

vector<int> v;
vector<int> res;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
    cin >> s;
    n = s.size();
    v.emplace_back(1);
    for (int i = 1; i < n; ++i)
    {
        if (s[i] == s[i - 1])
        {
            ++v.back();
        }
        else
        {
            v.emplace_back(1);
        }
    }
    for (int i = 0; i < v.size(); i += 2)
    {
        int x = v[i], y = v[i + 1];
        int c = (x + y) / 2, d = (x + y) / 2;
        if (((abs(x - y) + 1) & 1) == 0)
        {
            if (x > y)
            {
                if (x & 1)
                {
                    ++c;
                }
                else
                {
                    ++d;
                }
            }
            else
            {
                if (y & 1)
                {
                    ++d;
                }
                else
                {
                    ++c;
                }
            }
        }
        for (int i = 1; i < x; ++i)
        {
            res.emplace_back(0);
        }
        res.emplace_back(c);
        res.emplace_back(d);
        for (int i = 1; i < y; ++i)
        {
            res.emplace_back(0);
        }
    }
    for (auto &k: res)
    {
        cout << k << ' ';
    }
    return 0;
}


Measured memory_bytes: 1480
M=10**9+7
N,K=gets.split.map(&:to_i)
if K.odd?
  p 0
  exit
end
dp=Array.new(N+1){Array.new(N+1){Array.new(K+N+1){0}}}
dp[0][0][0]=1
N.times do |i|
  N.times do |j|
    0.upto(K/2) do |k|
      dp[i][j][k] %= M
      # 新規同士で繋げる
      dp[i+1][j][k+j] += dp[i][j][k]
      # 片方だけ保留と繋げる
      dp[i+1][j][k+j] += 2 * j * dp[i][j][k]
      # 両方とも保留と繋げる
      dp[i+1][j-1][k+j-1] += j * j * dp[i][j][k] if 0<=j-1
      # 両方とも保留する
      dp[i+1][j+1][k+j+1] += dp[i][j][k]
    end
  end
end
p dp[N][0][K/2]%M

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

#define int long long
#define double long double

#define override_rep(i, l, r, mes, ...) mes
#define rep1(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = l; i < r; i++)
#define rep(...) override_rep(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)

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

constexpr int MOD = 1e9+7;

template<typename T, typename U>
istream& operator>>(istream& in, pair<T, U>& p) {
    in >> p.first >> p.second;
    return in;
}

// https://twitter.com/vane11ope ←フォローしましょう
// (ノ)>◡<(ヾ)ﾓﾁﾓﾁ
signed main(signed argc, char* argv[]) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int n,cnt=0;
    cin>>n;
    rep(i,n){
        int in;
        cin>>in;
        if(i%2==0&&in%2){
            cnt++;
        }
    }
    cout<<cnt<<endl;
}


Measured memory_bytes: 3644
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

func pos(i, h, w int) (int, int) {
	x := i % w
	y := i / w
	if y%2 == 1 {
		x = w - 1 - x
	}

	return x, y
}

func main() {
	sc.Split(bufio.ScanWords)

	H, W := getInt(), getInt()
	N := getInt()
	a := make([]int, N)
	for i := 0; i < N; i++ {
		a[i] = getInt()
	}

	var mat [100][100]int
	n := a[0]
	c := 1
	for i := 0; i < H*W; i++ {
		px, py := pos(i, H, W)
		mat[px][py] = c
		n--
		if c != N && n == 0 {
			n = a[c]
			c++
		}
	}

	for y := 0; y < H; y++ {
		for x := 0; x < W; x++ {
			fmt.Printf("%d ", mat[x][y])
		}
		fmt.Println()
	}
}


Measured memory_bytes: 896
#include<iostream>
using namespace std;
int main()
{
  int a,b,c;
  cin>>a>>b>>c;
  if(a==b&&b==c){
    cout<<"1";
  }
   else if(a==b||a==c||b==c){
    cout<<"2";
   }
  else{
    cout<<"3";
  }
}

Measured memory_bytes: 3596
#include <iostream>
#include <bits/stdtr1c++.h>
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
using namespace std;
typedef long long ll;
const int N = 100005;
const int MOD = 1000000007;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    int a[n+1];
    int sum=0;
    for(int i=1;i<=n;i++) {cin >> a[i];sum+=a[i];}
    int m;cin >> m;
    while(m--){
        int i,x;
        cin >> i >> x;
        int prev=sum;
        cout  << sum-a[i]+x << endl;;
    }

    
    return 0;
}


Measured memory_bytes: 3576
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
#define ll long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,0,n)
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007
using namespace std;

int main(){
  int N;
  cin>>N;
  double A[N],ans=0;
  REP(i,N) cin>>A[i];
  
  REP(i,N) ans+=1/A[i];
  cout<<1/ans<<endl;
}


Measured memory_bytes: 256
while True:
    m,n=map(int,input().split())
    if m==n==0:
        break
    else:
        ans=0
        for a in range(1,m+1):
            for b in range(1,a):
                for c in range(1,b):
                    if a+b+c==n:
                        ans+=1
        print(ans)


Measured memory_bytes: 5596
/*
    ->->->->-> Vora Mahammasasim <-<-<-<-<-
*/
#include<bits/stdc++.h>
#define Quick std :: ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define pb emplace_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define MOD 1e7+7;
using namespace std;





signed main(){

    Quick;
    int n;
    cin>>n;
    vector<int>x(n),y(n);
    for(int i=0;i<n;i++) cin>>x[i]>>y[i];
    int ans1 = 1e18,ans2 = 1e18,ans3 = -1e18,ans4 = -1e18;
    for(int i=0;i<n;i++){
        ans3 = max(ans3,x[i]+y[i]);
        ans4 = max(ans4,x[i]-y[i]);
        ans1 = min(ans1,x[i]+y[i]);
        ans2 = min(ans2,x[i]-y[i]);
    }
    cout<<max(ans3-ans1,ans4-ans2);
    return 0;
}


Measured memory_bytes: 6364
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
    // Your code here!
    
    while(1){
    int n = 0;
    int m = 0;
    scanf("%d %d",&n, &m);
    if(n==0 && m==0)break;
    int a[1000] = {0};
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    
    int max = 0;
    int koushin = 0;
    
    for(int i=0;i<n-1;i++){
        for(int j=i+1;j<n;j++){
            if(max<a[i]+a[j] && m>=a[i]+a[j]){
                max = a[i]+a[j];
                koushin = 1;
            }
        }
    }
    
    if(koushin !=1){
        cout << "NONE" << endl;
    }
    else{
    cout << max << endl;
    }
    }

    return 0;
}


Measured memory_bytes: 3144
using System;
using System.Linq;
using System.Collections.Generic;

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var nk = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
        var (n, k) = (nk[0], nk[1]);
        var treats = new (int d, int[] A)[k];
        for (int i = 0; i < treats.Length; ++i)
        {
            var d = int.Parse(Console.ReadLine());
            var seqA = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
            treats[i] = (d, seqA);
        }

        var sunukes = new HashSet<int>(E.Range(1, n));
        for (int i = 0; i < treats.Length; ++i)
        {
            sunukes.ExceptWith(treats[i].A);
        }

        Console.WriteLine(sunukes.Count);
    }
}


Measured memory_bytes: 28472
#include<bits/stdc++.h>
#define pb push_back
#define in insert
#define ff first
#define ss second
#define mp make_pair
#define int long long
#define uint unsigned long long
#define rep(i,x,m) for(int i=x;i<m;i++)
#define repr(i,x,m) for(int i=x;i>=m;i--)
#define MOD 1000000007
#define endl "\n"
using namespace std;
#define noob ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

void ram5564()
{
    int n,a,b;
    cin>>n>>a>>b;
    int ans=(n/(a+b))*a;
   if ((n%(a+b))<=a)
    ans+=(n%(a+b));
else
  ans+=a;
cout<<ans;
}

signed main()
{
		noob
		
        
        int t=1;
       //	 cin>>t;
        while(t--)
        ram5564();
        return 0;
}

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

int main(int argc, char *argv[]){
    char s[1001],t[1001];
    cin >> s >> t;
    int c=0;
    int max=0;
    int a=strlen(s)-strlen(t)+1;
    for(int i=0;i<a;i++){//何周するか
        c=0;
        for(int j=0;j<strlen(t);j++){//比較する文字
            if(s[j+i]==t[j]){
                c++;
            }
        }
        if(max<c) max=c;
    }
    cout << strlen(t)-max << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG
#include "../../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

int main(void) {
    ll n;
    cin >> n;

    ll r = n%10;
    if(r==3) {
        cout << "bon\n";
    } else if(r==0 || r==1 || r==6 || r==8) {
        cout << "pon\n";
    } else {
        cout << "hon\n";
    }

    return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
//cout << setprecision(20) << 

int D = 365;
vector<int> c(27);
vector<vector<int>> s(D + 1);

ll calc_score(vector<int> &t) {
    ll satisfy = 0;
    vector<int> last(27, 0);
    for (int i = 1; i <= D; ++i) {
        int con = t[i];
        // add satisfy
        satisfy += s[i][con];
        // update last
        last[con] = i;
        // sub satisfy
        for (int j = 1; j <= 26; ++j) {
            satisfy -= c[j] * (i - last[j]);
        }
    }
    return satisfy;
}

int main() {
    clock_t start = clock();

    cin >> D;
    for (int i = 1; i <= 26; ++i) cin >> c[i];
    for (int i = 1; i <= D; ++i) {
        vector<int> v(27);
        for (int j = 1; j <= 26; ++j) cin >> v[j];
        s[i] = v;
    }

    // output
    vector<int> ans(D + 1);
    vector<int> last(27, 0);
    ll satisfy = 0;
    for (int i = 1; i <= D; ++i) {
        ll max_pen = 0;
        ll choose_con = 0;
        for (int j = 1; j <= 26; ++j) {
            ll penalty = c[j] * (i - last[j]);
            if (penalty > max_pen) {
                choose_con = j;
                max_pen = penalty;
            }
        }
        // actual update
        int con = choose_con;
        last[con] = i;
        ans[i] = con;
    }

    // random
    // cout << "random" << endl;
    clock_t end = clock();
    double time = static_cast<double>(end-start) / CLOCKS_PER_SEC * 1000.0;
    ll best_score = calc_score(ans);
    random_device rd{};
    while (time < (double)1600) {
        // random
        ll times = rd() % 50;
        vector<int> c_ans = ans;
        for (int j = 0; j < times; ++j) {
            ll day = rd() % 360 + 1;
            ll con = rd() % 25 + 1;
            c_ans[day] = con;
        }
        ll score = calc_score(c_ans);
        if (score > best_score) ans = c_ans;
        end = clock();
        time = static_cast<double>(end-start) / CLOCKS_PER_SEC * 1000.0;
    }

    // output
    for (int i = 1; i <= D; ++i) {
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 3728
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define ull unsigned long long
#define F first
#define S second
#define eps 1e-6
#define mp make_pair
const long long INF=1e18+2;
const int MX=353;
int N, M, k;
ll arr[MX];
int row[222], col[222];
char g[MX][MX];
int main()
{
    scanf("%d%d", &N, &k);
    vector<int> v;bool found=0;
    for(int i=0;i<N;i++)
    {
        int x;
        scanf("%d", &x);
        if(!x) found=1;
        v.pb(x);
    }
    if(!found) v.pb(0);
    N=v.size();
    sort(v.begin(), v.end());
    int idx=-1;
    for(int i=0;i<v.size();i++)
    {
        if(v[i] == 0)
        {
            idx=i;
            break;
        }
    }
    int t=1e9*2;
    for(int i=idx;i<v.size();i++)
    {
        if(i-idx+found > k) break;
        int rem=k-(i-idx+found);
        if(idx-rem <0) continue;
      //  cout<<rem<<'\n';
        t=min(t, min(abs(v[idx-rem])*2+v[i], v[i]*2+abs(v[idx-rem])));
    }
    cout<<t;
    return 0;
}



Measured memory_bytes: 892
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define endl "\n"

const long long INF = (long long)1e18;
const long long MOD = 1'000'000'007; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}



signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int H, W, A, B;
	
	cin>>H>>W>>A>>B;
	
	int hoge = 0;
	
	for(int i = 0; i < H; i++){
		if(i < B) hoge = 1;
		else hoge = 0;
		for(int j = 0; j < W; j++){
			if(j == A) hoge = !hoge;
			cout<<hoge;
		}
		cout<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 1280
N, A, B = map(int, input().split())
i = 0
total = 0
arr = [num for num in range(1,N+1)]
while len(arr) > i:
	if A <= arr[i] and arr[i] <= B and arr[i] < 10:
		total += arr[i]
	if arr[i] >= 10:
		u10 = list(str(arr[i]))
		splt = sum([int(num)  for num in u10])
		if A <= splt and splt <= B:
			total += arr[i]
	i += 1
print(total)

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

int main() {
    int n; cin >> n;
    string s[n];
    int a[4];
    rep(i, 4) a[i] = 0;
    rep(i, n){
        cin >> s[i];
        if(s[i] == "AC") a[0]++;
        if(s[i] == "WA") a[1]++;
        if(s[i] == "TLE") a[2]++;
        if(s[i] == "RE") a[3]++;
    }

    cout << "AC x " << a[0] << endl;
    cout << "WA x " << a[1] << endl;
    cout << "TLE x " << a[2] << endl;
    cout << "RE x " << a[3] << endl;
    

    return 0;
}

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

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

  vector<int> X(N);
  rep(i, N) cin >> X[i];

  vector<ll> dp(N);
  dp[0] = 0;
  for (int i = 1; i < N; ++i) {
    ll a = (X[i] - X[i - 1]) * A;
    ll b = B;
    dp[i] = min(a, b) + dp[i - 1];
  }

  cout << dp.back() << endl;
}

Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <array>
#include <unordered_set>
#include <unordered_map>
#include <math.h>
using namespace std;
using s64 = int64_t;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep2(i, x, n) for(int i=x;i<n;++i)

int main()
{
    string s;
    cin >> s;
    int year = stoi(s.substr(0,4));
    int month = stoi(s.substr(0,4));
    if(year < 2019)
        cout << "Heisei" << endl;
    else if(year > 2019)
        cout << "TBD" << endl;
    else
    {
        if(stoi(s.substr(5,2)) <= 4)
            cout << "Heisei" << endl;
        else
            cout << "TBD" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
import java.lang.*;

public class Main{
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int n = sc.nextInt();
		System.out.println((n - 1) / 2);
	}
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;
	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}
	private int readByte() {
		if (hasNextByte()) {
			return buffer[ptr++];
		} else {
			return -1;
		}
	}
	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}
	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
			ptr++;
		}
		return hasNextByte();
	}
	public String next() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	public long nextLong() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || Integer.MAX_VALUE < nl) {
			throw new NumberFormatException();
		}
		return (int) nl;
	}
	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


Measured memory_bytes: 20692
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dy[] = {1, 0, -1, 0};
const int dx[] = {0, 1, 0, -1};
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n;
    vector<int> v(n + 1);
    for(int i = 0; i < n; i++) cin >> v[i];
    cin >> m;
    vector<int> w(m + 1);
    for(int i = 0; i < m; i++) cin >> w[i];
    int ans;
    for(int i = 0; i < min(n, m); i++)
    {
        if(v[i] == w[i]) continue;
        if(v[i] > w[i]) ans = 0;
        else ans = 1; 
        cout << ans << endl;
        return 0;
    }
    if(v.size() == w.size()) cout << 0 << endl;
    else cout << (v.size() > w.size() ? 0 : 1) << endl;
    return 0;
}




Measured memory_bytes: 3160
using System;

class Aserval
{
    static void Main(string[] args)
    {
        var input = Console.ReadLine().Split(' ');
        var strength = int.Parse(input[0]);
        var damage = int.Parse(input[1]);
        int count = 0;

        while(strength > 0)
        {
            strength = strength - damage;
            count++;
        }

        Console.WriteLine(count);
    }
}

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

n, m = map(int, input().split())
X = list(map(int, input().split()))
X.sort()
nums = []
for i in range(1, m):
    nums.append(X[i] - X[i-1])
nums.sort()
for i in range(n-1):
    if len(nums) == 0:
        break
    nums.pop()
print(sum(nums))

Measured memory_bytes: 14076
import java.math.BigInteger;
import java.util.Scanner;



public class Main {


	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		BigInteger ans = BigInteger.ZERO;
		for (long i=1;i*i<n;i++) {
			if (n%i==0 && n/i-1>i) {
				ans=ans.add(BigInteger.valueOf(n/i-1));
			}
		}
		System.out.println(ans);
	}



}





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

using namespace std;

#define int long long
#define tie() ios_base :: sync_with_stdio(0); cin.tie(0) ; cout.tie(0)
#define err(x) cerr << #x << " is : " << x << endl
#define mem(a , v)   memset(a , v , sizeof a)
#define all(v) v.begin() , v.end()
#define endl '\n'


const int N = 1e5 + 20;
const int mod = 1e9 + 7;
string SMAX = "3234566667";



bool operator < (string &a  , string &b)
{
      if(a.size() < b.size())
            return true;
      if(a.size() > b.size())
            return false;
      for(int i = 0 ; i < a.size();  i++)
      {
            if(a[i] > b[i])
                  return false;
            if(a[i] < b[i])
                  return true;
      }
      return false;
}


bool operator > (string &a  , string &b)
{
      if(a.size() > b.size())
            return true;
      if(a.size() < b.size())
            return false;
      for(int i = 0 ; i < a.size();  i++)
      {
            if(a[i] > b[i])
                  return true;
            if(a[i] < b[i])
                  return false;
      }
      return false;
}


char low(char c)
{
      return (c < '0') ? '0' : c;
}

char high(char c)
{
      return c > '9' ? '9' : c;
}

vector <string> ans;

void rec(string s , int idx = -1)
{
      if(s > SMAX)
            return;
      if(!s.empty())
            ans.push_back(s);

      if(idx == -1)
      {
            for(char i = '1' ; i <= '9' ; i++)
            {
                  s += i;
                  rec(s , idx + 1);
                  s.pop_back();
            }
            return;
      }

      char l = low(s[idx] - 1);
      char h = high(s[idx] + 1);
      for(char i = l ; i <= h; i++)
      {
            s += i;
            rec(s , idx + 1);
            s.pop_back();
      }

      return;
}


int32_t main()
{
      tie();
      int t = 1;
      //cin >> t;
      string s = "";
      rec(s);
      sort(all(ans) , [&](string &a , string &b)
      {
            return a < b;
      });
      while(t--)
      {
            int k;
            cin >> k;
            k--;
            cout << ans[k] << endl;
      }
      return 0;
}


Measured memory_bytes: 6388
h,n = map(int,input().split())
# 整数の入力値をスペースで受け取ってリスト化
a = list(map(int,input().split()))

# アライグマの体力(h)が必殺技の合計(sum(s))が大きければNo
if h > sum(a):
    print("No")
# 必殺技の合計が大きければYes
else:
    print("Yes")

Measured memory_bytes: 20492
N,K = map(int, input().split())
MOD = int(1e9+7)

fac = [0] * (N+10)
finv = [0] * (N+10)
inv = [0] * (N+10)

fac[0], fac[1] = 1, 1
finv[0], finv[1] = 1, 1
inv[1] = 1
for i in range(2,N+10):
  fac[i] = fac[i-1] * i % MOD
  inv[i] = MOD - inv[MOD%i] * (MOD // i) % MOD
  finv[i] = finv[i - 1] * inv[i] % MOD
  
def cmb(n, k):
  if n < k:
    return 0
  if n < 0 or k < 0:
    return 0
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;

red,blue = N-K,K
for i in range(1,K+1):
  # Bが2回に分かれるということは、R[0], B[1], R[1], B[1], R[0] となること
  # なので、Bの並べ方はblue-2個と区切り一つの重複並び替え
  # R の並べ方は red-1個と区切り２つの重複並び替え
  # B=3 R BRBRB R
  # B blue-3 と区切り２
  # R red-2 と区切り３つ
  bc = cmb(blue - 1, i-1)
  #if blue == i:
    #bc = 1
  rc = cmb(red + 1, i)
  #if red == i-1:
    #rc = 1
  #print(bc, rc)
  print(bc*rc % MOD)


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

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        int n = sc.NextInt();
        int[] a = sc.IntArray();

        int answer = a.Max() - a.Min();

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 13396
import sys
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    N = int(readline())
    A = list(map(int, readline().split()))
    ans = 1
    if 0 in A:
        print(0)
        sys.exit()
    for i in range(N):
        ans *= A[i]
        if ans>10**18:
            print('-1')
            break
    else:
        print(ans)
if __name__ == '__main__':
    main()

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

// const int mod = 1000000007;
const int mod = 998244353;
struct mint {
  ll x;  // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const { return mint(*this) += a; }
  mint operator-(const mint a) const { return mint(*this) -= a; }
  mint operator*(const mint a) const { return mint(*this) *= a; }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod - 2); }
  mint& operator/=(const mint a) { return *this *= a.inv(); }
  mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

int main() {
  ll n, s;
  cin >> n >> s;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  vector<vector<mint>> dp(n + 1, vector<mint>(s + 1));
  dp[0][0] = 1;
  rep(i, n) {
    rep(j, s + 1) {
      dp[i + 1][j] += dp[i][j] * 2;
      if (j + a[i] <= s) dp[i + 1][j + a[i]] += dp[i][j];
    }
  }
  cout << dp[n][s] << endl;
  return 0;
}


Measured memory_bytes: 73644
#座標も数値も全部0-indexedに直す
H,W,D=map(int,input().split())
coordinate = [None for _ in range(H*W)]
for i in range(H):
    raw = list(map(int,input().split()))
    for j in range(W):
        coordinate[raw[j]-1] = (i,j)
l = H*W//D + 2
cumm = [[0 for _ in range(l)] for _ in range(D)]
for i in range(H*W):
    q,r = divmod(i,D)
    if q==0:
        continue
    #q>0
    x1,y1 = coordinate[i]
    x0,y0 = coordinate[i-D]
    distance = abs(x1-x0) + abs(y1-y0)
    cumm[r][q] = cumm[r][q-1] + distance
Q = int(input())
for _ in range(Q):
    L,R = map(int,input().split())
    q0,r0 = divmod(L-1,D)
    q1,r1 = divmod(R-1,D)
    print(cumm[r1][q1]-cumm[r0][q0])


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

#define int long long
#define sup (int)(1e8 - 1)
#define inf (int)(1e9 + 7)
#define datatype pos

typedef struct {
	int X;
	int Y;
}pos;

//比較関数
int compare(datatype a, datatype b){
	return a.X - b.X;
}

//昇順
void sort_sub(datatype *origin, int left, int right, datatype *tmp){
	if(right - left > 1){
		int i, j, k, half = (left + right) / 2;
		sort_sub(origin, left, half, tmp);
		sort_sub(origin, half, right, tmp);
		for(i = left; i < right; i++){
			tmp[i] = origin[i];
		}
		for(i = left, j = left, k = half; i < right; i++){
			if((compare(tmp[j], tmp[k]) <= 0 && j < half) || k == right){
				origin[i] = tmp[j];
				j++;
			}
			else{
				origin[i] = tmp[k];
				k++;
			}
		}
	}
}

void sort(datatype *origin, int N){
	datatype *tmp = (datatype *)malloc(sizeof(datatype) * N);
	sort_sub(origin, 0, N, tmp);
	free(tmp);
}

int min(int a, int b){
	if(a < b){
		return a;
	}
	else{
		return b;
	}
}

signed main(){
	int x1, y1, x2, y2, N, X, Y, i, f = 0;
	scanf("%lld%lld%lld%lld", &x1, &y1, &x2, &y2);
	if(x1 < x2 && y1 > y2){
		f = 1;
		y1 = sup - y1;
		y2 = sup - y2;
	}
	else if(x1 > x2 && y1 < y2){
		f = 2;
		x1 = sup - x1;
		x2 = sup - x2;
	}
	else if(x1 >= x2 && y1 >= y2){
		f = 3;
		x1 = sup - x1;
		x2 = sup - x2;
		y1 = sup - y1;
		y2 = sup - y2;
	}
	scanf("%lld", &N);
	pos *fountain = (pos *)malloc(sizeof(pos) * N);
	for(i = 0; i < N; i++){
		scanf("%lld%lld", &X, &Y);
		if(f == 1){
			Y = sup - Y;
		}
		else if(f == 2){
			X = sup - X;
		}
		else if(f == 3){
			X = sup - X;
			Y = sup - Y;
		}
		if(X < x1 || x2 < X || Y < y1 || y2 < Y){
			X = inf;
			Y = inf;
		}
		fountain[i].X = X;
		fountain[i].Y = Y;
	}
	sort(fountain, N);
/*	printf("test:\n");
	for(i = 0; i < N; i++){
		printf("%lld  ", fountain[i].X);
	}
	printf("\n");
*/	for(i = 0; fountain[i].X < inf && i < N; i++){}
	N = i;
//	printf("N = %lld\n", N);
	int *dp = (int *)malloc(sizeof(int) * (N + 2));
	dp[0] = -inf;
	for(i = 1; i <= N + 1; i++){
		dp[i] = inf;
	}
	int l, h, r, fountain_num;
	for(i = 0; i < N; i++){
		for(l = 0, r = N + 1; r - l > 1;){
			h = (l + r) / 2;
			if(dp[h] > fountain[i].Y){
				r = h;
			}
			else{
				l = h;
			}
		}
		dp[r] = fountain[i].Y;
	}
	for(i = 0; dp[i] < inf; i++){}
	fountain_num = i - 1;
	double ans;
	if(fountain_num == min(x2 - x1, y2 - y1) + 1){
		ans = 100 * ((x2 - x1) + (y2 - y1)) - 2 * 10 * fountain_num + (5 * M_PI) * (fountain_num + 1);
	}
	else{
		ans = 100 * ((x2 - x1) + (y2 - y1)) - 2 * 10 * fountain_num + (5 * M_PI) * fountain_num;
	}
//	printf("fountain_num = %lld\n", fountain_num);
	printf("%.15lf\n", ans);
	return 0;
}

Measured memory_bytes: 6400
// Problem: D - Friends
// Contest: AtCoder - AtCoder Beginner Contest 177
// URL: https://atcoder.jp/contests/abc177/tasks/abc177_d
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define pb push_back
#define mp make_pair
#define y1 y114514
#define elif else if
#define VPII vector<PII>
#define y2 y1919810
typedef pair<int, int> PII;
typedef vector<int> VI;
//#define int long long
#define all(x) x.begin(), x.end()
#define lsh(i) (1 << (i))
#define lshll(i) (1LL << (i))
#define repn(i, n) for (int i = 1; i <= (int)n; i++)
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define range(i, s, t) for (int i = s; i <= (int)t; i++)
#define RESET(x) memset((x), 0, sizeof(x))
const int INF = 0x3f3f3f3f;
const long double EPS = 1e-6;
const int N = 200020;
int fa[N], sz[N], n, m;
void init(int size) {
  rep(i, size) {
    fa[i] = i;
    sz[i] = 1;
  }
}
int find(int x) { return x == fa[x] ? x : fa[x] = find(fa[x]); }
void merge(int x, int y) {
  x = find(x);
  y = find(y);
  if (x == y) return;
  if (sz[x] < sz[y]) swap(x, y);
  fa[y] = x;
  sz[x] += sz[y];
}
void solve() {
  cin >> n;
  init(n + 1);
  cin >> m;
  repn(i, m) {
    int u, v;
    cin >> u >> v;
    merge(u, v);
  }
  int ans = 0;
  repn(i, n) if (fa[i] == i) ans = max(ans, sz[i]);
  cout << ans << endl;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int T = 1;
  // cin >> T;
  while (T--) solve();
  return 0;
}


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

using i64 = int64_t;

constexpr int INF = 1e9;

bool check(const vector<int> &v){
    for(auto e: v){
        if(e > 0)return false;
    }
    return true;
}

int main(){
    int n;
    cin >> n;
    vector<int> v;
    for(int i=0;i<n;++i){
        int h;
        cin >> h;
        v.push_back(h);
    }
    v.push_back(0);
    int ans = 0;
    while(!check(v)){
        int mini = v[0], left = 0;
        for(int i=0;i<v.size();++i){
            if(v[i] == 0){
                ans += mini;
                for(int j=left;j<i;++j){
                    v[j] -= mini;
                }
                left = i+1;
                mini = v[left];
            }else{
                mini = min(mini, v[i]);
            }
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
#define acc(v) accumulate(v.begin(), v.end(), 0)
#define cinv(n,v) rep(i,n) cin >> v[i]
using namespace std;
const int INF = 1e9;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
int x_pos[4] = {1,0,-1,0}, y_pos[4] = {0,1,0,-1};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

char upper(char c){
	return c-0x20;
}

char lower(char c){
	return c+0x20;
}

void unique_vector(vector<int>& v){
	sort(all(v));
	v.erase(unique(all(v)), v.end());
}

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

//ユークリッドの互除法
//最大公約数
ll gcd(ll x, ll y) {
  if (y == 0) return x;
  return gcd(y, x%y);
}

//最小公倍数
ll lcm(ll x, ll y){
	ll g = gcd(x,y);
	return x/g*y;
}

ll myPow(ll x, ll n, ll m){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}

int main() {
	int a,b,c;cin>>a>>b>>c;
	cout << (a-b >= c ? 0 : c-(a-b)) << endl;
}



Measured memory_bytes: 256