akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long n;
	cin>>n;
	long long a[n];
	long long b[n+1]={0};
	for(int i=0;i<n;i++){
		cin>>a[i];
		b[a[i]]++;
	}	

	long long ans=0;
	for(int i=0;i<n+1;i++){
		if(b[i]>=2){
			ans=ans+(b[i]*(b[i]-1));
		}
	}
	ans/=2;
	long long t=ans;
	//cout<<ans<<endl;
	for(int i=0;i<n;i++){
		long long temp=a[i];
		ans=t;
		//cout<<temp<<"temp"<<endl;
		if(b[temp]>=3){
		ans=ans-((b[temp]*(b[temp]-1))/2)+(((b[temp]-1)*(b[temp]-2))/2);
		cout<<ans<<endl;
	}else {
		if(b[temp]==2)
		ans=ans-((b[temp]*(b[temp]-1))/2);
		cout<<ans<<endl;
	}
	}
	return 0;
}

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

int main(){
    int N;
    string S;
    cin >> N >> S;
    int l = N-1,r = 0;
    for(int i=0;i<N;i++){
        if(S[i]=='>') l = min(l,i);
        else r = max(r,i);
    }
    cout << r-l+1 + max(l,N-1-r) << endl;
}


Measured memory_bytes: 3312
//ヘッダー
#include<bits/stdc++.h>
using namespace std;

//型定義
typedef long long ll;

//定数
const int INF=1e+9;
const int MOD=1e+9+7;

//REPマクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REP2(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>(ll)(b);i--)

// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値

int main(){
    ll N,A,B,C,D;
    
    cin>>N>>A>>B>>C>>D;
    
    bool ok=false;
    
    ll val=B-A;
    REP(i,N){
        ll m=i;
        ll n=N-1-m;
        if(val<=m*D-n*C&&val>=m*C-n*D) ok=true;
    }
    if(ok) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}

Measured memory_bytes: 3636
#include <iostream>

using namespace std;
using ll = long long;

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

int main() {
  ll w, h;
  int x, y;
  cin >> w >> h >> x >> y;

  printf("%.10f ", w * h / 2.0);
  cout << ((ll)(2 * x) == w && (ll)(2 * y) == h ? 1 : 0) << endl;

  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>                                           
 
#define int long long
//#pragma GCC optimize("Ofast")
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
 
 
#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);
#define forev(i, b, a) for(int i = (b); i >= (a); --i)
#define forn(i, a, b) for(int i = (a); i <= (b); ++i)
#define all(x) x.begin(), x.end()
#define sz(s) (int)s.size()
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define s second
#define f first
 
 
using namespace std;
 
 
typedef pair < long long, long long > pll;    
typedef pair < int, int > pii;
typedef unsigned long long ull;         
typedef vector < pii > vpii;
typedef vector < int > vi;
typedef long double ldb;  
typedef long long ll;  
typedef double db;                             
 
 
const int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1}, block = 555;
const pii base = mp(1171, 3307), Mod = mp(1e9 + 7, 1e9 + 9);
const int inf = 1e9, maxn = 4e5 + 148, mod = 1e9 + 7, N = 2e5 + 21;
const db eps = 1e-12, pi = 3.14159265359;
const ll INF = 1e18;

int n, k, a[N], c, s;
bool was[N];

void dfs (int v) {
	if (was[v]) {
		c = v;
		return; 
	}

	k--;
	
	if (!k) {
		cout << a[v] << endl;
		exit(0);
	}

	was[v] = 1;
	dfs(a[v]);			
}

void dfs1 (int v) {
	if (!was[v])
		return;
	was[v] = 0;	
	++s;
	dfs1(a[v]);
}

main () {
	cin >> n >> k;
	for (int i = 1; i <= n; ++i)
		cin >> a[i];

	dfs(1);
	dfs1(c);
	k %= s;

	int v = c;
	while (k--) 
		v = a[v];
	
	cout << v << endl;
}


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

int main(){
    double l;
    cin>>l;
    cout<<fixed<<pow(l/3,3)<<endl;    
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main{
	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);
		String S = scan.next();
		Boolean flag = true;
		for(int i=0;i<S.length();i++){
			if(S.charAt(i)=='U'||S.charAt(i)=='D'){
				continue;
			}
			if(i%2==0){
				if(S.charAt(i)=='R'){
					continue;
				}else{
					flag = false;
					// System.out.println(S.charAt(i)+"\t"+i);
					break;
				}
			}else{
				if(S.charAt(i)=='L'){
					continue;
				}else{
					flag = false;
					// System.out.println(S.charAt(i)+"\t"+i);
					break;
				}
			}
		}
		if(flag){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 23508
#define int long long

struct meshi { int time, umami; } meshi[3010];
n, t, dp[3010][3011];

comparator (const void *a, const void *b) {
    return ((struct meshi*)a)->time - ((struct meshi*)b)->time;
}

main ()
{
    scanf("%lld %lld", &n, &t);

    for(int i = 0; i < n; i++) scanf("%lld %lld", &meshi[i].time, &meshi[i].umami);
    qsort(meshi, n, sizeof(struct meshi), comparator);

    for(int tt = 0; tt <= t; tt++)
    {
        for (int nn = 0; nn < n; nn++)
        {
            int taberu = 0, tabenai = 0;

            if (tt >= (tt == t ? 1 : meshi[nn].time))
            {
                taberu += meshi[nn].umami;
                if (nn > 0) taberu += dp[tt - (tt == t ? 1 : meshi[nn].time)][nn - 1];
            }

            if (nn > 0)
            {
                tabenai += dp[tt][nn - 1];
            }

            dp[tt][nn] = taberu > tabenai ? taberu : tabenai;
        }
    }

    printf("%lld\n", dp[t][n - 1]);
}


Measured memory_bytes: 35580
human_num, time = tuple(int(i) for i in input().split(" "))
time_list = tuple(int(i) for i in input().split(" "))
ans = 0
for i in range(human_num):
    if i == 0:
        ans += time
    else:
        time_differance = time_list[i] - time_list[i - 1]
        if time_differance <= time:
            ans += time_differance
        else:
            ans += time
print(ans)


Measured memory_bytes: 26964
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


class Eratosthenes:
    def __init__(self, n):
        self.n = n
        self.min_factor = [-1] * (n + 1)
        self.min_factor[0], self.min_factor[1] = 0, 1

    def get_primes(self):
        primes = []
        is_prime = [True] * (self.n + 1)
        is_prime[0] = is_prime[1] = False
        for i in range(2, self.n + 1):
            if not is_prime[i]:
                continue
            primes.append(i)
            self.min_factor[i] = i
            for j in range(i * 2, self.n + 1, i):
                is_prime[j] = False
                if self.min_factor[j] == -1:
                    self.min_factor[j] = i
        return primes

    def prime_factorization(self, n):
        res = []
        while n != 1:
            prime = self.min_factor[n]
            exp = 0
            while self.min_factor[n] == prime:
                exp += 1
                n //= prime
            res.append([prime, exp])
        return res



def resolve():
    n = int(input())

    er = Eratosthenes(n + 1)
    er.get_primes()
    res = 0
    for c in range(1, n + 1):
        ab = n - c
        if n - c <= 0:
            continue
        prime = er.prime_factorization(ab)
        cnt = 1
        for _, ex in prime:
            cnt *= ex + 1
        res += cnt
    print(res)



if __name__ == '__main__':
    resolve()


Measured memory_bytes: 89024
N, K = gets.split(' ').map(&:to_i)
A = gets.split(' ').map(&:to_i)
r = 1000 * 1000 * 1000 + 7
A_MAX = 2000

tento = 0
cnts = (0..A.size).to_a.map { |i| Array(A[i+1..-1]).select { |n| n < A[i] }.size }
cnts.each do |c|
  tento += c 
  tento %= r
end

cnt = [0] * (A_MAX + 1)
A.each do |n|
  cnt[n] += 1
end

belows = 0
aboves = 0
(1..A_MAX).each do |n|
  belows += cnt[n - 1]
  aboves += (belows * cnt[n]) % r
  # pp [n, belows, aboves]
end

betweens = (K - 1) * K / 2

hoge = aboves * betweens % r

puts ((tento * K % r) +  hoge ) % r


Measured memory_bytes: 11644
#include<iostream>
#include<stack>
#include<queue>
using namespace std;

int main()
{
  int n,x,t;
 cin>>n>>x>>t;
  int make=0;
  int time=0;
  while(1)
    {
       if(make>=n)break;
       make=make+x;
       time=time+t;
      
      
    
    
    }
    cout<<time<<endl;
}

Measured memory_bytes: 3628
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;




int main(){
    ll n;
    cin>>n;
    vector<ll> a(n);
    vector<ll> b(n);
    vector<ll> c(n);
    for(auto &i:a){cin>>i;}
    for(auto &i:b){cin>>i;}
    ll sum=0;
    ll cnt=0;
    for(int i=0;i<n;i++){
        if(a[i]<b[i]){
            sum+=b[i]-a[i];
            cnt++;
        }
        c[i]=a[i]-b[i];
    }
    sort(c.begin(),c.end(),greater<ll>());
    for(int i=0;i<n && sum>0;i++){
        sum-=c[i];
        cnt++;
    }
    if(sum>0){cout<<-1<<endl;}
    else{cout<<cnt<<endl;}
    
    
    
    
    return 0;
}


Measured memory_bytes: 2560
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        int Y = scan.nextInt();

        for(int i = 0; i<= N; i++){
            for(int j = 0; j<= N-i; j++){
                if(10000*i + 5000*j + 1000*(N-i-j) == Y){

                    System.out.println(i);
                    System.out.println(j);
                    System.out.println(N-i-j);
                    return;
                }
            }
        }

        System.out.println(-1);
        System.out.println(-1);
        System.out.println(-1);

    }
}

Measured memory_bytes: 23636
#include <stdio.h>

int main(void){
    char input[8];
    scanf("%s",input);
    //printf("%s",input);
    if(input[0]!=input[1]&&input[1]!=input[2]&&input[2]!=input[0]){
        printf("Yes");
    }
    else{
        printf("No");
    }
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define reps(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; --i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define repc2(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define inf 2e9
#define linf 9000000000000000000ll
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int n, m;
ll k;
vector<ll> a, b;

int main() {
    cin >> n >> m >> k;
    a.push_back(0);
    reps(i, n) {
        ll num;
        cin >> num;
        a.push_back(num);
        if (i != 1) a[i] += a[i - 1];
    }
    rep(i, m) {
        ll num;
        cin >> num;
        b.push_back(num);
        if (i) b[i] += b[i - 1];
    }
    int ans = 0;
    rep(i, n + 1) {
        if (a[i] > k) break;
        auto itr = upper_bound(all(b), k - a[i]);
        ans = max(ans, i + (int)(itr - b.begin()));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 7964
#pragma GCC optimize "Ofast"
#pragma GCC optimize "unroll-loops"
#pragma GCC target "sse,sse2,sse3,sse4,abm,avx,mmx,popcnt,tune=native"
#include <bits/stdc++.h>
#define scan(x) do{while((x=getchar_unlocked())<'0'); for(x-='0'; '0'<=(_=getchar_unlocked()); x=(x<<3)+(x<<1)+_-'0');}while(0)
char _;
#define ll long long
#define ull unsigned long long
#define MAXN 100010
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define min(a, b) (a) < (b) ? (a) : (b)
#define max(a, b) (a) < (b) ? (b) : (a)
#define vi vector<int>
#define vll vector<ll>
#define pb push_back
#define pii pair<int, int>
#define mp make_pair
#define f first
#define s second
#define mii map<int, int>
#define umii unordered_map<int, int>
#define allof(x) x.begin(), x.end()
// #define DEBUG 1
// #define NOT_DMOJ 0
#ifdef DEBUG
	#define D(x...) printf(x)
#else
	#define D(x...)
#endif
using namespace std;

inline int GCD (int a, int b) { return b == 0 ? a : GCD(b, a % b); }
inline int LCM (int a, int b) { return a * b / GCD(a, b); }
inline ll PowMod (ll a, ll b, ll mod) { ll val = 1; while (b) { if (b & 1) val = (val * a) % mod; a = (a * a) % mod; b >>= 1; } return val; }

// https://atcoder.jp/contests/kupc2016/tasks/kupc2016_h

int N;
ll A[MAXN], B[MAXN];
ll res, ans;
priority_queue<ll, vector<ll>, greater<ll> > pq;

int main (int argc, char const *argv[]) {
	#ifdef NOT_DMOJ
	freopen("DATA.in", "r", stdin);
	freopen("DATA.out", "w", stdout);
	#endif // NOT_DMOJ
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> N;
	for (int i=0; i<N; i++) cin >> A[i];
	for (int i=0; i<N; i++) cin >> B[i];
	for (int i=0; i<N; i++) {
		res += B[i] - A[i];
		if (res <= 0) {
			pq.push(res);
			pq.push(res);
		}
		else {
			pq.push(0);
			pq.push(0);
		}
		ll curr = pq.top(); pq.pop();
		D("%d %d\n", res, curr);
		ans += res - curr;
	}
	while (!pq.empty() && pq.top() <= res) {
		D("%d %d\n", res, pq.top());
		ans += res - pq.top();
		pq.pop();
	}
	cout << ans << "\n";
	return 0;
}

/* 
 Look for:
 * the exact constraints (multiple sets are too slow for n=10^6 :( ) 
 * special cases (n=1?)
 * overflow (ll vs int?)
 * array bounds
 * number of test cases (T = 10)
 * resetting containers, variables, etc
 */

Measured memory_bytes: 2936
type ABC(stream:System.IO.TextReader) =
  member this.Scan1 f = stream.ReadLine() |> f
  member this.Scan2 f = stream.ReadLine().Split() |> Array.map f |> (fun a -> (a.[0], a.[1]))
  member this.Scan3 f = stream.ReadLine().Split() |> Array.map f |> (fun a -> (a.[0], a.[1], a.[2]))
  member this.Scan4 f = stream.ReadLine().Split() |> Array.map f |> (fun a -> (a.[0], a.[1], a.[2], a.[3]))
  member this.ScanVecH f = stream.ReadLine().Split() |> Array.map f
  member this.ScanVecV n f = seq { for i in 1..n -> stream.ReadLine() |> f }
  member this.ScanMatrix n f  = seq { for i in 1..n do yield stream.ReadLine().Split() |> Array.map f }
  member this.ScanCharMatrix n = [| for i in 1..n -> stream.ReadLine().ToCharArray() |]
  member this.Close () = stream.Close()

let util = ABC(stdin)

let isOK (cx,cy,ch) (x,y,h) =
  h = List.max [0; ch - (abs (cx - x)) - (abs (cy - y))]

let N = util.Scan1 int
let xs = util.ScanMatrix N int |> Seq.toList |> List.map (fun x -> x.[0],x.[1],x.[2] )
let x0, y0, h0 = List.find (fun (x,y,h) -> h > 0) xs

[ for cx in 0..100 do
  for cy in 0..100 do
    let ch = h0 + (abs (x0-cx)) + (abs (y0-cy))
    yield (cx,cy,ch)
]
|> List.filter (fun answer -> xs |> List.forall (isOK answer))
|> List.head
|> fun (x,y,h) -> printfn "%d %d %d" x y h

util.Close()


Measured memory_bytes: 16348
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;




int main()
{
    int a,b,c;
    cin >> a >> b >> c;
    if((a < c && c < b)||(b < c && c < a)) cyes;
    else cno;

    
    
    
    

    return 0;
}


Measured memory_bytes: 256
export class Main {
  static main(input: string): string {
    const tmp: string[] = input.split("\n");
    const a: number = parseInt(tmp.shift().split(" ")[0]);
    const b: number = parseInt(tmp.shift().split(" ")[0]);
    return `${[1, 2, 3].filter(i => i != a && i != b)[0]}`;
  }
}
console.log(Main.main(require("fs").readFileSync("/dev/stdin", "utf8")));


Measured memory_bytes: 7372
def search(num, key)
  l = 0
  m = num/2
  r = num

  while num > 0 do
    if @array[m] > key
      r = m
      m = l + (r-l)/2
    elsif @array[m] < key
      l = m + 1
      m = l + (r-l)/2
    elsif @array[m] == key
      return 1
    end
    break if l > m
    num /= 2
  end
  return 0
end

count = 0
n = gets.to_i
@array = gets.split(" ").map{|x| x.to_i}
@array.unshift(nil)
gets
search = gets.split(" ").map{|x| x.to_i}
search.each do |x|
  count += search(n, x)
end
puts count



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

using namespace std;

#define pb push_back
#define endl '\n'
#define all(x) (x).begin(),(x).end()
#define ff first
#define ss second
#define sz(x) (int)(x).size()
#define f(n) for(int i=0;i<n;++i)
#define f2(n) for(int j=0;j<n;++j)
#define f3(n) for(int k=0;k<n;++k)
#define F(i,x,n,y) for(i=x;i<n;i+=y)
#define fi(i) for(i=0;i<n;++i)
#define fa(x,y) for(auto x:y)

//Warsaw debug template
//#define LOCAL
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
    enable_if<sizeof dud<c>(0) x 1,debug&>::type operator<<(c i){
sim > struct rge {c b,e;};
sim > rge<c> range(c i, c j) {return rge<c>{i,j};}
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug{
#ifdef LOCAL
~debug() {cerr<<endl; }
eni(!=) cerr<< boolalpha << i; ris;}
eni(==) ris <<range(begin(i),end(i)); }
sim, class b dor(pair<b,c> d){
ris<<"("<<d.first<<","<<d.second<<")";
}
sim dor(rge<c> d){
    *this << "[";
    for(auto it=d.b;it!=d.e;++it)
        *this <<"," +(it==d.b)<< *it;
    ris<<"]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) "["<<#__VA_ARGS__":"<<(__VA_ARGS__)<<"]"
//End of debug template        
    

typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long long ll;


int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n,m;
    cin>>n>>m;
    ll a[1010];
    ll b[1010];
    ll c[1010];
    f(n){
        cin>>a[i]>>b[i]>>c[i];
    }
    int i,j,k,l;
    ll ans=0;
    F(i,-1,2,1){
        if(i==0) continue;
        F(j,-1,2,1){
            if(j==0) continue;
            F(k,-1,2,1){
                if(k==0) continue;
                //debug()<<imie(i) imie(j) imie(k);
                vector<ll> val;
                F(l,0,n,1){
                    ll res=i*a[l]+j*b[l]+k*c[l];
                    val.pb(res);
                }
                //debug()<<imie(val);
                sort(all(val));
                reverse(all(val));
               // debug()<<imie(val);
                ll tot=0;
                f(m) tot+=val[i];
                ans=max(ans,tot);
            }
        }
    }    
    cout<<ans<<endl;
    return 0;
}


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

#undef int
int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
#define int long long int
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int t = 1;
	//cin >> t;
	while (t--) {
		int n;
		cin >> n;
		int arr[n + 1], brr[n + 1], crr[n + 1];
		for (int i = 1; i <= n; i++)
			cin >> arr[i];
		for (int i = 1; i <= n; i++) {
			brr[i] = arr[i] + i;
			crr[i] = arr[i] - i;
		}
		map<int, int> mp;
		for (int i = 1; i <= n; i++) {
			mp[crr[i]]++;
		}
		int ans = 0;
		for (int i = 1; i <= n; i++) {
			ans += mp[-brr[i]];
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 31004
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <stack>
#include <math.h>
#include <map>
#define Z class
#define ln cout<<'\n'
#define ll long long
#define rep(i, n) for(int i = 0; i < (n); ++i)
//ASCII a=97, A=65
// int H[N]; rep(i,N) scanf("%d", &H[i]);
// int max_x = *std::max_element(x.begin(), x.end());
// int min_y = *std::min_element(y.begin(), y.end());
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;}
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
const long long INF = 1LL << 60;

int main(){
    long A,B,C; cin>>A>>B>>C;
    string res;
    if((B*10+C)%4==0) res="YES";
    else res="NO";
    pr(res);
    
}



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

using namespace std;

#define all(x) x.begin(), x.end()
#define sz(x) (int) x.size()
#define pb push_back
#define endl '\n'
#define snd second
#define fst first
#define fastio cin.tie(NULL),cout.sync_with_stdio(true)

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector <int> vi;
typedef pair <ll, int> ii;
typedef pair <ii,int> iii;

const ll inf = 1e17;
const ll mod = 1e9 + 7;
const int N = 200005;

ll powll(ll x, ll y){
    x %= mod;
    ll res = 1LL;
    while(y){
        if (y & 1LL)
            res *= x;
        res %= mod;
        x = (x*x) % mod;
        y >>= 1LL;
    }
    return res;
}

ll divll(ll x, ll y){
	x %= mod;
    return (x * powll(y,mod-2)) % mod;
}

void solve(){
	int n, k, has = 0;
	cin >> n >> k;
	vector<ii> v;
	for(int i = 0; i < n; i++){
		int x; cin >> x;
		v.pb({abs(x), x});
		has |= (x>0);
	}
	sort(v.rbegin(), v.rend());
	ll ans = 1;
	if(!has and (k%2) == 1){ // pego os k menores
		for(int i = n-1; k > 0; i--, k--)
			ans = (ans * v[i].snd + mod)%mod;
		cout << ans << endl;
		return ;
	}
	ll cnt = 0, nu = mod, nn = mod, pu = mod, pn = mod;
	for(int i = 0; i < k; i++){ // pego os k maiores
		ans = (ans * v[i].fst)%mod;
		if(v[i].snd < 0)
			cnt++, nu = v[i].snd; // maior negativo usado
		else
			pu = v[i].snd; // menor positivo usado
	}
	for(int i = k; i < n; i++){
		if(v[i].snd < 0 and nn == mod)
			nn = v[i].snd;	// maior neg n usado
		if(v[i].snd > 0 and pn == mod)
			pn = v[i].snd; // maior pos n usado
	}
	if((cnt % 2) == 1){ // the ans is < 0
		nu = abs(nu), nn = abs(nn);
		ll ans1 = (divll(ans, nu) * pn) % mod;
	 	ll ans2 = (divll(ans, pu) * nn) % mod;
		bool a = ((nu != mod) and (pn != mod));
		bool b = ((pu != mod) and (nn != mod));
		if(a and b){ // tenho as 2 possib
			if(pn*pu > nn*nu)ans = ans1;
			else ans = ans2;
		}else if(a){
			ans = ans1;
		}else if(b){
			ans = ans2;
		}else{ // ans still < 0
			cout << (mod-ans)%mod << endl;
			return ;
		}
	}
	cout << ans << endl;
}

int main(){
	fastio;
	int t = 1;
	//cin >> t;
	while(t--)
		solve();
	return 0;
}


Measured memory_bytes: 7380
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); ++i)
#define rep2(i,n) for(int i=1; i<=(n); ++i)
#define all(x) (x).begin(),(x).end()
#define Sort(x) sort((x).begin(),(x).end())
#define Sort2(x) sort((x).begin(),(x).end(), greater<int>())
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>; // グラフ型

int main()
{
    int n,k; cin >> n >> k;
    vector<int> p(n); rep(i, n) cin >> p[i];
    Sort(p);
    int ans=0;
    rep(i,k) ans+=p[i];
    cout << ans << endl;
}

/*
g++ b.cpp
./a.out

oj d https://atcoder.jp/contests/abc170/tasks/abc170_d
oj t
*/


Measured memory_bytes: 3632
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int x, y ,z;
bool check(int a, int b, int c) {
    if (max(a,b)!=x)return false;
    if (max(a,c)!=y)return false;
    if (max(b,c)!=z)return false;
    return true;
}
int main() {
    int t,n,a,b,c;
    //scanf("%d",&t);
    while (scanf("%d %d %d",&a,&b,&c)!=EOF) {
        printf("%d\n", (a%b?a/b+1:a/b)*c);
    }
    return 0;
}


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

#define REP(i ,n) for(int i=0 ;i < n; i++)
#define REPB(i ,n) for(int i=n; i >= 0; i--)
#define FOR(i ,m ,n) for(int i=m; i < n; i++)
#define FORB(i, m, n) for(int i=m; i>= m; i--)
#define ll long long
#define pb push_back
#define popb pop_back
using namespace std;

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

    cin >> n;
    REP(i, n){
        cin >> t;
        a.pb(t);
    }

    REP(j, n) ans+= a[j];

    ans-= n;

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

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

using namespace std;

#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n)　for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
#define Eunique(v) v.erace(unique(all(v)),v.end())
#define pvec(v)　rep(i,v.size()){cout << v[i] << " ";}
#define INF 0x3f3f3f3f
#define mset(m,v) memset(m,v,sezeof(m))
#define mod 1e9 +7;

const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll,ll> P;
ll dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};

ll gcd(ll x,ll y)
{
    ll r;
    while((r = x % y) != 0)
    {
        x = y;
        y = r;
    }
    return y;
}

ll lcm(ll x,ll y)
{
    x /= gcd(x,y);
    y /= gcd(x,y);
    return (x*y);
}

int main()
{
    ll n,T,sum=0;
    cin >> n >> T;
    vll t(n);
    rep(i,n)cin >> t[i];
    for(int i=1;i<n;i++){
        //cout << "000" << endl;
        if(t[i]-t[i-1] >= T){
            sum += T;
            //cout << "0101" << endl;
        }
        else{
            sum += (t[i]-t[i-1]);
            //cout << "1010" << endl;
        }
    }
    sum += T;
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=n-1;i>=(0);i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define eall(v) unique(all(v), v.end())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;

int h[200010], a[200010];

template <class T> //T : dat[]の中身の型
class segtree{
public:
	int n;
	T neutral;
	vector<T> dat;
	T func(T l, T r){ //区間をマージする関数
		return max(l, r); /* ここを変える */
	}
	segtree(int n_, T val): n(n_), neutral(val){ //n_:要素数 val:単位元
		n = 1;
		while(n < n_) n *= 2;
		dat.resize(n * 2, neutral); //初期値
	}
	void update(int k, T val){ // k番目の値(0-indexed)を val に変更
		for (dat[k += n] = val; k > 0; k >>= 1){ // kを含む区間のインデックスを下から順に列挙
			dat[k>>1] = func(dat[k], dat[k ^ 1]);
		}
	}
	T query(int l, int r){ //[l, r)の区間
		/* 可換出ない時危険 */
		T ret = neutral;
		for (l += n, r += n; l < r; l >>= 1, r >>= 1){
			if(l & 1) ret = func(ret, dat[l++]);
			if(r & 1) ret = func(ret, dat[--r]);
		}
		return ret;
	}
};


int main(int argc, char const *argv[])
{
	int n; cin >> n;
	rep(i, n) cin >> h[i];
	rep(i, n) cin >> a[i];

	segtree<ll> dp(n + 1, 0);
	// rep(i, n) dp.update(h[i], a[i]);

	rep(i, n) {
		ll val = dp.query(0, h[i]);
		dp.update(h[i], val + a[i]);
	}

	ll ans = 0;
	printf("%lld\n", dp.query(0, n + 1));	
	return 0;
}

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

#define N 200010
int n, a[N], c[N], d[N];

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


Measured memory_bytes: 3968
#include <stdio.h>
#define N 300000

int main(void){
	int j,n,minv=0;
	int maxv=-2000000000;
	int R[N]={0};
	
	scanf("%d",&n);
	for(j=0;j<n;j++)scanf("%d",&R[j]);
	
	minv=R[0];
	for(j=1;j<=n-1;j++) {
		if(maxv<R[j]-minv)maxv=R[j]-minv;
		if(minv>R[j])minv=R[j];
	}
	
	printf("%d\n",maxv);
	
	return 0;
}



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


int main(){
  int a,b,c;
  cin>>a>>b>>c;
  
  int s=min(a,b),g=max(a,b);

  if(s<=c&&g>=c) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

  return 0;
}

Measured memory_bytes: 256
/*
ID:wmj20041
TASK:
LANG:C++
*/
#include<functional>
#include<algorithm>
#include<exception>
#include<stdexcept>
#include<streambuf>
#include<iterator>
#include<string.h>
#include<stdlib.h>
#include<typeinfo>
#include<valarray>
#include<iostream>
#include<sstream>
#include<istream>
#include<stdio.h>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<ctype.h>
#include<cassert>
#include<cstdlib>
#include<utility>
#include<cstring>
#include<numeric>
#include<ostream>
#include<cwctype>
#include<fstream>
#include<iomanip>
#include<math.h>
#include<bitset>
#include<cctype>
#include<string>
#include<vector>
#include<limits>
#include<locale>
#include<memory>
#include<cerrno>
#include<time.h>
#include<iosfwd>
#include<cfloat>
#include<cstdio>
#include<cwchar>
#include<cmath>
#include<ctime>
#include<deque>
#include<queue>
#include<stack>
#include<list>
#include<ios>
#include<map>
#include<set>
#include<new>
#define ll long long
#define pb push_back
#define pob pop_back
#define mp make_pair
#define FILL(a,v) memset((void*)a,v,sizeof(a))
#define FILL0(a) FILL(a,0)
#define FILL1(a) FILL(a,-1)
#define FILLBIG(a) FILL(a,0x7f)
#define ALL(a) (a).begin(),(a).end()
#define Inf ((int)0x7f7f7f7f)
#define Mod 1000000007
#define foreach(it,x) for(__typeof(x.begin()) it=x.begin();it!=x.end();it++)
#define FOR(i,x) for(int i=0;i<x;i++)
#define RFOR(i,x) for(int i=x-1;i>=0;i--)
#define FFOR(i,a,b) for(int i=a;i<b;i++)
#define FRFOR(i,a,b) for(int i=a-1;i>=b;i--)
#define SZ(a) ((int)(a).size())
#define fi first
#define se second
#define OVER(a) return puts(a),0
#define fastio ios::sync_with_stdio(0)
#define filei(f) freopen(f,"r",stdin)
#define fileo(f) freopen(f,"w",stdout)
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define MASK(a) (1<<(a))
#define MASKX(x,a) ((x)<<(a))
#define BIT(a,b) ((a>>b)&1)
#define cddx(a) priority_queue<a >
#define cxdd(a) priority_queue<a,vector<a >,greater<a > >
#define deval(a) {cerr<<#a<<" = "<<a<<endl;}
#define dearr(be,en) {cerr<<#be;cerr<<" = {";for(auto i=be;i!=en;i++)cerr<<' '<<*i;cerr<<" }\n";}
#define reg register
using namespace std;
typedef pair<int,int> pii;
typedef unsigned long long UINT;
typedef unsigned int uint;
typedef long long INT;
typedef long double ldouble;
typedef pair<INT,INT> PII;
typedef stringstream sst;
typedef istringstream iss;
typedef vector<int> vint;
typedef vector<INT> VINT;
typedef vector<pii> vpii;
typedef vector<PII> VPII;
typedef priority_queue<int> pqi;
typedef priority_queue<INT> PQI;
typedef priority_queue<pii> pqp;
typedef priority_queue<PII> PQP;
typedef priority_queue<int,vint,greater<int> > xqi;
typedef priority_queue<INT,VINT,greater<INT> > XQI;
typedef priority_queue<pii,vpii,greater<pii> > xqp;
typedef priority_queue<PII,VPII,greater<PII> > XQP;
const int INF=1e9+7;
using namespace std;
string s;
int prime(int x)
{
	if (x==1) return 0;
	for (int i=2;i*i<=x;i++)
	if (x%i==0) return 0;
	return 1;
}
int main()
{
	//freopen("input.in","r",stdin);
	//freopen("output.out","w",stdout);
	cin>>s;
	s[3]++;
	cout<<s;
	return 0;
}

Measured memory_bytes: 764
//#include<bits/stdc++.h>
    #include<iostream>
    using namespace std;
    const int N = 1000005;
    int main(){
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
        int a,b,k;  cin >> k >> a >> b;
        for(int i = a;i <= b;i++){
            if(i % k == 0){
                cout << "OK";
                return 0 ;
            }
        }
        cout << "NG";
        return 0;
    }

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

const int MAX = 36;

struct poker {
	char suit;
	char value;
};

poker C[MAX];
poker D[MAX];
int N;

void BubbleSort(poker C[], int n)
{
	int isSorted = 0;
	bool flag = true;
	while (flag)
	{
		flag = false;
		for (int j = n - 1; j > isSorted; --j)
		{
			if (C[j].value < C[j - 1].value)
			{
				swap(C[j], C[j - 1]);
				flag = true;
			}
		}
		isSorted++;
	}
}

void SelectionSort(poker C[], int n)
{
	int minj;
	for (int i = 0; i < n - 1; ++i)
	{
		minj = i;
		for (int j = i + 1; j < n; ++j)
		{
			if (C[j].value < C[minj].value) minj = j;
		}
		if (minj != i) swap(C[minj], C[i]);
	}
}

void Print(poker C[], int n)
{
	for (int i = 0; i < n; ++i)
	{
		if (i) cout << ' ';
		cout << C[i].suit << C[i].value;
	}
	cout << endl;
}

int main()
{
	cin >> N;
	bool isStable = true;
	for (int i = 0; i < N; ++i)
	{
		cin >> C[i].suit >> C[i].value;
		D[i].suit = C[i].suit;
		D[i].value = C[i].value;
	}
	BubbleSort(C, N);
	Print(C, N);
	cout << "Stable" << endl;
	SelectionSort(D, N);
	Print(D, N);
	for (int i = 0; i < N; ++i)
	{
		if (D[i].suit != C[i].suit) isStable = false;
	}
	if (isStable) cout << "Stable" << endl;
	else cout << "Not stable" << endl;

	return 0;
}


Measured memory_bytes: 3096
#include <cstdio>
#include <cstring>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
using namespace std;

#define int long long

int s(int n){
  int res=0;
  while(n>0){
    res+=n%10;
    n/=10;
  }
  return res;
}

double f(int n){
  return (double)n/s(n);
}

signed main(){
  vector<int> v;
  int b=1;
  for(int i=0;i<15;i++){
    for(int j=1;j<150;j++){
      v.push_back(b*(j+1)-1);
    }
    b*=10;
  }
  sort(v.begin(),v.end());
  v.erase(unique(v.begin(),v.end()),v.end());
  for(int i=0;i<v.size();i++){
    for(int j=i+1;j<v.size();j++){
      if(f(v[i])>f(v[j])){
	v.erase(v.begin()+i--);
	break;
      }
    }
  }
  int k;
  cin>>k;
  for(int i=0;i<k;i++)cout<<v[i]<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
// #include <functional>

using namespace std;

void solve()
{
    // 入力の処理
    int A, B;
    cin >> A;
    cin >> B;
    if (A != 1 && B != 1)
    {
        cout << "1" << endl;
        return;
    }
    if (A != 2 && B != 2)
    {
        cout << "2" << endl;
        return;
    }
    if (A != 3 && B != 3)
    {
        cout << "3" << endl;
        return;
    }

    return;
}

int main()
{
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using i64 = int64_t;
using ll = long long;
int main() {
  vector<vector<int>> card(3,vector<int>(3));
  int n;
  int b;
  rep(i,3)rep(j,3) cin >> card.at(i).at(j);
  cin >> n;
  rep(k,n){
    cin >> b;
    rep(i,3)rep(j,3){
      if(card.at(i).at(j) == b){
        card.at(i).at(j) = 0;
        continue;
      }
    }
  }
  rep(i,3){
    if(card.at(i).at(0) + card.at(i).at(1) + card.at(i).at(2) == 0){
      cout << "Yes" <<endl;
      return 0;
    }
  }
  rep(j,3){
    if(card.at(0).at(j) + card.at(1).at(j) + card.at(2).at(j) == 0){
      cout << "Yes" <<endl;
      return 0;
    }
  }
  if(card.at(0).at(0) + card.at(1).at(1) + card.at(2).at(2) == 0){
    cout << "Yes" <<endl;
    return 0;
  }
  if(card.at(2).at(0) + card.at(1).at(1) + card.at(0).at(2) == 0){
    cout << "Yes" <<endl;
    return 0;
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
a = [[0 for i in range(100)] for j in range(100)]
b = [[0 for i in range(100)] for j in range(100)]
n, m, l = map(int, input().split())
for i in range(n):
    a[i][:m] = map(int, input().split())
for i in range(m):
    b[i][:l] = map(int, input().split())
for i in range(n):
    for j in range(l):
        c = 0
        for k in range(m):
            c += a[i][k] * b[k][j]
        if j == l-1:
            break
        print(c, end=' ')
    print(c)

Measured memory_bytes: 8552
#include <cstdio>

const int N = 1 << 18 | 1;

int n, U;
int f[N], g[N], a[N];

inline int Ma(int &a, int b) {
  return (a < b)? a = b : a;
}

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


Measured memory_bytes: 6016
import java.util.Scanner;

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

		int x = Integer.parseInt(sc.next());
		int y = Integer.parseInt(sc.next());
		int z = Integer.parseInt(sc.next());

		System.out.println(z + " " + x + " " + y);
	}

}


Measured memory_bytes: 22868
#include <iostream>
#include <cstring>

using namespace std;

const int MAX_N = 1e6 + 10;

bool is_prime[MAX_N + 1];

void SieveOfEratosthenes(int n)
{
    for (int i = 0; i <= n; ++i)
        is_prime[i] = true;
    is_prime[0] = is_prime[1] = false;

    for (int i = 2; i <= n; ++i)
        if (is_prime[i])
            for (int j = 2 * i; j <= n; j += i)
                is_prime[j] = false;
}


int main()
{
    int n, x;

    SieveOfEratosthenes(1000000);

    while (cin >> n >> x, n || x) {
        int item[n];
        bool flag[x + 1];

        memset(flag, 0, sizeof(flag));
        for (int i = 0; i < n; ++i)
            cin >> item[i];

        flag[0] = true;
        for (int i = 0; i < n; ++i) {
            for (int j = 0; j + item[i] <= x; ++j)
                if (flag[j])
                    flag[j + item[i]] = true;
        }

        int money = x;
        for ( ; money >= 0; --money)
            if (is_prime[money] && flag[money])
                break;

        if (money > 0)
            cout << money << endl;
        else
            cout << "NA\n";
    }

    return 0;
}

Measured memory_bytes: 3116
n = int(input())

plus = []
minus = []

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

print(max(plus[-1] - plus[0], minus[-1] - minus[0]))

Measured memory_bytes: 104628
#include <map>
#include <set>
#include <ctime>
#include <queue>
#include <stack>
#include <cmath>
#include <vector>
#include <bitset>
#include <cstdio>
#include <cctype>
#include <string>
#include <cstring>
#include <cassert>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std ;
#define rep(i, a, b) for (int (i) = (a); (i) <= (b); (i)++)
#define per(i, a, b) for (int (i) = (a); (i) >= (b); (i)--)
#define clr(a) memset(a, 0, sizeof(a))
#define ass(a, sum) memset(a, sum, sizeof(a))
#define lowbit(x) (x & -x)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define enter cout << endl
#define siz(x) ((int)x.size())
typedef long long ll ;
typedef unsigned long long ull ;
typedef vector <int> vi ;
typedef pair <int, int> pii ;
typedef map <int, int> mii ;
typedef map <string, int> msi ;
const int N = 100010 ;
const int INF = 0x3f3f3f3f ;
const int iinf = 1 << 30 ;
const ll linf = 2e18 ;
const int MOD = 1000000007 ;
void print(int x) { cout << x << endl ; exit(0) ; }
void PRINT(string x) { cout << x << endl ; exit(0) ; }
void douout(double x){ printf("%lf\n", x + 0.0000000001) ; }

int n, k ;
int dp[N][2] ;
int a[N] ;

bool dfs(int k, int t) {
	if (dp[k][t] >= 0) return dp[k][t] ;
	int ans = 0 ;
	for (int i = 1; i <= n; i++) if (k >= a[i]) ans |= !dfs(k - a[i], !t) ;
	return dp[k][t] = ans ;
}

signed main() {
	memset(dp, -1, sizeof(dp)) ;
	scanf("%d%d", &n, &k) ;
	for (int i = 1; i <= n; i++) scanf("%d", &a[i]) ;
	if (dfs(k, 0) == true) puts("First") ;
	else puts("Second") ;
//	for (int j = 2; j <= n; j++) {
//		for (int i = 1; i <= k; i++) cout << dp[i][j] << " " ;
//		enter ;
//	}
}

/*
写代码时请注意：
	1.ll？数组大小，边界？数据范围？
	2.精度？
	3.特判？
	4.至少做一些
思考提醒：
	1.最大值最小->二分？
	2.可以贪心么？不行dp可以么
	3.可以优化么
	4.维护区间用什么数据结构？
	5.统计方案是用dp？模了么？
*/

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

main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	for (int i = 1, x; i <= n; i++) {
		cin >> x;
		if (x % 2 == 0) {
			if (x % 3 != 0 && x % 5 != 0) {
				cout << "DENIED\n";
				return 0;
			}
		}
	}
	cout << "APPROVED\n";
}


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

int main() {
long long n,a,b;
cin >> n >> a >> b;
if((b-a)%2==0){
    cout << (b-a)/2;
    return 0;
}
else if(n-b>a-1)cout << a-1+(b-a-1)/2+1;
else cout << n-b+(b-a-1)/2+1;
}


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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

const int N = 1e5+23;

int a[N];

void solve() {
  int n, k; scanf("%d%d", &n, &k);
  int zero = -1;
  for (int i = 0; i < n; ++i) {
    scanf("%d", a+i);
    if (a[i] == 0) { // real stupid
      --k; --n; --i;
      continue;
    }
    if (zero == -1 && a[i] > 0) zero = i;
  }
  if (zero == -1) zero = n;
  if (k == 0) {
    printf("0");
    return;
  }
  long long ans = 1e15;
  for (long long cur, cnt, i = 0; i < n; ++i) {
    if (a[i] < 0) {
      cnt = zero-i;
      cur = -a[i];
      if (cnt < k) {
	if (k+i-1 >= n) continue;
	cur += -a[i] + a[k+i-1];
      }
    } else {
      cnt = i-zero+1;
      cur = a[i];
      if (cnt < k) {
	if (i-k+1 < 0) continue;
	cur += a[i] + -a[i-k+1];
      }      
    }
    ans = min(ans, cur);
  }
  printf("%lld", ans);
}

int main() {
  init();
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


Measured memory_bytes: 640
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdbool.h>
#include<math.h>
#include<limits.h>
#define MAX 100002
int main(){
   int N;
   char result[MAX][3];
   int ac=0,wa=0,tle=0,re=0;
   scanf("%d",&N);
   for(int i=0;i<N;i++){
       scanf("%s",result[i]);
       if(strcmp(result[i],"AC")==0)  ac++;
       else if(strcmp(result[i],"WA")==0)  wa++;
       else if(strcmp(result[i],"TLE")==0) tle++;
       else if(strcmp(result[i],"RE")==0) re++;
   }
   printf("AC x %d\n",ac);
   printf("WA x %d\n",wa);
   printf("TLE x %d\n",tle);
   printf("RE x %d",re);
}


Measured memory_bytes: 2028
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;

ll n, a;
V vi;

int main(){
	while (cin >> n&&n){
		REP(i, n){
			cin >> a;
			vi.push_back(a);
		}
		sort(ALL(vi));
		ll sum = 0;
		REP(i, n){
			REP(j, i){
				sum += vi[j];
			}
		}
		cout << sum << endl;
		vi.clear();
	}
}

Measured memory_bytes: 1340
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> a1(n);
    vector<int> a2(n);
    for (int i=0; i<n; i++) cin >> a1[i];
    for (int i=0; i<n; i++) cin >> a2[i];

    int ans = 0;
    for (int i=0; i<n; i++) {
        int cnt = 0;
        cnt += accumulate(a1.begin(), a1.begin()+i+1, 0);
        cnt += accumulate(a2.begin()+i,a2.end(), 0);
        ans = max(ans, cnt);
    }

    cout << ans << endl;
}

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

int main(){
    
    int N,x;cin>>N>>x;
    vector<int> S(N);
    for(int i=0;i<N;i++){
        cin>>S[i];
    }
    sort(S.begin(),S.end());
    int ans=N-1;
    for(int i=0;i<N;i++){
        x-=S[i];
        if(x<0){
            ans=i;
            break;
        }
    }
    if(x==0) ans++;
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  ll w, h, x, y;
  cin >> w >> h >> x >> y;
  double g = w * h / 2.0;
  int m = w/2.0 == x && h/2.0 == y ? 1 : 0;
  cout << g << " " << m << endl;
  return 0;
}

Measured memory_bytes: 3740
import java.util.*;

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

        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int x = Integer.parseInt(sc.next());
        int[] ary = new int[n];
        int ans = 0;
        for (int i = 0; i < n; i++) {
            ary[i] = Integer.parseInt(sc.next());
        }
        Arrays.sort(ary);
        for (int i = 0; i < n; i++) {
            if (x < ary[i]) {
                break;
            } else if (i == n -1 && x - ary[i] > 0) {
                x -= ary[i];
                ans = i;
            }
            else {
                x -= ary[i];
                ans = i +1;
            }

        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 21844
using System;
using System.Linq;
class program{
  static void Main(){
    int n = int.Parse(Console.ReadLine());
    int[] a = Array.ConvertAll(Console.ReadLine().Split(' '),int.Parse);
    int xa = 0;
    for(int i=0;i < n;i++){
      xa ^= a[i];
    }
   	int[] ans = new int[n];
    for(int i=0;i < n;i++){
      ans[i] = xa^a[i];
    }
    Console.WriteLine(string.Join(" ", ans));
  }
}

Measured memory_bytes: 65876
import java.io.InputStreamReader;
import java.util.Arrays;
import java.io.BufferedReader;
import java.io.IOException;

class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		boolean[] s = new boolean[13];
		boolean[] h = new boolean[13];
		boolean[] c = new boolean[13];
		boolean[] d = new boolean[13];
		Arrays.fill(s, false);
		Arrays.fill(h, false);
		Arrays.fill(c, false);
		Arrays.fill(d, false);
		int n = Integer.parseInt(br.readLine());
		for (int i = 0; i < n; i++) {
			String[] strAry = br.readLine().split(" ");
			switch (strAry[0]) {
			case "S":
				s[Integer.parseInt(strAry[1]) - 1] = true;
				break;
			case "H":
				h[Integer.parseInt(strAry[1]) - 1] = true;
				break;
			case "C":
				c[Integer.parseInt(strAry[1]) - 1] = true;
				break;
			case "D":
				d[Integer.parseInt(strAry[1]) - 1] = true;
				break;
			}
		}
		for (int i = 0; i < s.length; i++) if (!s[i]) System.out.println("S " + (i + 1));
		for (int i = 0; i < h.length; i++) if (!h[i]) System.out.println("H " + (i + 1));
		for (int i = 0; i < c.length; i++) if (!c[i]) System.out.println("C " + (i + 1));
		for (int i = 0; i < d.length; i++) if (!d[i]) System.out.println("D " + (i + 1));
	}
}

Measured memory_bytes: 24488