akhauriyash/Code-Regression huggingface dataset:
import sys,collections;sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

n = I()
a = [0] + Is() + [0]
d = []
for i in range(n+1):
    d.append(abs(a[i+1]-a[i]))
total = sum(d)
for i in range(n):
    print(total - d[i+1] -d[i] + abs(a[i+2]-a[i]))

Measured memory_bytes: 13772
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
 
public class Main {
 
    void solve() throws IOException {
        int X = ni();
        int Y = ni();
        int A = ni();
        int B = ni();
        int C = ni();
        
        PriorityQueue<Integer> red = new PriorityQueue<>(Comparator.reverseOrder());
        PriorityQueue<Integer> green = new PriorityQueue<>(Comparator.reverseOrder());
        PriorityQueue<Integer> white = new PriorityQueue<>(Comparator.reverseOrder());
        for (int i = 0; i < A; i++) {
            red.add(ni());
        }
        for (int i = 0; i < B; i++) {
            green.add(ni());
        }
        for (int i = 0; i < C; i++) {
            white.add(ni());
        }
        for (int i = 0; i < X; i++) {
            white.add(red.poll());
        }
        for (int i = 0; i < Y; i++) {
            white.add(green.poll());
        }
        long ans = 0;
        for (int i = 0; i < X+Y; i++) {
            ans += white.poll();
        }

        out.println(ans);
    }

 
    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }
 
    int ni() throws IOException {
        return Integer.parseInt(ns());
    }
 
    long nl() throws IOException {
        return Long.parseLong(ns());
    }
 
    double nd() throws IOException {
        return Double.parseDouble(ns());
    }
 
    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }
 
    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }
 
    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }
 
    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;
 
    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}

Measured memory_bytes: 60484
n,l = map(int, input().split())
if l > 0:
    print(int(n*(n-1)/2+l*n)-l)
elif l <= -n:
    print(int(n*(n-1)/2+l*n)-(l+n-1))
else:
    print(int(n*(n-1)/2+l*n))

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

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

	long long int wt[n];
	long long int val[n];

	// Taking Input
	for(int i=0 ; i<n ; i++){
		cin >> wt[i] >> val[i];
	}

	long long int dp[n][w+1];

	for(int i=0 ; i<n ; i++){
		for(int j=0 ; j<=w ; j++){
			if(i==0 && j==0){
				dp[i][j] = 0;
			}
			else if(i==0 && j!=0){
				if(j>=wt[i]){
					dp[i][j] = val[i];
				}
				else{
					dp[i][j] = 0;
				}
			}
			else if(i!=0 && j==0){
				dp[i][j] = 0;
			}
			else{
				if(j>=wt[i]){
					dp[i][j] = (dp[i-1][j]>val[i] + dp[i-1][j-wt[i]])?dp[i-1][j]:val[i]+dp[i-1][j-wt[i]];
				}
				else{
					dp[i][j] = dp[i-1][j];
				}
			}	
		}
	}
	cout << dp[n-1][w] << "\n";
	return 0;	
}

Measured memory_bytes: 78336
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;

const int MAX_N = 200001;        // 131072

struct RMQ {
  ll n;
  ll dat[MAX_N * 2 - 1];
  RMQ(ll _n) {
    for (n=1; n<_n; n*=2);
    fill(dat, dat+2*n-1, 0);
  }
  RMQ(vector<ll> v) {
    for (n=1; n<v.size(); n*=2);
    fill(dat, dat+2*n-1, 0);
    copy(ALL(v),dat+n-1);
    for (ll i=n-2; i>=0; --i)
      dat[i] = max(dat[i*2+1], dat[i*2+2]);
  }
  void update(ll k, ll a) {
    k += n - 1;
    dat[k] = a;
    while(k>0) {
      k = (k-1) / 2;
      dat[k] = max(dat[k*2 + 1], dat[k*2 + 2]);
    }
  }
  ll query(ll a, ll b) { return q(a, b, 0, 0, n); }
  ll q(ll a, ll b, ll k, ll l, ll r) {
    if (r <= a || b <= l) return 0;
    if (a <= l && r <= b) return dat[k];
    return max(q(a, b, k*2+1, l, (l+r)/2),
               q(a, b, k*2+2, (l+r)/2, r));
  }
};

int main() {
  int n;
  cin >> n;
  RMQ rmq(n+1);
  ll hoge = 0;
  ll ans = 0;
  REP(i,n) {
    ll x;
    cin >> x;
    ll a = rmq.query(0,x);
    // cout << x << " " << a << endl;
    rmq.update(x,a+x);
    ans = max(ans, a+x);
    hoge += x;
  }
  cout << hoge-ans << endl;
}

Measured memory_bytes: 4160
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;

int main() {
    long x, y;
    cin>>x>>y;
    if(abs(x) > abs(y)){
        if(x < y){
            cout<<min(y-x, 1+(-y-x))<<endl;
        }
        else{
            cout<<min(1+(y+x), 1+(-y+x)+1)<<endl;
        }
    }
    else if(abs(x) < abs(y)){
        if(x < y){
            cout<<min(y-x,1+(y+x))<<endl;
        }
        else{
            cout<<min(1+(-y+x)+1, 1+(-y-x))<<endl;
        }
    }
    else {
        if(x==y)cout<<0<<endl;
        else cout<<1<<endl;
    }
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int W, H, x, y, r;
	cin >> W >> H >> x >> y >> r;
	if (W < x + r||x - r < 0||H<y+r||y-r<0) { cout << "No"<<endl; }
	else { cout << "Yes"<<endl; }
return 0;
}

Measured memory_bytes: 1156
#include<iostream>
using namespace std;
int main(){
  int N,ans,i,count;
  cin >> N;
  int A[N];
  for(i = 0;i<N;i++){
      cin>>A[i];
  }
  i = 0;
  ans = 0;
  count = 0;
  while(A[i+1] != NULL){
    if(A[i] == A[i+1]){
      count++;
      if(count%2 != 0)
        ans++;
    }
    else
      count = 0;
    i++;
  }
  
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int H,W;
  while(cin>>H>>W,H+W!=0){
    string tile[H];
    for(int i=0;i<H;i++)
      cin>>tile[i];
    if(tile[0][0]=='.'){
      cout<<"0 0"<<endl;
      continue;
    }
    int i=0;
    pair<int,int> now=make_pair(0,0);
    while(i!=20001){
      i++;
      if(i==20000)
	cout<<"LOOP"<<endl;
      if(tile[now.first][now.second]=='.'){
	cout<<now.second<<" "<<now.first<<endl;
	break;
      }else if(tile[now.first][now.second]=='>')
	now.second++;
      else if(tile[now.first][now.second]=='<')
	now.second--;
      else if(tile[now.first][now.second]=='v')
	now.first++;
      else if(tile[now.first][now.second]=='^')
	now.first--;
    }
  }
  return 0;
}

Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <string.h>
int main() 
{ 
    string s;cin>>s;
    long int length=s.length();
    long long int sum=0;
    while(length--){
        //cout<<s[length]-48<<" ";
        sum+=s[length]-48;
    }
    if (sum%9==0)cout<<"Yes";
    else cout<<"No";
        
}         

Measured memory_bytes: 3728
#include <stdio.h>
#include <algorithm>
#include <set>
#include <utility>
using namespace std;
typedef long long ll;

int main(void) {
  ll i, j, k, n, ans = 0, now;
  scanf("%lld", &n);
  pair<ll, ll> p[n];
  for(i = 0; i < n; ++i) scanf("%lld", &p[i].first), p[i].second = i;
  multiset<ll> s;
  multiset<ll>::iterator it, it2;
  s.insert(-1), s.insert(-1), s.insert(n), s.insert(n);
  sort(p, p + n);
  s.insert(p[n - 1].second);
  for(i = n - 2; i >= 0; --i) {
    it = s.lower_bound(p[i].second);
    it2 = it;
    now = -(*it);
    it++;
    now += *it;
    it2--;
    ans += now * (p[i].second - *it2) * p[i].first;
    it--;
    now = *it2;
    it2--;
    now -= *it2;
    ans += now * (*it - p[i].second) * p[i].first;
    s.insert(p[i].second);
  }
  printf("%lld", ans);
  return 0;
}

Measured memory_bytes: 6528
#include <iostream>
#include<vector>
#include<string>
#include<cmath>
#include<climits>
#include<algorithm>
#include <math.h>
using namespace std;

typedef long long ll;
int main(){
	int test,i,j;
	//cin>>test;
	long int n,x,ans=0,sum2;
	vector<int> a;
	/*for(i=0;i<test;i++){
	}*/
	cin>>n;
	x=n;
    if(x%2!=0){
        cout<<0;
        return 0;
    }
   else{
        n/=2;
        while(n!=0){
            n/=5;
            ans+=n;
        }
            
    }
   cout<<ans;
    return 0;
    


}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <numeric>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <memory>
#include <thread>
#include <tuple>
#include <limits>

using namespace std;

int main() {
  int w, h, x, y;
  scanf("%d%d%d%d", &w, &h, &x, &y);
  double ans = (double)w * (double)h / 2;
  printf("%.10f %d\n", ans, (x * 2 == w && y * 2 == h) ? 1 : 0);
  return 0;
}


Measured memory_bytes: 128
N = int(input())
A = list(map(int,input().split()))
from itertools import accumulate
P = list(accumulate(A))
l,right = 0,2
diff = float('inf')
for c in range(1,N-1):
    p = P[l]
    q = P[c]-P[l]
    while True:
        if abs(p+2*A[l+1]-q)>=abs(p-q):
            break
        p = P[l+1]
        q = P[c]-P[l+1]
        l += 1
    r = P[right]-P[c]
    s = P[-1]-P[right]
    while True:
        if abs(r+2*A[right+1]-s)>=abs(r-s):
            break
        r = P[right+1]-P[c]
        s = P[-1]-P[right+1]
        right += 1
    diff = min(diff,max(p,q,r,s)-min(p,q,r,s))
print(diff)

Measured memory_bytes: 25056
#include<cstdio>
#include<iostream>
#include<cstring>
#define RG register
using namespace std;
int n,cnt=1;
long long ans;
template<typename I> inline void read(I &ot){
	I ch=getchar(), x=0, f=1;
	while(ch<'0' || ch>'9'){if(ch=='-') f=-1; ch=getchar();	}
	while(ch>='0' && ch<='9'){x=x*10+ch-'0'; ch=getchar();	}
	ot=x*f;}
template<typename I, typename... U> inline void read(I &x,U&... y){read(x); read(y...);}
int main()
{
	//freopen("Greedy Customers.in","r",stdin);
	//freopen(".out","w",stdout);
	read(n);
	for(int i=1,a;i<=n;i++)
	{
		read(a);
		if(a<cnt) continue;
		if(a==cnt) cnt++;
		else
		{
			if(a%cnt==0) ans+=a/cnt-1;
			else ans+=a/cnt;
		}
		if(cnt==1) cnt++;
	}
	printf("%lld\n",ans);
	//fclose(stdin); fclose(stdout);
	return 0;
}

Measured memory_bytes: 256
//CLMN
//Every cloud has a silver lining
//Hakuna matata
 
#include <bits/stdc++.h>
 
using namespace std;
 
typedef pair<int, int> ii;
 
#define fi first
#define se second
#define pb push_back
#define sqr(x) ((x) * (x))
 
const char *fin = "arc077_b.inp";
const char *fon = "arc077_b.out";
 
#define oo (int) (1e9+7)
#define maxn (int) (1e5+5)
 
int n, A, B;
int a[maxn], pos[maxn];
long long fact[maxn], inverse[maxn];
 
int getbit(int x, int y) {
    return (x >> y) & 1;
}
 
long long power(long long a, int x) {
    long long res = a;
    int cnt = 0;
    long long p = 1;
    while ((p << 1) <= x) p <<= 1, ++cnt;
    for(int i = cnt; i > 0; --i) {
        res = (res * res) % oo;
        if (getbit(x, i - 1) == 1) res = (res * a) % oo;
    }
    return res;
}
 
long long C(int n, int k) {
    if (k > n) return 0;
    long long tmp = (inverse[k] * inverse[n - k]) % oo;
    return (fact[n] * tmp) % oo;
}
 
void sol() {
    fact[0] = 1;
    inverse[0] = 1;
    for(int i = 1; i <= n + 1; ++i) {
        fact[i] = (fact[i - 1] * i) % oo;
        inverse[i] = power(fact[i], oo - 2);
    }
 
    for(int l = 1; l <= n + 1; ++l) {
        long long res = C(n + 1, l);
        long long sub = C(A + B, l - 1);
        printf("%I64d\n", (res - sub + oo) % oo);
    }
}
 
void inp() {
    scanf("%d", &n);
    for(int i = 1; i <= n + 1; ++i) {
        scanf("%d", a + i);
        if (pos[a[i]] != 0) B = n - i + 1, A = pos[a[i]] - 1;
        else pos[a[i]] = i;
    }
    sol();
}
 
int main() {
    //ios_base::sync_with_stdio(false); cin.tie(NULL);
    //freopen(fin, "r", stdin); freopen(fon, "w", stdout);
    inp();
    return 0;
}

Measured memory_bytes: 8960
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
  ll h,n;
  cin>>h>>n;
  ll a[n],b[n];
  for(int i=0;i<n;i++)
    cin>>a[i]>>b[i];
  ll dp[9*h];
  dp[0]=0;
  for(int i=1;i<9*h;i++)
    dp[i]=INT_MAX;
  for(ll i=1;i<9*h;i++)
  {
    for(int j=0;j<n;j++)
      if(i>=a[j])
      dp[i]=min(dp[i],dp[i-a[j]]+b[j]);
  }
  ll ans=INT_MAX;
  for(int i=h;i<9*h;i++)
    ans=min(ans,dp[i]);
    cout<<ans<<"\n";
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
typedef unsigned long ulong;

int main()
{
    ulong n = 0;
    double t, a;
    std::cin >> n;
    std::cin >> t >> a;

    double tmp;
    std::vector<double> v;
    for (int i = 0; i < n; i++) {
        std::cin >> tmp;
        v.push_back(std::abs(a - (t - tmp * 0.006)));
    }
    double ans = v[0];
    int ansn = 1;
    for (int i = 0; i < v.size(); i++) {
        if (ans > v[i]) {
            ans = v[i];
            ansn = i + 1;
        }
    }
    std::cout << ansn << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define newl "\n"
using namespace std;
using lli = long long int;
using vvint = vector <vector <int>>;
const int mod = 1e9 + 7;

const int N = 2e5 + 1;
lli pow1(lli a,lli b){
	lli out = 1;
	for(int i = 0;i < b;++i) out = out * a;
	return out;
}

void solve(){
	lli n;
	cin >> n;
	n = n - 1;
	vector <lli> a;
	for(int i = 0;i <= 11;++i) a.push_back(26ll * (pow1(26ll,i) - 1) / 25);
	int len = upper_bound(a.begin(),a.end(),n) - a.begin();
	n = n - a[len - 1];
	string out = "";
	for(int i = 1;i <= len;++i){
		lli k = pow1(26ll,len - i);
		out += 'a' + n / k;
		n = n % k;
	}
	//reverse(out.begin(),out.end());
	cout << out << newl;
	return;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(10);
	#ifdef EXECUTE_LOCALLY
		   freopen("in.txt","r",stdin);
	#endif
	int t = 1;
	//cin >> t;
	while(t--) solve();
	#ifdef EXECUTE_LOCALLY
    	cout << setprecision(3) << "program time: " << (double)clock() / CLOCKS_PER_SEC << newl;
	#endif
	return 0;
}


Measured memory_bytes: 3608
#include <iostream>
#include <algorithm>

using namespace std;
int h[100005];
int dp[100005];

int main() {
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) cin >> h[i];
    dp[0] = 0;
    dp[1] = abs(h[1] - h[0]);
    for (int i = 2; i < n; ++i) dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]));
    cout << dp[n - 1] << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string.h>
#include <algorithm>
#include <stdio.h>
#include <vector>
#include <math.h>
#include <queue>
using namespace std;
typedef long long ll;
int main()
{
    double r;
    cin>>r;
    double pi=6.28318530717958623200;
    pi=pi*r;
    cout<<pi<<endl;
	return 0;
}


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

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

struct Vertex {
    vector<pll> node;
};

Vertex V[100005];
ll C[100005];

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

    REP(i, N - 1) {
        ll a, b;
        cin >> a >> b;
        a--;
        b--;
        V[a].node.push_back(pll(b, i));
        V[b].node.push_back(pll(a, i));
    }

    ll color = 0;
    queue<pll> q;
    q.push(pll(0, 0));
    memset(C, 0, sizeof(C));
    while (!q.empty()) {
        pll t = q.front();
        q.pop();

        color = std::max(color, static_cast<ll>(V[t.first].node.size()));
        ll index = 1;
        REP(i, V[t.first].node.size()) {
            pll n = V[t.first].node[i];
            if (C[n.second] > 0)
                continue;
            while (index == t.second)
                index++;
            C[n.second] = index;
            q.push(pll(n.first, index));
            index++;
        }
    }

    cout << color << endl;
    REP(i, N - 1) {
        cout << C[i] << endl;
    }
    return 0;
}

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

int main(){
    int N,H[21],max_h=-1,cnt=0;
    cin>>N;
    for(int i=0; i<N; i++){
        cin>>H[i];
        if(H[i]>=max_h){
            cnt++;
        }
        max_h=max(max_h,H[i]);
    }
    cout<<cnt<<endl;

    return 0;
}


Measured memory_bytes: 256
#![allow(unused_imports)]
use proconio::{input, fastout};
use proconio::marker::*;

#[fastout]
fn main() {
    input! {
    d: usize,
    t: usize,
    s: usize
    }
    let ans = if t * s >= d {"Yes"} else {"No"};
    println!("{}", ans);
}


Measured memory_bytes: 2200
A, B, C = list(map(int,input().split()))

K = int(input())

for i in range(K):
  if A < B < C:
    print("Yes")
    exit()
  elif C <= B or C <= A:
    C *= 2
    continue
  elif B <= A:
    B *= 2
    continue

if A < B < C:
	print("Yes")
	exit()
else:
  print("No")

Measured memory_bytes: 8880
#include <iostream>

using lint = long long;
using namespace std;

bool solve() {
    int N;
    cin >> N;
    if (N == 0) return false;

    for (lint D = 100000; D >= 0; --D) {
        lint sum = D * (D - 1) / 2;
        if (N > sum && (N - sum) % D == 0) {
            cout << (N - sum) / D << " " << D << endl;
            break;
        }
    }
    return true;
}

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



Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL (-1)
#define LL long long
using namespace std;
const int64_t MOD = 1e9 + 7;
const int INF = INT_MAX;

int main() {
	string S;
	cin >> S;

	bool b = true;
	for (int i = 0; i < S.size(); i++) {
		if (i & 1) {
			if (S[i] == 'R') b = 0;
		}
		else {
			if (S[i] == 'L') b = 0;
		}
	}

	cout << (b ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <stdio.h>
#include <math.h> 
#include <algorithm>
#include <numeric>
#include <functional>
#include <vector>
#include <string>
#include <numeric>
#include <bitset>

using namespace std;
vector<int> vec;
int time_cnt = 0;

int seach(int a, int b, int c, int max_num) {

	int tmp_cnt = 0;
	time_cnt++;

	if (a >= max_num + 3 || b >= max_num + 3 || c >= max_num + 3) return 0;
	if (time_cnt >= 1000000) return 0; //実行時間を短くするため

	if (a == b && b == c) {
		for (int i = 0; i < vec.size(); ++i) {
			if (a == vec.at(i)) {
				tmp_cnt++;
			}
		}
		if (tmp_cnt == 0) {
			vec.push_back(a);
			//cout << "comb:" << a << b << c << endl;
			return 0;
		}
		tmp_cnt = 0;
	}

	seach(a + 2, b, c, max_num);
	seach(a, b + 2, c, max_num);
	seach(a, b, c + 2, max_num);
	seach(a + 1, b + 1, c, max_num);
	seach(a + 1, b, c + 1, max_num);
	seach(a, b + 1, c + 1, max_num);

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

}

int main() {
	//input
	int a, b, c = 0;
	cin >> a >> b >> c;

	int max_num_tmp = max(a, b);
	int max_num = max(c, max_num_tmp);

	int d = 0;
	d = a + b + c;

	seach(a, b, c, max_num);

	int ans = 0;

	ans = (3 * vec.at(0) - d) / 2; //どの処理でも2増えるので最終的な揃った値の3倍から初期の値の和を引いて2で割ると回数になる

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define REP(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;
int x[110];
int y[110];
int h[110];

int main(){ _;
  int n;cin>>n;
  REP(i,n)cin>>x[i]>>y[i]>>h[i];
  REP(cy,101){
    REP(cx,101){
      int height=0;
      REP(i,n){
        if(h[i]!=0){
          height=abs(x[i]-cx)+abs(y[i]-cy)+h[i];
          break;
        }
      }
      bool found=true;
      REP(i,n){
        if(max(height-abs(x[i]-cx)-abs(y[i]-cy),0)!=h[i]){
          found=false;
          break;
        }
      }
      if(found){
        cout<<cx<<" "<<cy<<" "<<height<<endl;
        return 0;
      }
    }
  }
}


Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>

using namespace std;

int main()
{
	int A, B, C;
	cin >> A >> B >> C;

	int n = B / A;

	if (n <= C) {
		cout << n << endl;
	}
	else {
		cout << C << endl;
	}
	
}

Measured memory_bytes: 3584
s=input().strip()
t=input().strip()

s_list=[]
for i in range(len(s)):
    s_list.append(s[i])
# print(s_list)
t_list=[]
for i in range(len(t)):
    t_list.append(t[i])
s_list=sorted(s_list)
t_list=sorted(t_list,reverse=True)
# print(s_list,t_list)

ans=False
comp_max_index=min(len(s_list),len(t_list))
for i in range(min(len(s_list),len(t_list))):
    if s_list[i]<t_list[i]:
        ans=True
        break
if ans==True:
    print('Yes')
else:
    if s_list[comp_max_index-1]==t_list[comp_max_index-1] and len(s_list)<len(t_list) :
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 3064
#include<iostream>

using namespace std;

int main()
{
	long long a,b,c;
	long long a_b,b_c,c_a; 
	
	cin>>a>>b>>c;
	if(a%2==0 || b%2==0 || c%2==0) cout<<0;
	else {
	
	long long res[3];
	res[0] = a*b;
	res[1] = b*c;
	res[2] = c*a;
	
	long long min = 1e18 + 1;
	for(int i=0;i<3;i++)
	{
		if(min > res[i])  min = res[i];
	}
	
	cout<<min;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		long a = sc.nextLong();
		long b = sc.nextLong();
		long ans = n / (a + b) * a + Math.min(a, n % (a + b));
		System.out.println(ans);
	}
}

Measured memory_bytes: 25300
/*   -----------------------------
    | If you see my code,         |
    | You are BC (best coder -_- )|
    |                             |
     -----------------------------
*/
#include<bits/stdc++.h>
#include<iomanip>
typedef long long ll;
typedef unsigned long long ul;
#define to_lower(x)  transform(x.begin(), x.end(), x.begin(), ::tolower)
#define to_upper(x)  transform(x.begin(), x.end(), x.begin(), ::toupper)
#define pi acos(-1)
#define ll long long
#define ull unsigned long long
#define vec vector<ll>
#define f1(x,n) for(i=x;i<n;i++)
#define input  ll nn;cin>>nn;ll arr[nn];for(i=0;i<nn;i++)cin>>arr[i];
#define test   ll ttt;cin>>ttt;while(ttt--)
#define faster  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define faster2 ios_base::sync_with_stdio(0);
#define en '\n'
#define eps 10e9
#define pb push_back
#define loop(n) for(i=0;i<n;i++);
#define print(v) for(auto u:v)cout<<u<<" ";
ll i,j;
using namespace std;

int main()
{
    faster;
    int n;cin>>n;
    while(n--)cout<<"ACL";
    cout<<endl;


}



Measured memory_bytes: 3584
#include <iostream>
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include<math.h>
using namespace std;

//#define int long long
#define endl "\n"
#define fi first
#define se second
#define fr front
#define m_p make_pair
#define mod 1000000007
#define all(v)  v.begin(),v.end()
#define rep(i,n)  for(int i=0; i<(int) (n); i++)
#define all(v)  v.begin(),v.end()
#define vecin(v) for(int i=0; i<(int)v.size(); i++)cin>>v[i];
using namespace std;

int jousu(int, int);
int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}
int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}




int main() {
	int n;
	cin >> n;
	vector<int>vec(n);
	vecin(vec);
	sort(all(vec));
	cout << vec[(n + 1) / 2] - vec[(n + 1) / 2 - 1] << endl;
}



Measured memory_bytes: 892
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <iostream>
#include <algorithm>

typedef char                SINT8;
typedef unsigned char       UINT8;
typedef short               SINT16;
typedef unsigned short      UINT16;
typedef int                 SINT32;
typedef unsigned int        UINT32;
typedef long long           SINT64;
typedef unsigned long long  UINT64;
typedef double              DOUBLE;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))
#define rep(i,a,b) for(int (i)=int(a);(i)<int(b);(i)++)

#define INF 1e9;
#define MOD 1e9+7;
#define INF64 1e18;


using namespace std;

int main() {

	SINT32 N,X;
	SINT32 min = INF;

	cin >> N;
	cin >> X;

	vector<SINT32> DATA(N);
	
	rep(i,0,N) {
		cin >> DATA[i];
		X -= DATA[i];
		min = MIN(min,DATA[i]);
	}

	cout << N+(X/min) << endl;
	return 0;
}

//	sort(DATA.begin(),DATA.end());
//	sort(DATA.begin(),DATA.end(),std::greater<SINT32>());
//	__gcd(ANS,DATA[i]);

//	// DATA.emplace_back(BUF);	//後ろに追加

//  DATA.erase(std::unique(DATA.begin(), DATA.end()), DATA.end());

//	DATA.insert(DATA.begin() + X, 0);	//X番目の要素に0を挿入


//	vector<vector<SINT32>> DP(N,vector<SINT32>(3));　//2次元配列

/*
	SINT32 M = 3;
	vector<pair<SINT32,SINT32>> DATA2(M);
	for (SINT32 i = 0; i < M; i++) {
		cin >> DATA2[i].first;
		cin >> DATA2[i].second;
	}
	sort(DATA2.begin(),DATA2.end());
	cout << DATA2[0].first << endl;
	cout << DATA2[0].second << endl;
*/

// 	vector<pair<int,pair<int,int>>> DATA(M);
//	cin >> DATA[i].first;
//	cin >> DATA[i].second.first;
//	cin >> DATA[i].second.second;


//		APOSI = lower_bound(ADATA.begin(),ADATA.end(),QDATA[i]) - ADATA.begin();
//		BPOSI = lower_bound(BDATA.begin(),BDATA.end(),QDATA[i]) - BDATA.begin();


/* 文字列回転
	string N;
	cin >> N;
	N = N[N.length()-1] + N.substr(0,N.length()-1);
*/

/* SET コンテナ
	set<SINT32> DATA;
	for (SINT32 i = 0; i < N; i++) {
		SINT32 buf;
		cin >> buf;
		DATA.insert(buf);
	}

	//全表示
    set<string>::iterator it; //  イテレータを用意
    for(it = DATA.begin(); it != DATA.end(); it++) {
        cout << *it << endl;
    }

	//N番目を一部表示
	set<string>::iterator it; //  イテレータを用意
	it = DATA.begin();
	rep (i,0,N) {
		it++;
	}
	cout << *it << endl;
*/

/* map
	map<string,SINT32> mp;
	SINT32 N = 0;
	SINT32 mx = 0;

	cin >> N;
	for (SINT32 i = 0; i < N; i++) {
		string s;
		cin >> s;
		mp[s]++;
	}
	for(auto it=mp.begin();it!=mp.end();it++) {
		mx=max(mx,it->second);
	}

*/

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.math.*;

public class Main {
	Scanner sc = new Scanner(System.in);

	void run() {
		for (;;) {
			String buffer = sc.next();
			int n = buffer.length();
			if (n == 1 && '0' == buffer.charAt(0)) {
				break;
			}

			int[] dp = new int[11];

			int prevMod = 0;

			dp[0] = 1;
			int ans = 0;
            int p = 1;
			for (int i = 0; i < n; i++) {
				int next = buffer.charAt(n - 1 - i) - '0';

				int v2 = (prevMod + p* next ) % 11;
				prevMod = v2;
				if (buffer.charAt(n - i - 1) != '0') {
					ans += dp[v2];
				}

				dp[v2]++;
		        p = (p*10)%11;
			}
			System.out.println(ans);
		}
	}

	public static void main(String[] args) {
		Main m = new Main();
		m.run();
	}
}

Measured memory_bytes: 13000
// stdin
macro_rules! stdin {
    () => {{
        use std::io::Read;
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }};
}

// input
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

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

// Test
macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
r"Sunny
" => r"Cloudy",

r"Rainy
" => r"Sunny"
}

fn solve(src: &str) -> String {
    input! {
        source=src,
        s:String,
//        a:[i32;n],
    }
    let a = ["Sunny", "Cloudy", "Rainy", "Sunny"];

    let s: String = s;

    for (i,&v) in a.iter().enumerate() {
        if v == s {
            return format!("{}", a[i+1])
        }
    }
    unreachable!();
}


fn main() {
    println!("{}", solve(&stdin!()));
}



Measured memory_bytes: 4352
package main

import (
	"fmt"
	"math"
)

func main() {
	var n int
	fmt.Scan(&n)

	xs := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&xs[i])
	}

	min := math.Inf(0)
	for p := 0; p <= 100; p++ {
		var sum float64
		for _, x := range xs {
			sum += math.Pow(float64(x-p), 2)
		}
		if min > sum {
			min = sum
		}
	}
	fmt.Println(int(min))
}


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

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  string S; cin >> S;
  int N = S.size();
  string ans;
  REP(i, N){
    ans += (char(((S[i]-'D'+26)%26)+'A'));
  }
  cout << ans << endl;
}


Measured memory_bytes: 3136
import sys
N, K = [int(x) for x in input().split()]
H = [int(x) for x in input().split()]
H.sort()
if(N<K):
  print(0)
  sys.exit()
else:
  for i in range(1,K+1):
    H[N-i] = 0
print(sum(H))

Measured memory_bytes: 31564
L, R = map(int, input().split())

mod = 2019
ans = 10 ** 7
results = [False for _ in range(2019)]
for low in range(L, R+1):
    for up in range(low+1, R+1):
        ans = min(ans, low * up % mod)
        if ans == 0:
            print(ans)
            exit()
        # results[low * up % mod] = True
        # if all(results):
        #     print(ans)
        #     exit()
print(ans)


Measured memory_bytes: 3060
S = input()
L = []
for i in range(4): L.append(int(S[i]))


if L[0]+L[1]+L[2]+L[3] == 7:
    print(S[0] +'+'+ S[1] +'+'+ S[2] +'+'+ S[3] +'=7')
elif L[0]+L[1]+L[2]-L[3] == 7:
    print(S[0] +'+'+ S[1] +'+'+ S[2] +'-'+ S[3] +'=7')
elif L[0]+L[1]-L[2]+L[3] == 7:
    print(S[0] +'+'+ S[1] +'-'+ S[2] +'+'+ S[3] +'=7')
elif L[0]+L[1]-L[2]-L[3] == 7:
    print(S[0] +'+'+ S[1] +'-'+ S[2] +'-'+ S[3] +'=7')
elif L[0]-L[1]+L[2]+L[3] == 7:
    print(S[0] +'-'+ S[1] +'+'+ S[2] +'+'+ S[3] +'=7')
elif L[0]-L[1]+L[2]-L[3] == 7:
    print(S[0] +'-'+ S[1] +'+'+ S[2] +'-'+ S[3] +'=7')
elif L[0]-L[1]-L[2]+L[3] == 7:
    print(S[0] +'-'+ S[1] +'-'+ S[2] +'+'+ S[3] +'=7')
elif L[0]-L[1]-L[2]-L[3] == 7:
    print(S[0] +'-'+ S[1] +'-'+ S[2] +'-'+ S[3] +'=7')

Measured memory_bytes: 3064
#include<stdio.h>
int main(void) {
  int N, M;
  int i;
  int nissu[1000000];
  int sum = 0;
  
  scanf("%d %d", &N, &M);
  
  for(i = 0; i < M; i++) {
    scanf("%d", &nissu[i]);
    sum += nissu[i];
  }
  
  if(N >= sum) {
    printf("%d", N - sum);
  }else if(N < sum) {
    printf("%d", -1);
  }
  
  return 0;
}

Measured memory_bytes: 1748
N,x = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
a.sort()
cnt = 0
for i in a[:-1]:
    if(x-i>=0):
        cnt+=1
        x-=i
    else:
        break
if(x==a[-1]):cnt+=1
print(cnt)


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

int main() {
  char c;
  cin >> c;
  if (c=='a' || c=='i' || c=='u' || c=='e' || c=='o') {
    cout << "vowel" << endl;
  }
  else {
    cout << "consonant" << endl;
  }
}

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

int main(){
  ll a,b,n;
  cin >> a >> b  >> n;
  n = min(n,b-1);
  cout << (a*n-a*n%b)/b - a*(n-n%b)/b;
  
  return 0;
}


Measured memory_bytes: 3632
import sys

def solve():
    input = sys.stdin.readline
    X, K, D = map(int, input().split())
    nearP = 0
    if abs(X) // D > K:
        if X >= 0: print(abs(X - K * D))
        else: print(abs(X + K * D))
    else:
        if X >= 0:
            move = X // D
            nearP = X % D
            if (K - move) % 2 == 0: print(nearP)
            else: print(abs(nearP - D))
        else:
            move = abs(X) // D
            nearM = X + move * D
            if (K - move) % 2 == 0: print(abs(nearM))
            else: print(abs(nearM + D))

    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 9168
#include <bits/stdc++.h>
                                                 
using namespace std;
              
int main() {
	int a, b, c;
	long long k;
	cin >> a >> b >> c >> k;	
	c = a - b;
	if (k & 1) c = -c;
	cout << c << endl;
	return 0;
}







Measured memory_bytes: 256
#include<bits/stdc++.h>
#define Fr(i,a,b) for(int i=(a);i<=(int)(b);++i)
#define Dr(i,a,b) for(int i=(a);i>=(int)(b);--i)
using namespace std;
typedef long long ll;
const int inf=0x3f3f3f3f;
#define debug(x,y) cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<endl
#define bug(x) cout<<#x<<"="<<x<<" "
const int M=1e5+5,Mo=1e9+7;
struct Garph {
    struct node {int fr,to,co;}e[M<<1];int head[M],tot;
    void clear() {tot=0,memset(head,-1,sizeof(head));}
    void add(int u,int v,int co) {e[++tot].to=v;e[tot].co=co;e[tot].fr=head[u];head[u]=tot;}
    #define Ed(i,u) for(int i=G.head[u];~i;i=G.e[i].fr)
} G;
int n,K,x,y,in[M],fa[M],siz[M];
void Find(int x,int f){
	int p=in[x];
	Ed(i,x){
		int y=G.e[i].to;
		if(y==f)continue;
		siz[y]=K-p;
		--p;
		Find(y,x);
	}
}
int main(){
	cin>>n>>K;
	G.clear();
	Fr(i,1,n-1)scanf("%d%d",&x,&y),in[x]++,in[y]++,G.add(x,y,0),G.add(y,x,0);
	Find(1,0);
	siz[1]=K;
	ll S=1;
	Fr(i,1,n){
		if(siz[i]<0)S=0;
		else S=S*siz[i]%Mo;
	}
	cout<<S<<endl;
}

Measured memory_bytes: 7296
def solve(string):
    n, *l = map(int, string.split())
    l.sort(reverse=True)
    nums = 0
    for i, a in enumerate(l[:-2]):
        j, k = i + 1, n - 1
        while (j < k):
            if (a < l[j] + l[k]):
                nums += k - j
                j += 1
            else:
                k -= 1
    return str(nums)


if __name__ == '__main__':
    print(solve('\n'.join([input(), input()])))


Measured memory_bytes: 3188
#include <iostream>
#include <array>

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

    long int n;

    while (std::cin >> n, n) {
        long int age;
        std::array<long int, 7> arr{{}};

        while (n--) {
            std::cin >> age;
            age < 70 ? ++arr[age / 10] : ++arr[6];
        }

        for (const auto& cnt : arr) {
            std::cout << cnt << '\n';
        }
    }

    return 0;
}

Measured memory_bytes: 1192
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";
		while ((line = br.readLine()) != null) {
			if (line.contains(" ")) {
				double[] c = new double[8];
				StringTokenizer st = new StringTokenizer(line);
				for (int i = 0; i < 8; i++) {
					c[i] = Double.parseDouble(st.nextToken());
				}
				if (c[0] == c[2] && c[5] == c[7]) {
					// 直交
					System.out.println("NO");
				} else if (c[1] == c[3] && c[4] == c[6]) {
					// 直交
					System.out.println("NO");
				} else if ((c[0] - c[2]) * (c[1] - c[3]) == (c[4] - c[6])
						* (c[5] - c[7])) {
					System.out.println("YES");
				} else {
					System.out.println("NO");
				}

			}
		}
	}
}

Measured memory_bytes: 16916
def resolve():
    '''
    code here
    '''
    import collections
    n = int(input())
    As = collections.deque([int(item) for item in input().split()])
    bs = collections.deque()

    for i in range(n):
        if i % 2 == 0:
            bs.append(As.popleft())
        else:
            bs.appendleft(As.popleft())
    res =list(bs)
    if n % 2 == 1:
        res.reverse()

    print(*res)




if __name__ == "__main__":
    resolve()


Measured memory_bytes: 31500
// AOJ CGL_2_A: Parallel/Orthogonal
// 2018.5.2 bal4u

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

typedef struct { double x, y; } PP;
typedef struct { PP s, e; } SEG, LINE;

#define INF			1e8
#define EPS			1e-8
#define EQ(a,b)		(fabs((a)-(b))<EPS)
#define PPeQ(a,b)	(EQ(a.x,b.x)&&EQ(a.y,b.y))

int dcmp(double x) { if (fabs(x) < EPS) return 0; return x <= 0 ? -1 : 1; }
PP vset(double x, double y) { PP r; r.x = x, r.y = y; return r; }
PP vadd(PP p1, PP p2) { PP r; r.x = p1.x + p2.x, r.y = p1.y + p2.y; return r; }
PP vsub(PP p1, PP p2) { PP r; r.x = p1.x - p2.x, r.y = p1.y - p2.y; return r; }
PP vsmul(PP p, double k) { PP r; r.x = p.x * k, r.y = p.y * k; return r; }
PP vmul(PP p1, PP p2) { PP r;
	r.x = p1.x * p2.x - p1.y * p2.y, r.y = p1.x * p2.y + p1.y * p2.x; return r; }
double vabs(PP a) { return hypot(a.x, a.y); }
double dist(PP p1, PP p2) {	return hypot(p1.x-p2.x, p1.y-p2.y); };
double cross(PP a, PP b) { return a.x * b.y - a.y * b.x; }
double dot(PP a, PP b) { return a.x * b.x + a.y * b.y; }
double norm(PP a) { return a.x * a.x + a.y * a.y; }

#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif
int in()
{
	int n = 0, c = gc();
	if (c == '-') {	c = gc();
		do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
		return -n;
	}
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

int checkLL(LINE s1, LINE s2)
{
	double dx1, dy1, dx2, dy2;

	dx1 = s1.e.x - s1.s.x, dy1 = s1.e.y - s1.s.y;
	dx2 = s2.e.x - s2.s.x, dy2 = s2.e.y - s2.s.y;
	if (EQ( dx2*dy1, dy2*dx1)) return 2;		// parallel
	if (EQ(-dx1*dx2, dy1*dy2)) return 1;        // orthogonal
	return 0;
}

int main()
{
	int q, x, y, ans;
	PP p0, p1, p2, p3;
	LINE s1, s2;

	q = in();
	while (q--) {
		x = in(), y = in(), p0 = vset(x, y);
		x = in(), y = in(), p1 = vset(x, y);
		x = in(), y = in(), p2 = vset(x, y);
		x = in(), y = in(), p3 = vset(x, y);
		s1.s = p0, s1.e = p1;
		s2.s = p2, s2.e = p3;
		ans = checkLL(s1, s2);
		printf("%d\n", ans);
	}
	return 0;
}



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

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

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

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

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

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

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

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

fn calc_score(v:& Vec<usize>,n:usize)->usize{
    let mut score = 0;
    let N = v.len() / 2;
    for i in 0..N{
        if n == i {
            score = score + v[i] + v[i + N];
        }
        else if i > n {
            score = score + v[i + N];
        }else{
            score = score + v[i];
        }
    }
    return score;
}

fn main() {
    input! {
        N: usize,
        a: [usize; N * 2]
    }

    let mut max = 0;
    for i in 0..N {
        max = std::cmp::max(calc_score(&a,i),max);
    }
    println!("{}",max)
}


Measured memory_bytes: 4352
fn main() {
  let mut lines = vec!();
  for i in  0..2 {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s);
    let x: Vec<i32> = s.trim().split_whitespace().map(|e| e.parse::<i32>().unwrap()).collect();
    lines.push(x);
  }
  let hp = lines.first().unwrap().first().unwrap();
  let attack_sum = lines.last().unwrap().iter().sum::<i32>();
  println!("{}",
           if attack_sum >= *hp {
             "Yes"
           } else {
             "No"
           }
  )
}


Measured memory_bytes: 4352
n,m=[int(x) for x in input().split()]

sc=[]
for i in range(m):
    sc.append([int(x) for x in input().split()])
ans=1000
for i in range(1000):
    i=str(i)
    if not len(i) == n:
        continue
    flag=True
    for s,c in sc:
        if not i[s-1] == str(c):
            flag=False
            break
    if flag:
        ans=min(ans,int(i))
if ans==1000:
    print(-1)
else:
    print(ans)

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

int main()
{
    int n;
    cin>>n;
    for(int i=1;i<=9;i++)for(int j=1;j<=9;j++){
        if(i*j==n){
          cout<<"Yes"<<endl;
          //  puts("Yes");
         return 0;
        }

    }
           cout<<"No"<<endl;
}


Measured memory_bytes: 3492
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = 1; i <= n; i++)
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
using P = pair <int, int>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

ll MOD = 1000000007;
ll INF =1<<29;

int main(){
    int x,y;
    cin >> x >>y;
    for(int i = 0;i<=x;++i){
        if((2*i+4*(x-i))==y){
            cout << "Yes" <<endl;
            return 0;
        }
    }
    cout << "No" <<endl;
}

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

using namespace std;

#define rep(i, x)   for (__typeof(x) i = 0; i < x; i++)
#define mp             make_pair
#define pb             push_back
#define fi             first
#define se             second
#define sz(x)          (int)((x).size())
#define all(x)         (x).begin(), (x).end()
#define sci(x)         int x;       scanf("%d", &x);
#define scii(x, y)     int x, y;    scanf("%d %d", &x, &y);
#define sciii(x, y, z) int x, y, z; scanf("%d %d %d", &x, &y, &z);
#define TC(x)          sci(x); while(x --)
#define eprintf(...)   fprintf(stderr, __VA_ARGS__)
#define debug(x)       { cerr << #x << " = " << x << endl; }
#define repi(i, x)  for (__typeof(x) i = x-1; i >= 0; i --)
#define fore(itr, x)   for (__typeof(x.begin()) itr = x.begin(); itr != x.end(); itr ++)
#define forei(itr, x)  for (__typeof(x.end()) itr = x.end() - 1; itr != x.begin() - 1; itr --)
typedef long long      ll;
typedef pair<int, int> ii;
typedef pair<ii, int>  iii;
typedef vector<int>    vi;
typedef vector<ii>     vii;
typedef vector<iii>    viii;
typedef vector<vector<int> > vvi;
typedef pair<ll, ll>   pairl;
typedef vector<ll>     vl;
typedef vector<ll>     vll;
typedef vector<vector<ll> > vvl;
const   int            infi = numeric_limits<int>::max();
const   ll             infl = numeric_limits<ll>::max();
const   double         eps = 0;
const   int            ms  = 0;



int main()
{
    ios::sync_with_stdio(false);//endl->"\n"
    cin.tie(0);
    
    int N, T;
    cin >> N >> T;
    vector<pair<int, int> > AB(N);
    rep(i, N){
        int a, b;
        cin >> a >> b;
        AB[i] = {a, b};
    }

    sort(all(AB));
    
    vvi mem(N+1, vi(6001, -1));

    int c = 0;
    for(int i = 0; i < N; i++){
        int a = AB[i].first;
        int b = AB[i].second;
        mem[i+1][a] =  b;
        c = max(c, mem[i+1][a]);
        for(int t = 1; t <= 6000; t++){
            
            mem[i+1][t] = max(mem[i+1][t], mem[i+1-1][t]);/////koko
            if(t - a > 0 && mem[i+1-1][t - a] != -1 && t - a  < T){
                mem[i+1][t] = max(mem[i+1][t], mem[i+1-1][t - a] + b);
                c = max(c, mem[i+1][t]);
            }
        }
    }
    
    cout << c << endl;
    
    return 0;
}

Measured memory_bytes: 70784
//** aman**/
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define dl          double
#define hell        1000000007
#define endl        '\n'
#define rep(i,a,b) for(int i=a;i<b;i++)
#define lb lower_bound
#define ub upper_bound
#define bs          binary_search
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
int main(){
	ll n;cin>>n;
	ll x=n;
	ll ans=n-1;
	for(ll i=2;i<=sqrt(x);i++){
		if(x%i==0){
			ans=min(i+x/i-2,ans);
		}
	}
	cout<<ans<<endl;
}

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


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


int main(){
    ll x, y;
    cin >> x >> y;
    cout << gcd(x, y) << endl;
    return 0;
}



Measured memory_bytes: 3100
#include <iostream>
#include <vector>
#include <cstdlib>

int main(){
  std::vector<int> s;
  while(true){
    s.clear();
    int n, k;
    std::cin >> n >> k;
    if (n==0 && k==0) return EXIT_SUCCESS;
    for(int i=0; i<k; i++){
      int tmp;
      std::cin >> tmp;
      s.push_back(tmp);
    }
    for(int i=0; i<n; i++){
      for(int j=0; j<k; j++){
        int tmp;
        std::cin >> tmp;
        s[j] = s[j] - tmp;
      }
    }
    std::cout << [&](){
      for(auto i : s){
        if(i<0) return "No";
      }
      return "Yes";
    }() << std::endl;
  }
}


Measured memory_bytes: 3056
N,K=map(int,input().split())
from collections import Counter
S=list(map(int,input().split()))
C=dict(Counter(S))

a=sorted(C.items(), key=lambda x:x[1])
num=len(C)-K
count=0
b=[]
for key in C:
    b.append(C[key])
c=sorted(b)
for i in range(num):
    count+=c[i]
print(count)

Measured memory_bytes: 40880