akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

struct field {
	int x;
	int y;
	bool is_black;

	bool operator<(const field &b) const {
		if (x == b.x) {
			return y < b.y;
		}
		return x < b.x;
	}
};

int main() {
	ios_base::sync_with_stdio(false);
	int vectors[] = {-1, -1, 0, -1, 1, -1, 1, 0, 1, 1, 0, 1, -1, 1, -1, 0};
	int vectors_size = 8;
	long long h, w;
	int n;
	cin >> h >> w >> n;
	vector<field> black_fields(n);
	set<field> interesting_fields;
	for (int i = 0; i < n; i++) {
		cin >> black_fields[i].y >> black_fields[i].x;
		black_fields[i].is_black = true;
		black_fields[i].y--;
		black_fields[i].x--;
		interesting_fields.insert(black_fields[i]);
	}
	for (field &f : black_fields) {
		for (int i = 0; i < vectors_size; i++) {
			interesting_fields.insert(field{f.x + vectors[2*i], f.y + vectors[2*i+1], false});
		}
	}
	vector<long long> square_count(10);
	for (field f : interesting_fields) {
		if (f.x <= 0 || f.x >= w-1 || f.y <= 0 || f.y >= h-1) {
			continue;
		}
		//cout << f.x << ' ' << f.y << ' ' << f.is_black << '\n';
		int black_count = f.is_black;
		for (int i = 0; i < vectors_size; i++) {
			set<field>::iterator it = interesting_fields.find(field{f.x + vectors[2*i], f.y + vectors[2*i+1]});
			if (it != interesting_fields.end()) {
				//cout << (*it).x << ' ' << (*it).y << ' ' << (*it).is_black << '\n';
				black_count += (*it).is_black;
			}
		}
		square_count[black_count]++;
	}
	square_count[0] = (h-2) * (w-2);
	for (int i = 1; i <= 9; i++) {
		square_count[0] -= square_count[i];
	}
	for (int i = 0; i < 10; i++) {
		cout << square_count[i] << '\n';
	}
	return 0;
}

Measured memory_bytes: 57728
n=int(input())
numbb=input().split(' ')
numb=[]
for i in numbb:
    numb.append(int(i))
numb=sorted(numb)
#print(numb)
if(n==len(numb)):
    if(n%2!=0):
        temp=[]
        temp.append(0)
        strt=2
        for i in range(0,int(n/2)):
            temp.append(strt)
            temp.append(strt)
            strt+=2
        if(temp==numb):
            #print(temp,numb)
            print(pow(2,len(set(numb))-1)%(1000000007))
        else:
            print(0)
    if(n%2==0):
        temp=[]
        strt=1
        for i in range(0,int(n/2)):
            temp.append(strt)
            temp.append(strt)
            strt+=2
        if(temp==numb):
            #print(temp,numb)
            #print(pow(2,len(set(numb))))
            print((pow(2,len(set(numb)))%(1000000007)))
        else:
            print(0)
    

Measured memory_bytes: 18788
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <complex>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>
#include <iterator>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;

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

Measured memory_bytes: 256
#include <iostream>
#define MAXN 100005
using namespace std;

int n, x;
int ap[MAXN];

int main () {
    ios::sync_with_stdio (0);

    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> x;
        ap[x] ++;
    }

    int sol = 0;

    for (int i = 1; i < MAXN - 1; ++i)
        sol = max (sol, ap[i - 1] + ap[i] + ap[i + 1]);

    cout << sol << "\n";

    return 0;
}

Measured memory_bytes: 640
import java.io.*;

class Main {
    public static void main (String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int num;
        while (true) {
            String[] nums = br.readLine().split(" ");
            int a = Integer.parseInt(nums[0]);
            int b = Integer.parseInt(nums[1]);
            if (a == 0 && b == 0) break;
            else if (a > b) System.out.println(b + " " + a);
            else System.out.println(a + " " + b);
        }
    }
}

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

const int M = 1e9 + 7;
ll dp[101][101010];
ll v[101];
int n;

ll amt, amt2;
ll f(int x, ll k) {
	if (k < 0) return 0;
	if (dp[x][k]) return dp[x][k];
	if (x == n-1) {
		if (k > v[x]) return 0;
		return 1;
	}
	++amt;
	if (amt % (int)1e7 == 0) cout << amt << endl;

	ll r = 0;
	dp[x][k] = r;
	++amt2;
	if(amt2 % 1000 == 0) cout << "2: " << amt << endl;
	return r;
}

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

	ll ok;
	cin >> n >> ok;

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

	for (int i = 0; i <= v[n-1]; ++i) dp[n-1][i] = 1;

	for (int x = n-2; x >= 0; --x) {
		vector<int> sum;
		ll s = 0;
		for (int i = 0; i <= ok; ++i) {
			s = (s + dp[x+1][i]) % M;
			sum.push_back(s);
		}
		for (ll k = 0; k <= ok; ++k) {
			if (k - v[x] > 0) dp[x][k] = (sum[k] - sum[k-v[x]-1] + M) % M;
			else dp[x][k] = sum[k];
		}
	}
	
	cout << dp[0][ok] << '\n';
}


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

int main()
{
    int n,k,cnt = 0;
    scanf("%d",&n);
    k = n;
    while(k)
    {
        cnt += k % 10;
        k /= 10;
    }
    if(n % cnt == 0)
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		
		int[] road = new int[n];
		for (int i = 0; i < m; i++) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			a--;
			b--;
			road[a]++;
			road[b]++;
		}
		
		for (int num : road)
			System.out.println(num);
		
		sc.close();
	}
}




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

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

    vector<int> a(n);
    for (auto& x : a) cin >> x;

    sort(a.begin(), a.end());

    int l = 0, r = 0, c = 0;
    int ans = 0;
    for (int i = 0; i < n; i++) {
        c = a[i];
        for (; r < n && a[r] <= c + 1; r++);
        for (; l < n && a[l] < c - 1; l++);
        ans = max(ans, r - l);
    }
    cout << ans << endl;

    return 0;
}


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

using namespace std;

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

	vector<string> vec(n);
	for(int i = 0; i < n; ++i) cin >> vec[i];

	set<string> s(vec.begin(), vec.end());
	int ans = s.size();

	cout << ans << "\n";

	return 0;
}

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

using namespace std;



void solver() {
    int n, x, t;
    cin >> n >> x >> t;

    int qt = (n / x) + (n % x != 0);
    cout << qt * t << '\n';
}

int main() {

    ios_base :: sync_with_stdio(0); cin.tie(NULL);

    int t = 1;
    //cin >> t;
    
    while(t--)
        solver();

    return 0;
}

Measured memory_bytes: 3616
def cmb(n, r, mod):
    if (r < 0 or r > n):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod


X, Y = map(int, input().split())
l = [(0, 0), (1, 2), (2, 1)]
if X * 2 < Y or Y * 2 < X:
    print(0)
else:
    x = X % 3
    y = Y % 3
    if not (x, y) in l:
        print(0)
    else:  # nCr
        n = (X + Y) // 3
        x = min(X, Y)
        y = max(X, Y)
        r = (n - (y - x)) // 2
        mod = 10**9+7  # 出力の制限
        N = 10**6
        g1 = [1, 1]  # 元テーブル
        g2 = [1, 1]  # 逆元テーブル
        inverse = [0, 1]  # 逆元テーブル計算用テーブル
        for i in range(2, N + 1):
            g1.append((g1[-1] * i) % mod)
            inverse.append((-inverse[mod % i] * (mod//i)) % mod)
            g2.append((g2[-1] * inverse[-1]) % mod)
        print(cmb(n, r, mod))

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

int main(){
  int n, k, q, a[200000], b[200000], ans=0, p;
  cin >> n >> k >> q;
  for(int i=1;i<=n;i++){
    a[i]=k;
    b[i]=0;
  }
  for(int i=0;i<q;i++){
    cin >> p;
    b[p]++;
  }
  for(int i=1;i<=n;i++){
    a[i]=k-q+b[i];
    if(a[i]<=0)cout << "No" << endl;
    else cout << "Yes" << endl;
  }
  return 0;
}


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

public class Main {
	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			char[] s = scanner.next().toCharArray();
			char[] t = scanner.next().toCharArray();

			Arrays.sort(s);
			Arrays.sort(t);

			String sString = new String(s);
			String tString = reverseString(t);

			System.out.println(sString.compareTo(tString) < 0 ? "Yes" : "No");
		}
	}

	private static String reverseString(char[] t) {
		return new StringBuffer(new String(t)).reverse().toString();
	}
}

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

int main(){
  int H, W, K;
  cin >> H >> W >> K;
  vector<string> S(H), T(H);
  int Ans=0;
  for(int i=0; i<H; i++){
    cin >> S.at(i);
  }
  for(int i=0; i<(int)pow(2, H); i++){
    for(int j=0; j<(int)pow(2, W); j++){
      T=S;
      int ii=i;
      int jj=j;
      for(int k=0; k<H; k++){
        if(ii%2==1){
          for(int l=0; l<W; l++){
            T.at(k).at(l)='r';
          }
        }
        ii/=2;
      }
      for(int m=0; m<W; m++){
        if(jj%2==1){
          for(int n=0; n<H; n++){
            T.at(n).at(m)='r';
          }
        }
        jj/=2;
      }
      int subAns=0;
      for(int o=0; o<H; o++){
        for(int p=0; p<W; p++){
          if(T.at(o).at(p)=='#'){
            subAns++;
          }
        }
      }
      if(subAns==K){
        Ans++;
      }
    }
  }
  cout << Ans << endl;
}

Measured memory_bytes: 4076
N, K = map(int, input().split(" "))
S = input()

cnt = []
tmp = 1
for i in range(N - 1):
    if S[i] != S[i + 1]:
        cnt.append(tmp)
        tmp = 1
    else:
        tmp += 1

cnt.append(tmp)
bn = 1 + 2 * K
if len(cnt) <= bn:
    print(N - 1)
    exit(0)
ans = sum(cnt) - (len(cnt) - bn + 1)
print(ans)

Measured memory_bytes: 45168
#include <iostream>
using namespace std;
int main(void){
    int max=0;
    int num1,num2;
    int Fa;
    int tmp;
    int n,k;
    cin>>n>>k;
    cin>>num1;
    Fa=num1;
    for(int i=0;i<k-1;i++){
        cin>>num2;
        tmp=num2-num1;
        if(max<tmp)max=tmp;
        num1=num2;
    }
    num2=Fa-num1+n;
    if(max<num2)max=num2;
    cout<<n-max;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<tuple>
#include<queue>
#include<set>
#include<algorithm>
#include<string>
#include<math.h>
#include<functional>

using namespace std;

int main(int argc, char* argv[]){
  long long int n,m;
  long long int x[100001];
  long long int d[100001];
  long long int ans = 0;
  cin >> n >> m;
  for(int i = 0; i < m; i++){
    cin >> x[i];
  }
  sort(x, x + m);
  for(int i = 0; i < m - 1; i++){
    d[i] = x[i + 1] - x[i];
  }
  sort(d, d+m-1, greater<int>());
  for(int i = n - 1; i < m - 1; i++){
    ans += d[i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
import numpy as np
A1 = [int(i) for i in input().split()]
A2 = [int(i) for i in input().split()]
A3 = [int(i) for i in input().split()]
A = np.array([A1,A2,A3])
N = int(input())
B = []
for i in range(N):
  B.append(int(input()))
#print(A1,A2,A3,A,N,B)

start = np.zeros((3,3))
flag = "No"
for i in range(3):
  for j in range(3):
    if A[i,j] in B:
      start[i,j] = 1
for i in range(3):
  if sum(start[i]) == 3:
    flag = "Yes"
  elif sum(start[:,i])==3:
    flag = "Yes"

if start[0,0]==1 and start[1,1]==1 and start[2,2]==1:
  flag = "Yes"
if start[2,0]==1 and start[1,1]==1 and start[0,2]==1:
  flag = "Yes"
print(flag)


Measured memory_bytes: 21124
n = int(input())
t, a = map(int, input().split())
h = list(map(int, input().split()))
absolute = 9999
ans = 0
for i in range(n):
    tmp = abs(a - (t - h[i] * 0.006))
    if tmp < absolute:
        absolute = tmp
        ans = i + 1
print(ans)

Measured memory_bytes: 3064
#!/usr/bin/env python3
# Generated by https://github.com/kyuridenamida/atcoder-tools
from typing import *
import collections
import functools
import itertools
import math
import sys

INF = float('inf')


def solve(K: int, N: int, A: "List[int]"):
    return sum(sorted([(i == 0)*K+A[i]-A[i-1] for i in range(N)])[:-1])


def main():

    sys.setrecursionlimit(10 ** 6)

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    K = int(next(tokens))  # type: int
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    print(f'{solve(K, N, A)}')


if __name__ == '__main__':
    main()


Measured memory_bytes: 109924
def m(S, left, mid, right):
  global count
  L = S[left:mid]
  R = S[mid:right]
  L.append(1000000000)
  R.append(1000000000)
  i = 0
  j = 0
  for k in range(left,right):
    count = count + 1
    if L[i] <= R[j]:
      S[k] = L[i]
      i = i + 1
    else:
      S[k] = R[j]
      j = j + 1

def ms(S,left,right):
  if (left+1) < right:
    mid = (left+right)//2
    ms(S, left, mid)
    ms(S, mid, right)
    m(S, left, mid, right)

n = int(input())
S = [int(x) for x in input().split()]
left = 0
right = n
count = 0

ms(S,left,right)

for i in range(n):
  if i != (n-1):
    print(S[i], end = " ")
  else:
    print(S[i])
print(count)



Measured memory_bytes: 63696
//105
#include<iostream>
#include<string>
#include<algorithm>
//#include<math>
#include<vector>

using namespace std;
int main(){
 int N;
 cin >> N;
vector<int> v(N);
vector<int> c(N);
 for(int i = 0;i < N;i++){
     cin >> v[i];
 }
 for(int i = 0;i < N;i++){
     cin >> c[i];
 }

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

 cout << ans << endl;

}

Measured memory_bytes: 256
// input macro from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input![a: usize, b: usize];
    println!("{}", a * b);
}


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// 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 a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a/gcd(a, b) * b;
}

int main()
{
    cout << fixed << setprecision(15);
    ll a, b, c;
    cin >> a >> b >> c;
    cout << min({a+b, b+c, c+a}) << endl;
    return 0;
}

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

int main() {
    int k, n;
    cin >> k >> n;
    int d = 0;
    vector<int> a(n);
    rep(i, n) {
        cin >> a[i];
    }
    rep(i, n) {
        if(i != n - 1) {
            int t = a[i + 1] - a[i];
            d = max(t, d);
        } else {
            int t = a[0] + k - a[i];
            d = max(t, d);
        }
    }
    cout << k - d << endl;
}


Measured memory_bytes: 1024
import sys
sys.setrecursionlimit(10000000)


def main():
    N, K = map(int, input().split())
    nums = [0] * N
    for i in range(K):
        _ = int(input())
        A = [int(c) for c in input().split()]
        for a in A:
            nums[a-1] += 1

    num = 0
    for i in range(N):
        if nums[i] == 0:
            num += 1

    print(num)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9196
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(int i=(n);i<(m);i++)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) for(int i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<int,int>;
using PP=pair<int,P>;
using Pl=pair<ll,ll>;
using PPl=pair<ll,Pl>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
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;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
int main(){
    int n;
    cin>>n;
    vs vec(n);
    set<string> se;
    REP(i,n){
        cin>>vec[i];
        if(se.count(vec[i])){
            cout<<"No"<<endl;
            return 0;
        }
        se.insert(vec[i]);
    }
    REP(i,n-1){
        if(vec[i].back()!=vec[i+1][0]){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}

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;
struct P{double x, y;};

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

	int n;
	cin >> n;

	vector<P> v(n);
	rep(i, n){
		cin >> v[i].x >> v[i].y;
	}

	vector<int> w(n);
	rep(i, n) w[i] = i;

	double cnt = 1.0;
	rep(i, n){
		cnt *= (i+1);
	}

	double avg = 0.0;
	do{
		double d = 0.0;
		rep(i, n - 1){
			int j = w[i];
			int k = w[i+1];
			double t = (v[j].x - v[k].x) * (v[j].x - v[k].x);
			t += (v[j].y - v[k].y) * (v[j].y - v[k].y);
			d += sqrt(t);
		}
		avg += d / cnt;
	}while(next_permutation(w.begin(), w.end()));

	cout << fixed << setprecision(10);
	cout << avg << endl;
}


Measured memory_bytes: 384
n = int(input())
m = 10**9 + 7
# ans = [0] * (n + 1)
ans = [0] * 2200
ans[0] = 1
# ans[3] = 1
# ans[4] = 1
# ans[5] = 1
for i in range(3, n + 1):
    ans[i] = ans[i - 1] + ans[i - 3]
    ans[i] %= m
    # for j in range(i - 2):
    #     ans[i] += ans[j]
    #     ans[i] %= m
print(ans[n])
# print(ans[:10])


Measured memory_bytes: 9188
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;cin>>n;
    int a1[n+1],a2[n+1],a3[n+1];
    for(int i=0;i<n;i++)
    {
        cin>>a1[i]>>a2[i]>>a3[i];
    }
    
    int dp[n+2][3];
    
    dp[0][0] = a1[0];
    dp[0][1] = a2[0];
    dp[0][2] = a3[0];
    
    for(int i=1;i<n;i++)
    {
        dp[i][0]= max(dp[i-1][1],dp[i-1][2])+a1[i];
        dp[i][1]= max(dp[i-1][2],dp[i-1][0])+a2[i];
        dp[i][2]= max(dp[i-1][1],dp[i-1][0])+a3[i];
    }
    cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]))<<endl;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0, i < n; ++i);
using namespace std;
int main(void){
  int a1,a2,a3; cin >> a1 >> a2 >> a3;
  if(a1+a2+a3 > 21) cout << "bust" << endl;
  else cout << "win" << endl;
}

Measured memory_bytes: 256
import sys


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


N = int(input())

plus = []
minus = []
for _ in range(N):
    x, y = map(int, input().split())
    plus.append(x+y)
    minus.append(x-y)

print(max(max(plus)-min(plus), max(minus)-min(minus)))


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

using namespace std;

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;
typedef vector<pii> vpii;

ll INF = (1ll << 32);
double EPS = 1e-4;

int isPrime(ll x) {
  for (ll i = 2; i * i <= x; i++) {
    if (x % i == 0) {
      return false;
    }
  }

  return true;
}

int main() {
  vi primes;
  for (ll i = 11; i <= 55555; i += 5) {
    if (isPrime(i)) {
      primes.push_back(i);
    }
  }

  ll N;
  cin >> N;

  for (ll i = 0; i < N; i++) {
    if (i == N - 1) {
      cout << primes[i] << endl;
    } else {
      cout << primes[i] << ' ';
    }
  }
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
int main()
{
    int N;
    cin >> N;
    vint A(N + 1);
    rep2(i, 1, N + 1)
    {
        cin >> A[i];
    }
    ll ans = 0;
    for (int i = N; i > 0; i--)
    {
        if (i == N)
        {
            ans += A[i] / 2;
            A[i] %= 2;
        }
        else
        {
            int a = A[i] + A[i + 1];
            ans += a / 2;
            if (A[i] != 0)
                A[i] = a % 2;
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 640
#include<stdio.h>

int main(void) {

	int n, m, i, j, k;
	int a[100][100];
	int b[100];
	int c[100];
	int ans[100] = { 0 };

	scanf("%d %d", &n, &m);

	for (i = 0; i < n; i++) {
		for (j = 0; j < m; j++) {
			scanf("%d", &a[i][j]);
		}
	}

	for (j = 0; j < m; j++) {

		scanf("%d", &b[j]);
	}

	for (i = 0; i < n; i++) {
		for (j = 0; j < m; j++) {
			
			c[i] = a[i][j] * b[j];

			for (i = 0; i < n; i++) {
				for (j = 0; j < m; j++) {
					
					

						ans[i] += a[i][j] * b[j];
						c[i] = ans[i];


					
				}
				printf("%d\n", c[i]);

			}
		

			
			

		}
	}


	return(0);
}


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

#define FOR(i,l,r) for(int i = int(l);i < int(r);i++)
template<typename T> bool chmax(T& a,const T& b){ return a < b ? (a = b,true) : false; }
template<typename T> bool chmin(T& a,const T& b){ return b < a ? (a = b,true) : false; }
typedef long long ll;

int N;
vector<int> A;

int main()
{
	scanf("%d",&N);
	A.assign(N,0);
	map<int,int> mp;
	FOR(i,0,N){
		scanf("%d",&A [i]);
		mp [A [i]]++;
	}

	vector<int> v;
	for(auto& it : mp){
		while(it.second >= 2){
			v.push_back(it.first);
			it.second -= 2;
		}
	}
	sort(v.begin(),v.end());

	if(v.size() < 2){
		puts("0");
	}
	else{
		ll ans = (ll) v.back() * v [(int) v.size() - 2];
		printf("%lld\n",ans);
	}

	return 0;
}


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

int main(){
  int n;
  cin >> n;
  long long ans =0;
  long long a =0;
  long long b =0;
  cin >> a;
  for(int i=0;i<n-1;i++){
   cin >> b;
    if(a>b){
      ans += (a-b);
     
      a = max(a,b);
    }
    else a = max(a,b);
  }
  
  cout << ans << endl;
}

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

#define rep(i, n) for(int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()

int main()
{
  int N; cin >> N;
  vector<int> A(N);
  rep(i, N) cin >> A[i];

  sort(ALL(A));

  // validate
  for (int i = (N%2==0?0:1); i < N; i+=2) {
    if (N%2==1 and A[0] != 0) {
      cout << 0 << endl;
      return 0;
    }

    if (A[i] != A[i+1] or A[i] != i+1) {
      cout << 0 << endl;
      return 0;
    }
  }

  ll ans = 1;
  rep(i, N/2) {
    ans = ans * 2 % mod;
  }

  cout << ans << endl;
}

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

namespace ConsoleApplication1
{
    class Program
    {
        static int H;

        static void Main(string[] args)
        {
            H = int.Parse(Console.ReadLine());
            int[] input = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);

            int[] A = new int[H + 1];
            input.CopyTo(A, 1);

            BuildMaxHeap(A);

            StringBuilder sb = new StringBuilder();
            for (int i = 1; i <= H; i++) sb.Append(" " + A[i]);
            Console.WriteLine(sb);
        }

        static void BuildMaxHeap(int[] A)
        {
            for (int i = H / 2; i > 0; i--)
            {
                MaxHeapify(A, i);
            }
        }

        static void MaxHeapify(int[] A, int i)
        {
            int l = i * 2;
            int r = i * 2 + 1;

            int largest = (l <= H && A[l] > A[i]) ? l : i;

            if (r <= H && A[r] > A[largest]) largest = r;

            if (largest != i)
            {
                int temp = A[i];
                A[i] = A[largest];
                A[largest] = temp;

                MaxHeapify(A, largest);
            }
        }
    }
}

Measured memory_bytes: 75476
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>

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

int main()
{
	int n, m, q;
	cin>>n>>m>>q;
	int ct[501][501]={};
	for(int i=0; i<m; i++){
		int l, r;
		cin>>l>>r;
		ct[l][r]++;
	}
	for(int i=1; i<=n; i++){
		for(int j=1; j<=n; j++){
			ct[i][j]+=(ct[i-1][j]+ct[i][j-1]-ct[i-1][j-1]);
		}
	}
	for(int i=0; i<q; i++){
		int x, y;
		cin>>x>>y;
		cout<<ct[y][y]-ct[x-1][y]-ct[y][x-1]+ct[x-1][x-1]<<endl;
	}
	return 0;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define rep(i, n) for(ll i = 0;i < n;i++)
template<class t, class u> void cmax(t& a, u b) { if (a<b) a = b; }
template<class t, class u> void cmin(t& a, u b) { if (a>b) a = b; }

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

  int n, h;
  cin >> n >> h;
  vector<int> a(n), b(n);
  int max_a = 0;
  rep(i, n) {
    cin >> a[i] >> b[i];
    if (max_a < a[i]) {
      max_a = a[i];
    }
  }

  sort(b.rbegin(), b.rend());
  int ans = 0;
  rep(i, n) {
    if (b[i] < max_a) break;
    ans++;
    h -= b[i];
    if (h <= 0) {
      cout << ans << endl;
      return 0;
    }
  }

  cout << ans+(h-1)/max_a+1 << endl;
}


Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main() {
int w,h;
cin >> h >> w;
while(w||h) {
for(int i=0; i<h; ++i){
for(int j=0; j<w; ++j) cout << "#";
cout << endl;
}
cout << endl;
cin >> h >> w;
}
}


Measured memory_bytes: 3084
A, B, K = list(map(int, input().split()))


for i in range(K):
    if i % 2 == 0:  # Tの操作
        if A % 2 == 1:
            A -= 1

        B += A // 2
        A = A // 2
    else:   # Aの操作
        if B % 2 == 1:
            B -= 1

        A += B // 2
        B = B // 2

print(A, B)

Measured memory_bytes: 3060
#include<stdio.h>

int main(void){
  int N,x,i,a,res=0;
  long long count=0;
  scanf("%d%d",&N,&x);
  /*scanf("%d",&a);
  if(a>x){
    count+=a-x;
    a=x;
    }
    res=a;*/
  for(i=0;i<N;i++){
    scanf("%d",&a);
    if(a+res>x){
      count+=a+res-x;
      a-=(a+res-x);
    }
    res=a;
  }

  printf("%lld\n",count);
  return 0;
}


Measured memory_bytes: 128
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
ll mod =1e9+7;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,a,b) for(int i=(a);i<(b);++i)

template<class T> T maxt(T x,T y) {if (x>y) return x;else return y;}
template<class T> T mint(T x,T y) {if (x>y) return y;else return x;}
//sort(v.begin(), v.end(), [](auto& x, auto& y){return x[1] < y[1];});


//小数出力
// double print_double(double d){printf("%.6f", d);}

//約数列挙
vector<ll> divisor(ll n) {
  vector<ll> ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}



// ll combination_mod(int n, int k) {
//   k = mint(k,n-k);
//   ll ans = 1;
//   if (n==0 || k ==0) return ans;
//   rep(i,k) {
//     ans = ans*(n-i)%mod;
//     ans = ans*modinv(i+1)%mod;
//   }
//   return ans;
// }

struct edge {
  int from; //出発点
  int to;   //到達点
  ll cost; //移動コスト
};

//ベルマンフォード法
vector<ll> bellman_ford (vector<edge> edges, int V, int E, int r, ll INF = 100000000000) {  
  vector<ll> cost_to(V,INF);
  cost_to[r] = 0;
  rep(i,V) {
    rep(j,E) {
      edge e = edges[j];
      if (cost_to[e.from]==INF) continue;
      if (cost_to[e.to] > cost_to[e.from] + e.cost) {
        cost_to[e.to] = cost_to[e.from] + e.cost;
        if (i==V-1) {
          printf("NEGATIVE CYCLE\n");
          return {};
        }
      }

    }
  }
  return cost_to;
}

// combination
const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


template<class T> inline void chmin(T& a, T b) {if (a > b) a = b;}
template<class T> inline void chmax(T& a, T b) {if (a < b) a = b;}


// 木上の探索
vector<int> cnt;
void dfs(const vector<vector<int>> &G, int v, int p) {
    for (auto nv : G[v]) {
        if (nv == p) continue; // nv が親 p だったらダメ
        dfs(G, nv, v);
    }

    // 帰りがけ時に、部分木サイズを求める
    cnt[v] = 1; // 自分自身
    for (auto c : G[v]) {
        if (c == p) continue;
        cnt[v] += cnt[c]; // 子のサイズを加える
    }
}

int main() {
  int N;
  cin >> N;
  vector<ll> A(N);
  priority_queue<vector<ll>> pq;
  for(ll i=0;i<N;i++) {
    cin >> A[i];
    pq.push({A[i],i+1});
  }

  vector<vector<ll>> dp(N+2,vector<ll> (N+2,0));
  rep2(i,1,N+1){
    auto t=pq.top();
    pq.pop();
    dp[i][0] = dp[i-1][0] + t[0]*abs(N-i+1-t[1]);
    // cout << dp[i][0] << ' ';
    rep2(j,1,i+1) {
      if (i==j) dp[i][j] = dp[i-1][j-1]+t[0]*abs(t[1]-j);
      else dp[i][j] = maxt(dp[i-1][j-1]+t[0]*abs(t[1]-j), dp[i-1][j] + t[0]*abs(N-i+j+1-t[1]));
      // cout << dp[i][j] << ' ';
    }
    // cout << endl;
  }  

  ll ans = *max_element(dp[N].begin(),dp[N].end());
  cout << ans << endl;
}


Measured memory_bytes: 34952
#include <iostream>
using namespace std;
int main(void){
    string str, ins;
    int n;
    cin >> str >> n;
    for (int i = 0; i < n; i++) {
        cin >> ins;
        if (ins == "print") {
            int a, b;
            cin >> a >> b;
            for (int j = a; j <= b; j++) {
                cout << str[j];
            }
            cout << endl;
        } else if (ins == "reverse") {
            int a, b;
            cin >> a >> b;
            for (int j = 0; j < (b-a+1)/2; j++) {
                char tmp = str[a+j];
                str[a+j] = str[b-j];
                str[b-j] = tmp;
            }
        } else {
            int a, b;
            string p;
            cin >> a >> b >> p;
            for (int j = a; j <= b; j++) {
                str[j] = p[j-a];
            }
        }
    }
    return 0;
}

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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)

int main()
{
    lint n,a,b;
    cin >> n>>a>>b;
    lint ans=0;

    if((b-a-1)%2==0){
        cout << "Borys"
             << "\n";
    }else{
        cout << "Alice"
             << "\n";
    }

    //cout << ans <<"\n";

    return 0;
}

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

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define IMOD 1000000007 
#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define lrep(i,n) for(long long  i = 0; i < (long long)(n); i++)
#define lrep2(i,a,n) for(long long i = (long long)(a); i <= (long long)(n); i++)

#define irrep(i,n) for(int i = (int)(n); i > -1; i--)
#define irrep2(i,a,n) for(int i = (int)(n); i >= (int)(a); i--)

typedef long long ll;
typedef std::vector<char> v_char;
typedef std::vector<v_char > v2_char;
typedef std::vector<double> v_double;
typedef std::vector<v_double > v2_double;
typedef std::vector<int> v_int;
typedef std::vector<v_int > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<v_ll > v2_ll;
typedef std::vector<std::string> v_string;
typedef std::vector<v_string > v2_string;
typedef std::vector<bool> v_bool;
typedef std::vector<v_bool > v2_bool;
typedef std::pair<ll, ll> pll;
typedef std::pair<int, int> pii;

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

using namespace std; 

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

    bool at;

    if(a == 'H') {
        at = true;
    } else {
        at = false;
    }

    if(b == 'H') {
        if(at) {
            cout << "H" << endl;
        } else {
            cout << "D" << endl;
        }
    } else {
        if(at) {
            cout << "D" << endl;
        } else {
            cout << "H" << endl;
        }
    }
    return 0;
}   
/** atcoder **/


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
using namespace std;
int main() {
	int H, W;
	string a[100];
	cin >> H >> W;

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

	for (int i = 0; i < W + 2; i++) {
		cout << '#';
	}
	cout << endl;
	for (int i = 0; i < H; i++) {
		cout << '#';
		cout << a[i];
		cout << '#' << endl;
	}
	for (int i = 0; i < W + 2; i++) {
		cout << '#';
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s,t;
getline(cin,s);
getline(cin,t);
  int a=0,b=0;
if(s>=t){
  for(int i=0;i<t.length();i++){
  if(s[i]==t[i]) a++;
  }
}
  else{
    for(int i=0;i<s.length();i++){
  if(s[i]==t[i]) b++;
  }
  }
  cout<<(a+b)<<endl;
}


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

using namespace std;
typedef long long ll;

#define MOD (long long)(1e9+7)
#define INF (1LL<<60)
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define rep1(i,n) for(ll i = 1; i <= (n); i++)

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;
}


// 最大公約数
ll gcd(ll a, ll b)
{
  if(b == 0) return a;
  return gcd(b, a % b);
}

// mod m におけるa の逆元
ll modinv(ll a, ll m) {
  ll b = m, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}

// 素因数分解
vector<pair<ll, ll>> prim;
void pf(ll n)
{
  ll s = sqrt(n);
  ll r = 0;
  for(ll i = 2; i <= s; i++) {
    if((n % i) == 0) {
      r = 0;
      do {
	r++;
	n = n / i;
      } while((n % i) == 0);
      prim.push_back({i, r});
    }
  }
  if(n > s) {
    prim.push_back({n, 1});
  }
}

void solve()
{
  ll N; cin >> N;
  // ll N, K; cin >> N >> K;
  // ll x, y, z; cin >> x >> y >> z;
  // ll a, b, c; cin >> a >> b >> c;
  // string s; cin >> s;
  // vector<ll> a(N); rep(i, N) cin >> a[i];
  
  ll ans = 0;
  rep1(i, N) ans += i;

  cout << ans << endl;
}


int main(void)
{
  // ll t; cin >> t; rep(i, t)
  solve();
}


Measured memory_bytes: 3572
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int A, B, M, min_fridge = INT_MAX, min_microwave = INT_MAX;
    cin >> A >> B >> M;
    vector<int> fridges(A), microwaves(B);
    for (auto& e: fridges) {
        cin >> e;
        min_fridge = min(min_fridge, e);
    }
    for (auto& e: microwaves) {
        cin >> e;
        min_microwave = min(min_microwave, e);
    }
    int min_money = min_fridge + min_microwave;
    for (int i = 0; i < M; ++i) {
        int x_fridge, y_microwave, discount;
        cin >> x_fridge >> y_microwave >> discount;
        min_money = min(min_money, fridges[x_fridge - 1] + microwaves[y_microwave - 1] - discount);
    }
    cout << min_money << "\n";
    return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int A[] = new int[N];

		int maxA = 0;
		int maxAIndex = -1;
		int maxA2 = 0;

		for (int i = 0; i < N; i++) {
			A[i] = sc.nextInt();

			if (maxA <= A[i]) {
				maxA = A[i];
				maxAIndex = i;
			}
		}

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

			if (i == maxAIndex) {
				continue;
			}

			if (maxA2 <= A[i]) {
				maxA2 = A[i];
			}
		}

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

			if (!(i == maxAIndex)) {
				System.out.println(maxA);
			} else {
				System.out.println(maxA2);
			}
		}
	}
}

Measured memory_bytes: 90380
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
using namespace std;
typedef long long LL;
int a[210000];
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]),a[i]-=i;
	sort(a+1,a+n+1);
	LL ans=0;
	for(int i=1;i<=n;i++) ans+=abs(a[i]-a[(n+1)/2]);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

typedef long long ll;
typedef long double ld;
typedef int32_t i32;

#define int long long
#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define pf push_front

#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define RFOR(i,a,b) for(ll i=a;i>=b;i--)
#define FILL(a,b,c) for(ll i=0;i<c;i++) a[i]=b;

#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define allr(v) (v).rbegin(), (v).rend()

#define endl "\n"
#define setpri(x) setprecision(x)
#define vp(x) cout<<#x<<" : "<< (x)<<" | "
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
#define forf(i,a,b) for(int i=a;i<b;i++)

#define INF 1e17+4
#define MINF 
#define MAX_INT 100000
#define MOD 1000000007
ll mod(ll n) { n %= MOD; if (n < 0) return n + MOD; else return n;}
vector<int> adj[1000002];
int vis[1000002],dep[1000002],siz[1000002];

// void dfs(ll cur,ll par)
// {
//     vis[cur]=1;siz[cur]=1;
//     for(auto x:adj[cur])
//     {
//         if(vis[x]!=1)
//         {
//             dep[x]=dep[cur]+1;
//             dfs(x,cur);
//             siz[cur]+=siz[x];
//         }    
//     }
// }

// bool sortfunc(const pair<int,int> &a, const pair<int,int> &b) 
// { 
//     return ;
// }

void solve()
{
    int y;cin>>y;
    vector<int> a;
    forf(i,0,1000)
        a.pb(pow(i,5));
    
    for(int i=0;i<1000;i++)
    {
        int l=y+a[i];
        auto x=find(a.begin(),a.end(),l);
        if(x!=a.end())
        {
            cout<<x-a.begin()<<" "<<i<<endl;
            return;
        }
        l=y-a[i];
        if(l<0)
            continue;
        x=find(a.begin(),a.end(),l);
        if(x!=a.end())
        {
            cout<<x-a.begin()<<" "<<-i<<endl;
            return;
        }
            
        
    }
    
}

signed main()
{
    FAST;
    
    // ll t;cin>>t;while(t--)
        solve();
 
    return 0;
}

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

int main(){
	string str1,str2;
	vector<char> s1;
	vector<char> s2;
	getline(cin,str1);
	for(int i=0; i<(int)str1.size(); i++){
		s1.push_back(str1[i]);
	}
	getline(cin,str2);
	for(int i=0; i<(int)str2.size(); i++){
		s2.push_back(str2[i]);
	}
	
	int path[s1.size()+1][s2.size()+1];
  	for(int h=0; h<s1.size()+1; h++){
  		for(int w=0; w<s2.size()+1; w++){
  			if(h==0 && w==0){
  				path[h][w]=0;
  			}else if(h==0){
  				path[h][w]=path[h][w-1]+1;
  			}else if(w==0){
  				path[h][w]=path[h-1][w]+1;
  			}else{
  				int min=path[h][w-1]+1;
  				if(min>path[h-1][w]+1) min=path[h-1][w]+1;
  				int x;
  				if(str1[h-1]==str2[w-1]){
  					x=path[h-1][w-1];
  				}else{
  					x=path[h-1][w-1]+1;
  				}
  				if(min>x) min=x;
  				path[h][w]=min;
  			}
  		}
  	}
	cout<<path[s1.size()][s2.size()]<<endl;
	return 0;
}


Measured memory_bytes: 7144
import math

n = int(input())
folia = list(map(int, input().split()))
#print(n, folia)

#_1 木の一番下から順に各深さの頂点数[min, max]を取得
seq = [[folia[-1], folia[-1]]]
for i in range(n): # 深さ'n'分
    tmp = folia[-(i+2)]
    sml = math.ceil(seq[i][0] / 2) + tmp 
    big = seq[i][1] + tmp
    seq += [[sml, big]]
#print(seq)

#_2 一番根本の頂点数[min, max]に'1'を含まない場合は '存在しない木'
if not (seq[-1][0] <= 1 <= seq[-1][1]):
    print(-1)
    exit()

#_3 木の一番上から順に各深さで理論最大頂点数と'#_1のmax'との'min'をとる
ans =[1]
for j in range(n): # 深さ'n'分
    tmp = min((ans[j] - folia[j]) * 2, seq[-(j+2)][1])
    ans.append(tmp)
print(sum(ans)) # その合計が'ans'


Measured memory_bytes: 33580
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		Scanner scan = new Scanner(System.in);

		//日ごとに晴れ(Sunny)、くもり(Cloudy)、雨(Rainy)、晴れ
		String s;
		s = scan.next();

		String[] wheathers = {
				"Sunny", "Cloudy", "Rainy"
		};

		for (int i = 0; i < wheathers.length; i++) {
			if (wheathers[i].equals(s)) {
				if (i == 0 || i == 1) {
					System.out.println(wheathers[i + 1]);
					break;
				} else {
					System.out.println(wheathers[0]);
					break;
				}
			}
		}
	}

	/**
	 * 余りを求める。
	 * @param a
	 * @param b
	 * @return 余り。余りがマイナスの時はプラスで返す。ｓ
	 */
	public static long myMod(long a, long b) {
		long ret = 0;

		ret = a % b;

		if (ret < 0) {
			ret += b;
		}

		return ret;
	}

	/**
	 * 乗数を求める ※mod対応
	 * @param a 基数
	 * @param n 乗数
	 * @param primeNumMod 法 mod値 使わない場合は「0」
	 * @return
	 */
	public static long myModPow(long a, long n, long primeNumMod) {

		long ans = 1;

		//乗数が0の場合→1
		if (n == 0)
			return 1;

		if (primeNumMod == 0) {
			//modを使わないとき

			while (n > 0) {

				if (n % 2 == 0) {
					//累乗が偶数の時

					a *= a;
					n = n / 2;
				} else {
					//累乗が奇数の時
					ans *= a;
					n--;
				}
			}

			return ans;

		} else {
			//modを使うとき

			while (n > 0) {

				if (n % 2 == 0) {
					//累乗が偶数の時

					a *= myMod(a, primeNumMod);
					n = n / 2;

				} else {
					//累乗が奇数の時
					ans *= myMod(a, primeNumMod);
					n--;

				}
			}

			return myMod(ans, primeNumMod);

		}

	}

}


Measured memory_bytes: 21332
#include<bits/stdc++.h>
using namespace std;
int read()
{
	char c;
	int w=1;
	while((c=getchar())>'9'||c<'0')if(c=='-')w=-1;
	int ans=c-'0';
	while((c=getchar())>='0'&&c<='9')ans=(ans<<1)+(ans<<3)+c-'0';
	return ans*w;
}
int n;
struct node
{
	int next,to,v;
}e[600005];
int cnt;
int h[600005];
void add(int x,int y,int z)
{
	cnt++;
	e[cnt].next=h[x];
	h[x]=cnt;
	e[cnt].to=y;
	e[cnt].v=z;
}
int c[100005];
void dfs(int x,int y)
{
	for(int i=h[x];i;i=e[i].next)
	{
		if(e[i].to==y)continue;
		c[e[i].to]=e[i].v^c[x];
		dfs(e[i].to,x);
	}
}
int main(){
	int n,m;
	n=read();
	for(int i=1;i<n;i++)
	{
		int a,b,c;
		a=read();
		b=read();
		c=read();
		c%=2;
		add(a,b,c);
		add(b,a,c);
	}
	dfs(1,0);
	for(int i=1;i<=n;i++)
	{
		printf("%d\n",c[i]);
//		cout<<c[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 9652
#include <bits/stdc++.h>
using namespace std;
#define MAXN 2000
#define MOD 1000000007
#define rint register int
#define gc() getchar()
inline int read(int r=0,int s=0,int c=gc()){for(;c<48||c>57;s=c,c=gc());for(;c>=48&&c<=57;(r*=10)+=c-48,c=gc());return s^'-'?r:-r;}
inline int fxp(int s, int n=MOD-2){int a=1; for(; n; n&1 ? a = 1ll*a*s%MOD : 0, s = 1ll*s*s%MOD, n >>= 1); return a;}
int fac[4002005], efac[4002005], f[MAXN+5][MAXN+5], n, m, N; inline int C(int n, int k){return n<0||k<0||n<k?0:1ll*fac[n]*efac[k]%MOD*efac[n-k]%MOD;}
int main()
{
	n = read(), m = read(), N = n*m; if(m==1||n==1) return puts("1"),0; for(rint i = fac[0] = 1; i <= N; fac[i] = 1ll*i*fac[i-1]%MOD, i++);
	efac[N] = fxp(fac[N]); for(rint i = N; i; efac[i-1] = 1ll*i*efac[i]%MOD, i--); f[0][0] = 1;
	for(rint i = 0, j; i <= n; i++) for(j = i; j <= n; j++)
		f[i+1][j] = (f[i+1][j]+f[i][j])%MOD, f[i][j+1] = (f[i][j+1]+1ll*C(i+j*(m-1)+m-2,m-2)*f[i][j])%MOD;
	printf("%d\n",1ll*fac[n]*f[n][n]%MOD); return 0;
}

Measured memory_bytes: 47232
#include <iostream>
#include <cstdio>
#include <queue>
#include <cstring>
using namespace std;
const int MAXSIZE = 1e4+7;
queue<pair<string,int> > que;
int n, q;
int main(){
	string name;
	int time;
	scanf("%d %d",&n, &q);{
		for(int i = 1; i <= n; i++){
			cin>>name>>time;
			que.push(make_pair(name,time));
		}
		pair<string, int> u;
		int elaps = 0, a;
		while(!que.empty()){
			u = que.front();
			que.pop();
			a = min(u.second,q);
			u.second -= a;
			elaps += a;
			if(u.second > 0){
				que.push(u);
			}else {
				cout<<u.first<<" "<<elaps<<endl;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 6424
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    string s;
    ll k;
    cin >> s >> k;
    ll n = s.size();

    set<string> st;
    ll len = 1;
    ll x = min(n, k);
    while(len <= x) {
        rep(i, n-len+1) {
            string t = s.substr(i, len);
            st.insert(t);
        }
        len++;
    }

    ll cnt = 1;
    for(auto p : st) {
        if(cnt == k) {
            out(p);
            re0;
        }
        cnt++;
    }
    
    re0;
}

Measured memory_bytes: 1664
n,t = gets.split.map!(&:to_i)
a = gets.split.map(&:to_i)

max = a[0]
min = a[0]
a << 0
gain = [0,0]

a.each do |e|
    if e >= max then
        max = e

    elsif e < min then
        m = max - min

        if gain[0] < m then
            gain[0] = m
            gain[1] = 1
        elsif gain[0] == m
            gain[1] += 1
        end

        max = e
        min = e
    end
end

puts gain[1]

Measured memory_bytes: 8452
#include<iostream>
#include<string>
using namespace std;
int main () {
    long long int n;cin>>n;
    string s;cin>>s;
    long long int l=s.length(),k;
    for (long long int i=0;i<l;i++) {
        k=(s[i]-'A')+n;
        k=k%26;
        s[i]=char(65+k);
    }
    cout<<s<<endl;
}


Measured memory_bytes: 256
//package Contest089;

import java.awt.print.Printable;
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    public static void main(String []args)
    {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        int n = sc.nextInt();
        out.println(n/3);

        out.flush();
    }
}


Measured memory_bytes: 23124