akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
ll n,k;
bool solve(ll mid, vector<ll> a, vector<ll> f){
    ll now = 0;
    for(int i=0;i < n;i++){
        now += max(a[i] - mid/f[i],0ll);
    }
    if(now > k) return 0;
    else return 1;
}
int main(){
    cout << fixed << setprecision(10);
    cin >> n >> k;
    vector<ll> a(n), f(n);
    rep(i,n) cin >> a[i];
    rep(i,n) cin >> f[i];
    sort(a.begin(),a.end());
    sort(f.rbegin(),f.rend());
    ll left = -1, right = 1e18+10;
    while(left + 1 < right){
        ll mid = (left + right)>>1;
        if(solve(mid,a,f)){
            right = mid;
        }else left = mid;
    }
    cout << right << endl;
    return 0;
}

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

using namespace std;
typedef long long ll;

ll n;
ll a[1000000];
ll b[1000000];
int main(){
    cin >> n;
    for(ll i=0; i<n; i++) cin >> a[i];
    for(ll i=0; i<n; i++) b[i]=0;

    ll cnt=0;
    b[0] = a[n-1];
    for(ll i=n-2; i>=0; i--){
        if( a[i] >= b[cnt]){
            cnt++;
            b[cnt] = a[i];
        }else{
            for( ll j=0; j<=cnt; j++){
                if( j==cnt) b[j] = a[i];
                if( b[j] > a[i]){
                    b[j] = a[i];
                    break;
                }
            }

        }
        /*
        cerr << i <<", " <<cnt << endl << "--";
        for( ll k=0; k<=cnt; k++){
            cerr << b[k] <<", ";
        }
        cerr << endl;
        */
        
    }

    cout << cnt +1 << endl;
    return 0;
}

Measured memory_bytes: 5120
import sys
import re
import math
import collections
import decimal
import bisect
import itertools
import fractions
import functools
import copy
import heapq
import decimal
import statistics
import queue

# import numpy as np

sys.setrecursionlimit(10 ** 9)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))
nb = lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().split()))


# ===CODE===


def main():
    n = ni()
    match = [collections.deque(nb()) for _ in range(n)]

    nxt = [-1] * n
    waiting = collections.deque(range(n))
    cnt = [0] * n

    while len(waiting) > 0:
        ego = waiting.popleft()
        if len(match[ego]) == 0:
            continue

        enemy = match[ego].popleft()

        if nxt[enemy] == ego:
            waiting.append(ego)
            waiting.append(enemy)
            cnt[ego] = cnt[enemy] = max(cnt[ego], cnt[enemy]) + 1

        else:
            nxt[ego] = enemy

    if any(match):
        print(-1)
    else:
        print(max(cnt))


if __name__ == '__main__':
    main()


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

int main()
{
	int N, Y, x, y;

	cin >> N >> Y;

	for (y = 0; y <= N; y++)
	{
		for (x = 0; x + y <= N; x++)
		{
			if (1000 * (9 * x + 4 * y + N) == Y)
			{
				cout << x << ' ' << y << ' ' << N - x - y << endl;
				return 0;
			}
		}
	}
	
	cout << -1 << ' ' << -1 << ' ' << -1 << endl;
}

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

using namespace std;


int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);

    int n,k;
    cin >> n >> k;
    vector <int> stones(n);
    for (int i=0;i<n;i++)
        cin >> stones[i];

    vector <bool> dp(k,false);
    for (int i=0;i<=k;i++)
        for (int j:stones)
        if (j<=i && !dp[i-j])
        dp[i]=true;

    cout << (dp[k] ? "First" : "Second");
}


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

static const int maxm = 100002;

struct sample {
	int num, par, diff, rank;//this - par
};

//1-origin
sample s[maxm];
//int mrank[maxm]; //child - parent

void init(int n) {
	for (int i = 1; i <= n; i++) {
		s[i].num = i;
		s[i].par = i;
		s[i].diff = 0;
		s[i].rank = 0;
	}
}

sample find(int x) {
	if (s[x].par == x) {
		return s[x];
	} else {
		sample root = find(s[x].par);
		s[x].par = root.par;
		s[x].diff += root.diff;
		root.diff = s[x].diff;
		return root;
	}
}

void unite(int x, int y, int d) {//d = y - x
	sample rootx = find(x);
	sample rooty = find(y);

	
	if (rootx.num == rooty.num)return;

	if (s[rootx.num].rank < s[rooty.num].rank) {
		s[rootx.num].par = rooty.num;
		s[rootx.num].diff = (-1) * (d - rooty.diff + rootx.diff);
	} else {
		s[rooty.num].par = rootx.num;
		s[rooty.num].diff = d - rooty.diff + rootx.diff;
		if (s[rootx.num].rank == s[rooty.num].rank)s[rootx.num].rank++;
	}
}

bool isSame(int x, int y) {
	return find(x).num == find(y).num;
}



int main() {
	while (1) {
		int i, j, k;
		int n, m;

		cin >> n >> m;
		if (n == 0 && m == 0)break;

		init(n);

		char cmd;
		int a, b, w;
		for (i = 0; i < m; i++) {
			cin >> cmd >> a >> b;
			if (cmd == '!') {
				cin >> w;
				unite(a, b, w); //w = b - a
			} else if (cmd == '?') {
				if (!isSame(a, b)) {
					cout << "UNKNOWN" << endl;
				} else {
					cout << find(b).diff - find(a).diff << endl;
				}
			}
		}
	}
	







	return 0;
}

Measured memory_bytes: 2728
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Text.RegularExpressions;

namespace AtCoder {
    class Program {
        static void Main(string[] args) {

            var input = Console.ReadLine().Split(' ').Select(n => int.Parse(n)).ToArray();
            var dx = input[2] - input[0];
            var dy = input[3] - input[1];

            Console.WriteLine("{0} {1} {2} {3}", input[2]-dy, input[3]+dx, input[0]-dy, input[1]+dx);
        }
    }
}

Measured memory_bytes: 13396
#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define isz(x) (int)(x).size()
#define watch(x) std::cerr << #x << " = " << x
#define watchsp(x) watch(x) << ' '
#define watchln(x) watch(x) << std::endl
#define cerr cerr && debug && std::cerr
using ll = long long;
using vi = std::vector<int>;
template<typename T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
    os << "{";
    for (int i = 0; i < isz(vec); i++) {
        if (i > 0) os << ", ";
        os << vec[i];
    } 
    return os << "}";
}
const int mod = (int)1e9+7, debug = 0;
int fast(int n, std::string s) {
    vi curr(1+n+1), prev(1+n+1);
    curr[1] = 1;
    for (int i = n-2; i >= 0; i--) {
        watchln(curr);
        int min = 1, max = n-i;
        if (s[i] == '<') {
            int sum = 0;
            for (int t = max; t >= min; t--) {
                sum += curr[t];
                if (sum >= mod) sum -= mod;
                if (t == max) {
                    prev[t] = 0;
                } else {
                    prev[t] = sum;
                }
            }
        } else { // prev > curr
            int sum = 0;
            for (int t = min; t <= max; t++) {
                if (t == min) {
                    prev[t] = 0;
                } else {
                    prev[t] = sum;
                }
                sum += curr[t];
                if (sum >= mod) sum -= mod;
            }
        }
        curr = prev;
    }
    watchln(curr);
    return int(std::accumulate(all(curr), ll(0)) % mod);
}
int slow(int n, std::string s) {
    vi p(n);
    for (int i = 1; i <= n; i++) {
        p[i-1] = i;
    }
    int answ = 0;
    do {
        bool ok = true;
        for (int i = 0; i + 1 < n; i++) {
            ok &= (s[i] == '>' && p[i] > p[i+1]) || (s[i] == '<' && p[i] < p[i+1]);
        }
        answ += ok;
    } while (std::next_permutation(all(p)));
    return answ;
}
void test() {
    for (int n = 2; n <= 8; n++) {
        std::string s(n-1,'>');
        for (int mask = 0; mask < (1 << (n-1)); mask++) {
            for (int bit = 0; bit < n-1; bit++) {
                s[bit] = (mask & (1 << bit)) ? '<' : '>';
            }
            if (fast(n,s) != slow(n,s)) {
                std::cout << "n = " << n << ", s = " << s << std::endl;
                std::cout << "fast = " << fast(n,s) << std::endl;
                std::cout << "slow = " << slow(n,s) << std::endl;
                std::exit(0);
            }
        }
    }
    std::exit(0);
}
int main() {
    //test();
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(0);
    int n; std::cin >> n; std::string s;
    std::cin >> s;
    std::cout << fast(n, s) << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
const int maxn =2e5+10;
const int mod=1e9+7;


int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
    ll a;
    string b;
    cin>>a>>b;
    ll c=(b[0]-'0')*100+(b[2]-'0')*10+(b[3]-'0');
    cout<<a*c/100<<'\n';


}



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

ll gcd(ll a, ll b){
  if(a<b) swap(a,b);
  ll r;
  while(b){
    r=a%b;
    a=b;
    b=r;
  }
  return a;
}

ll lcm(ll a, ll b){
  return a/gcd(a,b)*b;
}


int main(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  
  int N,M; cin>>N>>M;
  string S,T; cin>>S>>T;
  ll L=lcm(N,M);

  vector<pair<int,pair<int,int>>> V;
  int s=1,t=1;
  for(int i=0;i<N;i++){
    V.push_back({s,{i,0}});
    s+=L/N;
  }
  for(int i=0;i<M;i++){
    V.push_back({t,{i,1}});
    t+=L/M;
  }
  sort(V.begin(),V.end());
  for(int i=0;i<V.size()-1;i++){
    if(V[i].first==V[i+1].first){
      if(V[i].second.second==0){
        int x=V[i].second.first;
        int y=V[i+1].second.first;
        if(S[x]!=T[y]){
          cout<<-1<<endl;
          return 0;
        }
      }else{
        int x=V[i+1].second.first;
        int y=V[i].second.first;
        if(S[x]!=T[y]){
          cout<<-1<<endl;
          return 0;
        }
      }
    }
  }

  cout<<L<<endl;
  return 0;
}


Measured memory_bytes: 5300
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

class SegmentTree:
    """
    引数：
        N: 処理する区間の長さ
        operator: モノイド演算 (max, min, __add__,ラムダ式,関数定義など)
        UNIT: 単位元
        a: 長さNの配列 a で初期化（a を与えない場合、単位元で初期化）
    注意: 内部的には 1-indexed
    """
    def __init__(self, N, operator, unit, a=None):
        self.op = operator
        self.UNIT = unit
        self.N0 = 2**(N-1).bit_length()
        self.tree = [self.UNIT]*(2*self.N0)
        if a != None:
            self.tree[self.N0:self.N0+N] = a[:]
            for k in range(self.N0-1, 0, -1):
                self.tree[k] = self.op(self.tree[2*k], self.tree[2*k+1])
    # k番目 の値を x に更新
    def update(self, k, x):
        k += self.N0
        self.tree[k] = x
        k //= 2
        while k:
            self.tree[k] = self.op(self.tree[2*k], self.tree[2*k+1])
            k //= 2
    # 区間[l,r]をopでまとめる
    def query(self, l, r):
        L = l + self.N0
        R = r + self.N0 + 1
        s = self.UNIT
        while L < R:
            if R & 1:
                R -= 1
                s = self.op(self.tree[R], s)
            if L & 1:
                s = self.op(s, self.tree[L])
                L += 1
            L >>= 1
            R >>= 1
        return s
    def get(self, k):  # k番目の値を取得。query[k,k]と同じ
        return self.tree[k+self.N0]

N = INT()
A = LIST()
lcm_base = lambda x, y: (x * y) // gcd(x, y)
many_lcm = lambda numbers: reduce(lcm_base, numbers)
unit = many_lcm(A)
seg = SegmentTree(N+1, gcd, unit)

for i, x in enumerate(A):
	seg.update(i+1, x)

ans = 0
for i, x in enumerate(A):
	seg.update(i+1, unit)
	ans = max(ans, seg.query(1, N))
	seg.update(i+1, A[i])
print(ans)


Measured memory_bytes: 90788
import sys
from collections import deque
from collections import defaultdict
import math
sys.setrecursionlimit(20000000)
input = sys.stdin.readline
n = int(input())
w = list(map(int,input().split()))
ans = 100000000
for i in range(n+1):
        ans = min(ans,abs(sum(w[:i])-sum(w[i:])))
print(ans)

Measured memory_bytes: 3572
inputStr = input()
for i in range(0, len(inputStr)):
  if(inputStr[i] == ' '):
    surface = int(inputStr[:i]) * int(inputStr[i+1:])
    edge = (int(inputStr[:i]) + int(inputStr[i+1:])) * 2
    print(str(surface) + ' ' + str(edge))

Measured memory_bytes: 7584
s = input()

cnt = 0
for i in range(0,len(s)):
    if s[i] != s[len(s)-1-i]: cnt += 1
    else: pass

test2 = int((len(s)-1)/2)
for i in range(0,test2):
    if s[i] != s[test2-1-i]: cnt += 1
    else: pass
    
test3 = int((len(s)+3)/2-1)
for i in range(test3,len(s)):
    if s[i] != s[len(s)-1-i]: cnt += 1
    else: pass
    
if cnt != 0: 
    print('No')
else:
    print('Yes')
    

Measured memory_bytes: 3064
#include <iostream>
#include <stack>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <cstring>
#include <map> 
#include<set>
#include<queue>
#include <iomanip>

typedef long long ll;

#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const long long INF = 1000000000000000;
const ll inf = -1e18;
typedef pair<ll, ll> P;
ll ma = 1000000000 + 7;
ll mx = 1000003;
ll h,n, w,m,t; string s;
ll R, C;
ll sy, sx, gy, gx;
char maze[20][20];
ll dis[20][20];
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };
ll gcd(ll x, ll y) {
	if (x % y == 0) return y;
	return gcd(y, x % y);
}
ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
void comb(vector<vector <ll> >& v) {
	for (ll i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (ll k = 1; k < v.size(); k++) {
		for (int j = 1; j < k; j++) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j])%ma;
		}
	}
}

ll GetDigit(ll num) {
	return log10(num) + 1;
}
ll Combination(int n, int r)
{
	if (n - r < r) r = n - r;
	if (r == 0) return 1;
	if (r == 1) return n;

	vector<ll> numerator(r);
	vector<ll> denominator(r);

	for (int k = 0; k < r; k++)
	{
		numerator[k] = n - r + k + 1;
		denominator[k] = k + 1;
	}

	for (int p = 2; p <= r; p++)
	{
		int pivot = denominator[p - 1];
		if (pivot > 1)
		{
			int offset = (n - r) % p;
			for (int k = p - 1; k < r; k += p)
			{
				numerator[k - offset] /= pivot;
				denominator[k] /= pivot;
			}
		}
	}

	ll result = 1;
	for (int k = 0; k < r; k++)
	{
		if (numerator[k] > 1) result *= numerator[k];
		result %= ma;
	}

	return result;
}

ll bfs() {
	queue<P> que;
	for (int i = 0; i < R; i++) {
		for (int j = 0; j < C; j++) dis[i][j] = INF;
	}
	que.push(P(sy - 1, sx - 1));
	dis[sy - 1][sx - 1] = 0;

	while (que.size() > 0) {
		P p = que.front();
		que.pop();
		if (p.first == gy - 1 && p.second == gx - 1) break;
		for (ll i = 0; i < 4; i++) {
			ll ny = p.first + dy[i];
			ll nx = p.second + dx[i];
			if (0 <= ny && ny < R && 0 <= nx && nx < C && maze[ny][nx] == '.' && dis[ny][nx] == INF) {
				que.push(P(ny, nx));
				dis[ny][nx] = dis[p.first][p.second] + 1;
			}
		}
	}
	return dis[gy - 1][gx - 1];
}
ll dp[20500];
int main() {
	cin >> n;
	vector<string> str(n);
	map<string, ll> mp;
	rep(i, n) {
		cin >> str[i];
		mp[str[i]]++;
	}
	ll cmax = 0;
	rep(i, n) {
		chmax(cmax, mp[str[i]]);
	}
	for (auto i = mp.begin(); i != mp.end();i++) {
		if (cmax == i->second) {
			cout << i->first << endl;
		}
	}
}



Measured memory_bytes: 26752
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) (x).begin(),(x).end()
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
	
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	
	ll ans=0;
	
	int n;
	cin >> n;
	
	vector<int> a(n+1);
	rep(i,n+1) cin >> a[i];
	
	vector<int> b(n);
	rep(i,n) cin >> b[i];
	
	int r;
	
	ans+=min(a[0],b[0]);
	r=max(0,b[0]-a[0]);
	
	for(int i=1;i<n;i++){
		// 1
		ans+=min(r,a[i]);
		a[i]-=min(r,a[i]);
		
		// 2
		ans+=min(a[i],b[i]);
		r=max(0,b[i]-a[i]);
	}
	
	ans+=min(r,a[n]);
	
	
	
	cout << ans << "\n";
	
	
	return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <math.h>
#include<bits/stdc++.h>
using namespace std;
#define int long long int
 #define hi ios_base :: sync_with_stdio(false); cin.tie(0);cout.tie(0);
int i,j,k,mo;

main()
{
    int x;
    cin>>x;
    cout<<!x<<endl;

}


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

using namespace std;

struct Node
{
    int data;
    struct Node* left;
    struct Node* right;
    Node(int x)
    {
        data=x;
        left=NULL;
        right=NULL;
    }
};
#define Node struct Node

int main()
{
    int t=1;
    //cin>>t;
    while(t--)
    {
        ll a,b,c,d;
        cin>>a>>b>>c>>d;
        cout<<max(a*c,max(a*d,max(b*c,b*d)))<<endl;
    }
    return 0;
}







Measured memory_bytes: 3620
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, islice
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce, lru_cache
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7

N = INT()
xy = [LIST() for _ in range(N-1)]
tree = [[] for _ in range(N)]
for x, y in xy:
    tree[x-1].append(y-1)
    tree[y-1].append(x-1)

@lru_cache(maxsize=None)
def DFS(i, par, c):  # c:0->white, 1->black
    if par and len(tree[i]) == 1:
        return 1
    if c == 0:
        cnt = 1
        for node in tree[i]:
            if node != par:
                cnt *= (DFS(node, i, 0) + DFS(node, i, 1))
                cnt %= mod
        return cnt
    elif c == 1:
        cnt = 1
        for node in tree[i]:
            if node != par:
                cnt *= DFS(node, i, 0)
                cnt %= mod
        return cnt

ans = DFS(0, None, 0)+DFS(0, None, 1)
print(ans%mod)


Measured memory_bytes: 167908
#include<bits/stdc++.h>
using namespace std ; 
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fast ios_base:: sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define f first
#define s second
#define int long long int

signed main(){
    fast;
    int n,sum; cin >> n >> sum;
    int a[n+1],b[n+1];
    for(int i=1 ; i<n+1 ; i++){
        cin >> a[i] >> b[i];
    }
    int dp[n+1][sum+1];
    memset(dp,0, sizeof(dp));

    for(int i =1;  i<n+1 ; i++){
        for(int j=1 ; j<sum+1 ; j++){
            if(j-a[i]>=0)
                dp[i][j] = max(dp[i-1][j] , b[i] + dp[i-1][j-a[i]]);
            else
            {
                dp[i][j] = dp[i-1][j];
            }
            
        }
    }

    cout << dp[n][sum] << endl;


}

Measured memory_bytes: 79104
import math
N = list(map(int, input().split()))
X = [i for i in range(math.ceil((N[0])*(1/0.08)), math.ceil((N[0]+1)*(1/0.08)))]
Y = [i for i in range(math.ceil((N[1])*(1/0.10)), math.ceil((N[1]+1)*(1/0.10)))]
#print(X, Y)
#for i in X:
#  print(math.floor(i*0.08))

cand = set(X) & set(Y)
if len(cand) == 0:
  print(-1)
else:
  print(min(cand))


Measured memory_bytes: 3064
#include<stdio.h>
int main(void)
{
  char str[256];
    scanf("%s", str);
  int i=0,sum,max=0;
while(str[i]!=0){
  if(str[i]=='A')sum++;
  else if(str[i]=='C')sum++;
  else if(str[i]=='G')sum++;
  else if(str[i]=='T')sum++;
  else sum=0;
  
  if(max<=sum)max=sum;
  i++;
}
printf("%d",max);
 return 0;
}

Measured memory_bytes: 128
import java.io.IOException;
import java.text.DecimalFormat;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {

	@SuppressWarnings("unused")
	public static void main(String[] args) throws IOException {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt(); // 県の個数
		int m = in.nextInt(); // 市の個数

		int city[][] = new int[m + 1][4]; // id, pref, year, number in pref

		// 県、年でソート
		for ( int id = 1; id <= m; id++ ) {
			city[id][0] = id;
			city[id][1] = in.nextInt();
			city[id][2] = in.nextInt();
		}
		Arrays.sort(city, new Comparator<int[]>() {

			@Override
			public int compare(int[] o1, int[] o2) {
				if ( o1[1] != o2[1] ) {
					return o1[1] - o2[1];	// １．prefでソート
				} else {
					return o1[2] - o2[2];	// ２．yearでソート
				}
			}
		});

		// 年を見てナンバリング
		DecimalFormat df = new DecimalFormat("000000");
		String result[] = new String[m];
		int pref = 0;
		int num = 0;
		for ( int i = 1; i <= m; i++ ) {
			int p = city[i][1];
			if ( pref != p ) {
				pref = p;
				num = 1;
			} else {
				num++;
			}
			result[city[i][0] - 1] = padding(pref) + padding(num); // df.format(pref) + df.format(num);
		}

		StringBuilder sb = new StringBuilder();
		for ( String s : result ) {
			sb.append(s).append("\n");
		}
		System.out.println(sb);
		in.close();
	}

	private static String padding(int n) {
		String padded = "";
		if ( n < 10 ) {
			padded = "00000" + n;
		} else if ( n < 100 ) {
			padded = "0000" + n;

		} else if ( n < 1000 ) {
			padded = "000" + n;

		} else if ( n < 10000 ) {
			padded = "00" + n;

		} else if ( n < 100000 ) {
			padded = "0" + n;

		} else {
			padded = String.valueOf(n);
		}
		return padded;
	}
}


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

int main() {
  int N,K;
  cin >> N >> K;
  int x;
  int ans = 0;
  for (int i=0; i<N; i++) {
    cin >> x;
    ans += min(x,K-x);
  }
  
  cout << ans*2 << endl;
  return 0;
}

Measured memory_bytes: 764
### ----------------
### ここから
### ----------------

import sys
from io import StringIO
import unittest
import math

def yn(b):
    print("Yes" if b==1 else "No")
    return

def resolve():
    readline=sys.stdin.readline

    #n,m,k=map(int, readline().rstrip().split())
    #arr=list(map(int, readline().rstrip().split()))
    n=int(readline())
    #ss=readline().rstrip()
    #yn(1)
    print(n*2*math.pi)

    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

### ----------------
### ここまで 
### ----------------

Measured memory_bytes: 16228
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define endl "\n"

int main()
{
  string N;
  cin >> N;
  for (i64 i = 0; i < 3; i++)
    if (N[i] == '7')
    {
      cout << "Yes" << endl;
      return 0;
    }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3628
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <numeric>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

int main(void)
{
    double ans = 0;
    ll n;
    cin >> n;

    for (int i = 0; i < n; i++)
    {
        double x;
        string s;

        cin >> x >> s;

        if (s == "JPY")
        {
            ans += x;
        }
        else
        {
            ans += x * 380000;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;
int main()
{
    int N;
    cin >> N;

    vector<int> A(N), B(N), C(N);
    rep(i, 3) {
        rep(j, N) {
            int k;
            cin >> k;
            if (i % 3 == 0) A[j] = k;
            else if (i % 3 == 1) B[j] = k;
            else C[j] = k;
        }
    }

    sort(all(A));
    sort(all(C));

    ll ans = 0;

    rep(i, N) {
        ll a = lower_bound(all(A), B[i]) - A.begin();
        ll b = C.end() - upper_bound(all(C), B[i]);
        ans += (a * b);
    }

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

Measured memory_bytes: 1408
#pragma comment(linker, "/STACK:512000000")
#define _CRT_SECURE_NO_WARNINGS
//#include "testlib.h"
#include <bits/stdc++.h>
using namespace std;

#define all(a) a.begin(), a.end()
typedef long long li;
typedef long double ld;
void solve(bool);
void precalc();
clock_t start;
int main() {
#ifdef AIM
  freopen("/home/alexandero/ClionProjects/ACM/input.txt", "r", stdin);
  //freopen("/home/alexandero/ClionProjects/ACM/output.txt", "w", stdout);
  //freopen("out.txt", "w", stdout);
#else
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
#endif
  start = clock();
  int t = 1;
  cout.sync_with_stdio(0);
  cin.tie(0);
  precalc();
  cout.precision(10);
  cout << fixed;
  //cin >> t;
  int testNum = 1;
  while (t--) {
    //cout << "Case #" << testNum++ << ": ";
    //cerr << testNum << endl;
    solve(true);
    //cerr << testNum - 1 << endl;
  }
  cout.flush();
#ifdef AIM1
  while (true) {
      solve(false);
  }
#endif

#ifdef AIM
  cerr << "\n\n time: " << (clock() - start) / 1.0 / CLOCKS_PER_SEC << "\n\n";
#endif

  return 0;
}

//BE CAREFUL: IS INT REALLY INT?

template<typename T>
T binpow(T q, T w, T mod) {
  if (!w)
    return 1 % mod;
  if (w & 1)
    return q * 1LL * binpow(q, w - 1, mod) % mod;
  return binpow(q * 1LL * q % mod, w / 2, mod);
}

template<typename T>
T gcd(T q, T w) {
  while (w) {
    q %= w;
    swap(q, w);
  }
  return q;
}
template<typename T>
T lcm(T q, T w) {
  return q / gcd(q, w) * w;
}

template <typename T>
void make_unique(vector<T>& a) {
  sort(all(a));
  a.erase(unique(all(a)), a.end());
}

void precalc() {

}

template<typename T>
void relax_min(T& cur, T val) {
  cur = min(cur, val);
}

template<typename T>
void relax_max(T& cur, T val) {
  cur = max(cur, val);
}

#define int li
//const int mod = 1000000007;

void solve(bool read) {
    string s;
    cin >> s;
    int n = s.length();
    vector<int> d1(n), d2(n);
    int ans = n * (n + 1) / 2;

    vector<int> num(26);
    for (char c : s) {
        ++num[c - 'a'];
    }
    for (int x : num) {
        ans -= x * (x + 1) / 2;
    }
    ++ans;

    cout << ans << endl;


}

Measured memory_bytes: 3732
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
int N,A[200004];
ll K;
int doubling[61][200004]; // ダブリング. 街jから2^i進めた街

int main() {
  INCANT;
  cin >> N >> K;
  rep(i, N) {
    cin >> A[i];
    A[i]--;
  }
  rep(i, N) doubling[0][i]=A[i];
  // 自分の街jの2^(i+1)後の街は、自分の街から2^i後の街からさらに2^i進んだ街に等しい
  rep(i, 60) {
    rep(j, N) doubling[i+1][j] = doubling[i][doubling[i][j]];
  }
  int n=0;
  rep(i, 60) {
    if ((K>>i) & 1) n = doubling[i][n]; 
  }
  cout << n+1 << endl;
  return 0;
}

Measured memory_bytes: 52084
import heapq
n,m,s,t=map(int,input().split())
s-=1
t-=1
Gyen=[dict() for i in range(n)]
Gsnu=[dict() for i in range(n)]
for i in range(m):
    u,v,a,b=map(int,input().split())
    u-=1
    v-=1
    Gyen[u][v]=a
    Gyen[v][u]=a
    Gsnu[u][v]=b
    Gsnu[v][u]=b
def dijkstra(adj, start):
    num = n          # グラフのノード数
    dist = [10**15 for i in range(num)] # 始点から各頂点までの最短距離を格納する
   
    dist[start] = 0
    q = []                  # プライオリティキュー．各要素は，(startからある頂点vまでの仮の距離, 頂点vのID)からなるタプル
    heapq.heappush(q, (0, start)) # 始点をpush
    while (len(q) != 0):
        prov_cost, src = heapq.heappop(q) # pop
        # プライオリティキューに格納されている最短距離が，現在計算できている最短距離より大きければ，distの更新をする必要はない
        if dist[src] < prov_cost:
            continue
        # 他の頂点の探索
        for dest in adj[src]:
            cost = adj[src][dest]
            if dist[dest] > dist[src] + cost:
                dist[dest] = dist[src] + cost # distの更新
                heapq.heappush(q, (dist[dest], dest)) # キューに新たな仮の距離の情報をpush                  
    return dist
CostYen=dijkstra(Gyen,s)
CostSnu=dijkstra(Gsnu,t)
Cost=[0 for i in range(n)]
for i in range(n):
    Cost[i]=CostYen[i]+CostSnu[i]
ans=[0 for i in range(n)]
ans[-1]=Cost[-1]
for i in list(range(n-1))[::-1]:
    ans[i]=min(ans[i+1],Cost[i])
for i in range(n):
    print(10**15-ans[i])

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

const int N = 100005;

int n, ans;
bool f[N];
vector<int> e[N];

void dfs(int x, int fa)
{
	int s = 0;
	for (int to : e[x]) if (to != fa)
	{
		dfs(to, x);
		s += !f[to];
		f[x] |= f[to];
	}
	if (s > 1) f[x] = 1, ans += s - 1;
}

int main()
{
	scanf("%d", &n);
	for (int i = 1; i < n; i++)
	{
		int x, y; scanf("%d%d", &x, &y);
		x++; y++;
		e[x].push_back(y); e[y].push_back(x);
	}
	int rt = 0;
	for (int i = 1; i <= n; i++) if (e[i].size() > 2) {rt = i; break;}
	if (!rt) {printf("%d\n", 1); return 0;}
	dfs(rt, 0);
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 13528
package main

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

func main() {
	N := nextInt()
	K := nextInt()

	initFact(3000)

	for i := 1; i <= K; i++ {
		fmt.Println(comb(N-K+1, i).mul(comb(K-1, i-1)))
	}
}

var facts []mint  // facts[i] = (i + 1)! mod
var ifacts []mint // ifacts[i] = (i + 1)! modの逆元

// nの階乗までを初期化します
func initFact(n int) {
	facts = make([]mint, n+1)
	ifacts = make([]mint, n+1)
	facts[0] = mint(1)
	ifacts[0] = mint(1)
	m := mint(n)
	for i := mint(0); i < m; i++ {
		facts[i+1] = facts[i].mul(i.add(1))
		ifacts[i+1] = ifacts[i].mul(i.add(1).pow(mod - 2))
	}
}

// perm はnPkを返します
func perm(n, k int) mint {
	if n < k {
		return 0
	}
	return ifacts[n-k].mul(facts[n])
}

// comb はnCkを返します
func comb(n, k int) mint {
	if n == 0 && k == 0 {
		return mint(1)
	} else if n < k || n < 0 {
		return mint(0)
	}
	return facts[n].mul(ifacts[n-k]).mul(ifacts[k])
}

// dupcomb はnHkを返します
func dupcomb(n, k int) mint {
	if n == 0 && k == 0 {
		return mint(1)
	} else if n < 0 || k == 0 {
		return mint(0)
	}
	return facts[n+k-1].mul(ifacts[n-1]).mul(ifacts[k])
}

type mint int64

var mod = mint(1e9 + 7)

// add は a + bを返します
func (a mint) add(b mint) mint {
	return (a + b) % mod
}

// sub は a - bを返します
func (a mint) sub(b mint) mint {
	return (a - b + mod) % mod
}

// mul は a * bを返します
func (a mint) mul(b mint) mint {
	return (a * (b % mod)) % mod
}

// div は a/bを返します
func (a mint) div(b mint) mint {
	return a.mul(b.inv())
}

// inv は aの逆元を返します
func (a mint) inv() mint {
	// 拡張ユークリッドの互除法
	b := mod
	u := mint(1)
	v := mint(0)
	for b > 0 {
		t := a / b
		a -= t * b
		a, b = b, a
		u -= t * v
		u, v = v, u
	}
	return (u + mod) % mod
}

// pow は a ^ bを返します
func (a mint) pow(b mint) mint {
	ans := mint(1)

	for b != 0 {
		if b&1 == 1 {
			ans = ans.mul(a)
		}
		a = a.mul(a)
		b = b >> 1
	}
	return ans
}

var stdin = initStdin()

func initStdin() *bufio.Scanner {
	bufsize := 1 * 1024 * 1024 // 1 MB
	var stdin = bufio.NewScanner(os.Stdin)
	stdin.Buffer(make([]byte, bufsize), bufsize)
	stdin.Split(bufio.ScanWords)
	return stdin
}

func nextString() string {
	stdin.Scan()
	return stdin.Text()
}

func nextBytes() []byte {
	stdin.Scan()
	return stdin.Bytes()
}

func nextInt() int {
	i, _ := strconv.Atoi(nextString())
	return i
}

func nextInt64() int64 {
	i, _ := strconv.ParseInt(nextString(), 10, 64)

	return i
}


Measured memory_bytes: 768
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    [n,x] <- getIntList
    as <- getIntList
    let s = foldl' (solve x) (0,0) as
    print $ fst s

solve x (s, a) b | a+b <= x = (s, b)
                 | otherwise = (s+a+b-x, max (x-a) 0)

Measured memory_bytes: 7440
#include <stdio.h>
#define MAX 100001
#define NOT_FOUND -1

int binarySearch(int *A, int N, int key) {
  int left = 0, right = N, mid;
  while(left < right) {
    mid = (left + right) / 2;
    if(A[mid] == key) return mid;
    else if (key < A[mid]) right = mid;
    else left = mid + 1;
  }
  return NOT_FOUND;
}

int main() {
  int n, q, s[MAX], t, i, count = 0;
  
  scanf("%d", &n);
  for(i = 0; i < n; i++) {
    scanf("%d", &s[i]);
  }
  
  scanf("%d", &q);
  for(i = 0; i < q; i++) {
    scanf("%d", &t);
    if(binarySearch(s, n, t) >= 0) count++;
  }
  
  printf("%d\n", count);
  return 0;
}



Measured memory_bytes: 2108
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author anand.oza
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ARoundOne solver = new ARoundOne();
        solver.solve(1, in, out);
        out.close();
    }

    static class ARoundOne {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            out.println(6 - in.nextInt() - in.nextInt());
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}



int main2() {
  int A, B; cin >> A >> B;
  int ans = 0;
  chmax(ans, A + (A-1));
  chmax(ans, A + B);
  chmax(ans, B + (B-1));
  cout << ans << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define rep11(i, n) for (int i = 1; i < (int)(n); ++i)
#define repo(i, o, n) for (int i = o; i < (int)(n); ++i)
#define repm(i, n) for (int i = (int)(n)-1; i >= 0; --i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1002000007
#define INF LONG_LONG_MAX

int main(){
  double k;
  cin>>k;
  double a,b;
  cin>>a>>b;
  double ans;
  ans=ceil(double(a/k))*k;
  if(b>=ans){
    cout<<"OK" <<endl;
    
  }
  else{
    cout<<"NG" <<endl;
  }
}

Measured memory_bytes: 3700
#include<bits/stdc++.h> 
#define LL long long
#define clr(x,i) memset(x,i,sizeof(x))
using namespace std;
const int N=200005;
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int n,a[N],sum[21][N],xs[21][N];
LL ans=0;
int main()
{
	n=read();
	for(int i=1;i<=n;i++) a[i]=read();
	for(int i=1;i<=n;i++){
		for(int j=0;j<20;j++){
			sum[j][i]=sum[j][i-1];
			if((1<<j)&a[i])
		      sum[j][i]++;
		}
	}
	for(int i=1;i<=n;i++){
		int cur=n-i+1;
		for(int j=0;j<20;j++){
			int ret=lower_bound(sum[j]+i,sum[j]+n+1,sum[j][i-1]+2)-sum[j]-i;
//			cout<<' '<<i<<' '<<j<<' '<<sum[j][i-1]+2<<endl;
			cur=min(cur,ret);
		}
//		cout<<i<<' '<<cur<<endl;
		ans+=cur;
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 17408
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int mod=1e9+7;
struct edge{
	int s,t,nxt;
}e[10005];
int e_cnt,lst[5005];
void ins(int a,int b){
	e[e_cnt]=(edge){a,b,lst[a]};
	lst[a]=e_cnt++;
}
int f[5005][5005][2],g[5005];
int fa[5005],size[5005];
int t[5005][2];
void dfs(int x){
	size[x]=1;
	f[x][1][0]=1;
	for(int i=lst[x];i!=-1;i=e[i].nxt)if(e[i].t!=fa[x]){
		fa[e[i].t]=x;
		dfs(e[i].t);
		for(int k=0;k<=size[x]+size[e[i].t];k++)
			for(int j=0;j<2;j++)t[k][j]=f[x][k][j],f[x][k][j]=0;
		// printf("%d %d %d %d %d %d\n",x,e[i].t,size[x],size[e[i].t],t[1][0],f[e[i].t][1][0]);
		for(int p=0;p<=size[x];p++)
			for(int j=0;j<=size[e[i].t];j++)
				for(int k=0;k<2;k++)
					for(int l=0;l<2;l++)
						f[x][p+j][k^l]=(f[x][p+j][k^l]+1ll*t[p][k]*f[e[i].t][j][l])%mod;
		size[x]+=size[e[i].t];
		// printf("%d\n",x);
		// for(int i=0;i<=size[x];i++)printf("[%d,%d]",f[x][i][0],f[x][i][1]); puts("");
	}
	for(int i=1;i<=size[x];i++)
		for(int j=0;j<2;j++)f[x][0][j^1]=(f[x][0][j^1]+1ll*g[i]*f[x][i][j])%mod;
	// printf("%d\n",x);
	// for(int i=0;i<=size[x];i++)printf("[%d,%d]",f[x][i][0],f[x][i][1]); puts("");
}
int main(){
	int n;
	scanf("%d",&n);
	memset(lst,-1,sizeof(lst));
	for(int i=1;i<n;i++){
		int u,v;
		scanf("%d%d",&u,&v);
		ins(u,v);
		ins(v,u);
	}
	g[0]=1;
	for(int i=2;i<=n;i++)g[i]=1ll*g[i-2]*(i-1)%mod;
	dfs(1);
	int ans=0;
	for(int i=1;i<=n;i++)ans=(ans+1ll*g[i]*f[1][i][0]-1ll*g[i]*f[1][i][1])%mod;
	printf("%d\n",(ans+mod)%mod);
}

Measured memory_bytes: 194944
#include <iostream>
#include <bits/stdc++.h>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <map>
#define for1(x,y) for(long long x = 1; x<ll(y); x++)
#define forn(x,y,z) for(long long x = y; x< ll(z); x++)
#define for0(x,y,z) for(long long x = y; x< ll(z); x++)
#define PII pair<int,int>
#define FF first
#define SS second
#define PB push_back
#define all(x) x.begin(), x.end()

#define forn(x,y,z) for(long long x = y; x< ll(z); x++)
#define for0(x,y,z) for(long long x = y; x< ll(z); x++)
using namespace std;
typedef long long ll;
typedef long double ld;	
#define vi vector<int> 
#define vl vector<ll> 
#define vvi vector<vector<int>>
#define vvl vector<vector<ll>>
#define maxn 1000015
const double EPS = (1e-7), EPSm= (1e7);
const ll linf = (ll)1e17 + 5;
long double PI = 3.14159265359;
int dir[8][2]={{1,0},{-1,0},{0,1},{0,-1},{-1,-1},{1,1},{-1,1},{1,-1}};
	
const int MAXN = 3*1e5+10;
const int NINF = -1e5;
const int INF = 20000000;
const ll mod=1e9+7;


void solve(){
    int n;
    cin>>n;
    vector<pair<int,int>> points(n);
    for(auto &[x,y] : points){
        cin>>x>>y;
    }
    sort(points.begin(), points.end());
    int mn1 = 1e9, mn2 = 1e9;   //x+y, x-y
    int ans = 0;
    for(auto &[x,y] : points){
        mn1 = min(mn1, x+y);
        mn2 = min(mn2, x-y);
        ans = max(ans, x+y - mn1);
        ans = max(ans, x-y - mn2);
    }
    cout<<ans<<"\n";
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int test;
	//cin >> test;
	//while(test--)
		solve();
	return 0;
}


Measured memory_bytes: 4776
#include<bits/stdc++.h>
using namespace std;
long long a[200005];
int main(){
    int n;
    cin>>n;
    string s;
    cin>>s;
    for(int i=0;i<s.length();i++){
        if(s[i]+n>'Z'){
            s[i]='A'+(n-('Z'-s[i]))-1;
        }
        else s[i]=s[i]+n;
    }
    cout<<s<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string a;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>a;
    int i,c=0;
    for(i=0;i<3;i++)
    {

        if(a[i]=='R'&& a[i+1]=='R')
        {
            c+=2;
            i++;
        }
       // else //if((a[i]=='S'&& a[i+1]=='R')||(a[i]=='R'&& a[i+1]=='S'))
        //{
          //  c++;
            //i++;
        //}
        else if(a[i]=='R'&&a[i+1]=='S'&&a[i+2]=='R')
        {
            c=1;
            break;
        }
        else if(a[i]=='R')
        {
            c++;
        }


    }
   cout<<c<<endl;

    return 0;
}


Measured memory_bytes: 3548
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String N = sc.next();
    int M = sc.nextInt();
    
    long n = Long.parseLong(N, 10);
    String ans = Long.toString(n, M);
    System.out.println(ans.length());
  }
}

Measured memory_bytes: 24276
#include <bits/stdc++.h>
using namespace std;
int main() {
    int a, b, t; cin >> a >> b >> t;
    int ans = 0;
    for (int i = 1; i <= t; i++) {
        if (i % a == 0) ans += b;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _0065
{
    class Program
    {
        static void Main(string[] args)
        {
            List<Customer> customer = new List<Customer>();
            List<Customer> customer1 = new List<Customer>();
            List<Customer> customers = new List<Customer>();
            Array(customer, "");
            Array(customer1, null);
            AddList(customers, customer);
            AddList(customers, customer1);
            var customer2 = customers.GroupBy(x => x.name).OrderBy(x => x.Key);
            foreach (var item in customer2)
            {
                if (item.Count() >= 2 && customer.Any(x => x.name == item.Key)
                    && customer1.Any(x => x.name == item.Key))
                {
                    Console.WriteLine(item.Key + " " + item.Count());
                }
            }
        }
        static void Array(List<Customer> list, string str1)
        {
            string str;
            int k = 0;
            while (!((str = Console.ReadLine()) == str1))
            {
                list.Add(new Customer());
                string[] line = str.Split(',');
                list[k].name = int.Parse(line[0]);
                list[k].date = int.Parse(line[1]);
                k++;
            }
        }
        static void AddList(List<Customer> list, List<Customer> list1)
        {
            for (int i = 0; i < list1.Count; i++)
            {
                list.Add(list1[i]);
            }
        }
    }
    class Customer
    {
        public int name;
        public int date;
        public Customer()
        {
            name = 0;
            date = 0;
        }
    }
}



Measured memory_bytes: 16456
#include <assert.h>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using ll = long long;
using P = std::pair<ll, ll>;

#define rep(i, a, b) for (ll(i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cerr << "debug "<< i << std::endl

// const ll MOD = 998244353;
const ll MOD = 1e9 + 7;

//非再帰累乗(mod付き)
ll pow_mod(ll a, ll b, ll mod=-1) {
  if ((a == 0)||(mod!=-1&&a%mod==0)) {
    return 0;
  }

  ll x = 1;

  while (b > 0) {
    if (b & 1) {
      x = (mod!=-1)?(x * a) % mod:x*a;
    }
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}

using mat=std::vector<std::vector<ll>>;

mat Mul(mat a,mat b,ll mod){
  assert(a[0].size()==b.size());

  mat ret(a.size(),std::vector<ll>(b[0].size()));

  for(ll i=0;i<a.size();i++){
    for(ll j=0;j<b[0].size();j++){
      ll temp=0;
      for(ll k=0;k<a[0].size();k++){
        temp=(temp+a[i][k]*b[k][j])%mod;
      }
      ret[i][j]=temp;
    }
  }

  return ret;
}

//非再帰累乗(mod付き)
mat pow_mod(mat a, ll b, ll mod=-1) {
  ll n=a.size();

  mat x(n,std::vector<ll>(n,0));

  rep(i,0,n)x[i][i]=1;

  while (b > 0) {
    if (b & 1) {
      x = Mul(x,a,mod);
    }
    a =Mul(a,a,mod);
    b >>= 1;
  }
  return x;
}

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  //問題文中の添え字が0-indexか1-indexか確認!

  ll l,a,b,m;
  std::cin>>l>>a>>b>>m;

  mat ans(3,std::vector<ll>(1,0));
  ans[0][0]=0;ans[1][0]=a%m;ans[2][0]=1;

  std::vector<ll> c(19,0);

  rep(i,1,19){
    ll temp=(pow_mod(10,i)-a-1)/b;
    if(temp<0)c[i]=0;
    else if(temp<l) c[i]=temp+1;
    else c[i]=l;
  }

  rep(i,1,19){
    mat po(3,std::vector<ll>(3,0));
    po[0][0]=pow_mod(10,i,m);po[0][1]=1;
    po[1][1]=1;po[1][2]=b%m;
    po[2][2]=1;

    po=pow_mod(po,c[i]-c[i-1],m);

    ans=Mul(po,ans,m);
  }

  std::cout<<ans[0][0];

  return 0;
}


Measured memory_bytes: 256
int main(){
  int a[1000000]={},n;
  long int b=0;
  scanf("%d",&n);
  for(int i=1;i<=n;i++){
    if(i%3==0) a[i]=1;
    if(i%5==0) a[i]=1;
  }
  for(int i=1;i<=n;i++){
    if(a[i]==0) b+=i;
  }
  printf("%ld\n",b);
  return 0;
}

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

struct Data {
	int l,r,s;
};

bool add(int x, int k, vector<int> &v){
	if(k == v.size()) return false;
	if(++v[k] > x){
		v[k] = 0;
		return add(x, 1+k, v);
	}
	return true;
}
int main(){
	int n,x,m;
	cin>>n>>x>>m;
	vector<Data> data;
	while(m--){
		Data d;
		cin>>d.l>>d.r>>d.s;
		data.push_back(d);
	}
	int max=-1;
	vector<int> answer;
	vector<int> lion(n,0);
	for(;;){
		int sum;
		for(Data d : data){
			sum = 0;
			for(int j=d.l-1; j<d.r; j++){
				sum += lion[j];
			}
			if(sum != d.s){
				goto NEXT;
			}
		}
		sum = accumulate(lion.begin(), lion.end(), 0);
		if(sum > max){
			max = sum;
			answer = lion;
		}
		NEXT: if(!add(x, 0, lion)){
			break;
		}
	}
	if(max == -1){
		cout<<max<<endl;
	}else for(int j=0; j<n; j++){
		cout<<answer[j]<<(j+1==n?"\n":" ");
	}
}

Measured memory_bytes: 3168
import sys
input = sys.stdin.readline
sx,sy,tx,ty=map(int,input().split())
dx=tx-sx
dy=ty-sy
ans=dy*'U'+dx*'R'+dy*'D'+dx*'L'+'L'+(dy+1)*'U'+(dx+1)*'R'+'D'+'R'+(dy+1)*'D'+(dx+1)*'L'+'U'
print(ans)

Measured memory_bytes: 3060